CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to implement equation of mixture fraction and variance of mixture fraction? (https://www.cfd-online.com/Forums/openfoam-programming-development/100281-how-implement-equation-mixture-fraction-variance-mixture-fraction.html)

Tobi April 23, 2012 04:13

How to implement equation of mixture fraction and variance of mixture fraction?
 
1 Attachment(s)
Hi all,

I am using OF for two years now and wanna get deeper into the code and wanna make a new solver using an old one and transform the steady equations into the time dependent equations.

Okay my problem for now is, that I am not sure if I interpret the *Eqn.H files correct. I read a few threats here in the forum which helped me a lot but now I need your help.
I added an attachment with my problem. There you can see my solving equations. I just wanna have a look at the differential equations but I think that I transformed them not right, or?

Further more I do not know what "Sp" means.

Thx in advance.

Regards Tobi

akidess April 23, 2012 08:17

fvm::Sp denotes an implicit source term. You can ignore it when translating code into equations, it's purely related to numerics.

niklas April 23, 2012 09:32

suppose you want to solve this equation

dU/dt = A + BU

implemented like
fvm:ddt(U) == A + B*U

using euler scheme,
this results in

U^n - U^{n-1} = dt*A + dt*B*U^{n-1}
=>
U^n = dt*A + (dt*B + 1)*U_{n-1}

implemented like this
fvm::ddt(U) == A + fvm::Sp(B, U)

this results in
U^n - U^{n-1} = dt*A + dt*B*U^n
=>
(1 - dt*B)*U^n = dt*A + U^{n-1}

so the first implementation is explicit treatment of the B*U term, while the other is implicit treatment.
Hope this makes it clearer

This also makes it possible to do some 'cheating' of large explicit source-terms by linearizing them

again...
dU/dt = A + B*U = A*1 + B*U + A*(U/U) + B*U

which can be implemented like
fvm::ddt(U) = fvm:Sp(A/U, U) + B*U

which in turn is treated numerically like
U^{n} - U ^{n-1} = dt*(A*U^n / U^{n-1} + B*U^{n-1})
so you see now that A is no longer multiplied by 1, but by something else, which for the
converged solution hopefully is 1 and have a stabilizing effect on the solver.

Tobi April 24, 2012 04:24

3 Attachment(s)
Hi nicklas,

thanks for your good explanation!
I used your statement and generated a file (attachment). can you have a look at the file?

I am interessted in the last line I added. Thats my understanding of your post.


The second file is a transformation from openfoam equation code into scalar equation. Is that correct? Its a while ago that I used grad, div and laplacian.

thx in advance
tobi

Tobi December 1, 2015 13:23

Hi all,

I just want to comment, that the "Schemes.pdf" file is incorrect.

dj18deepak December 18, 2019 23:55

fvc and Sp
 
Sorry for bumping into this old thread. I am a beginner in CFD and OpenFoam and i am trying to implement mixture fraction and mixture fraction variance equations.

Can anyone help me understand why we need fvc apart from the fact that it is an explicit equation? I have seen that for calculating gradient or with source terms (Sp), it is always accompanied with fvc. Why is it so?

Also what is happening when the Sp term is introduced.

Thanks in advance

dj18deepak December 26, 2019 05:41

Hi all,
I am trying to implement mixture fraction and mixture fraction variance conserved transport equations to simulate a simple propane non reacting jet flame. The simulation is well and running with slight amount of deviations from experimental data while using small value of grading in the x and y directions (8 and 8 resp). The problem i am facing is that with higher values of grading (12 in x-direction and 15 in y-direction), even though the velocity, temperature and all profiles are evolving, the mixture fraction and mixture fraction variance variables are having very low values of the order of 10^-70 (for mixture fraction). What might be the possible causes of the error. Kindly help me. I am a beginner.

Code

fvScalarMatrix mifEqn
(
fvm::ddt(rho, mif)
+ fvm::div(phi, mif)
- fvm::laplacian(turbulence->mut()/0.7, mif)
);
mifEqn.relax();
mifEqn.solve();

fvScalarMatrix mifvarEqn
(
fvm::ddt(rho, mifvar)
+ fvm::div(phi, mifvar)
- fvm::laplacian(turbulence->mut()/0.7, mifvar)
- 2.86*turbulence->mut()*magSqr(fvc::grad(mif))
+ 2*rho*(turbulence->epsilon()/(turbulence->k()+k_small))*mifvar
);
mifvarEqn.relax();
mifvarEqn.solve(mesh.solver("mifvar"));

fvSchemes dictionary

ddtSchemes
{
default Euler;
}

gradSchemes
{
default cellLimited Gauss linear 1;
}

divSchemes
{
default none;

div(phi,U) Gauss limitedLinearV 1;
div(phiU,p) Gauss limitedLinear 1;
div(phi,epsilon) Gauss limitedLinear 1;
div(phi,K) Gauss limitedLinear 1;
div(phi,k) Gauss limitedLinear 1;
div(phi,H) Gauss limitedLinear 1;
div(phi,Yi_h) Gauss limitedLinear 1;
div(phi,mif) Gauss limitedLinear 1;
div(phi,mifvar) Gauss limitedLinear 1;
div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;
}

laplacianSchemes
{
default Gauss linear corrected;

}

interpolationSchemes
{
default linear;
}

fluxRequired
{
p;
}

fvSolution dictionary

solvers
{

"rho.*"
{
solver diagonal;
}

p
{
solver PCG;
preconditioner DIC;
tolerance 1e-6;
relTol 0.1;
}

pFinal
{
$p;
tolerance 1e-6;
relTol 0.1;
}

"(U|h|k|epsilon)"
{
solver PBiCGStab;
preconditioner DILU;
tolerance 1e-6;
relTol 0.1;
}

"(U|h|k|epsilon|mif)Final"
{
$U;
relTol 0.1;
}

"(mif|mifvar)"
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-07;
relTol 0.;
}
Yi
{
$hFinal;
}

}
relaxationFactors
{
fields
{
p 0.4;
rho 0.5;
}
equations
{
U 0.4;
k 0.5;
epsilon 0.5;
//H 0.5;
mif 0.5;
mifvar 0.2;
}
}
PIMPLE
{
momentumPredictor no;
nOuterCorrectors 1;
nCorrectors 2;
nNonOrthogonalCorrectors 0;
}

Kindly note: mif is mixture fraction and mifvar is mixture fraction variance

Thanks and regards
Deepak J

Tobi December 26, 2019 09:01

Hi, check out my repository of the flamelet model. There you see how it has to be implemented.

dj18deepak December 26, 2019 09:47

Hi Tobi,
Thanks for the reply. Will definitely check the same.

Thanks and regards
Deepak


All times are GMT -4. The time now is 14:57.