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/)
-   -   Solving for absolute enthalpy in the 2.2.x psiReactionThermo (http://www.cfd-online.com/Forums/openfoam-programming-development/118303-solving-absolute-enthalpy-2-2-x-psireactionthermo.html)

sushant May 24, 2013 10:22

Solving for absolute enthalpy in the 2.2.x psiReactionThermo
 
Dear all,

I am trying to change the energy equation variable in 2.2.x sprayFoam from sensible enthalpy to absolute enthalpy. This is my current thermophysical setup:

Code:

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

If I change sensibleEnthalpy to absoluteEnthalpy I get a list of possible combinations supported, which does not include the one I want. http://www.openfoam.org/version2.2.0/thermophysical.php has this to say:

Quote:

If the particular combination of models is not available in the list, that combination can be compiled into a library or the application (as always).
If I look in src/thermophysicalModels/reactionThermo/psiReactionThermo/psiReactionThermos.C, it is straightforward to construct absoluteEnthalpy variants that will apply for homogeneousMixture, inhomogeneousMixture, etc., which is done by

Code:

makeReactionThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    inhomogeneousMixture,
    sutherlandTransport,
    absoluteEnthalpy,
    janafThermo,
    perfectGas,
    specie
);

However the construction for the reaction mixtures is:

Code:

makeReactionMixtureThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    reactingMixture,
    gasHThermoPhysics
);

How can I reformulate this to use the absolute enthalpy?

Regards,
Sushant

zqlhzx September 16, 2013 02:40

Hi,sushant:
I have some problem like you.I add codes:
makeReactionThermo
(
psiThermo,
psiReactionThermo,
hePsiThermo,
inhomogeneousMixture,
sutherlandTransport,
absoluteEnthalpy,
janafThermo,
perfectGas,
specie
); to psiReactionThermos.C,then save the file.But when I run my case using
thermoType
{
type hePsiThermo;
mixture inhomogeneousMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
},it still gave me the some error "Unknow psiReationThermo type"and showed me valid psiReactionThermo types.Do you can define your thermotype by add the above codes to psiReactionThermos.C?The thermo type I want to define as following:
thermoType
{
type hePsiThermo;
mixture singleStepReactingMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}However,I really do not know how to do it.According to userguide "if the particular combination of models is not available in the list, that combination can be compiled into a library or the application (as always).",I have to build new library include my defined thermotype,can you success it?If you know something about it,could you give me some advises?

dkxls September 16, 2013 04:28

Quote:

Originally Posted by sushant (Post 429823)
I am trying to change the energy equation variable in 2.2.x sprayFoam from sensible enthalpy to absolute enthalpy.

I would really recommend you to use the sensible enthalpy when using chemistry in OpenFOAM.
I gave some more explanations here:
http://www.cfd-online.com/Forums/ope...tml#post451802

Also, for spray simulation there are more changes required than just in the thermo class, as the spray also has source terms in the transport equations! I have a working sprayFoam solver that uses absolute enthalpy, but I cut out the whole chemistry part and replaced it by my own combustion model, i.e. Flamelet Generated Manifolds (FGM).

Quote:

Originally Posted by sushant (Post 429823)
How can I reformulate this to use the absolute enthalpy?

If you really want to get into this business, I posted here a peace of code that should get you started, but still some way to:
http://www.cfd-online.com/Forums/ope...tml#post451645

Maybe a last comment on the sprayFoam: It has been horribly broken until a couple of days ago. I fixed most of the issues concerning the thermodynamics together with the OpenFOAM developers, but there are still several issues, especially concerning the breakup models.
For more infos, see the list of bugs I reported/fixed in the last couple of weeks (and there are still more to come...):
http://www.openfoam.org/mantisbt/vie...hide_status=90

Likun June 12, 2014 03:15

Dear Armin,

I also want to use the sprayFoam with FGM combustion model. As you mentioned there are lots of bugs in the sprayFoam under 2.2.x, so I want to use 2.3.0, hopefully some of the bugs have been fixed.

