 ## Fluids

• pavankonchada123
Subscriber

When I try to use below mentioned udf at interface of water and watervapor/air mixture for saturation pressure it is giving floating point exception

#include "udf.h"

#define MOLAR_MASS_WATER 18.01534 //g/mol

#define MOLAR_MASS_AIR 28.97 // g/mol

#define RHO_WV 0.5542 // kg/m3

#define RHO_AIR 1.225 // kg/m3

DEFINE_PROPERTY(saturation_pressure,c,t)

{

real z,sat_p,p_w;

real vapor_p;

//#!RP_HOST

real vol = C_VOLUME(c, t);

real temp = C_T(c,t);//300K

real p_op = RP_Get_Real ("operating-pressure");

// Get the volume fraction of both phases

real vf_p = C_VOF(c, pt);

real vf_s = 1 - vf_p;

real rho_s = C_R(c, st);

//vapor_p = static_p + operating_p; // absolute pressure = static pressure + operating pressure

z=8.07131-(1730.63/((temp-273.15)+233.426));

sat_p = pow(10,z)*133; // Pressure in Pa to mmHg (Yaws 35320pa

if (vf_p == 1)

{

p_w = sat_p + p_op;

}

// If primary phase or mixture of phases

else

{

// Find the partial pressure of water vapour

// partial pressure = cell pressure * water mole fraction

// mass of primary phase in cell

real m_sec = rho_s * vol * vf_s;

// mass of water vapour and air in cell

real m_wv = C_YI(c, st, 0) * m_sec;

real m_air = m_sec - m_wv;

// No of moles in water vapour and air

real N_wv = m_wv / MOLAR_MASS_WATER;

real N_air = m_air / MOLAR_MASS_AIR;

real N_total = N_wv + N_air;

// water vapour partial pressure

p_w = (sat_p+ p_op)* (N_wv / N_total);

//Message("Pressure %f %f %f ",p_w,sat_p,(N_wv / N_total));

}

//#endif

return p_w;

}

• Rob
Ansys Employee
As a general tip, set all the real definitions at the top, don't scatter them through the code. Also note that Fluent will return SI units only, so check the equations are in kmol etc. Due to some Americanisms creeping into the software a kgmol is a kmol, which can cause some confusion. 