CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

Formulation in compressibleInterFoam

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

Like Tree9Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   June 6, 2013, 02:58
Default
  #41
New Member
 
NaiXian Leslie Lu
Join Date: Jun 2009
Location: France
Posts: 26
Rep Power: 8
LESlie is on a distinguished road
Quote:
Originally Posted by richpaj View Post
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

LESlie is offline   Reply With Quote

Old   July 2, 2014, 06:08
Default
  #42
New Member
 
Cong Gu
Join Date: Jun 2013
Posts: 5
Rep Power: 4
gucong is on a distinguished road
Quote:
Originally Posted by richpaj View Post
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?
gucong is offline   Reply With Quote

Old   July 2, 2014, 11:55
Default
  #43
Member
 
Richard Kenny
Join Date: Mar 2009
Posts: 59
Rep Power: 9
richpaj is on a distinguished road
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.
richpaj is offline   Reply With Quote

Old   July 2, 2014, 15:38
Default
  #44
New Member
 
Cong Gu
Join Date: Jun 2013
Posts: 5
Rep Power: 4
gucong is on a distinguished road
Quote:
Originally Posted by richpaj View Post
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,
gucong is offline   Reply With Quote

Old   July 2, 2014, 21:21
Default
  #45
Member
 
Richard Kenny
Join Date: Mar 2009
Posts: 59
Rep Power: 9
richpaj is on a distinguished road
In p(tot) = pd + p0 + rho (g . z),
p0 = 0 and 'vector' g = (0, 0, -g), which accounts for the sign.
Rgds,
Richard K.
richpaj is offline   Reply With Quote

Old   July 2, 2014, 21:42
Default
  #46
New Member
 
Cong Gu
Join Date: Jun 2013
Posts: 5
Rep Power: 4
gucong is on a distinguished road
Quote:
Originally Posted by richpaj View Post
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?
gucong is offline   Reply With Quote

Old   July 2, 2014, 22:49
Default
  #47
Member
 
Richard Kenny
Join Date: Mar 2009
Posts: 59
Rep Power: 9
richpaj is on a distinguished road
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
richpaj is offline   Reply With Quote

Old   December 11, 2014, 14:30
Default
  #48
New Member
 
james wilson
Join Date: Aug 2014
Location: Orlando, Fl
Posts: 29
Rep Power: 2
jameswilson620 is on a distinguished road
Kenny,

Thanks for your guidance on this topic.

Your reference to:

fvScalarMatrix psiConvectionDiffusion
(
fvm::ddt(rho, psi)
+ fv::gaussConvectionScheme<scalar>(mesh, phi, UDs).fvmDiv(phi, psi)
//- fv::gaussLaplacianScheme<scalar, scalar>(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<class RhoType, class SpType, class SuType>
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
jameswilson620 is offline   Reply With Quote

Old   December 28, 2014, 05:32
Default
  #49
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 669
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by richpaj View Post

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.
sharonyue is offline   Reply With Quote

Old   January 5, 2015, 18:51
Default
  #50
New Member
 
james wilson
Join Date: Aug 2014
Location: Orlando, Fl
Posts: 29
Rep Power: 2
jameswilson620 is on a distinguished road
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<class RhoType, class SpType, class SuType>
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<class RdeltaTType, class RhoType, class SpType, class SuType>
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
jameswilson620 is offline   Reply With Quote

Old   March 30, 2015, 02:36
Default
  #51
New Member
 
Sasa Goran
Join Date: Feb 2015
Location: Japan
Posts: 22
Rep Power: 2
Supersale is on a distinguished road
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.
Supersale is offline   Reply With Quote

Old   May 2, 2015, 11:39
Default
  #52
New Member
 
Francis Lee
Join Date: Jul 2013
Location: Jiangsu, China
Posts: 18
Rep Power: 4
epi_c is on a distinguished road
Quote:
Originally Posted by sharonyue View Post
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)
epi_c is offline   Reply With Quote

Old   May 2, 2015, 11:42
Default temperature equation in compressibleInterFoam
  #53
New Member
 
Francis Lee
Join Date: Jul 2013
Location: Jiangsu, China
Posts: 18
Rep Power: 4
epi_c is on a distinguished road
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?
epi_c is offline   Reply With Quote

Reply

Tags
compressible, compressibleinterfoam, theory

Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Low Reynolds Number k-epsilon formulation CFX 10.0 Chris CFX 4 December 8, 2009 00:51
Immersed Boundary Formulation Rave Main CFD Forum 0 August 11, 2008 14:55
DPM Steady formulation with collisions kulwinder FLUENT 0 May 22, 2004 18:44
energy equation formulation Pedro Phoenics 1 July 5, 2001 12:17
Compressible vs. Incompressible formulations Fernando Velasco Hurtado Main CFD Forum 3 January 7, 2000 17:51


All times are GMT -4. The time now is 13:55.