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

Cantera

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 30, 2010, 04:19
Default
  #41
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by SilPaut View Post
Hi everybody,

In order to call the "speciesData" I use these lines in reactingFoam.

reactingMixture& multiMix = (reactingMixture&) thermo->composition();
PtrList<reactingMixture::reactionThermo> speciesData = multiMix.speciesData();

but I have some troubles to do the same with alternateReactingFoam / cantera solver.
Does somebody know how I can access to the "speciesData()" using alternateReactingFoam?

Thank you!!
Silvano
Problem is that as Cantera has his own data structures for data about the species. And these are not converted to OpenFOAM. The alternateSolver only needs, and gets, the mixture properties. Accessing these properties involves heavy casting and specializing for the actually used chemistry implementation

Bernhard
gschaider is offline   Reply With Quote

Old   August 30, 2010, 13:33
Default
  #42
New Member
 
Silvano
Join Date: Aug 2010
Location: Chicago /Torino Us/Italy
Posts: 11
Rep Power: 15
SilPaut is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Problem is that as Cantera has his own data structures for data about the species. And these are not converted to OpenFOAM. The alternateSolver only needs, and gets, the mixture properties. Accessing these properties involves heavy casting and specializing for the actually used chemistry implementation

Bernhard
Bernhard,
thanks a lot! actually I need to access to the H[i] (enthalpy of each species )... is there another way to call them?

Silvano
SilPaut is offline   Reply With Quote

Old   August 30, 2010, 14:05
Default Sensible Enthalpy
  #43
Senior Member
 
sahm's Avatar
 
Seyyed Ali H.M.
Join Date: Nov 2009
Location: Utah
Posts: 107
Rep Power: 16
sahm is on a distinguished road
Hi Everybody
I have the same problem, I want to have access to sensible enthalpy of mixture, and the chemical energy source term in Cantera. How can I do that?
__________________
SAHM
sahm is offline   Reply With Quote

Old   September 1, 2010, 10:54
Default Questions about Cantera
  #44
New Member
 
Olli
Join Date: Mar 2010
Location: Berlin
Posts: 13
Rep Power: 16
Moelfus is on a distinguished road
Hi everyone,

I'm researching in the field of swirl burners and have some experiences simulating combustion with CFX. Unfortunately I fell in love with OF. Due to the instructions I've installed the cantera-interface and now I ready to go. So here are my questions, which are probably easy to answer for you experts:

1. How is the coupling between OF and Cantera done. I mean is OF calculating the transport of each species and cantera calculates the reaction rates. Is this done via a source term? I just want to understand how the programs work.

2. Is the cantera thing able to simulate a premixed case (Methane/Air)

3. Is there an introduction on how to set an OF case with comubustion and cantera up? Something like a step-by-step. The provided tutorials are not commented. If someone can give me hint on the setup I would write it down for everyone.

Regards,

Olli
Moelfus is offline   Reply With Quote

Old   September 4, 2010, 16:34
Default
  #45
Senior Member
 
Markus Rehm
Join Date: Mar 2009
Location: Erlangen (Germany)
Posts: 184
Rep Power: 17
markusrehm is on a distinguished road
Hello Sahm and Silvano,

sorry for letting you wait for so long. Here a possible solution to your problem:


Quote:
Originally Posted by sahm View Post
Hi Everybody
I have the same problem, I want to have access to sensible enthalpy of mixture, and the chemical energy source term in Cantera. How can I do that?
Inside the solve function (canteraLocalTimeChemistryModel::solve) the Cantera gas mix object is created. There you can access all functions Cantera provides. Such as the mass fraction:

Code:
gas.gas().getMassFractions(y1.begin())
or the density

Code:
rhomean = gas.gas().density()
For the enthalpies it should be something like

Code:
getEnthalpy_RT()
.

See the Cantera Header files for more information (in CANTERA_INSTALLATION/include/cantera/kernel/).

