# Fluent - species - density - UDF

Hi,

I have two species (air + CO2) and I want to calculate the density of CO2 as it varies with temperature from the equation of state through a UDF. The density of the mixture is set as Incompressible Ideal Gas. I need the density of CO2 to calculate the ppm(volume) of CO2.

CO2 is assigned as species 0.

density0 = P * MW0 / (R_universal * T)

my question is, P here is the static pressure which I can call via C_P(c,t) or I need to do something with the operating pressure as well?

Thanks!

## Comments

Just a clarification:

P is supposed to be the partial pressure, P_gas = P_air + P_CO2, so in the udf how can I call P_CO2?

density0 = P0 * MW0 / (R_universal * T). Does that mean I need to choose Ideal Gas not Incompressible Ideal Gas for the density of the mixture?

in the ideal gas expression for density, P is the absolute pressure = gauge + operating. Fluent solves flow field variables, including pressure, for the mixture, so there is no separate variables for partial pressures. You can easily reconstruct partial pressures from mixture pressure and species mass fraction by taking a product of the two.

Thank you for your answer. So, Pi = Yi * P where Yi is the mass fraction of component i ? When I tried to prove it I found that Pi = Xi * P where Xi is the mole fraction. Is that correct?

If the mole fraction is correct, is there a way to call a mole fraction of a single component within the UDF or I need to multiply the mass fraction by MW_mix/MW_i, where MW is the molar mass? Again, is there a way to call the MW_mix within the UDF since it is a variable that depends on the current mole fraction?

Thank you for your help.

indeed, I mistyped, this is mole fraction that should be used. Mole fraction will need to be constructed from mass fraction and molecular weight as you described. Molecular weights can be accessed in a UDF as shown in 2.5.6.3. Example of UDF manual

Mole fraction is available directly in Fluent post processing, given that would a Custom Field Function do the job?

Thank you guys for your help. Yes, I think I can take this part out of the UDF and do it through a Custom Field. But I got really confused:

ppm_volume = Y_i * rho_mixture * 10^6 / rho_i

Y_i is the mass fraction of component i. rho_i = P_i * MW_i / (R_universal * T) and rho_mixture = P MW_mixture / (R_universal * T). So, if we sub this in the ppm_volume formula, the whole thing vanishes and I get ppm_volume = 10^6. What mistake I am introducing here, please.

ppm_volume by definition is the (V_i/V_mixture) * 10^6 but since we assume we have partial pressure so the V_i = V_mixture?

is there a way to call or post-processing the partial volume?

Thank you,