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/)
-   -   passive scalar increases (http://www.cfd-online.com/Forums/openfoam-solving/117979-passive-scalar-increases.html)

immortality May 18, 2013 13:02

passive scalar increases
 
3 Attachment(s)
I have written a passive scalar equation that should be used in a compressible solver like rhoCentralFoam but in each test case i use that the passive scalar (gas) itself and also its residuals increases during the run.
i thought its because of included rho but don't know how to remove rho from the equation because at least phi includes rho in it and the code doesn't accept dividing by rho.
how to overcome the situation of issue?

Tobi May 21, 2013 13:55

2 Attachment(s)
Quote:

Originally Posted by immortality (Post 428454)
I have written a passive scalar equation that should be used in a compressible solver like rhoCentralFoam but in each test case i use that the passive scalar (gas) itself and also its residuals increases during the run.
i thought its because of included rho but don't know how to remove rho from the equation because at least phi includes rho in it and the code doesn't accept dividing by rho.
how to overcome the situation of issue?


Hi,

as we wrote the last weeks via PM I 'll share everything now with the other peoples.

I am not sure if its working with the "rhoCentralFoam" couse in the describtion there is a line that this solver works with central schemes. So I am not sure if that is working with my suggestions. Here are the steps building a new solver with a conserved scalar:


Create a new solver (example is a compressible sovler)
---------------------------------------------------------------------------------------

1. go into your $FOAM_RUN dictionary
2. go one folder back (cd ..)
3. create a folder
Code:

mkdir -p applications/solvers/compressible
4. switch into that folder
5. copy existing solver to that one
Code:

cp -r $FOAM_SOLVERS/compressible/rhoSimpleFoam scalarRhoSimpleFoam

Rename and rebuild the new solver
---------------------------------------------------------------------------------------


1. wclean
2. rename the rhoSimpleFoam.C into scalarRhoSimpleFoam.C
3. change the file Make/files
Code:

scalarRhoSimpleFoam.C

EXE = $(FOAM_USER_APPBIN)/scalarRhoSimpleFoam

4. wmake (you should compile everything now, if yes everything is okay)
5. wclean


Add new conserved scalar
---------------------------------------------------------------------------------------

1. create a new file (e.g. scalarEqn.H; here its ZEqn.H)
2. insert the following lines:
Code:

//-  Solving equation of conserved scalar (Z)
fvScalarMatrix ZEqn
(
        (
            fvm::ddt(rho, Z)
          + fvm::div(phi, Z)
          - fvm::laplacian(turbulence->muEff(), Z)
        )
);

ZEqn.relax();
ZEqn.solve(mesh.solver("Z"));

3. Create a new scalar field in createFields.H:
Code:

    volScalarField Z
    (
        IOobject
        (
            "Z",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

4. insert the eqn. into the solver; for that insert the following line into scalarRhoSimpleFoam.C

Code:

        // Pressure-velocity SIMPLE corrector
        {
            #include "UEqn.H"
            #include "EEqn.H"
            #include "pEqn.H"
            #include "ZEqn.H"
        }

5. wmake
6. finished


Congratulations
---------------------------------------------------------------------------------------


- a friend used my solver for prediction of a mixture of methan - air
- gives very good results, only weakness is the constant density. For that I build a new one with two different densitys (not tested).


In the attachment are pictures of my test case (laminar + turbulent).
The conserved scalar is between 0 and 1.



Hope that helps.

immortality May 21, 2013 14:17

Hi Tobias
could you please have a look into rhoCentralFoamModified I have put in the above post?
Code:

        tmp<fvScalarMatrix> gasEqn
        (
        fvm::ddt(rho,gas)
            + fvm::div(phi, gas)
                -fvm::Sp(fvc::div(phi), gas)
                      - fvm::laplacian(turbulence->muEff(), gas)
        );
       
        gasEqn().relax();
       
        gasEqn().solve(mesh.solver("gas"));

then this term(you told me before is for more stability) should be removed?
Code:

-fvm::Sp(fvc::div(phi), gas)
and also have a look into position of
Code:

#include "gasEqn.H"
in the .C code if its in appropriate position.
thanks.

Tobi May 21, 2013 14:20

Hi,

the term for stabilisation dont have to be removed. In OF2.2.x you can activate that term in the fvSchemes file :)
Code:

bounded
For more details have a look into that post: http://www.openfoam.org/version2.2.0/numerics.php

In my opinion the problem depends on the centralFoam. I have no idea how that algo is working. So you should change to the rhoSimpleFoam.

immortality May 21, 2013 14:35

1 Attachment(s)
my case is treansient so rhoSimpleFoam may not be appropriate for my case.
I also have used rhoPimpleFoam with the same problem(not be scalar between 0 and 1)
that term is necessarily have to be there?
could you have a look into rhoPimpleFoamModified?

Tobi May 21, 2013 15:27

3 Attachment(s)
Hi,

okay for a transient solver you have to use the following conserved equation:

Code:

//-  Solving equation of variance of mixture fraction

fvScalarMatrix ZEqn
(
    fvm::ddt(rho, Z)
  - fvm::Sp(fvc::ddt(rho), Z)
  + fvm::div(phi, Z)
  - fvm::Sp(fvc::div(phi), Z)
  - fvm::laplacian(turbulence->muEff(), Z)
);

ZEqn.relax();
ZEqn.solve(mesh.solver("Z"));

With that code in the rhoPimpleFoam I get the results in the attachement.

Seems that everything is working fine.

Hope it helps :)

Have fun
Tobi

immortality May 21, 2013 16:36

thanks.I'm testing it now.but residuals of scalar still are higher than other equations. isn't it wrong?
and should I also add "bounded" in fvSchemes for all terms in 2.2.0 like
Code:

ddt(rho, h)    bounded Euler;
or shouldn't?

Tobi May 21, 2013 16:38

Hi,

with that code above you do not have to use bounded schemes. If you do so, you ll do it twice! Thats wrong.


The scalar must be between 0-1 or the value you use in the 0/Scalar file

immortality May 21, 2013 17:32

Thank you dear Tobias.Its exactly between 0 and 1 now.:D
I didn't grasp what did that openfoam.org page say.
it says in line 8 that:
Code:

For transient solutions, it is usually better to implement only the fvm::div(phi, h) term
but under the divScheme{} dictionary it is saying:
Code:

Compressible solvers for transient problems generally use the PIMPLE algorithm, which supports partial convergence of intermediate iterations. The solution may benefit from the use of the bounded form of convection but, in such cases, the corresponding bounded time derivative must also be included
then should I add "bounded" for other terms in continuity,momentum and energy(not scalar parameter that has modified in the ZEqn.H code) also so that their boundednes be maintained better or not(they have included in the code of solver like rhoPimpleFoam also rhoCentralFoam)?
like the example:
Code:

ddtSchemes
{
    default        Euler;
    ddt(rho, h)    bounded Euler;
}

if its required then my runs till now are not accurate or its not necessary?
what means at all!
thank you for a bit clarification.:confused:

immortality May 21, 2013 17:45

2 Attachment(s)
and also I forgot to ask about its residual.only want to know does it has a specific reason or its ordinary and hasn't anything wrong.
the residuals of passive scalar are of order of .001 while others are lower,does it have any specific reason?

immortality May 22, 2013 08:31

since the problem is resolved now,I put this answer by dear Tobias in private(by his permission:D),here so that someone needs now or in future knows more about what I asked:
Quote:

Hi,

normally you do not have to do that but you can do that in the fvSchemes if you have Problems with some variables.


Please note!

You are not allowed to Change the time Derivation to bounded couse then you would have it twice in the scalar equation.

If you wanna use a bounded scheme on "U" you should Change that in the div and ddt schemes but in the ddt schemes you have to write a new entry just for the ddt(rho,U) -> bounded or something like that

Hope it s clear.

It makes me happy to solve your Problem.
Keep foaming and good luck.

Tobi

Tobi May 22, 2013 13:47

Hi,

for clearness - please note that I meant the following:

if you are using the bounded time derivation you are not allowed to set the d efault value to "bounded" couse the implemented scalar has this line explicit in the code.

For that you have to use default as standard and modify the other values:

Code:


ddt(rho,U) bounded ...

Otherwise if you want to set the default value to b ounded you have to remove the red lines
Code:

fvScalarMatrix ZEqn
(   
    fvm::ddt(rho, Z)
    - fvm::Sp(fvc::ddt(rho), Z) 
  + fvm::div(phi, Z)
    - fvm::Sp(fvc::div(phi), Z)
    - fvm::laplacian(turbulence->muEff(), Z)
);

And insert the bounds into div and ddt

:)