As long as you need the data only within that function and calculate the source terms there it won't be difficult. But if you want it in the hEqn of the solver the problems Bernhard mentioned will occur.

I hope that helps. Regards, Markus.
markusrehm is offline   Reply With Quote

Old   September 4, 2010, 16:46
Default
  #46
Senior Member
 
Markus Rehm
Join Date: Mar 2009
Location: Erlangen (Germany)
Posts: 184
Rep Power: 17
markusrehm is on a distinguished road
Hello Olli,

thanks for your interest in the code. I hope to be able to help a bit further.

Quote:
Originally Posted by Moelfus View Post

1. How is the coupling between OF and Cantera done. I mean is OF calculating the transport of each species and cantera calculates the reaction rates. Is this done via a source term? I just want to understand how the programs work.

2. Is the cantera thing able to simulate a premixed case (Methane/Air)

3. Is there an introduction on how to set an OF case with comubustion and cantera up? Something like a step-by-step. The provided tutorials are not commented. If someone can give me hint on the setup I would write it down for everyone.

Regards,
Olli
1) Yes it is done via source terms the species transport and energy equation are solved in the OF loop then the mixture is given to Cantera which calculates source terms and also viscosity.

2) It depends on the combustion model. Cantera is only used as database and to integrate the chemistry. For the combustion model you have to see if the available models fit.

3.) The solver is based on reactingFoam. So try to understand this one and then see what are the differences to the new one.

Reactingfoam is for example explained here:

http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2007/AndreasLundstrom/reactingFoam.pdf

Additionally I recommend you to have a look at the Cantera tutorials and test cases.

If there are more things you do not understand feel free to ask.

Bye, Markus.
markusrehm is offline   Reply With Quote

Old   September 8, 2010, 15:28
Default
  #47
New Member
 
Silvano
Join Date: Aug 2010
Location: Chicago /Torino Us/Italy
Posts: 11
Rep Power: 15
SilPaut is on a distinguished road
Quote:
Originally Posted by markusrehm View Post

As long as you need the data only within that function and calculate the source terms there it won't be difficult. But if you want it in the hEqn of the solver the problems Bernhard mentioned will occur.

I hope that helps. Regards, Markus.
Markus, Thank you very much!

actually I would like modify the hEqn adding the the term: sum{div[h(i)*(muEff-alphaEff)]gradY(i)} that you get considering all Sc=1 in stead have unity Lewis Number.

So for ReactingFoam I use the following hEqn:
Code:
{
    reactingMixture& multiMix = (reactingMixture&) thermo->composition();
    PtrList<reactingMixture::reactionThermo> speciesData = multiMix.speciesData();
  canteraLocalTimeChemistryModel::solve
    { 

   
        energySource *= 0.0;  

        surfaceScalarField alphaF = fvc::interpolate(turbulence->alphaEff() );
        surfaceScalarField muF = fvc::interpolate( turbulence->muEff() );
        
        volScalarField hY("hY",h);
        surfaceScalarField alphaH("alphaH", alphaF * fvc::interpolate( h) );

        for (label i = 0; i < Y.size(); i++) 
    {
            Info << "\tCalculating differential flux for species " <<  Y[i].name() << endl;
            reactingMixture::reactionThermo& spData = speciesData[i];
            forAll(T, iCell) 
            {
                hY[iCell] = spData.H(T[iCell] );
            }   
            forAll(T.boundaryField(), iPatch)
            {
                const fvPatchScalarField& T_patch = T.boundaryField()[iPatch];
                fvPatchScalarField& hY_patch = hY.boundaryField()[iPatch];
                
                forAll(T_patch, iFace) 
                {
                    hY_patch[iFace] = spData.H(T_patch[iFace] );
                }
            }                         
            alphaH = fvc::interpolate(hY) * (muF - alphaF);  
                        
            energySource += fvc::laplacian( alphaH, Y[i] );
        }
    }

   
     solve
    (
        fvm::ddt(rho, h)
      + mvConvection->fvmDiv(phi, h)
      - fvm::laplacian(turbulence->alphaEff(), h)
     ==
        DpDt
      + energySource
    );

    thermo->correct();
}
where "energySource"is defined in createFields.H
Code:
volScalarField energySource
    (
        IOobject
        (
            "energySource",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("zero", DpDt.dimensions(), 0.0)
    );
I have still some problem to convert this equation for the alternateReactingFoam solver...
I would be very grateful if you could help me with this issue...

Thanks,
Silvano
SilPaut is offline   Reply With Quote

Old   September 9, 2010, 04:12
Default
  #48
New Member
 
Olli
Join Date: Mar 2010
Location: Berlin
Posts: 13
Rep Power: 16
Moelfus is on a distinguished road
Hi Markus,
thank you for your answers. I will start with understanding reactingFoam and than continue to cantera. So be prepared for more questions;-)

