CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Using liquidMixtureProperties (

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 ( 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:


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,


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

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 02:53.