CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

modify reactingFoam in order to make it a steady state solver

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 3 Post By wyldckat
  • 3 Post By ssss

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 7, 2014, 11:14
Cool modify reactingFoam in order to make it a steady state solver
  #1
New Member
 
Pedro Obando
Join Date: Jun 2014
Posts: 3
Rep Power: 11
Peoban2 is on a distinguished road
Hi

I have tried to modify reactingFoam in order to make it a steady state solver, so I took as base file rhoSimpleFoam and added the YEqn term on the main .C file of the solver and also the corresponding terms on theEEqn. The problem is that when I run it, the Temperature increase as well as the CO2 production are much lower than the results obtained using Fluent, which I was using in order to validate the solver, or even the same case using reactingFoam after a long time.

Actually I donīt know where the error is, whether in the solver itself, in the relaxation parameters or tolerances and numerical solvers defined in fvSolution. Iīve tryed to check as much as I can, but I have no clue.

Here I attach the solver, I couldnīt attach the case Iīm modelling since itīs a little heavy, but I would have no problem also sending it.

Iīm new in the whole CFD world and this is my first customized solver so would really appreciate any help I could get.
Attached Files
File Type: gz simpleReactingFoam.tar.gz (10.0 KB, 219 views)
Peoban2 is offline   Reply With Quote

Old   August 17, 2014, 12:53
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Pedro,

If the case is too big, then it's best that you create a much smaller test case that you can share, because it will also make it easier for anyone to help you.

Beyond this, I'm not so certain that it's possible to create a steady-state reaction solver, since it might not be able to release the heat fast enough, therefore the temperature would continue to rise continually. Keep in mind that steady-state simulations are almost an averaging of the flow over a long time frame.

Here are a few more ideas/hints:


Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   August 21, 2014, 06:01
Default
  #3
New Member
 
Pedro Obando
Join Date: Jun 2014
Posts: 3
Rep Power: 11
Peoban2 is on a distinguished road
Hi Bruno

Thank you for replying, as a simpler case here I attach the modified counterFlowFlame2D case in order to be solved with the steady state solver that I previously uploaded. When comparing the results obtained with this solver when it converges (according to the tolerances that I stated that Iīm also not sure if are ok) with the ones obtained with the transient solver after 10s (when I assumed that it was long enough as to have reached steady state) the differences in the obtained temperatures and CO2 concentrations are huge.

I have found this steady state solver with chemical reactions
https://github.com/Unofficial-Extend...rnateChemistry
Itīs just that its in an older OF version which I havenīt installed so I couldnīt test it, however by checking the code, it seemed to me that it followed pretty much the same logic as the modifications I tried to implement, except that on the Yeqn they include a some controling loops in order to stabilize the solution.

thanks

Pedro
Attached Files
File Type: gz steady_counterFlowFlame2D.tar.gz (10.0 KB, 111 views)
Peoban2 is offline   Reply With Quote

Old   April 5, 2015, 15:59
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Pedro,

Sorry for the reaaaallly late reply, but only today did I finally managed to look into this.

Technically I'm not an expert on this topic, but as I stated in the previous post, the issue seems to be related to problems on how the heat is injected and extracted from the domain. Transient simulations are time dependant and steady-state simulations usually are not. And heat transfer is usually very time dependant, which is very likely why your simulations were either crashing or increasing too much in temperature.

And from what I could figure out, you used OpenFOAM 2.2 (not sure which minor version).

In file "EEqn.H", you have this line:
Code:
        reaction->Sh()  // THIS IS THE TERM THAT BLOWS IT OFF!!!!!
Indeed, this term has the following units:
Code:
dimEnergy/dimVolume/dimTime
which means that it's strongly dependant on time. My deduction is that you'll need to somehow neutralize the time dependence for this and other terms that depend directly on time.

