CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Water vapor condensation (http://www.cfd-online.com/Forums/fluent-udf/92450-water-vapor-condensation.html)

 be89 September 14, 2011 15:36

Water vapor condensation

I'm trying to simulate the condensation of water vapor of moist air as a mass transfer.
I have a multiphase fluid: phase 1 is a mixture of air and water vapor, and phase 2 is water liquid.
I wrote a UDF where I used a macro called "define_mass_transfer" and compiled it in Fluent. But when I try to initialize the calculation, I receive a "segmentation violation error".
Does anyone know why?
Or can anyone tell me another way to simulate condensation?

The UDF I wrote is this:
#include "udf.h"

real H2O_Saturation_Pressure(real T)
{
real esp;
esp=7.5*(T-273.15)/(237.7+T-273.15);
return (611*pow(10,esp));
}

DEFINE_MASS_TRANSFER(vap_condensation,c,t,from_pha se_index,from_species_index,to_phase_index,to_spec ies_index)
{
real m_lg;
real x_h2o, x_sat, w_sat; /* w=mv/ma; x=mv/(ma+mv) */
#define p 101325

x_h2o = C_YI(c,t,from_species_index);
w_sat = 0.622*H2O_Saturation_Pressure(C_T(c,t))/(p-H2O_Saturation_Pressure(C_T(c,t)));
x_sat = w_sat/(1+w_sat);

m_lg = 0.;

if (x_h2o > x_sat)
{
m_lg = (x_h2o-x_sat)*C_R(c,t);
}
return (m_lg);
}

 All times are GMT -4. The time now is 18:55.