# Formulation in compressibleInterFoam

 Register Blogs Members List Search Today's Posts Mark Forums Read

June 6, 2013, 02:58
#41
New Member

NaiXian Leslie Lu
Join Date: Jun 2009
Location: France
Posts: 26
Rep Power: 9
Quote:
 Originally Posted by richpaj so that when you discretize you get something like Ap * Up = F(Up-1, .. ) and where Ap is the diagonal coefficient. 2) as for adjustPhi(phiHbyA, U, p_rgh) this is applied in the case of incompressible problems when the pressure reference (or level) is unknown. If you look in the source code (src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C) you'll find: if (p.needReference()) { }
Thanks Richard, it's what I was looking for!
Have a good day.

Leslie
__________________
Cheers,
Leslie LU

July 2, 2014, 06:08
#42
New Member

Cong Gu
Join Date: Jun 2013
Posts: 7
Rep Power: 5
Quote:
 Originally Posted by richpaj dgdt = (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) *(p_rghEqnComp & p_rgh);
The code shows that
dgdt = (psi2 / rho2 - psi1 / rho1) *DDt(p - rho * g * h).

But in the derivation, it is
dgdt = (psi2 / rho2 - psi1 / rho1) * DDt(p).

They are not equivalent, are they?

 July 2, 2014, 11:55 #43 Member   Richard Kenny Join Date: Mar 2009 Posts: 64 Rep Power: 10 Hello Gucong, the expression looks like a variation on the original (circa OF17) but I think the same reasoning/derivation still applies, but now of course it appears the 'dynamic' and 'static' components of the pressure are clearly indicated. Recalling that the static contribution is written as p0 + rho (g . z), and hence the sign. I've just scanned the OF23x version of compressibleInterfoam and it seems a lot more is going on in pEqn these days, possibly with a view to stabilizing the explicit terms. If the latter fails then and the average density is varying considerably I think an alternative approach similar to the old dieselFoam might be more appropriate. But that's getting off-topic. Regards, Richard K.

July 2, 2014, 15:38
#44
New Member

Cong Gu
Join Date: Jun 2013
Posts: 7
Rep Power: 5
Quote:
 Originally Posted by richpaj Hello Gucong, the expression looks like a variation on the original (circa OF17) but I think the same reasoning/derivation still applies, but now of course it appears the 'dynamic' and 'static' components of the pressure are clearly indicated. Recalling that the static contribution is written as p0 + rho (g . z), and hence the sign. I've just scanned the OF23x version of compressibleInterfoam and it seems a lot more is going on in pEqn these days, possibly with a view to stabilizing the explicit terms. If the latter fails then and the average density is varying considerably I think an alternative approach similar to the old dieselFoam might be more appropriate. But that's getting off-topic. Regards, Richard K.
Thank you so much for the timely reply. Regarding the definition of dgdt, it is p in OF17x. But in OF21x, it is changed to p_rgh (which means p - rho * (vector g) dot (vector x) ). According to my understanding, the change is not justified unless something else is done to compensate for the difference. But I cannot find such things in the code of OF21x. I have yet to see what the solver is like since OF22x. But here's my current question: Is the solver in OF21x correct or not?

Regards,

 July 2, 2014, 21:21 #45 Member   Richard Kenny Join Date: Mar 2009 Posts: 64 Rep Power: 10 In p(tot) = pd + p0 + rho (g . z), p0 = 0 and 'vector' g = (0, 0, -g), which accounts for the sign. Rgds, Richard K.

July 2, 2014, 21:42
#46
New Member

Cong Gu
Join Date: Jun 2013
Posts: 7
Rep Power: 5
Quote:
 Originally Posted by richpaj In p(tot) = pd + p0 + rho (g . z), p0 = 0 and 'vector' g = (0, 0, -g), which accounts for the sign. Rgds, Richard K.