If we look at the source code for "AlternateChemistry" repository you pointed out, you'll notice a few important details:
  1. The question on the transient "h" equation is this:
    Code:
        solve
        (
            fvm::ddt(rho, h)
          + mvConvection->fvmDiv(phi, h)
          - fvm::laplacian(turbulence->alphaEff(), h)
         ==
            DpDt
        );
  2. While on the steady-state, the respective piece of code is this:
    Code:
    fvScalarMatrix hEqn
        (
            fvm::div(phi, h)
          - fvm::Sp(fvc::div(phi), h)
          - fvm::laplacian(turbulence->alphaEff(), h)
         ==
            fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p, "div(U,p)"))
          - p*fvc::div(phi/fvc::interpolate(rho))
        );
    
        hEqn.relax();
    
        if(fixedCells.size()>0) {
            Info << "Fixing enthalpy in " << fixedCells.size() << " cells" << endl;
    
            scalarField hFix=dynamic_cast<basicThermo&>(thermo()).h(fixedTemp,fixedCells);
            hEqn.setValues(fixedCells,hFix);
        }
    
        eqnResidual = hEqn.solve().initialResidual();
  3. There are 2 major differences between the two:
    1. This:
      Code:
           fvm::ddt(rho, h)
            + mvConvection->fvmDiv(phi, h)
      was replaced by this:
      Code:
              fvm::div(phi, h)
            - fvm::Sp(fvc::div(phi), h)
    2. This:
      Code:
      DpDt
      was replaced by this:
      Code:
              fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p, "div(U,p)"))
            - p*fvc::div(phi/fvc::interpolate(rho))
  4. This essentially points out that the convection term has to be accounted a bit differently, as well as the pressure based changes (the second difference).
But then I took a look at the source code differences between buoyantSimpleFoam and rhoSimpleFoam, and the only difference between the two in the "EEqn.H" file is the source term "Sh" for the radiation, which has the same exact units as the other "Sh" term:
Code:
    fvScalarMatrix EEqn
    (
        fvm::div(phi, he)
      + (
            he.name() == "e"
          ? fvc::div(phi, volScalarField("Ekp", 0.5*magSqr(U) + p/rho))
          : fvc::div(phi, volScalarField("K", 0.5*magSqr(U)))
        )
      - fvm::laplacian(turbulence->alphaEff(), he)
     ==
        radiation->Sh(thermo)
      + fvOptions(rho, he)
    );
... uhm, sorry, now I'm lost. I tried using OpenFOAM 2.2.x, but the solver is crashing regardless of what is done.

Weirder still is that I've taken a look at the source code for reactingParcelFoam and simpleReactingParcelFoam, which are essentially the same changes you've tried to do.
So I took another glance at the tutorials for these two solvers and found that there the chemistry solver cannot use the ODE option, in the file "constant/chemistryProperties".
By using the following in your test case, the simulation worked fine:
Code:
chemistryType
{
    //chemistrySolver   ode;
    chemistrySolver   noChemistrySolver;
    chemistryThermo   psi;
}
As for the results I got, they seem consistent albeit a bit lower in the maximum temperature. This is somewhat natural to occur, because not solving the chemistry part can lead to inaccuracies...

I then tried:
Code:
chemistryType
{
    //chemistrySolver   ode;
    chemistrySolver   sequential; //noChemistrySolver;
    chemistryThermo   psi;
}

chemistry           on;

initialChemicalTimeStep 1e-07;

sequentialCoeffs
{
    cTauChem        0.001;
    equilibriumRateLimiter on;
}
And it gave much better results!

In addition, I removed the residual stopping criteria and at around iteration 4410 it was as good as stable. I then compared with the run in the original tutorial "combustion/reactingFoam/ras/counterFlowFlame2D" and it gave closer results.

Attached is this last test case I used, in the package "steady_counterFlowFlame2D_v2.tar.gz".
The values I got:
  • transient:
    Code:
    min/max(T) = 788.691, 828.766
  • steady-state:
    Code:
    min/max(T) = 792.176, 829.846
These differences scale are normal to occur, since the resolution between the two methods are not identical. In addition, a mesh study should be done in order to access what is the exact origin of the differences.

By the way, I used your solver without additional modifications.

Best regards,
Bruno
Attached Files
File Type: gz steady_counterFlowFlame2D_v2.tar.gz (4.4 KB, 170 views)
Tobi, justsmile2007 and Akanksha90 like this.
__________________
wyldckat is offline   Reply With Quote

Old   April 7, 2015, 13:31
Default
  #5
New Member
 
Ali Kadar
Join Date: Oct 2014
Location: Delft
Posts: 25
Rep Power: 11
flowAlways is on a distinguished road
Thank you very much Pedro and Bruno! I

Now have some good hopes with my masters thesis!!. The current simulation time for our furnace application using reactingFoam is in days. Hope we will bring it to hours using the steady state version(hope it works!!).

Earlier I was planning to accelerate the simulation using the idea of more outer correctors and under-relaxation with PIMPLE. But it is good to know that SIMPLE can be used too!