Thanks,
Olli
Moelfus is offline   Reply With Quote

Old   October 7, 2010, 13:53
Default
  #49
Senior Member
 
sahm's Avatar
 
Seyyed Ali H.M.
Join Date: Nov 2009
Location: Utah
Posts: 107
Rep Power: 16
sahm is on a distinguished road
Hi Markus and Bernhard
This was the last error I got when trying to install canterathermochemistry
/usr/bin/ld: /usr/local/lib/libsundials_cvodes.a(cvodes.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libsundials_cvodes.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [/home/sahm/OpenFOAM/sahm-1.5-dev/lib/linux64GccDPOpt/libcanteraThermosChemistry.so] Error 1

As far as I know, installation of sundials was done with -fPIC, so I don't what to do with this final error. Should I run wmake with this key?
Still there's a chance that I have defined the addresses wrong.
I would really appreciate if any one could help me with this.
__________________
SAHM
sahm is offline   Reply With Quote

Old   October 8, 2010, 04:35
Default
  #50
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by sahm View Post
Hi Markus and Bernhard
This was the last error I got when trying to install canterathermochemistry
/usr/bin/ld: /usr/local/lib/libsundials_cvodes.a(cvodes.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libsundials_cvodes.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [/home/sahm/OpenFOAM/sahm-1.5-dev/lib/linux64GccDPOpt/libcanteraThermosChemistry.so] Error 1

As far as I know, installation of sundials was done with -fPIC, so I don't what to do with this final error. Should I run wmake with this key?
Still there's a chance that I have defined the addresses wrong.
I would really appreciate if any one could help me with this.
Please double-check your sundials-compilation. I'm pretty sure that things are like ld reports them (that not everything was compiled with -fPIC). Especially check that ALL compilers that are used to compile it use that switch (one .o-file that is non-PICt taints the whole library)

Bernhard
gschaider is offline   Reply With Quote

Old   October 8, 2010, 11:19
Smile
  #51
Senior Member
 
sahm's Avatar
 
Seyyed Ali H.M.
Join Date: Nov 2009
Location: Utah
Posts: 107
Rep Power: 16
sahm is on a distinguished road
Please double-check your sundials-compilation. I'm pretty sure that things are like ld reports them (that not everything was compiled with -fPIC). Especially check that ALL compilers that are used to compile it use that switch (one .o-file that is non-PICt taints the whole library)

Bernhard[/QUOTE]
Thanks bernhard, but I have a question,
I was trying to wmake the canterachemistrythermo, one by one, and I just removed the -l libraries inside the Make/options file, then tried to wmake it, and it compiled, I have no Idea what they were for, or what will happen next as I have not used it with any solver yet. Could you tell me what those libraries are for ? or where they're being used.
SAHM.
__________________
SAHM
sahm is offline   Reply With Quote

Old   October 11, 2010, 05:13
Default
  #52
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by sahm View Post
Please double-check your sundials-compilation. I'm pretty sure that things are like ld reports them (that not everything was compiled with -fPIC). Especially check that ALL compilers that are used to compile it use that switch (one .o-file that is non-PICt taints the whole library)

Bernhard
Thanks bernhard, but I have a question,
I was trying to wmake the canterachemistrythermo, one by one, and I just removed the -l libraries inside the Make/options file, then tried to wmake it, and it compiled, I have no Idea what they were for, or what will happen next as I have not used it with any solver yet. Could you tell me what those libraries are for ? or where they're being used.
SAHM.[/QUOTE]

Would have to look at the sources myself.

Try running the solver. If the dynamic linker doesn't throw an error about missing references everything is fine

Bernhard
gschaider is offline   Reply With Quote

Old   October 11, 2010, 18:40
Talking
  #53
Senior Member
 
sahm's Avatar
 
Seyyed Ali H.M.
Join Date: Nov 2009
Location: Utah
Posts: 107
Rep Power: 16
sahm is on a distinguished road
Quote:
Originally Posted by gschaider View Post

Would have to look at the sources myself.

Try running the solver. If the dynamic linker doesn't throw an error about missing references everything is fine

Bernhard
Apparently the linker is giving me error, as I get the following message.

Selecting thermodynamics package hMixtureThermo<canteraMixture>


Unknown hCombustionThermo type hMixtureThermo<canteraMixture>

Valid hCombustionThermo types are :

9
(
hMixtureThermo<multiComponentMixture<sutherlandTra nsport<specieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<dieselMixture<sutherlandTransport<s pecieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<veryInhomogeneousMixture<sutherland Transport<specieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<inhomogeneousMixture<sutherlandTran sport<specieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<homogeneousMixture<sutherlandTransp ort<specieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<veryInhomogeneousMixture<constTrans port<specieThermo<hConstThermo<perfectGas>>>>>
hMixtureThermo<inhomogeneousMixture<constTransport <specieThermo<hConstThermo<perfectGas>>>>>
hMixtureThermo<homogeneousMixture<constTransport<s pecieThermo<hConstThermo<perfectGas>>>>>
hMixtureThermo<reactingMixture>
)


From function hCombustionThermo::New(const fvMesh&)
in file hCombustionThermo/newhCombustionThermo.C at line 68.

FOAM exiting.
So, what should I do with those libraries. How can I make sure that I have installed them correctly and I have linked the canteraThermochemistry correctly.
Thanks for your help.
__________________
SAHM
sahm is offline   Reply With Quote

Old   October 12, 2010, 07:47
Default
  #54
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by sahm View Post
Apparently the linker is giving me error, as I get the following message.

Selecting thermodynamics package hMixtureThermo<canteraMixture>


Unknown hCombustionThermo type hMixtureThermo<canteraMixture>

Valid hCombustionThermo types are :

9
(
hMixtureThermo<multiComponentMixture<sutherlandTra nsport<specieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<dieselMixture<sutherlandTransport<s pecieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<veryInhomogeneousMixture<sutherland Transport<specieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<inhomogeneousMixture<sutherlandTran sport<specieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<homogeneousMixture<sutherlandTransp ort<specieThermo<janafThermo<perfectGas>>>>>
hMixtureThermo<veryInhomogeneousMixture<constTrans port<specieThermo<hConstThermo<perfectGas>>>>>
hMixtureThermo<inhomogeneousMixture<constTransport <specieThermo<hConstThermo<perfectGas>>>>>
hMixtureThermo<homogeneousMixture<constTransport<s pecieThermo<hConstThermo<perfectGas>>>>>
hMixtureThermo<reactingMixture>
)


From function hCombustionThermo::New(const fvMesh&)
in file hCombustionThermo/newhCombustionThermo.C at line 68.

FOAM exiting.
So, what should I do with those libraries. How can I make sure that I have installed them correctly and I have linked the canteraThermochemistry correctly.
Thanks for your help.
Nope. That is not the linker talking. That is the OF run-time-selection system. Fine difference.

Make sure that
a) you load the Cantera-library via libs in controlDict
b) if you do: check whether there is a warning/error about not being able to load it further up in the log-file (it is usually a good idea to look for the first sign of trouble)