My problem is not with the sign. But does DDt(p) = DDt(p_rgh) in general?

 July 2, 2014, 22:49 #47 Member   Richard Kenny Join Date: Mar 2009 Posts: 64 Rep Power: 10 Oh right, sorry for the misinterpretation. But otherwise, DDt(p) != DDt(p_rgh) owing to the spatial cpt of DDt(..), but presumably this latter is assumed to be much smaller than the value of ddt(p). It would be interesting to verify numerically. RGK

 December 11, 2014, 14:30 #48 Member   james wilson Join Date: Aug 2014 Location: Orlando, Fl Posts: 38 Rep Power: 4 Kenny, Thanks for your guidance on this topic. Your reference to: fvScalarMatrix psiConvectionDiffusion ( fvm::ddt(rho, psi) + fv::gaussConvectionScheme(mesh, phi, UDs).fvmDiv(phi, psi) //- fv::gaussLaplacianScheme(mesh, CDs, snGrads) //.fvmLaplacian(Dpsif, psi) - fvm::Sp(Sp, psi) - Su ); Is found in "IMULESTemplates.C" for a call to Foam::MULES::implicitSolve. We however are using a call to Foam::MULES::explicitSolve found in MULESTemplates.C (as youve specified) where the structure of the fvScalarMatrix is less clear: " template void Foam::MULES::explicitSolve ( const RhoType& rho, volScalarField& psi, const surfaceScalarField& phi, surfaceScalarField& phiPsi, const SpType& Sp, const SuType& Su, const scalar psiMax, const scalar psiMin ) { const fvMesh& mesh = psi.mesh(); const scalar rDeltaT = 1.0/mesh.time().deltaTValue(); psi.correctBoundaryConditions(); limit(rDeltaT, rho, psi, phi, phiPsi, Sp, Su, psiMax, psiMin, 3, false); explicitSolve(rDeltaT, rho, psi, phiPsi, Sp, Su); } " Could you comment on this portion of the code and extend your explanation to cover this specific template the compressibleInterFoam solver uses? Your explanation of the source term implementation using "fvScalarMatrix psiConvectionDiffusion (...)" makes sense but THIS template is not being used. I am assuming MULES::explicitSolve operates the same way as MULES::implicitSolve in terms of how the source terms are passed using the template where the solution of course is different. Using this style of source term distribution in openFoam, I have been able to validate analytic Stefan type problems, so I do not doubt it's validity one bit. I would however, like to gain a deeper understanding of the form of the FV equations such that I can get creative with new source terms. I've modified the compressibleInterFoam solver to output Su, Sp and divU (=alpha1*divU). I have a line plot along the center-line at y and a surface plot of Su and Sp at the instant the line plots are shown in the attached images. I hope this helps with visualization. Looking at the surface plot of Sp, there are portions of the gaseous phase where Sp is non zero. I would assume that this non zero contribution in the alpha equation would lead to un-bounding of alpha in the gasseous phase. If the solver does take the form described by kenny where Sp --> Sp*alpha1 however, this non zero portion would have no contribution since alpha = 0 in this region and therefore would support Kenny's argument. One final note, The images shown here correspond to expanding gas.. when the gas cools due to convection and diffusion of thermal energy, the sign of the source terms change since the gas is now contracting and the interface must move inward, and as a result, the assignment of divU should change as well divU --> Su (expand) vs. divU --> Sp (contract) to promote diagonal dominance. It is not treated intuitively in this manner in the default solver. Food for thought ; ) James Su: Screenshot from 2014-12-12 08:59:22.jpg; Sp: Screenshot from 2014-12-12 09:03:51.jpg Last edited by jameswilson620; December 12, 2014 at 10:17. Reason: adding result data

December 28, 2014, 05:32
#49
Senior Member

Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 742
Rep Power: 9
Quote:
 Originally Posted by richpaj ddt( alpha1) + div( alpha1 * U ) = - ( alpha1 / rho1 ) * DDt( rho1 ) ..........(3) Then, introducing a compressibility so that rho1 = rho1_0 + psi1 * p yields ddt( alpha1) + div( alpha1 * U ) = - ( alpha1 * psi1 / rho1) DDt( p ) .......(4)
from my point, DDt( rho1 ) is not the same with (psi1 / rho1) DDt( p ). Maybe its :

DDt( rho1 ) = DDt( rho1_0 ) + (psi1 / rho1) DDt( p )