I will soon let you guys know how my results with the new solver compare to the existing reactingFoam results(after a long time).
__________________
A good solution is one which does justice to the inner nature of the problem- Cornelius Lanczos in a letter to Albert Einstein on March 9, 1947
flowAlways is offline   Reply With Quote

Old   April 10, 2015, 12:14
Default
  #6
New Member
 
Ali Kadar
Join Date: Oct 2014
Location: Delft
Posts: 25
Rep Power: 11
flowAlways is on a distinguished road
Hello Bruno,

If you could find time please can you have a look. I tested the solver simpleReactingFoam in OF2.2.2 with the following problem.
1. Non-premixed turbulent gaseous combustion in a furnace.
2. Swirling Flow at Inlet.
3. Global 1 step irreversible reaction mechanism for CH4.

I used all the settings with the counterFlowFlame2D tutorial(except 0 and polyMesh) provided by you. The simulation in the beginning throws janafThermo error but later(after many iterations) the simulation proceeds without error. However the result compared to reactingFoam and Fluent is completely wrong. The max temperatures falls to 1200K where it should be ~2000K .

I dont know what am I doing wrong or the solver is not completely correct. ?? The mesh is very refined and therefore the simulation takes many hours(5-6) for convergence. I increased the max steps to 10000.

Code:
SIMPLE: no convergence criteria found. Calculations will run for 4410 steps.

Creating reaction model

Selecting combustion model PaSR<psiChemistryCombustion>
Selecting chemistry type
{
    chemistrySolver sequential;
    chemistryThermo psi;
}

Selecting thermodynamics package
{
    type            hePsiThermo;
    mixture         reactingMixture;
    transport       sutherland;
    thermo          janaf;
    energy          sensibleEnthalpy;
    equationOfState perfectGas;
    specie          specie;
}

Selecting chemistryReader foamChemistryReader
chemistryModel: Number of species = 5 and reactions = 1
Reading field U

Reading/calculating face flux field phi

Creating turbulence model.

Selecting turbulence model type RASModel
Selecting RAS turbulence model kEpsilon
kEpsilonCoeffs
{
    Cmu             0.09;
    C1              1.44;
    C2              1.92;
    C3              -0.33;
    sigmak          1;
    sigmaEps        1.3;
    Prt             1;
}

Creating field kinetic energy K

No finite volume options present


Reading g
Courant Number mean: 109.439 max: 21454.1

Starting time loop

Time = 1

smoothSolver:  Solving for Ux, Initial residual = 0.00530601, Final residual = 0.000446973, No Iterations 2
smoothSolver:  Solving for Uy, Initial residual = 0.0424394, Final residual = 0.00302406, No Iterations 2
smoothSolver:  Solving for Uz, Initial residual = 0.00906213, Final residual = 0.000165917, No Iterations 4
DILUPBiCG:  Solving for O2, Initial residual = 1, Final residual = 6.42829e+09, No Iterations 1001
DILUPBiCG:  Solving for H2O, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for CH4, Initial residual = 1, Final residual = 4.10261e+10, No Iterations 1001
DILUPBiCG:  Solving for CO2, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for h, Initial residual = 1, Final residual = 0.0107451, No Iterations 1
min/max(T) = 300, 2102.62
GAMG:  Solving for p, Initial residual = 1, Final residual = 0.0378342, No Iterations 16
time step continuity errors : sum local = 0.124907, global = -0.123693, cumulative = -0.123693
rho max/min : 1.14168 0.174843
smoothSolver:  Solving for epsilon, Initial residual = 0.190803, Final residual = 0.0150082, No Iterations 2
smoothSolver:  Solving for k, Initial residual = 1, Final residual = 0.040656, No Iterations 4
ExecutionTime = 1.97 s  ClockTime = 2 s

Time = 2

smoothSolver:  Solving for Ux, Initial residual = 0.0950581, Final residual = 0.00133338, No Iterations 4
smoothSolver:  Solving for Uy, Initial residual = 0.156577, Final residual = 0.0023826, No Iterations 4
smoothSolver:  Solving for Uz, Initial residual = 0.0181092, Final residual = 0.000291685, No Iterations 4
--> FOAM Warning :
    From function janafThermo<EquationOfState>::limit(const scalar T) const
    in file /opt/apps/openfoam-2.2.2/OpenFOAM-2.2.2/src/thermophysicalModels/specie/lnInclude/janafThermoI.H at line 108
    attempt to use janafThermo<EquationOfState> out of temperature range 200 -> 5000;  T = 5748.93