If you do a) and b) gives no problem then hMixtureThermo<canteraMixture> should be part of that list (or you get no error at all)

Bernhard
gschaider is offline   Reply With Quote

Old   October 12, 2010, 16:39
Post log files.
  #55
Senior Member
 
sahm's Avatar
 
Seyyed Ali H.M.
Join Date: Nov 2009
Location: Utah
Posts: 107
Rep Power: 16
sahm is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Nope. That is not the linker talking. That is the OF run-time-selection system. Fine difference.

Make sure that
a) you load the Cantera-library via libs in controlDict
b) if you do: check whether there is a warning/error about not being able to load it further up in the log-file (it is usually a good idea to look for the first sign of trouble)

If you do a) and b) gives no problem then hMixtureThermo<canteraMixture> should be part of that list (or you get no error at all)

Bernhard
Hi Bernhard.
Apparently I have included the Cantera library in my control dict file, and I don't get any other error message. I have attached my log files. insta7 is the log file for installing cantera library, and log.txt is the error I get when I try to run alternateReactingFoam.
Thanks for your time.
Attached Files
File Type: zip Cantera.zip (28.0 KB, 25 views)
__________________
SAHM
sahm is offline   Reply With Quote

Old   October 12, 2010, 21:08
Wink new error
  #56
Senior Member
 