If Im wrong correct it pls.

 January 5, 2015, 18:51 #50 Member   james wilson Join Date: Aug 2014 Location: Orlando, Fl Posts: 38 Rep Power: 4 So in case anyone is interested.. a call to MULES::explicitSolve(geometricOneField(), alpha1, phi, tphiAlpha(),Sp,Su, 1, 0); references this template in MULESTemplates.C for OF2.3 Code: template void Foam::MULES::explicitSolve ( const RhoType& rho, volScalarField& psi, // Note the use of the pointer, I believe this is how psi is updated without explicitly defining a "return psi" const surfaceScalarField& phi, surfaceScalarField& phiPsi, const SpType& Sp, const SuType& Su, const scalar psiMax, const scalar psiMin ) { const fvMesh& mesh = psi.mesh(); const scalar rDeltaT = 1.0/mesh.time().deltaTValue(); psi.correctBoundaryConditions(); limit(rDeltaT, rho, psi, phi, phiPsi, Sp, Su, psiMax, psiMin, 3, false); //I haven't looked much into this explicitSolve(rDeltaT, rho, psi, phiPsi, Sp, Su); //CALL TO ANOTHER TEMPLATE WHERE PSI IS SOLVED FOR THE NEXT TIME STEP } which references the next template (above it in MULESTemplates.C): Code: template void Foam::MULES::explicitSolve ( const RdeltaTType& rDeltaT, const RhoType& rho, volScalarField& psi, const surfaceScalarField& phiPsi, const SpType& Sp, const SuType& Su ) { Info<< "MULES: Solving for " << psi.name() << endl; const fvMesh& mesh = psi.mesh(); scalarField& psiIf = psi; // initialize psiIf const scalarField& psi0 = psi.oldTime(); // Store old values of psi for solution psiIf = 0.0; // Set psiIf to zero fvc::surfaceIntegrate(psiIf, phiPsi); // Calculate divergence of phiPsi; update psiIf as result //NOTE: psiIf is utilized for two purposes here. It is used to advance psi in time (what were after) and also as a temporary dummy variable to store the value of the divergence of phiPsi if (mesh.moving()) { psiIf = ( mesh.Vsc0()().field()*rho.oldTime().field() *psi0*rDeltaT/mesh.Vsc()().field() + Su.field() - psiIf )/(rho.field()*rDeltaT - Sp.field()); } else { // VOF EQUATION // (psiIf(unknown) - psi0)/dt + psiIf(known dummy place holder for divergence of phiPsi) = psiIf(unknown)*Sp + Su // OR // ddt(psi) + div(phiPsi) = psi*Sp + Su // Now solve for psiIf, the unknown value of psiIf at t+dt by re arranging the above expression psiIf = ( rho.oldTime().field()*psi0*rDeltaT + Su.field() - psiIf // Divergence )/(rho.field()*rDeltaT - Sp.field()); }//NOTE rho.field() is geometricOneField() (simply = 1) psi.correctBoundaryConditions(); } I hope this is helpful since i've struggled with this for a while. Can anyone comment on limit(rDeltaT, rho, psi, phi, phiPsi, Sp, Su, psiMax, psiMin, 3, false) from the first template? James

 March 30, 2015, 02:36 #51 New Member   Sasa Goran Join Date: Feb 2015 Location: Japan Posts: 23 Rep Power: 3 OK, i've been looking at this transportationProperties file for a couple of days now, and i'm none the wiser. I guess i figured out how to set rho0 (initial density, i guess, and equals 0 for compressible fluids) and pMin (i guess it's the minimum pressure, and should be above 0) but this psi thing bother me to death. It's compresibity, but i've never seen such a formulation, all the data i can get for psi is for the [1/MPa] unit, not the [s^2/m^2] as specified in the file. I would grealty appreciate it if someone could help me out in finding the values for psi (ATM i need water and air) or tell me where a good database is. Also culd you clarify my guesses about rho0 and pMin, or explain what they are indeed. Thank you guys in advance. Edit: OK found out. The 1/MPa formulation comes from \beta = ( d_rho / d_p ) / rho So multiplying beta by rho should give psi Last edited by Supersale; March 31, 2015 at 01:03.

May 2, 2015, 11:39
#52
New Member

Jianzhi Li
Join Date: Jul 2013
Location: Shanghai, China
Posts: 27
Rep Power: 5
Quote:
 Originally Posted by sharonyue from my point, DDt( rho1 ) is not the same with (psi1 / rho1) DDt( p ). Maybe its : DDt( rho1 ) = DDt( rho1_0 ) + (psi1 / rho1) DDt( p ) If Im wrong correct it pls.
Dear Dongyue,

I saw three expressions for rho:
rho1 = rho1_0 + psi1 * p
rho1 = rho1_0 + psi1 * (p - p_0)
rho1 = psi1 * p
In all cases, rho1_0 and p_0 are constants, their material derivative should be zero.
From its definition, psi1 is isothermal compressibility, aka, be a constant when temperature fixed.
So, DDt(rho1) = psi1 * DDt(p)

May 2, 2015, 11:42
temperature equation in compressibleInterFoam
#53
New Member

Jianzhi Li
Join Date: Jul 2013
Location: Shanghai, China
Posts: 27
Rep Power: 5
Hi guys,

