CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Species Mass Fraction in reactingFOAM (

Marshak November 28, 2012 20:39

Species Mass Fraction in reactingFOAM

I am simulating methane CH4 combustion using reactingFOAM solver. I want to define a variable which is a function of local mass fraction of CO2, H2O in each computational cell and the cell size.for example:

A=Y_CO2*Y_H2O* cell size

Can anyone help me on how can I write the above in openFOAM coding language to access these variables.

kalle November 29, 2012 02:31


To access species, something like this should work:

const volScalarField& Y_CO2 = composition.Y("CO2");
const volScalarField& Y_H2O = composition.Y("H2O");

Then you should consider that mesh.V() is just a scalarField, so you cannot directly multiply it with the above.

You can let A be a scalarField too and try this:

scalarField A(mesh.V() * Y_CO2.internalField() * Y_H2O.internalField() );

I have not tried the above code, so get back here if you get compilation or runtime problems.


All times are GMT -4. The time now is 12:33.