CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Calculating Reaction Rates (http://www.cfd-online.com/Forums/openfoam-solving/77137-calculating-reaction-rates.html)

mturcios777 June 14, 2010 14:12

Calculating Reaction Rates
 
I'm updating a solver I have from 1.4 to 1.6, and I've run into a problem with chemical reactions. In 1.4 I could call chemistry.calculate() to calculate reaction rates. With the new way chemistry models are created, that call fails (complaints of trying to access a non-existent member function). Looking through the source, I'm not sure I would do this in the new version.

My solver uses a psiChemistryModel; here are some of the relevant entries from the code and from the case

createFields.H:
autoPtr<psiChemistryModel> pChemistry
(
psiChemistryModel::New(mesh)
);
psiChemistryModel& chemistry = pChemistry();
(just like in reactingFoam)

constant/chemistryProperties: psiChemistryModel ODEChemistryModel<gasThermoPhysics>

constant/thermophysicalProperties: thermoType hPsiMixtureThermo<reactingMixture<gasThermoPhysics >>;

I know there must be some way to call the member function, but I'm struggling to understand the new way things are done.

mehdi-combustion June 16, 2010 03:30

If you define the chemistry as:

Info<< nl << "Reading thermophysicalProperties" << endl;
autoPtr<psiChemistryModel> pChemistry
(
psiChemistryModel::New(mesh)
);
psiChemistryModel& chemistry = pChemistry();

hCombustionThermo& thermo = chemistry.thermo();

basicMultiComponentMixture& composition = thermo.composition();
PtrList<volScalarField>& Y = composition.Y();

How you can access to the thermodynamic properties of the specie such as enthalpy at a given temprature Ti and molecular weight and so on ?
In OpenFoam-1.5 you could write:

scalar hi = chemistry.specieThermo()[i].h(Ti); //openFoam-1.5

However, If you write the same in OpenFoam-1.6 you would get
psiChemistryModel does not have member function named specieThermo.

hk318i July 5, 2010 18:54

I have the same problem. what should I do to access specieThermo.Hc()?

mturcios777 October 7, 2010 17:31

[solved]
 
Figured it out. psiChemistryModel is built somewhat on basicChemistryModel. I need to add a

Code:

virtual void calculate()
to basicChemsitryModel.H. This may cause problems if your implementation of psiChemistryModel doesn't use ODEChemistryModel, but at present I don't see any solvers that have it otherwise.

lx882211 June 3, 2016 03:24

Quote:

Originally Posted by mturcios777 (Post 278355)
Figured it out. psiChemistryModel is built somewhat on basicChemistryModel. I need to add a

Code:

virtual void calculate()
to basicChemsitryModel.H. This may cause problems if your implementation of psiChemistryModel doesn't use ODEChemistryModel, but at present I don't see any solvers that have it otherwise.

I meet a problem in Openfoam 2.3.0, reactingFoam, i need the data of CH4 reaction rate, but i failed to autowrite it like U or Yi.

First i added this code in the CreatField.H,

volScalarField Rrate
(
IOobject
(
"Rrate",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("Rrate", dimMass/dimVolume/dimTime, 0.0)
);

Then, i added this code in YEqn,

forAll(Y, i)
{
if (Y[i].name() != "CH4")
Rrate = reaction->R(Yi);
}

After wmake, it shows

YEqn.H:26:14: error: no match for ‘operator=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘Foam::tmp<Foam::fvMatrix<double> >’)
Rrate = reaction->R(Yi);

Can you tell me how to do that? Thank you very much.


All times are GMT -4. The time now is 04:44.