sahm's Avatar
 
Seyyed Ali H.M.
Join Date: Nov 2009
Location: Utah
Posts: 107
Rep Power: 16
sahm is on a distinguished road
Bernhard
Is this the error you were talking about?
Attached Files
File Type: txt log.txt (1.7 KB, 10 views)
__________________
SAHM
sahm is offline   Reply With Quote

Old   October 13, 2010, 04:54
Default
  #57
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by sahm View Post
Bernhard
Is this the error you were talking about?
You mean:
Code:
alternateReactingFoam: symbol lookup error: /home/sahm/OpenFOAM/sahm-1.5-dev/lib/linux64GccDPOpt/libcanteraThermosChemistry.so: undefined symbol: dgemv_
Yep. One of the libraries you omitted defines that. From the shortness of the name I'd say that this is one of the linear algebra things and Fortran (but I didn't verify that). That is what I meant some days ago with "check that all compilers use -fPIC". I think you only set that for the C/C++-compiler and the Fortran compiler happily still produced non-FPIC-objects. And there is still another thing: have you made sure that when you changed the options ALL .o-files were removed before recompiling. Dependency analysis in the Sundials/Cantera-Makefiles is not what you're used to from wmake

Bernhard
gschaider is offline   Reply With Quote

Old   October 14, 2010, 10:37
Default Cantera Installation (support pacakges)
  #58
Member
 
N. A.
Join Date: May 2010
Posts: 64
Rep Power: 15
N. A. is on a distinguished road
Hi foamers,

I am interested in using Cantera along with OpenFoam. I found information at wiki http://openfoamwiki.net/index.php/Co...teReactingFoam .

The question I have is probably very basic.
Can I install and download BLAS, LAPACK, numpy and gfortran in the third party directory, just as I download cantera and sundials in the third party. I am not very familiar with UNIX oeprations and hence asking this question.

Will this package work with OpenFOAM1.6 version?

Thanks,
Nir
N. A. is offline   Reply With Quote

Old   October 14, 2010, 11:50
Default
  #59
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by N. A. View Post
Will this package work with OpenFOAM1.6 version?
The currently available version only works with 1.5
gschaider is offline   Reply With Quote

Old   October 14, 2010, 11:59
Default warning cantera /opt opt /opt/
  #60
Senior Member
 
Join Date: Dec 2009
Posts: 112
Rep Power: 16
heavy_user is on a distinguished road
just an general advise:

do NOT install cantera in /opt/ !!!!!!!!!!!!!!!!!

guess what...I did...just finished reinstalling the system..
it screws up your kernel !!
heavy_user 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



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