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/)
-   -   Using liquidMixtureProperties (http://www.cfd-online.com/Forums/openfoam-programming-development/107667-using-liquidmixtureproperties.html)

Smed October 3, 2012 12:50

Using liquidMixtureProperties
 
I would like to use the water properties functions offered by the liquidMixtureProperties class, specifically, I want to calculate the mixture density in a sprayFoam calculation. The density function requires the pressure, temperature, and mole fraction (http://foam.sourceforge.net/docs/cpp...b69ac33c0e3962). The problem for me seems to be in passing the mole fraction in the correct format. Here is the code that I've placed in sprayFoam.C:

Code:

const scalar pc = p[cellI];
const scalar Tc = T[cellI];
const scalarField& Y_(Y[0]);
// Find the mole fraction, given the mass fraction
const scalarField X_ = slgThermo.liquids().X(Y_);
const scalar rho_ = slgThermo.liquids().rho(pc, Tc, X_);

The code compiles, but fails in the line that defines X_. It steps into the X function of liquidMixtureProperties with a Y which has a size of 4000 (number of cells in my mesh), which causes a failure on the second iteration. It looks like the X function can only handle a Y of size 1, but I don't understand why, or how to supply a Y of size 1. I have also tried,

Code:

const scalarField& Y_(Y[0][0]);
but this fails to compile with the following error message,
Quote:

error: invalid initialization of reference of type 'const FOAM::scalarField&' from expression of type 'double'
Any help with this would be greatly appreciated.


All times are GMT -4. The time now is 16:13.