CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   About the gammaEqn in interFoam (http://www.cfd-online.com/Forums/openfoam-solving/58149-about-gammaeqn-interfoam.html)

sandy January 7, 2009 04:22

Hi guys, I am newbie to Ope
 
Hi guys,

I am newbie to OpenFOAM. Could somebody explain the code about gammaEqn in interFoam?

surfaceScalarField phic = mag(phi/mesh.magSf());
---------------
phi=uf·Sf
phic=|uf·Sf/Sf|=|uf| ???
---------------

phic = min(interface.cGamma()*phic, max(phic));
---------------
What is "cGamma"? Where can I find its definition?
---------------

surfaceScalarField phir = phic*interface.nHatf();
---------------
nHat=grad(Gamma)/mag(grad(Gamma))
nHatf=fvc::interface(nHat) ????
---------------

for (int gCorr=0; gCorr<nGammaCorr; gCorr++)
{
surfaceScalarField phiGamma =
fvc::flux
(
phi,
gamma,
gammaScheme
)
+ fvc::flux
(
-fvc::flux(-phir, scalar(1) - gamma, gammarScheme),
gamma,
gammarScheme
);
-------------------
What are "fvc::flux" and "gammarScheme"? What is the definition of "phiGamma"?
--------------------

MULES::explicitSolve(gamma, phi, phiGamma, 1, 0);

rhoPhi = phiGamma*(rho1 - rho2) + phi*rho2;
}
-----------------
rhoPhi is mass flux (rho·uf·Sf), right?

In Rusche's thesis, the indicator equation is solved by Eq.(3.58)or (3.59). Why I can not find this equation in gammaEqn.h ??

Please give me some hint.

Thank you in advance.
Sandy

sega January 7, 2009 05:54

Hi guys, I am newbie to O
 
Quote:

Hi guys,

I am newbie to OpenFOAM. Could somebody explain the code about gammaEqn in interFoam?
I'm currently dealing with the same problem.
Let me try to help you.
All other readers are welcome to correct me and help both of us.

Quote:

surfaceScalarField phic = mag(phi/mesh.magSf());
---------------
phi=uf·Sf
phic=|uf·Sf/Sf|=|uf| ???
---------------
So far so good.

phi=uf & Sf

(It's the dot product of the velocity at the face and the face vector, I will use & as the dot product)

So phic = |phi/|Sf||

Quote:

phic = min(interface.cGamma()*phic, max(phic));
---------------
What is "cGamma"? Where can I find its definition?
---------------
cGamma is a scalar expression for limiting the artificial compression velocity.
You will find it in fvSolution in the PISO sub-dictionary.

This artificial compression velocity is Ur in (3.58) in Rusche's thesis.
So to calculate phir is to calculate phir = Ur & Sf! This is exactly what is done in the following steps!
With cGamma=0 you will simply skip the additional compression, with cGamma=1 the gamma-field will be solved like (3.58) in Rusche!

Quote:

surfaceScalarField phir = phic*interface.nHatf();
---------------
nHat=grad(Gamma)/mag(grad(Gamma))
nHatf=fvc::interface(nHat) ????
---------------
Now this is the phir mentioned above phir = Ur & Sf.
You will find the definitions for nHat and nHatf in the interfaceProperties.C and .H files.

nHatf = nHat & Sf !

nHat = grad(gamma)/(|grad(gamma)| + deltaN)

deltaN is a very small stabilization factor in case |grad(gamma)| will become 0 (the denumerator would be zero without deltaN, which will lead to termination of the program).
This is the case outside the transition region of gamma!

Quote:

for (int gCorr=0; gCorr<nGammaCorr; gCorr++)
{
surfaceScalarField phiGamma =
fvc::flux
(
phi,
gamma,
gammaScheme
)
+ fvc::flux
(
-fvc::flux(-phir, scalar(1) - gamma, gammarScheme),
gamma,
gammarScheme
);
-------------------
What are "fvc::flux" and "gammarScheme"? What is the definition of "phiGamma"?
--------------------
Step by step, I'm not sure what happens in detail here. fvc::flux will calculate explicit values of the phi and phir values defined above.

I understand it like this.
phiGamma = gamma * (uf & Sf) is the transformed (Gauss theorem) div(u*gamma) in (3.58).
When calling it with fvc::flux(phi,gamma,gammaScheme)
it will be discreizised using the gammaScheme, which is the scheme used for div(phi,gamma) in the fvSchemes dictionary. Have a look at the very first line in gammaEqn.H. The entry for div(phi,gamma) is assigned to the variable gammaScheme.

The same holds for calling -fvc::flux(-phir,scalar(1)-gamma,gammarScheme)
which will lead to a discretization of
(1-gamma)*(Ur & Sf) in (3.58) with the fvScheme for div(phirb,gamma). Calling THIS expression like
fvc::flux(THIS,gamma,gammarScheme)
leads to a discretization of
gamma*(ur & Sf)*(1-gamma)

Quote:

MULES::explicitSolve(gamma, phi, phiGamma, 1, 0);
This will give the two above calculated fluxes (the two divergences in (3.58) at the faces to MULES. MULES is a special numerical scheme for solving convective transport equations.
So after calculating the fluxes MULES will solve them explicitly in time.

Quote:

In Rusche's thesis, the indicator equation is solved by Eq.(3.58)or (3.59). Why I can not find this equation in gammaEqn.h ??
Basically the gammaEqn.H simply caluclates the discretisized values of the divergences in (3.58) and gives them to MULES. Maybe a direct representation of (3.58) can be found in MULES.

Quote:

rhoPhi = phiGamma*(rho1 - rho2) + phi*rho2;

-----------------
rhoPhi is mass flux (rho·uf·Sf), right?
I think rhoPhi can be interpreted as an averaged mass flux, weighted between the two phases for gamma? Here I'm guessing more than knowing ...

Dear Sandy.
I hope I could help you and would appreciate and further help from the message board, as this is very interesting for me too.
Greetings. Sebastian.
Bu

suraj June 9, 2009 14:43

Thanks Sebastin!
 
Hello Sebastian,
Thanks for such an elaborate explanation. I was looking exactly for this!

Regards,
Suraj

isabel June 30, 2009 05:22

MULES::explicitSolve(gamma, phi, phiGamma, 1, 0);


This line means this:
gamma: is the actual value to be solved
phi: is the normal convective flux
phiGamma: U*gamma + gamma*(1-gamma)*U
1, 0 : max and min gamma values

Please correct me if I am wrong.
My doubt is: How can I add a source to this equation? I want to solve this:

d(gamma)/dt + div(phigamma) = Source


How can I add the source term?

http://www.cfd-online.com/Forums/ima...ser_online.gif http://www.cfd-online.com/Forums/ima...reputation.gif http://www.cfd-online.com/Forums/ima...ons/report.gif http://www.cfd-online.com/Forums/ima...c/progress.gif http://www.cfd-online.com/Forums/ima...ttons/edit.gif

lord_kossity July 29, 2009 07:48

Hi Isabel,

did you succeed in implementing a source term into the gamma equation? And would you share you're knowledge?

Best,
Andreas

isabel July 31, 2009 04:01

Hi kossity,

There is a tutorial in Internet called "Solve Cavitating flow around a 2D hydrofoil using a user modified version of interPhaseChangeFoam"
I have followed that tutorial and tried this:

volScalarField Su = source;
volScalarField Sp = 0;
MULES::implicitSolve(oneField(), gamma, phi, phiGamma, Sp, Su, 1, 0);

The problem runs Ok but I don't have good convergence. I don't know if it is because I have set Sp to zero.

sandy July 31, 2009 08:01

Hi kossity, try to read gammaEqn.H and pdEqn.H of the interPhaseChangeFoam solver, maybe you will find how to add source term to gamma equation.

Hi isable, why you set Sp = 0? Usually it is not useful because it will lead to be disconvergent. People always try to find a way to discrete the source term linearizing (namely Sp*psi + Su) in order to get the "diagonal predominance" of the matrix.
In fact, I also never try to derive this rule :o, however, it was wrote by every CFD book.

isabel August 3, 2009 02:55

Hi sandy,

My source is cte*(grad(T) & grad(phi)), so I set:

volVectorField gradT = fvc::grad(T);
volVectorField gradpsi = fvc::grad(psi);
Sp = 0;
Su = cte*(gradT & gradpsi);


I don't know how to discretize Sp in order to became different from zero.

lord_kossity August 3, 2009 06:57

Quote:

Originally Posted by sandy (Post 224846)
Hi kossity, try to read gammaEqn.H and pdEqn.H of the interPhaseChangeFoam solver, maybe you will find how to add source term to gamma equation.

Thank you - I will do so.


I suppose Isabel is right. Source got to be added in the MULES routine.

Finally added some (senseless) source - works. Now it's time to deal with the real source.

isabel August 3, 2009 15:40

Hi Kossity,

If you want more information about the gammaEqn, you must real carefully the file MULESTemplates.C

sandy August 3, 2009 20:52

Quote:

Originally Posted by isabel (Post 225030)
Hi sandy,

My source is cte*(grad(T) & grad(phi)), so I set:

volVectorField gradT = fvc::grad(T);
volVectorField gradpsi = fvc::grad(psi);
Sp = 0;
Su = cte*(gradT & gradpsi);

I don't know how to discretize Sp in order to became different from zero.

Hi isabel, my supervisor just told me:

a: if source term = constant, you need to do nothing;

b: if there is a relationship between source term with the variable psi, you can do two ways:

1) if you use the value psi of the last interative step instead of the current varialbe, the source term is still equal to a constant; however, it will lead to a very very slowly iteration, so this method is not available;

2) you can linearize the source term into (Sp*psi + Su). You need to keep Sp <or= 0 in order to get the diagonal predominance.

Do you understand clearly? I seldom meet Sp = 0 because source terms are always a fuction relationship with the variable psi.

PS: I mean psi = the solved variable in a equation.

bojiezhang November 7, 2011 10:34

Quote:

Originally Posted by sandy (Post 225143)
Hi isabel, my supervisor just told me:

a: if source term = constant, you need to do nothing;

b: if there is a relationship between source term with the variable psi, you can do two ways:

1) if you use the value psi of the last interative step instead of the current varialbe, the source term is still equal to a constant; however, it will lead to a very very slowly iteration, so this method is not available;

2) you can linearize the source term into (Sp*psi + Su). You need to keep Sp <or= 0 in order to get the diagonal predominance.

