CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Combustion model:PaSR model in ReactingFoam2.2.1 (http://www.cfd-online.com/Forums/openfoam-programming-development/125970-combustion-model-pasr-model-reactingfoam2-2-1-a.html)

zqlhzx November 5, 2013 10:03

Combustion model:PaSR model in ReactingFoam2.2.1
 
Hi Foamers,
The species eqn inReactingFoam is :
Code:


            fvScalarMatrix YiEqn
            (
                fvm::ddt(rho, Yi)
              + mvConvection->fvmDiv(phi, Yi)
              - fvm::laplacian(turbulence->muEff(), Yi)
            ==
                reaction->R(Yi)
              + fvOptions(rho, Yi)
            );

and reactingFoam2.2.1 use PaSR combustion model(Partially stirred reactor combustion model).The difficult term is reaction->R(Yi),and it is the source termo for species i(expressed as RRi) . It is necesssary to use some form of treatment for chemistry and turbulent mixing,So for PaSR model,the source termo for species i become k(kappa)*RRi.

I found the following codes in src/combustionModels/PaSR/PaSR.C:
Code:

template<class Type>
Foam::tmp<Foam::fvScalarMatrix>
Foam::combustionModels::PaSR<Type>::R(volScalarField& Y) const
{
    tmp<fvScalarMatrix> tSu(new fvScalarMatrix(Y, dimMass/dimTime));
    fvScalarMatrix& Su = tSu();
    if (this->active())
    {
        const label specieI = this->thermo().composition().species()[Y.name()];
        Su += kappa_*this->chemistryPtr_->RR(specieI);
    }
    return tSu;
}

Howerer,I still can not know "this->chemistryPtr_->RR(specieI);",and I can not find the function this->chemistryPtr_->RR(specieI),Where can I find the its define ?

Thamali March 5, 2014 07:44

I do not know whether you solved your problem.But I think you can refer chemistryModel.C file,although I have no idea how this "chemistryPtr" pointer connects to it.
If you have any idea please help me too.

Thamali

mturcios777 March 5, 2014 13:53

For more information on the usage of this:

http://www.tutorialspoint.com/cplusp...is_pointer.htm

The reasons is that the chemistryType is templated on the thermo types. Thamali is right that the function you want is in chemistryModel.C. One way to see this is to look at the online code documentation for OpenFOAM, as you can trace the inheritance diagram.

http://www.openfoam.org/docs/cpp/

Thamali March 6, 2014 02:04

Marco,
Thanks for your reply.I need more help.:)
If we are using following in PaSR model,do we have to switch on the chemistry in reactingFoam.
Code:

combustionModel  PaSR<psiChemistryCombustion>;
active  true;

PaSRCoeffs
{
    Cmix                0.147;
    turbulentReaction  on;
    useReactionRate    yes;
}

actually in my case,it does not run when Chemistry is on.
To find out about this error and to understand about more on the usage of
Code:

chemistry on
switch,I went through the codes.But,I don't see it is using in any code.
In PaSR,it handles chemistry on its own,when
Code:

useReactionRate yes
so,I am thinking we don't have to switch on chemistry at all,when using PaSR with
Code:

useReactionRate yes
am I correct?
If so,whether chemistry is on/off,the other properties in "chemistryProperties" file are active,is it?
What really happens when chemistry switch is on?I am confused.(you may think this must be the 1st question):confused:
Thanks in advance.
Thamali

mturcios777 March 6, 2014 13:35

If you look in the file PaSR.C, in the combustion->correct() function you will see this if statement:

Code:

if (this->active())
. The active function for the combustion object checks is the swtich active is on. It then proceeds to calculate the turbulent mixing parameters.

The second question about useReactionRate can be also answered by looking at the correct() function. I'll leave you to figure that one out and post the answer.

When you are unsure what a keyword or parameter does that is in a Coeffs dictionary, have a look at the constructor for the object, see where the value of the key is stored and where it is later used (grep is your friend)

Thamali April 21, 2014 05:27

Foam::combustionModels::PaSR<Foam::combustionModel s::psiChemistryCombustion>::correct
 
Dear Marco and other foamers,

I am sorry for not replying the former thread.I am really stucked with running a case which is necessary for completion of my MSc.Actually my major part of MSc was to develop a solver to model a packed bed in a wood chip combustion boiler.I have completed that part(though it is not very advanced).My next part is to use resulting packed bed parameters to be used to model free-board region combustion.