Recently I'm learning the solver compressibleInterFoam in OpenFOAM-2.3.x. From the discussion above, I've already figure out the pressure equation and alpha equation, What bothers me is the temperature equation, which seems to be derived from specific total internal energy equation:

ddt(rho * e) + div(rho * U * e) + ddt(rho * K) + div(rho * U * K) = -div(U * p) + laplacian((Cp/Cv) * (kappa / Cp), e)

where e = Cv * T, e has dimension J/kg, and Cv has dimension J/kg/K.

For a multiphase flow, and in solver's description:
Quote:
 The momentum and other fluid properties are of the "mixture"
usually, the mixture properties are taken as volume average of both phases, such as dynamic viscosity mu. From intuition, the mixture fluid will behave more like the phase which has more volume, so I can understand this.

But for specific total internal energy, the equation is derived based on the conservation of energy in a control volume (cell). I think the total energy in a computation cell should be taken as mass average of both phases.

Let us use Y1, Y2 denote mass fraction and alpha1, alpha2 denote the volume fraction of two phases. And Cv denotes the specific heat capacity at constant volume of the mixture, Cv1 and Cv2 for each phase. In my opinion, Cv = Y1*Cv1 + Y2*Cv2, so let the energy equation be devided by Cv, we get

ddt(rho * T) + div(rho * U * T) - laplacian((Cp/Cv) * (kappa / Cp), T)
+ (ddt(rho * K) + div(rho * U * K) + div(U * p))/Cv = 0

but in the TEqn:

Code:
    fvScalarMatrix TEqn
(
fvm::ddt(rho, T)
+ fvm::div(rhoPhi, T)
- fvm::laplacian(twoPhaseProperties.alphaEff(turbulence->mut()), T)
+ (
fvc::div(fvc::absolute(phi, U), p)
+ fvc::ddt(rho, K) + fvc::div(rhoPhi, K)
)
*(
alpha1/twoPhaseProperties.thermo1().Cv()
+ alpha2/twoPhaseProperties.thermo2().Cv()
)
);
it can be interpreted as 1/Cv = alpha1/Cv1 + alpha2/Cv2, this expression is neither volume averaging nor mass averaging.

Also I think the term twoPhaseProperties.alphaEff(turbulence->mut()) should be twoPhaseProperties.alphaEff(turbulence->alphat()) or turbulence->alphaEff(), note that the last two expression are equivalent. The only difference is that in OpenFOAM alphat = mut / Prt. Can anybody help me with these?

October 10, 2015, 17:24
#54
New Member

Cong Gu
Join Date: Jun 2013
Posts: 7
Rep Power: 5
Quote:
 Originally Posted by gucong The code shows that dgdt = (psi2 / rho2 - psi1 / rho1) *DDt(p - rho * g * h). But in the derivation, it is dgdt = (psi2 / rho2 - psi1 / rho1) * DDt(p). They are not equivalent, are they?
In this paper, they have a term to correct this, namely the "lambda" defined equation (22)

http://www.sciencedirect.com/science...45793013001229

October 10, 2015, 18:36
#55
New Member

Cong Gu
Join Date: Jun 2013
Posts: 7
Rep Power: 5
Quote:
 Originally Posted by epi_c Hi guys, Recently I'm learning the solver compressibleInterFoam in OpenFOAM-2.3.x. From the discussion above, I've already figure out the pressure equation and alpha equation, What bothers me is the temperature equation, which seems to be derived from specific total internal energy equation: ddt(rho * e) + div(rho * U * e) + ddt(rho * K) + div(rho * U * K) = -div(U * p) + laplacian((Cp/Cv) * (kappa / Cp), e) where e = Cv * T, e has dimension J/kg, and Cv has dimension J/kg/K. For a multiphase flow, and in solver's description: usually, the mixture properties are taken as volume average of both phases, such as dynamic viscosity mu. From intuition, the mixture fluid will behave more like the phase which has more volume, so I can understand this. But for specific total internal energy, the equation is derived based on the conservation of energy in a control volume (cell). I think the total energy in a computation cell should be taken as mass average of both phases. Let us use Y1, Y2 denote mass fraction and alpha1, alpha2 denote the volume fraction of two phases. And Cv denotes the specific heat capacity at constant volume of the mixture, Cv1 and Cv2 for each phase. In my opinion, Cv = Y1*Cv1 + Y2*Cv2, so let the energy equation be devided by Cv, we get ddt(rho * T) + div(rho * U * T) - laplacian((Cp/Cv) * (kappa / Cp), T) + (ddt(rho * K) + div(rho * U * K) + div(U * p))/Cv = 0 but in the TEqn: Code:  fvScalarMatrix TEqn ( fvm::ddt(rho, T) + fvm::div(rhoPhi, T) - fvm::laplacian(twoPhaseProperties.alphaEff(turbulence->mut()), T) + ( fvc::div(fvc::absolute(phi, U), p) + fvc::ddt(rho, K) + fvc::div(rhoPhi, K) ) *( alpha1/twoPhaseProperties.thermo1().Cv() + alpha2/twoPhaseProperties.thermo2().Cv() ) ); it can be interpreted as 1/Cv = alpha1/Cv1 + alpha2/Cv2, this expression is neither volume averaging nor mass averaging. Also I think the term twoPhaseProperties.alphaEff(turbulence->mut()) should be twoPhaseProperties.alphaEff(turbulence->alphat()) or turbulence->alphaEff(), note that the last two expression are equivalent. The only difference is that in OpenFOAM alphat = mut / Prt. Can anybody help me with these?
