CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   How to convert psiChemistryModel for multi Zone? (http://www.cfd-online.com/Forums/openfoam/109579-how-convert-psichemistrymodel-multi-zone.html)

Hanzo November 21, 2012 03:17

How to convert psiChemistryModel for multi Zone?
 
Hello,

I am currently working on a code to use chemistry in different zones. I started with chtMultiRegionFoam solver as basis source code. I basically try to realize chemFoam behavior for all fluid zones (solid zones are removed completely).

So far, I managed to read initial conditions, chemKin input files and chemistry properties for each region. The next step is to create an instance of psiChemistryModel for each region. In chemFoam (or rhoReactionFoam) this is done doing the following:

http://foam.sourceforge.net/docs/cpp/a03249_source.html
Code:

00026    Info<< nl << "Reading thermophysicalProperties" << endl;
00027    autoPtr<psiChemistryModel> pChemistry(psiChemistryModel::New(mesh));

So in a regional context the variable mesh should be replaced by the mesh of the current region which is stored as fluidRegions[i]
Code:

autoPtr<psiChemistryModel> pChemistry(psiChemistryModel::New(fluidRegions[i]));
Compiling works fine but when OpenFoam initiates the chemistryReader I get a floating point exception:

Code:

Reading initial conditions.

    Adding to YdefaultFluid

Selecting psiChemistryModel ODEChemistryModel<gasThermoPhysics>

Selecting thermodynamics package hsPsiMixtureThermo<reactingMixture<gasThermoPhysics>>

Selecting chemistryReader chemkinReader

#0  Foam::error::printStack(Foam::Ostream&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigFpe::sigHandler(int) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  in "/lib/libc.so.6"
#3  Foam::fvPatchField<double>::operator/=(Foam::fvPatchField<double> const&) in "/home/florian/OpenFOAM/florian-2.0.x/platforms/linux64GccDPOpt/bin/multiRegionChemFoam"
#4  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::operator/=(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libreactionThermophysicalModels.so"
#5  Foam::multiComponentMixture<Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > >::correctMassFractions() in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libreactionThermophysicalModels.so"
#6  Foam::multiComponentMixture<Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > >::multiComponentMixture(Foam::dictionary const&, Foam::List<Foam::word> const&, Foam::HashPtrTable<Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > >, Foam::word, Foam::string::hash> const&, Foam::fvMesh const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libreactionThermophysicalModels.so"
#7  Foam::reactingMixture<Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > >::reactingMixture(Foam::dictionary const&, Foam::fvMesh const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libreactionThermophysicalModels.so"
#8  Foam::hsPsiMixtureThermo<Foam::reactingMixture<Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > > >::hsPsiMixtureThermo(Foam::fvMesh const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libreactionThermophysicalModels.so"
#9  Foam::hsCombustionThermo::addfvMeshConstructorToTable<Foam::hsPsiMixtureThermo<Foam::reactingMixture<Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > > > >::New(Foam::fvMesh const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libreactionThermophysicalModels.so"
#10  Foam::hsCombustionThermo::NewType(Foam::fvMesh const&, Foam::word const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libreactionThermophysicalModels.so"
#11  Foam::psiChemistryModel::psiChemistryModel(Foam::fvMesh const&, Foam::word const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libchemistryModel.so"
#12  Foam::ODEChemistryModel<Foam::psiChemistryModel, Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > >::ODEChemistryModel(Foam::fvMesh const&, Foam::word const&, Foam::word const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libchemistryModel.so"
#13  Foam::ode<Foam::ODEChemistryModel<Foam::psiChemistryModel, Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > > >::ode(Foam::fvMesh const&, Foam::word const&, Foam::word const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libchemistryModel.so"
#14  Foam::psiChemistryModel::addfvMeshConstructorToTable<Foam::ode<Foam::ODEChemistryModel<Foam::psiChemistryModel, Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > > > >::New(Foam::fvMesh const&, Foam::word const&, Foam::word const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libchemistryModel.so"
#15  Foam::psiChemistryModel::New(Foam::fvMesh const&) in "/opt/OpenFOAM/OpenFOAM-2.0.x/platforms/linux64GccDPOpt/lib/libchemistryModel.so"
#16 
 in "/home/florian/OpenFOAM/florian-2.0.x/platforms/linux64GccDPOpt/bin/multiRegionChemFoam"
#17  __libc_start_main in "/lib/libc.so.6"
#18 
 in "/home/florian/OpenFOAM/florian-2.0.x/platforms/linux64GccDPOpt/bin/multiRegionChemFoam"
浮動小数点例外

I assume that the call psiChemistryModel::New(fluidRegions[i]) uses the appropriate region mesh but does not load T,p, and Y fields from the $CASE_DIR/0/region/ folder.

In chtMultiRegionFoam there is an analog line where the current region mesh is plugged into a constructor of similar type (it only takes a const mesh as input):

http://foam.sourceforge.net/docs/cpp/a02601_source.html
Code:

00029        thermoFluid.set
00030 (
00031            i,
00032            basicRhoThermo::New(fluidRegions[i]).ptr()
00033        );

except that here the result is stored in a pointer list.

So I wonder if anybody has an idea why I cannot do this in the same manner for the psiChemistryModel constructor.

Any hints or comments are highly appreciated.

Hanzo November 21, 2012 05:16

Reason found
 
Looks like I found the reason for my floating point error :)

First of all, the constructor for psiChemistryModel can be used for zonal calculations in the same way as for example basicRhoThermo.

What actually caused the problems were zero boundary values. On the interface boundary between my regions, I had zero values for the species in the field Ydefault.
So setting this to zeroGradient or any nonzeroValue solved the problem.

I realised that for a boundary I cannot define all species to be zero.
Looking at line 5 of my previously posted error message
Code:

#5  Foam::multiComponentMixture<Foam::sutherlandTransport<Foam::specieThermo<Foam::janafThermo<Foam::perfectGas> > > >::correctMassFractions()
At a certain point in the code the sum of all Yi is taken and then Y are corrected by a similar computation like Yi = Yi/Ytot.


All times are GMT -4. The time now is 08:48.