I have uploaded it to the following link.
https://www.dropbox.com/sh/4jew3uxfrt7ddtd/cazVzK0X3F

For that case I am using "reactingFoam" and "PaSR" as combustion model.I have so much of doubts in presenting reactions,turbulence property values,etc.
  1. I have created single folder to present 4 major reactions which are CO,CH4,CxHyOz combustion and then H2 combustion chain reaction which converted to a foam file using utility chemkinToFoam.(please refer reactions file).Dont know whether this method is correct.If someone have any idea please help.
  2. Cmix,k,mut,initial Chemical time step,deltaT value,odeCoeffs.etc were put referring to some literature,but the error which occurs making me doubt about all those values

Case always stops at some point with Floating Point Exception and I have failed to figure out where is the problem.
The error is;
PHP Code:

 Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2   in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::combustionModels::PaSR<Foam::combustionModels::psiChemistryCombustion>::correct() at ??:?
#4  
 
at ??:?
#5  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#6  
 
at ??:?
Floating point exception (core dumped

I highly appreciate even a very little idea to solve my problem.


Thanks.
Thamali

mturcios777 April 22, 2014 12:49

Thamali, have you run your solver/cases with a debug version of OpenFOAM. The error message you have is pretty vague and doesn't give much indication as to where the code dies.

Could you also post the last few timesteps and all associated error messages?

Thamali April 23, 2014 02:07

simplified case
 
Dear Marco,
I am very glad you replied.I did not run with Debug version.
I did some simplifications for the case for now to solve this issue.
  1. I removed gas components,temperature,velocity non-uniform inlet field for now and added uniform fields to them.
  2. removed chain reaction of H2 and other reactions are still there.
  3. Cmix=0.9
  4. case is running up to 0.0217(I have attached last three time directories and the log file to look at any errors shown)
the link for the new case is follows;
https://www.dropbox.com/sh/gbwuj5xxhaxew3s/ZU8ncig617

  • Actually I have not run any case/solver with debug version.If you think it is helpful for me?I would appreciate any documentation related to that.I have little idea but not much.
  • I am now trying to make an LTS solver out of reactingFoam(Actually I did and it is compiling without errors.),because my solver for packed bed is for steady state.I am willing to share it with anyone interested.I would love for your comments on that too.Here is the link.
https://www.dropbox.com/sh/od60ye13oyv0v3s/QgPk3MyF6n
  • I tried to run the case with above LTS solvers,but still the same error occurs.
(when running janaf thermo out of range is occurring at several time.Does that may be the reason,which makes Temperature at some points are 5000(or 200).pls refer folder 0.0217 line 114-122 in https://www.dropbox.com/sh/gbwuj5xxhaxew3s/ZU8ncig617).

when looking at Residulas at the time of error residuals seems like go to infinity.


Thank you very much again for your reply and eager for a reply.

With Regards,
Thamali

mturcios777 April 23, 2014 12:51

Whenever you are making your own solvers with custom sub-models, the debug version can help greatly as the stack track will give you the line numbers where the crash occurs (99% of the time anyway).

To set this up, you need to change the WM_COMPILE_OPTION from "Opt" to "Debug", source your bashrc file and then recompile the entire OpenFOAM installation, including your solver and models.

Thamali April 28, 2014 04:09

Debug version run
 
Dear Marco,
I ran the case in Debug version following your instructions.(for the same case in
https://www.dropbox.com/sh/gbwuj5xxhaxew3s/ZU8ncig617 ).

Now the error is as follows,
Code:

#0  Foam::error::printStack(Foam::Ostream&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OSspecific/POSIX/printStack.C:221
#1  Foam::sigFpe::sigHandler(int) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OSspecific/POSIX/signals/sigFpe.C:117
#2  in "/lib/x86_64-linux-gnu/libc.so.6"
#3  in "/lib/x86_64-linux-gnu/libm.so.6"
#4  Foam::sqrt(double) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/Scalar.H:258
#5  Foam::combustionModels::PaSR<Foam::combustionModels::psiChemistryCombustion>::correct() at ~/OpenFOAM/OpenFOAM-2.2.2/src/combustionModels/PaSR/PaSR.C:111 (discriminator 2)
#6 
 at ~/OpenFOAM/OpenFOAM-2.2.2/applications/solvers/combustion/reactingFoam/YEqn.H:14
#7  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#8 
 at ??:?
Floating point exception (core dumped)

PaSR.C:111 is equation for calculating for tk(mixing time scale) which is;

HTML Code:

Cmix_*Foam::sqrt(muEff[i]/rho[i]/(epsilon[i] + SMALL))
and the error Floating point Exception is shown in calcullating square root which is;

HTML Code:

sqrt(muEff[i]/rho[i]/(epsilon[i] + SMALL))
so,the reasons should be one of the following as I think;
  • muEff<0
  • rho=<0
  • (epsilon+SMALL)=<0
Now,I am trying to put a write() function to "rho" and see whether it is becoming "zero".
Yeaaaah,
It is this "rho" value is (-)ve at 3 points in time=0.0217543.I am adding "rho" file 0.0217543 to the link https://www.dropbox.com/sh/gbwuj5xxhaxew3s/ZU8ncig617 .

Do you have any idea which could lead to this? and also I cannot find from where this "rhoEqn.H" come to "reactingFoam.C"?

Please try to help.
Thanks in advance.
Thamali

mturcios777 April 28, 2014 13:30

reactingFoam uses the compressible rhoEqn from the default CFD library in $FOAM_SRC/finiteVolume/cfdTools/compressible/rhoEqn.H. If your density is becoming negative, I would check your boundar conditions and chemistry. Also, I would be sure that the density works properly with chemistry off first.

Thamali May 29, 2014 02:10

Thanking
 
Dear Marco,

It was an error in initial conditions which made sum of initial mass fractions were greater than 1.
Took a long time to point out that since i never thought that type of error would occur.
Anyway thank you very much for your kind help.
Regards,
Thamali

epi_c September 3, 2014 20:37

reactingFoam: Floating Point Exception
 
Dear Thamali

I have the same problem (FPE) you posted in this thread, and congratulations you have solved the problem.

But I can't open the links you gave, could you share me your case settings? So I can set my case with reference to your settings (Cmix, k, mut, initial Chemical time step, odeCoeffs and initial and boundary conditions).

Regards
Francis

Thamali September 4, 2014 00:11

Dear Francis,
I will put you a working case .
https://www.dropbox.com/sh/6edomtqox...tW153vFaa?dl=0

but,i do not know your real problem.If this does not work;you can tell us more detail to see whether we can help.
Thanks
Thamali

Howard March 27, 2015 16:04

Quote:

Originally Posted by Thamali (Post 487613)
Dear Marco,
I am very glad you replied.I did not run with Debug version.
I did some simplifications for the case for now to solve this issue.
  1. I removed gas components,temperature,velocity non-uniform inlet field for now and added uniform fields to them.
  2. removed chain reaction of H2 and other reactions are still there.
  3. Cmix=0.9
  4. case is running up to 0.0217(I have attached last three time directories and the log file to look at any errors shown)
the link for the new case is follows;
https://www.dropbox.com/sh/gbwuj5xxhaxew3s/ZU8ncig617

  • Actually I have not run any case/solver with debug version.If you think it is helpful for me?I would appreciate any documentation related to that.I have little idea but not much.
  • I am now trying to make an LTS solver out of reactingFoam(Actually I did and it is compiling without errors.),because my solver for packed bed is for steady state.I am willing to share it with anyone interested.I would love for your comments on that too.Here is the link.
https://www.dropbox.com/sh/od60ye13oyv0v3s/QgPk3MyF6n
  • I tried to run the case with above LTS solvers,but still the same error occurs.
(when running janaf thermo out of range is occurring at several time.Does that may be the reason,which makes Temperature at some points are 5000(or 200).pls refer folder 0.0217 line 114-122 in https://www.dropbox.com/sh/gbwuj5xxhaxew3s/ZU8ncig617).

when looking at Residulas at the time of error residuals seems like go to infinity.


Thank you very much again for your reply and eager for a reply.

With Regards,
Thamali

Hi friend! Now I'm learning to use the reactiongFoam. But I don't know how the combustion is in reactingFoam, like the PaSR. Could you give me some information about the model?

Thamali March 30, 2015 07:04

PaSR model
 
Dear Howard,

I'll give you some references about PaSR model.As per my knowledge it has been developed by Chalmers university.

  1. 1http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2007/rhiechow.pdf
  2. J. Karlsson, “Modeling auto-ignition,flame propagation and combustion in non-
    stationary turbulent sprays,” Ph.D. dissertation, Chalmers university of technol-
    ogy, 1995.
  3. P. Nordin, “Complex chemistry modeling of diesel spray combustion,” Ph.D. dissertation, Chalmers University of Technology,Dept. of Thermo and Fluid Dynamics,Goteborg, 2001
Good luck!
Thamali


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