CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Bubble Foam momentum equation (https://www.cfd-online.com/Forums/openfoam-programming-development/80164-bubble-foam-momentum-equation.html)

 balkrishna September 17, 2010 00:56

Bubble Foam momentum equation

I want to use the standard momentum equation in bubble Foam rather than the phase intensive one as suggested by Henrik Rusche in his PhD thesis... I got the following problems :

Code:

```UEqns.H volVectorField Uamod = alpha*Ua ; volVectorField Ubmod = beta*Ub; fvVectorMatrix UaEqn(Ua, Ua.dimensions()*dimVol/dimTime); fvVectorMatrix UbEqn(Ub, Ub.dimensions()*dimVol/dimTime); {     volTensorField Rca = -nuEffa*(fvc::grad(Ua)().T());     Rca = Rca + (2.0/3.0)*sqr(Ct)*I*k - (2.0/3.0)*I*tr(Rca);     Rca = alpha*Rca ;     surfaceScalarField phiRa =       - fvc::interpolate(nuEffa)       *mesh.magSf()*fvc::snGrad(alpha);     UaEqn =     (         (scalar(1) + Cvm*rhob*beta/rhoa)*         (             fvm::ddt(Uamod)             + fvm::div(phia,Uamod,"div(phia,Ua,alpha)")             - fvm::Sp(fvc::div(phia,alpha), Ua)         )         - fvm::laplacian(nuEffa,Uamod)         + fvc::div(Rca)       + fvm::div(phiRa,Ua,"div(phia,Ua)")       - fvm::Sp(fvc::div(phiRa), Ua)       + (fvc::grad(alpha)&Rca)     ==     //  g                        // Buoyancy term transfered to p-equation       - fvm::Sp(alpha*beta/rhoa*dragCoef, Ua)     //    + beta/rhoa*dragCoef*Ub    // Explicit drag transfered to p-equation       - alpha*beta/rhoa*(liftCoeff - Cvm*rhob*DDtUb)     );     UaEqn.relax();```
This compiles fine but I am not able to run it . The fvSchemes file is modified as follows :
Code:

```/*--------------------------------*- C++ -*----------------------------------*\ | =========                |                                                | | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          | |  \\    /  O peration    | Version:  1.7.0                                | |  \\  /    A nd          | Web:      www.OpenFOAM.com                      | |    \\/    M anipulation  |                                                | \*---------------------------------------------------------------------------*/ FoamFile {     version    2.0;     format      ascii;     class      dictionary;     location    "system";     object      fvSchemes; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ddtSchemes {     default        Euler; } gradSchemes {     default        Gauss linear; } divSchemes {     default        none;     div(phia,Uamod)    Gauss limitedLinearV 1;     div(phib,Ubmod)    Gauss limitedLinearV 1;     div(phia,Ua)    Gauss limitedLinearV 1;     div(phib,Ub)    Gauss limitedLinearV 1;     div(phib,k)    Gauss limitedLinear 1;     div(phib,epsilon) Gauss limitedLinear 1;     div(phi,alpha)  Gauss limitedLinear01 1;     div((-nuEffa*grad(Ua).T())) Gauss linear;     div((-nuEffb*grad(Ub).T())) Gauss linear; } laplacianSchemes {     default        none;     laplacian(nuEffa,(alpha*Ua)) Gauss linear corrected;     laplacian(nuEffb,(beta*Ub)) Gauss linear corrected;     laplacian(nuEffa,Ua) Gauss linear corrected;     laplacian(nuEffb,Ub) Gauss linear corrected;     laplacian((rho*(1|A(U))),p) Gauss linear corrected;     laplacian(DkEff,k) Gauss linear corrected;     laplacian(DepsilonEff,epsilon) Gauss linear corrected;     laplacian(DREff,R) Gauss linear corrected;     laplacian(DnuTildaEff,nuTilda) Gauss linear corrected; } interpolationSchemes {     default        linear; } snGradSchemes {     default        corrected; } fluxRequired {     default        no;     p              ; }```
This gives the following error .... what can be done to correct this ???
Code:

```    gradientInternalCoeffs cannot be called for a calculatedFvPatchField     on patch inlet of field (alpha*Ua) in file "/home/ifmg/MySIM/CHECK/balBubbleFoam/bubbleColumn/0/(alpha*Ua)"     You are probably trying to solve for a field with a default boundary condition.     From function calculatedFvPatchField<Type>::gradientInternalCoeffs() const     in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 186.```
Any suggestion to overcoming this problem ...

 l_r_mcglashan September 17, 2010 04:29

Are you sure about doing this? There are some very good reasons for dividing the momentum equation by the phase fraction! Alberto Passalacqua was working on this, have a read through this thread:

Conservative Two Phase Euler

The error is probably due to the boundary condition not being explicitly stated. You can either setup the Uamod field in the 0/folder, use the == operator instead of = (not sure if that works... try it) or

Code:

```      volVectorField Uamod         (             IOobject             (                 "Uamod",                 runTime.timeName(),                 mesh,                 IOobject::NO_READ,                 IOobject::AUTO_WRITE             ),             1.0,             Ua.boundaryField().types()         );```

 balkrishna September 17, 2010 04:33

 balkrishna September 17, 2010 04:40

I read the same arguments in Dr. Rusche's thesis .... The doubt I had was what is exactly meant by equations becoming singular ... I didnt quite understand the effect it would have on the flow ... For the same purpose , I decided to implement momentum eqn in the conservative form and check out how it affected the solution .....

Another doubt I face is :
How is the non conservative form of the momentum equation derived ? i.e. how is it possible to divide by alpha when alpha is a variable in itself ....

 balkrishna September 17, 2010 04:42

Presently I am getting the following error on running the program :

Code:

``` FOAM FATAL ERROR: incompatible fields for operation     [Ua] - [Uamod]     From function checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)     in file /home/ifmg/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/fvMatrix.C at line 1181. FOAM aborting #0  Foam::error::printStack(Foam::Ostream&) in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so" #1  Foam::error::abort() in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so" #2  #3  #4  #5  __libc_start_main in "/lib/tls/i686/cmov/libc.so.6" #6  Aborted```

 l_r_mcglashan September 17, 2010 04:48

Another link in case you haven't spotted it is the bubbleFoam wiki article. Again, thanks to Alberto.

I haven't got first hand experience of the difficulties you'll encounter, but effectively in areas where the phase fraction is zero, your momentum becomes zero and the velocity becomes undefined. The matrix probably becomes ill conditioned.

I have a full derivation. If you want to see how to get it for yourself, just expand the derivatives in the momentum equation and then divide the whole equation by its phase fraction.

 l_r_mcglashan September 17, 2010 04:50

I just spotted that your UaEqn/UbEqn should have Uamod and Ubmod as the variable to solve for, not Ua and Ub. There may be other mistakes.

 balkrishna September 17, 2010 04:51

can u send me a link to the derivation .... thanks ...

 balkrishna September 17, 2010 05:24

got it!!! derived it myself ... but are there cases when using a non conservative form for multiphase flow may result in spurious results ...

 balkrishna September 18, 2010 05:03

Have you shared (made it open source ) the PEA source code ???

 l_r_mcglashan September 20, 2010 11:36

Not yet, maybe soon!

 balkrishna September 20, 2010 12:04

I have started working on the same ..... right now working on two things ...
A spalding approach to calculate the volume fractions and the second one being the PEA ... Have completed the first one ... and will start the second part soon ....

How are you programming the PEA ? As a general elimination algorithm or hard coding it ...

 l_r_mcglashan September 20, 2010 12:09

The PEA is Spalding's approach, no? That's the method where you substitute one momentum equation into the other and rearrange.

I created a multiphase PISO abstract class and have semiImplicit/partialElimination/multiphasePartialElimination derived classes.

I don't think you need the PEA for bubbles. It's only necessary when the drag force is large, which is true for small particles in fluidised beds.

 balkrishna September 20, 2010 12:21

I meant the spalding approach to solving the volume fraction ... discretise the volume fraction eqns and then calculate alpha = alphadis/(alphadis + betadis) where alphadis and betadis are the discretized volume fraction eqns ...

 balkrishna September 23, 2010 02:17

I have come up with an implementation of the PEA .. .....

Can anyone tell me whether the implementation is correct ....
Code:

```fvVectorMatrix UaEqn(Ua, Ua.dimensions()*dimVol/dimTime); fvVectorMatrix UbEqn(Ub, Ub.dimensions()*dimVol/dimTime); {     volTensorField Rca = -nuEffa*(fvc::grad(Ua)().T());     Rca = Rca + (2.0/3.0)*sqr(Ct)*I*k - (2.0/3.0)*I*tr(Rca);     surfaceScalarField phiRa =       - fvc::interpolate(nuEffa)       *mesh.magSf()*fvc::snGrad(alpha)/fvc::interpolate(alpha + scalar(0.001));     UaEqn =     (         (scalar(1) + Cvm*rhob*beta/rhoa)*         (             fvm::ddt(Ua)           + fvm::div(phia, Ua, "div(phia,Ua)")           - fvm::Sp(fvc::div(phia), Ua)         )       - fvm::laplacian(nuEffa, Ua)             + fvm::div(phiRa, Ua, "div(phia,Ua)")       - fvm::Sp(fvc::div(phiRa), Ua)       ==       - beta/rhoa*(liftCoeff - Cvm*rhob*DDtUb)     );     UaEqn.relax();     volTensorField Rcb = -nuEffb*fvc::grad(Ub)().T();     Rcb = Rcb + (2.0/3.0)*I*k - (2.0/3.0)*I*tr(Rcb);     surfaceScalarField phiRb =       - fvc::interpolate(nuEffb)         *mesh.magSf()*fvc::snGrad(beta)/fvc::interpolate(beta + scalar(0.001));     UbEqn =     (         (scalar(1) + Cvm*rhob*alpha/rhob)*         (             fvm::ddt(Ub)           + fvm::div(phib, Ub, "div(phib,Ub)")           - fvm::Sp(fvc::div(phib), Ub)         )       - fvm::laplacian(nuEffb, Ub)             + fvm::div(phiRb, Ub, "div(phib,Ub)")       - fvm::Sp(fvc::div(phiRb), Ub)       ==                   + alpha/rhob*(liftCoeff + Cvm*rhob*DDtUa)     );     UbEqn.relax();     volScalarField beta12 = alpha/rhoa*dragCoef ;     volScalarField beta21 = alpha/rhob*dragCoef ;     volScalarField denomA = UaEqn.A()*UbEqn.A() + UbEqn.A()*beta12 +UaEqn.A()*beta21 ;     volScalarField denomB = UbEqn.A()*UaEqn.A() + UbEqn.A()*beta12 +UaEqn.A()*beta21 ;     Ua = ((UbEqn.A()+beta21)*(UaEqn.H()- fvc::div(Rca)-(fvc::grad(alpha)/(fvc::average(alpha) + scalar(0.001)) & Rca) + g)           + beta12 * (UbEqn.H() -  fvc::div(Rcb)-(fvc::grad(beta)/(fvc::average(beta) + scalar(0.001)) & Rcb) + g) ) / denomA ;     Ub = ((beta21)*(UaEqn.H()- fvc::div(Rca)-(fvc::grad(alpha)/(fvc::average(alpha) + scalar(0.001)) & Rca)+g)           + (UaEqn.A() + beta12) * (UbEqn.H() -  fvc::div(Rcb)-(fvc::grad(beta)/(fvc::average(beta) + scalar(0.001)) & Rcb)+g) ) / denomB ; }```
Its still premature ... hence a bit messy ... sry for that ...

 l_r_mcglashan September 23, 2010 04:01

The equations are not in that link. Best to check those before code.

You're not solving the equations simultaneously, you're eliminating the other phase's velocity from each velocity equation.

 balkrishna September 23, 2010 04:06

I have updated the link ....

 balkrishna September 27, 2010 04:11

I am getting the following error ... How can it be resolved ??
<code>
--> FOAM FATAL ERROR:
incompatible fields for operation
[Ubmod] == [Ub]

From function checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)
in file /home/ifmg/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/fvMatrix.C at line 1181.

FOAM aborting

#0 Foam::error::printStack(Foam::Ostream&) in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::error::abort() in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#2

#3

#4 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#5

Aborted
</code>
When is the function checkMethod executed ??

 mikeP October 19, 2012 04:08

Not very relevant to the original poster's problem, but I'd like to have make sure about something in bubblefoam momentum equation.

Code:

` surfaceScalarField phiRa =      - fvc::interpolate(nuEffa)        *mesh.magSf()*fvc::snGrad(alpha)/fvc::interpolate(alpha +        scalar(0.001));`
As I understand, scalar(0.001) is there to avoid division by zero. Is that correct?

If yes, then why not VSMALL but a random scalar number?

 mikeP October 19, 2012 04:08

Not very relevant to the original poster's problem, but I'd like to have make sure about something in bubblefoam momentum equation.

Code:

``` surfaceScalarField phiRa =       - fvc::interpolate(nuEffa)       *mesh.magSf()*fvc::snGrad(alpha)/fvc::interpolate(alpha + scalar(0.001));```
As I understand, scalar(0.001) is there to avoid division by zero. Is that correct?

If yes, then why not VSMALL but a random scalar number?

All times are GMT -4. The time now is 20:05.