--> FOAM Warning :
    From function janafThermo<EquationOfState>::limit(const scalar T) const
    in file /opt/apps/openfoam-2.2.2/OpenFOAM-2.2.2/src/thermophysicalModels/specie/lnInclude/janafThermoI.H at line 108
    attempt to use janafThermo<EquationOfState> out of temperature range 200 -> 5000;  T = 6743.5
__________________
A good solution is one which does justice to the inner nature of the problem- Cornelius Lanczos in a letter to Albert Einstein on March 9, 1947
flowAlways is offline   Reply With Quote

Old   April 16, 2015, 02:41
Default
  #7
TBO
Member
 
Join Date: May 2013
Location: Netherlands
Posts: 30
Rep Power: 12
TBO is on a distinguished road
Interesting discussion how to make reactingFoam steady state, looking forward to the results. Might be worth implementing it in OF 2.3 instead of 2.2. Some new solvers have been added in OF 2.3 which can speed up the chemistry calculations significantly. For some reason, OF 2.2 is relatively slow with chemistry (compared to OF 2.1 and OF 2.3). Running similations with chemFoam (which basically uses the same chemistry models and solvers as reactingFoam, but only for a single cell) are much faster in versions other than 2.2.
TBO is offline   Reply With Quote

Old   September 20, 2015, 14:58
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@Ali: Sorry for the very late reply, but only today did I finally manage to give at least a quick look into this. I guess that since so much time as passed, you've already moved on and/or solver your problem.

Either way, as pointed out by TBO in another thread: http://www.cfd-online.com/Forums/ope...tml#post542001 post #108 - the LTSReactingFoam solver would be a preferable approach. Because steady state heat transfer and chemical reactions, when done incorrectly, can result in having the whole fluid domain populated by the maximum temperature, due to averaging effects (not the actual technical term, but I can't remember right now which one is the correct term).

I'll answer your other question on the thread I mentioned.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 9, 2015, 13:15
Default Experiments with LTSReactingParcelFoam
  #9
New Member
 
Martina Blank
Join Date: Feb 2014
Posts: 8
Rep Power: 12
TinaB is on a distinguished road
Dear all,

I have been reading this (and the related) threads with great interest, since I also want to have a steady state solver for combustion. Following the suggestions posted above, I made some experiments with LTSReactingParcelFoam, based on the counterFlowFlame2D tutorial. At first, it looked really promising, but I found a problem. Maybe you can shed some light.

This is what I did:

Test 1:
No modifications, I just ran the tutorial. After 2000 iterations, the maximal temperature was 2432 K.

Test 2:
I changed the maximal Courant number from 1 to 5 in fvSolution:
Code:
    maxCo           5;
Resulting maximal temperature did not change significantly. The same happened with maxCO=10.

Test 3:
I used a Courant number smaller than one.
Code:
    maxCo           0.5;
The maximal temperature changed by 10 K to 2442 K.

Test 4:
Code:
    maxCo           0.1;
Maximal temperature: 2491 K.

Can anyone explain this behaviour? The Courant number gives - as far as I understand it - a maximum limit for the "time-step". Why does the temperature change if I make the time step smaller?

I suspect that there are problems in the solver (or the chemistryModel, or both) concerning the modeling of the species and energy source terms for combustion. The source terms seem to depend on the time step, even though the solver is steady-state.

A related question: Did anyone ever successfully use simpleReactingParcelFoam for a combustion case?
TinaB is offline   Reply With Quote

Old   October 10, 2015, 03:18
Default
  #10
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12
ssss is on a distinguished road
Because if you reduce the time step you reduce the time discretization errors and thus your solution is less diffusive
wyldckat, mactone and muhsinkhan like this.
ssss is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solver for transonic flow? Martin Hegedus OpenFOAM Running, Solving & CFD 22 December 16, 2015 04:59
Is steady state solver grid dependent? mmkr825 OpenFOAM 4 March 22, 2013 12:46
convergence issues on steady state solver icemaniac178 CFX 1 March 30, 2011 19:11
time step and iterations in steady state problem using transient solver jing113cn FLUENT 2 January 15, 2010 03:18
Steady state solver for chemical reaction hamburgFoam OpenFOAM Running, Solving & CFD 2 January 8, 2010 08:34


All times are GMT -4. The time now is 22:13.