For the FGM model, I have the Rostock extension(http://www.cfd-online.com/Forums/ope...ion-model.html). But it was previous used in 1.7.x, and I have lot of troubles in compiling it into 2.3.

Quote:

lnInclude/SIJPDFthermo.H:196: error: there are no arguments to 'psi' that depend on a template parameter, so a declaration of 'psi' must be available
lnInclude/SIJPDFthermo.H:196: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from lnInclude/SIJPDFthermo.H:314,
from thermophysicalModels/compositionPdf/abstractProgressVariableThermo/abstractProgressVariableThermo.C:31:
lnInclude/SIJPDFthermo.C: In member function 'Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::SIJPDFthermo<IndexDriver>::normalizedFirstMo ment(Foam::label) const':
lnInclude/SIJPDFthermo.C:143: error: 'psi_' was not declared in this scope
lnInclude/SIJPDFthermo.C: In member function 'virtual void Foam::SIJPDFthermo<IndexDriver>::initialize()':
lnInclude/SIJPDFthermo.C:786: error: 'psi_' was not declared in this scope
lnInclude/SIJPDFthermo.C:793: error: there are no arguments to 'hBoundaryTypes' that depend on a template parameter, so a declaration of 'hBoundaryTypes' must be available
In file included from lnInclude/SIJPDFthermo.H:314,
from thermophysicalModels/compositionPdf/abstractProgressVariableThermo/abstractProgressVariableThermo.C:31:
lnInclude/SIJPDFthermo.C: In member function 'virtual void Foam::SIJPDFthermo<IndexDriver>::correct()':
lnInclude/SIJPDFthermo.C:1170: error: 'psi_' was not declared in this scope
lnInclude/SIJPDFthermo.C:1206: error: 'mu_' was not declared in this scope
lnInclude/SIJPDFthermo.C:1247: error: 'mu_' was not declared in this scope
lnInclude/SIJPDFthermo.C: In member function 'bool Foam::SIJPDFthermo<IndexDriver>::readPreIntegrated TableFromCache()':
lnInclude/SIJPDFthermo.C:1446: error: 'psi_' was not declared in this scope
lnInclude/SIJPDFthermo.C: In member function 'void Foam::SIJPDFthermo<IndexDriver>::writeCache() const':
lnInclude/SIJPDFthermo.C:1492: error: 'psi_' was not declared in this scope
thermophysicalModels/compositionPdf/abstractProgressVariableThermo/abstractProgressVariableThermo.C: In constructor 'Foam::abstractProgressVariableThermo::abstractPro gressVariableThermo(const Foam::fvMesh&)':
thermophysicalModels/compositionPdf/abstractProgressVariableThermo/abstractProgressVariableThermo.C:133: error: no matching function for call to 'Foam::basicThermo::basicThermo(const Foam::fvMesh&)'
/home6695/likun/OpenFOAM/OpenFOAM-2.3.0/src/thermophysicalModels/basic/lnInclude/basicThermo.H:128: note: candidates are: Foam::basicThermo::basicThermo(const Foam::fvMesh&, const Foam::dictionary&, const Foam::word&)
/home6695/likun/OpenFOAM/OpenFOAM-2.3.0/src/thermophysicalModels/basic/lnInclude/basicThermo.H:121: note: Foam::basicThermo::basicThermo(const Foam::fvMesh&, const Foam::word&)
/home6695/likun/OpenFOAM/OpenFOAM-2.3.0/src/thermophysicalModels/basic/lnInclude/basicThermo.H:84: note: Foam::basicThermo::basicThermo(const Foam::basicThermo&)
As I understand these errors are due to the difference of the thermophysical model in 1.7.x and 2.3. Can you please kindly share some experiences and give me some hints on what modification should I do to make it work in 2.3?

Many thanks in advance!

Best regards,
Likun

dkxls June 12, 2014 05:20

Hello Likun,
Quote:

Originally Posted by Likun (Post 496713)
As you mentioned there are lots of bugs in the sprayFoam under 2.2.x, so I want to use 2.3.0, hopefully some of the bugs have been fixed.

Yeah, the most crucial bugs are fixed in 2.2.x and 2.3.x. However, there are still some outstanding bugs concerning the breakup modeling and I would generally recommend you to use the 2.3.x git-version.

Quote:

Originally Posted by Likun (Post 496713)
As I understand these errors are due to the difference of the thermophysical model in 1.7.x and 2.3. Can you please kindly share some experiences and give me some hints on what modification should I do to make it work in 2.3?

I assume that you got the code from here: http://sourceforge.net/projects/ofca/
In this case, I cannot really help you, as I have actually never used that code.

I implemented the FGM combustion model from scratch, as I use a different approach to couple the flamelet solutions to the flow solver, mainly due to the spray.
Also, I use chem1d (http://www.tue.nl/en/university/depa...vities/chem1d/) to compute the flamelet solutions.

There is btw also another implementation of a tabulated flamelet model:
https://github.com/shor-ty/flameletModel-2.2.x
http://www.cfd-online.com/Forums/ope...nsmoke-18.html
But also this implementation is not really suited for spray combustion and requires you to use a specific flamelet-code. But you could probably extend this code for spray combustion, not quite sure though.

Cheers,
Armin

Likun June 12, 2014 10:17

Hi Armin,

Thank you so much for the quick answer. Yes, http://sourceforge.net/p/ofca/code/ref/master/ is the code that I tried to compile into OpenFoam-2.3. But there are a lot of problems for the compiling, probably it is impossible for me to do that, because I am quiet new with OpenFoam as well as C++.

I am trying the steady flamelet model that you mentioned, I think I will try to extend it to FGM and for spray combustion, because as we know the flamelet model can not correctly predict the ignition process.

For the FGM, I also use Chem1D for generating the FGM table. Then to use that in OpenFoam, we have to first integrate the table with presumed PDFs for the independent variables. Who do you do the integration? With your own code or there are some utilities available? Indeed, to make it work for spray combustion, there is still a long way to go. Do you added the FGM model in the sprayFoam or how do you deal with the spray part?

Best regards,
Likun

dkxls June 12, 2014 10:40

Quote:

Originally Posted by Likun (Post 496793)
For the FGM, I also use Chem1D for generating the FGM table. Then to use that in OpenFoam, we have to first integrate the table with presumed PDFs for the independent variables. Who do you do the integration? With your own code or there are some utilities available? Indeed, to make it work for spray combustion, there is still a long way to go. Do you added the FGM model in the sprayFoam or how do you deal with the spray part?

I'm still using per-integrated tables, I have python script for that. I had some plans at some point to do the integration during run-time, but I haven't implemented it yet in OpenFOAM (shouldn't be too hard, and there is the FSD model as a reference implementation).

Otherwise, I wrote a custom solver based on sprayFoam that links the FGM tables to the flow calculation.

Who are you btw working with from the Eindhoven group?

Likun June 12, 2014 14:18

Quote:

Originally Posted by dkxls (Post 496800)
I'm still using per-integrated tables, I have python script for that. I had some plans at some point to do the integration during run-time, but I haven't implemented it yet in OpenFOAM (shouldn't be too hard, and there is the FSD model as a reference implementation).

Otherwise, I wrote a custom solver based on sprayFoam that links the FGM tables to the flow calculation.

Who are you btw working with from the Eindhoven group?

Thank you very much for the information. Btw what does FSD model refers to? I am sorry, but I am not aware of the FSD model.

In think integrate the table during run time is really time consuming and not really necessary if you are not doing transported PDF simulation. For the presumed PDF method, the pre-integrated FGM table should be fine.

I am in Delft, we have some collaboration with Prof. Jeroen van Oinen in Eindhoven.

dkxls June 16, 2014 09:27

Quote:

Originally Posted by Likun (Post 496822)
Btw what does FSD model refers to? I am sorry, but I am not aware of the FSD model.

Flame Surface Dennsity (FDS) combustion model, see here:
Code:

src/combustionModels/FSD/FSD.H
Quote:

Originally Posted by Likun (Post 496822)
In think integrate the table during run time is really time consuming and not really necessary if you are not doing transported PDF simulation. For the presumed PDF method, the pre-integrated FGM table should be fine.

As I said, there are pros and cons, e.g. CPU vs memory usage. ;)

Quote:

Originally Posted by Likun (Post 496822)
I am in Delft, we have some collaboration with Prof. Jeroen van Oinen in Eindhoven.

Ah, OK. Jeroen is mostly working on premixed combustion. I'm working with Prof. Bart Somers on the non-premixed combustion. Though both are combustion experts, especially when it comes to tabulated chemistry and FGM. ;)

Likun June 16, 2014 10:31

Thank you for the answer.

Are you doing LES or RANS with SprayFoam?

flavio_galeazzo October 10, 2014 19:01

Hello Armin,

Sorry for bumping this thread, but I am very interested in the discussion here.

I am using a sort of FGM model developed by a colleague and implemented for OF 1.5.x, however it works with an absolute enthalpy formulation. Now I am working in the extension of the model to handle spray combustion. The problem I am facing is that the new lagrangian library (from OF 2.1 and ahead) has only support for sensible enthalpy. I understand from your threads that you have a sprayFoam solver that uses absolute enthalpy, which is exactly what I am also trying to develop. Do you mind sharing how you did that?

Best regards,

Flavio

dkxls October 13, 2014 05:31

Have you had a look at the code I posted here?
http://www.cfd-online.com/Forums/ope...tml#post451645

I implemented there a multi-component mixture for absolute enthalpy.

This should be enough for a FGM (i.e. tabulated chemistry) model, since you don't need the OpenFOAM chemistry part in that case.
To be more specific, a reactingMixture is a multiComponentMixture plus chemistry reader/solver. All the species related stuff (Cp, viscosity, ...) is implemented in the multiComponentMixture.

Hope this helps!

-Armin

flavio_galeazzo October 13, 2014 22:11

Thank you for the prompt reply, Armin.

Your code is very helpful! It is small and get the job done. My solution to get the solver to use absolute enthalpy and multiComponentMixture was a bit dirtier, but worked also.

The real difficulty is in calculating the enthalpy source term of the spray. From the lagrangian library I got the sensible enthalpy (parcels.Sh(he) ). To have the absolute enthalpy my approach was to use the mass source term of each species multiplied by the standard heat of formation (here just an example with only one component)

Code:

  tmp<fvScalarMatrix>thSource(new fvScalarMatrix(h, dimEnergy/dimTime));
    fvScalarMatrix& hSource = thSource();

    forAll(Y, i)
    {
        // enthalpy of ethanol -5.0973E+006 J/kg (from cantera, f=1)
        hSource.source() += parcels.rhoTrans(i)*5.0973E+006/mesh.time().deltaTValue();
    }

This solution is not good enough, because after some time (say 10k time steps) I start getting really low temperatures where the spray evaporates, below 200K, and the solver crashes.

Do you have a clue what I am missing here?

Best regards,

Flavio

dkxls October 14, 2014 03:34

Quote:

Originally Posted by flavio_galeazzo (Post 514167)
The real difficulty is in calculating the enthalpy source term of the spray. From the lagrangian library I got the sensible enthalpy (parcels.Sh(he) ). To have the absolute enthalpy my approach was to use the mass source term of each species multiplied by the standard heat of formation (here just an example with only one component)

I assume that the standard enthalpy of formation, or "chemical enthalpy" in OpenFOAM terms, corresponds to the one you would get from the thermo library, i.e. the enthalpies calculated from cantera and OpenFOAM are matching.
I'm not quite sure if all signs and units are correct, but that should be easy to figure out. Otherwise your approach is generally correct.
I don't have my code at hand right now, but I remember using the standard enthalpy of formation from the thermo classes, i.e. something like composition.Hc(i).
Also, I typically create in such cases a dimensionedScalar and divide then by runTime.deltaT() instead of deltaTValue()


Quote:

Originally Posted by flavio_galeazzo (Post 514167)
This solution is not good enough, because after some time (say 10k time steps) I start getting really low temperatures where the spray evaporates, below 200K, and the solver crashes.

Alright, there were unfortunately too many bugs in sprayFoam. So which version are you using and is the "cold" spray with sensible enthalpy working correctly? Also, are you using a breakup model and if so which one?

For sprayFoam you have two options: the latest 2.2.x git version or the latest 2.3.x git version. With older versions there were so many bugs that led to very weird temperatures (e.g. -200 or +8000), but that stuff is fixed in the latest git versions.

flavio_galeazzo October 14, 2014 18:57

Thank you very much for your comments, Armin, it helped a lot to know that I am not following a wrong path. The hint about the enthalpy of formation helped a lot also. You are probrably correct, and as I finish porting my stuff to OF 2.3.x a lot of the weird behavior should be gone. It appears I have a lot of work ahead of me, hehehe.

Cheers

epi_c April 28, 2015 03:49

which enthalpy to use
 
Hi, Armin

@dkxls, I'm now doing a two compressible fluids mixing problem. One treats as perfect gas, and another a compressible liquid satisfy the equation of state rho = rho0 + psi * (p - p0). For each phase, I use a rhoThermo thermo type. But if I want to solve mixture energy equation, which energy type should I use? sensibleEnthalpy absoluteEnthalpy sensibleInternalEnergy absoluteInternalEnergy...
Because under standard condition, the heat of formation of a perfect gas is zero, and that of liquid(oil) is a very huge negative value. The energy in a cell changes with its composition and temperature, which energy type do you think is suitable for this situation?

Best Regards
Francis Lee

dkxls April 28, 2015 04:15

Quote:

Originally Posted by epi_c (Post 544058)
The energy in a cell changes with its composition and temperature, which energy type do you think is suitable for this situation?

This is merely a matter of taste. They all should give you the same results.

In some specific cases, like highly compressible (i.e. supersonic) flows or chemically reacting flows (i.e. combustion), one or another may be preferred, but even there all energy representations will give you correct results.

epi_c April 28, 2015 04:49

Dear Armin,
Thank you for your quickly reply. Now I understand, all type of energy give the correct reuslt, but different energy type corresponds to different coding difficulty.

Then, there is another question. I write a twoPhaseThermo class refered to that used in compressibleInterFoam but uses both mass fraction and volume fraction to calculate mixture properties. And I want to add energy (he_) in that class, so the energy boundary condition comes as a problem.

I read heBoundaryBaseTypes() in basicThermo.C, cause I want to use zeroGradient for T, so then I read updateCoeffs() in gradientEnergyFvPatchScalarField.C, in there I found

fvPatchScalarField& Tw =
Tw.evaluate();

before calculate gradient of energy on that patch. But in my konwledge, all T (boundary and internal) are calculated based on the solved energy ty write thermo.correct(), why in correcting he boundary, Tw is a non-const variable?

Thanks ahead.
Best Regard

wenxu July 10, 2015 05:43

Dear Armin,

Now I want to simulate premixed flame using flamelet model. And i want to take FGM as a reference which had been released here. Unfortunately, I can not download it. Could you send them to me? Thank you in advance! My email address: 981588592@qq.com

Best regards,
Wen Xu

wenxu July 16, 2015 21:15

Why the reactionThermo is not based on the psiuRectionThermo but on psiRectionThermo for premixed combustion?


All times are GMT -4. The time now is 09:24.