# About the gammaEqn in interFoam

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

 January 7, 2009, 04:22 Hi guys, I am newbie to Ope #1 Senior Member   Sandy Lee Join Date: Mar 2009 Posts: 207 Rep Power: 9 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

January 7, 2009, 05:54
Hi guys, I am newbie to O
#2
Senior Member

Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 11
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.
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:
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 !

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
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)
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
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!"

 June 9, 2009, 14:43 Thanks Sebastin! #3 New Member   Suraj Deshpande Join Date: Mar 2009 Location: Madison, WI, USA Posts: 18 Rep Power: 8 Hello Sebastian, Thanks for such an elaborate explanation. I was looking exactly for this! Regards, Suraj

 June 30, 2009, 05:22 #4 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 8 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? sharonyue likes this. Last edited by isabel; June 30, 2009 at 06:49.

 July 29, 2009, 07:48 #5 Member     Andreas Dietz Join Date: Mar 2009 Location: Munich Posts: 79 Rep Power: 8 Hi Isabel, did you succeed in implementing a source term into the gamma equation? And would you share you're knowledge? Best, Andreas

 July 31, 2009, 04:01 #6 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 8 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.

 July 31, 2009, 08:01 #7 Senior Member   Sandy Lee Join Date: Mar 2009 Posts: 207 Rep Power: 9 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 , however, it was wrote by every CFD book. vonboett likes this.

 August 3, 2009, 02:55 #8 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 8 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.

August 3, 2009, 06:57
#9
Member

Andreas Dietz
Join Date: Mar 2009
Location: Munich
Posts: 79
Rep Power: 8
Quote:
 Originally Posted by sandy 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.

Last edited by lord_kossity; August 3, 2009 at 11:06.

 August 3, 2009, 15:40 #10 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 8 Hi Kossity, If you want more information about the gammaEqn, you must real carefully the file MULESTemplates.C

August 3, 2009, 20:52
#11
Senior Member

Sandy Lee
Join Date: Mar 2009
Posts: 207
Rep Power: 9
Quote:
 Originally Posted by isabel 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.

November 7, 2011, 10:34
#12
Member

bojiezhang
Join Date: Jan 2010
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by sandy 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
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

 February 24, 2012, 03:14 different between mDotp() and mDotAlphal()?? #13 Member   vahid Join Date: Feb 2012 Location: Mashhad-Iran Posts: 80 Rep Power: 4 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?

February 21, 2014, 05:31
#14
New Member

Join Date: Nov 2010
Posts: 9
Rep Power: 6
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

March 19, 2014, 10:30
#15
Member

Join Date: Aug 2011
Posts: 81
Rep Power: 6
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?

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

 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 jaswi OpenFOAM Running, Solving & CFD 18 October 20, 2011 23:29 elisabet OpenFOAM Running, Solving & CFD 20 April 22, 2009 11:50 floooo OpenFOAM Running, Solving & CFD 0 November 3, 2008 12:00 qiu OpenFOAM Running, Solving & CFD 0 May 6, 2007 22:48 adekian OpenFOAM Running, Solving & CFD 1 April 11, 2007 02:03

All times are GMT -4. The time now is 08:11.