immortality May 22, 2013 14:15

thank you for summary.
and what I haven't understood yet is that when we have to use a bounded term in both steasy and unsteady,compressible and incompressible cases? some more clarification is good.

immortality May 23, 2013 06:57

2 Attachment(s)
Hi again before close the issue dossier!
when I used linear scheme for probably more accuracy it didn't get a good result(not good appearance and also higher than 1)
Code:

div(phi,gas) Gauss linear;
but in upwind worked well again.
the question is:why its so?!;)

Tobi May 23, 2013 07:15

Quote:

Originally Posted by immortality (Post 429472)
Hi again before close the issue dossier!
when I used linear scheme for probably more accuracy it didn't get a good result(not good appearance and also higher than 1)
[CODEdiv(phi,gas) Gauss linear;][/CODE]
but in upwind worked well again.
the question is:why its so?!;)


That depend on the schemes. On my Homepage you can find a summary about that Topic (unfortunatelly only in german). But the grapics show everything I think.


http://www.holzmann-cfd.de/index.php...rische-schemen

Tobi May 23, 2013 07:21

Info about the added Lines: Sp(...)

-> http://www.cfd-online.com/Forums/ope...tml#post407482

immortality May 23, 2013 08:18

thanks Tobias
related to vanLeer nothing has said but it has nice results,then what do you suggest for better accurate and physical results for passive scalar transport?

Tobi May 23, 2013 11:44

Quote:

Originally Posted by immortality (Post 429500)
thanks Tobias
related to vanLeer nothing has said but it has nice results,then what do you suggest for better accurate and physical results for passive scalar transport?

I always prefer 2. order schemes.

For the scalar I prefer
Code:


limitedLimitedLinear 1 0 1


immortality May 23, 2013 14:45

thanks.
vanLeer isn't a second order scheme?
what do 1 0 1 refer to respectively in the scheme?

Tobi May 23, 2013 15:05

vanLeer is a second order scheme.

To prevent unphysical results (the only scheme which is not producing unphysical results is gauss upwind 1st order) you can use limited schemes and schemes that are bouding the values:

Code:


limtiedLinear 1
limitedLinear 0.33
limitedLinear 0 = linear

The number behind the name is the value of the lmiiter. If you set it to one you have full limited functionallity. If you set it to zero there is no limiting in the scheme so you have the normal linear scheme.


Code:

limitedLimitedLinear 1 0 1
- first number is for the limiter function as befor

- the second one is the lower bouding value
- the third one is the upper bouding value


As you set your scalar between 0-13.54 you should write:

Code:

limitedLimitedLinear 1 0 13.54


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