Do you understand clearly? I seldom meet Sp = 0 because source terms are always a fuction relationship with the variable psi.

PS: I mean psi = the solved variable in a equation.

Hello sandy:
I have a problem. I want to add a source like source*psi, and the source is the funcion of runtime. When I use the form like
"MULES::explicitSolve(geometricOneField(), alpha1, phi, phiAlpha, source , geometricZeroField() , 1, 0);"

the result comes not true, the source fraction become complex at the souce place and the surface become inconsistent. I do not know what is wrong? can you give me some advice! Thank you!

bojiezhang

vahid.najafi February 24, 2012 03:14

different between mDotp() and mDotAlphal()??
 
Hello OpenFoam users ,
I'm studying on the Kunz model.we know in this model we have two term for mass dest and prod.(m+ and m-)
What mean mDotAlphal() and mDotP() In interphasechangeFoam?
What is the difference between these two?


Friederike February 21, 2014 05:31

Hello FOAMers,
this discussion is old but i hope that someone is still interested...
I have a question about the deltaN. Sega said:
Quote:

deltaN is a very small stabilization factor
.
in interfaceProperties.C deltaN is defined as:
1e-8/pow(average(alpha1.mesh().V()), 1.0/3.0)
so it depends on the Volume. With decresing Volume i.e. with a mesh refinement deltaN gets bigger!? Does that make sense? To me it looks like it could become a not so small constant that could influence the simulation?
Has anyone more details about the backround of that formula for deltaN and its influence?
Best regards
Friederike

idefix March 19, 2014 10:30

Hello,

Quote:

in interfaceProperties.C deltaN is defined as:
1e-8/pow(average(alpha1.mesh().V()), 1.0/3.0)
so it depends on the Volume. With decresing Volume i.e. with a mesh refinement deltaN gets bigger!? Does that make sense? To me it looks like it could become a not so small constant that could influence the simulation?
Has anyone more details about the backround of that formula for deltaN and its influence?

I just have the same thoughts about deltaN.
Could anybody comment on this please?
It would be very helpful.

Anyway: I did two calculations
1 ) rough grid: the average cell volume is 10 m³ -> deltaN = 4.6e-9
2 ) fine grid: the average cell volume is 0.0001 m³ -> deltaN = 2.2e-7

So maybe the factor is still small enough not to influence the calculation - but I am not sure about it, because the gradients of alpha are also smaller in finer grid...

Thanks a lot for your help


All times are GMT -4. The time now is 12:02.