CFD Online URL
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

passive scalar increases

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

Like Tree5Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   May 18, 2013, 14:02
Default passive scalar increases
  #1
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
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?
Attached Files
File Type: h gasEqn.H (698 Bytes, 7 views)
File Type: gz rhoCentralFoamModified.tar.gz (4.3 KB, 4 views)
File Type: gz for_test_2.tar.gz (7.0 KB, 2 views)
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 21, 2013, 14:55
Default
  #2
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by immortality View Post
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.
Attached Images
File Type: jpg test_laminar.jpg (14.5 KB, 24 views)
File Type: jpg test_turbulent.jpg (14.9 KB, 20 views)
Tobi is offline   Reply With Quote

Old   May 21, 2013, 15:17
Default
  #3
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
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.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 21, 2013, 15:20
Default
  #4
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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.
Tobi is offline   Reply With Quote

Old   May 21, 2013, 15:35
Default
  #5
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
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?
Attached Files
File Type: gz rhoPimpleFoamModified.tar.gz (4.0 KB, 1 views)
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 21, 2013, 16:27
Default
  #6
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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
Attached Images
File Type: jpg test_0.1seconds.jpg (13.6 KB, 12 views)
File Type: jpg test_0.2seconds.jpg (14.0 KB, 11 views)
File Type: jpg residual.jpg (36.1 KB, 14 views)
Tobi is offline   Reply With Quote

Old   May 21, 2013, 17:36
Default
  #7
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
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?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 21, 2013, 17:38
Default
  #8
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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
Tobi is offline   Reply With Quote

Old   May 21, 2013, 18:32
Default
  #9
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
Thank you dear Tobias.Its exactly between 0 and 1 now.
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.
wyldckat likes this.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 21, 2013, 18:45
Default
  #10
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
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?
Attached Images
File Type: jpg gas_1.5e-5_500*50.jpg (12.0 KB, 9 views)
File Type: png linear.png (4.5 KB, 9 views)
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 22, 2013, 09:31
Default
  #11
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
since the problem is resolved now,I put this answer by dear Tobias in private(by his permission),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
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 22, 2013, 14:47
Default
  #12
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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 likes this.
Tobi is offline   Reply With Quote

Old   May 22, 2013, 15:15
Default
  #13
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
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.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 23, 2013, 07:57
Default
  #14
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
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?!
Attached Images
File Type: jpg gas_1.5e-5_100*10.jpg (16.5 KB, 7 views)
File Type: jpg gas_1.5e-5_500*50.jpg (15.5 KB, 6 views)
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 23, 2013, 08:15
Default
  #15
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by immortality View Post
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 is offline   Reply With Quote

Old   May 23, 2013, 08:21
Default
  #16
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Info about the added Lines: Sp(...)

-> libOpenSMOKE
Tobi is offline   Reply With Quote

Old   May 23, 2013, 09:18
Default
  #17
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
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?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 23, 2013, 12:44
Default
  #18
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by immortality View Post
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
Tobi is offline   Reply With Quote

Old   May 23, 2013, 15:45
Default
  #19
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 16
immortality is on a distinguished road
thanks.
vanLeer isn't a second order scheme?
what do 1 0 1 refer to respectively in the scheme?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   May 23, 2013, 16:05
Default
  #20
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 988
Blog Entries: 4
Rep Power: 18
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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
immortality likes this.

Last edited by Tobi; May 24, 2013 at 08:38. Reason: prefent :D
Tobi is offline   Reply With Quote

Reply

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
dieselFoam problem!! trying to introduce a new heat transfer model vivek070176 OpenFOAM Programming & Development 9 August 26, 2014 04:14
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 02:47
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 11 April 22, 2014 13:32
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 03:27
passive scalar for carbon monoxide kraizy STAR-CCM+ 0 October 12, 2009 21:13


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