I tried to explain the averaging of Cv in the code. Correct me if I'm wrong. First we have energy equation of each phase

ddt( alpha_1 * rho_1 * (Cv_1 * T + K) ) + div( alpha_1 * rho_1 * U * (Cv_1 * T + K) )
- laplacian(kappa_1 , T ) * alpha_1 * rho_1 / rho + div( p * U ) * alpha_1 * rho_1 / rho
+ alpha_1 * rho_1 * g dot U = 0

Note that the thermal diffusion and mechanical work are distributed to the phases in proportion to the mass. Then expand the first two terms by product rule and apply conservation of phase mass

ddt(alpha_1 * rho1) + div(alpha_1 * rho_1 * U) = 0

Should get

alpha_1 * rho_1 * ddt(Cv_1 * T + K) + alpha_1 * rho_1 * U dot grad(Cv_1 * T + K)

for the first two terms.

And let alpha_Eff = (alpha_1 * kappa_1 / Cv_1) + (alpha_2 * kappa_2 / Cv_2)

Divide the whole equation by (rho_1 * Cv_1), maybe assuming constant Cv_1. Then sum it with the similar equation for phase 2. Finaly multiply the sum with rho. You should arrive at similar things in the code, except some small deviations in the work of gravity. They use p_rgh instead of p, which should take care of work by gravity. But it gets complicated if rho is changing.

Last edited by gucong; October 11, 2015 at 04:33.

November 12, 2015, 03:07
#56
New Member

Jianzhi Li
Join Date: Jul 2013
Location: Shanghai, China
Posts: 27
Rep Power: 5
Quote:
 Originally Posted by gucong I tried to explain the averaging of Cv in the code. Correct me if I'm wrong. First we have energy equation of each phase ddt( alpha_1 * rho_1 * (Cv_1 * T + K) ) + div( alpha_1 * rho_1 * U * (Cv_1 * T + K) ) - laplacian(kappa_1 , T ) * alpha_1 * rho_1 / rho + div( p * U ) * alpha_1 * rho_1 / rho + alpha_1 * rho_1 * g dot U = 0 Note that the thermal diffusion and mechanical work are distributed to the phases in proportion to the mass. Then expand the first two terms by product rule and apply conservation of phase mass ddt(alpha_1 * rho1) + div(alpha_1 * rho_1 * U) = 0 Should get alpha_1 * rho_1 * ddt(Cv_1 * T + K) + alpha_1 * rho_1 * U dot grad(Cv_1 * T + K) for the first two terms. And let alpha_Eff = (alpha_1 * kappa_1 / Cv_1) + (alpha_2 * kappa_2 / Cv_2) Divide the whole equation by (rho_1 * Cv_1), maybe assuming constant Cv_1. Then sum it with the similar equation for phase 2. Finaly multiply the sum with rho. You should arrive at similar things in the code, except some small deviations in the work of gravity. They use p_rgh instead of p, which should take care of work by gravity. But it gets complicated if rho is changing.
Thanks Cong

It's more clear now. But I don't understand the div( p * U ) * alpha_1 * rho_1 / rho term, should it be div( p * U ) * alpha_1?

 Tags compressible, compressibleinterfoam, theory

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Chris CFX 4 December 8, 2009 00:51 Rave Main CFD Forum 0 August 11, 2008 14:55 kulwinder FLUENT 0 May 22, 2004 18:44 Pedro Phoenics 1 July 5, 2001 12:17 Fernando Velasco Hurtado Main CFD Forum 3 January 7, 2000 17:51

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