CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   how to perform condensation on a boundary face (https://www.cfd-online.com/Forums/fluent/87424-how-perform-condensation-boundary-face.html)

wwt650420 April 20, 2011 02:18

how to perform condensation on a boundary face
 
hi, everyboby.
Recently I would like to use UDF to preform condensaion phenomenon on a boundary face.
And the model I used is a mixture model. In this model phase one is a multi-species gas which contains N2, CO2, O2, H2O, SO2, NO and a specifically defined condensable gas, phase two is the liquid condensation product due to condensation of that specifically defined gas.
The boundary condition is that phase one (i.e. mixture gas) flows into the space through the inlet with 10m/s, and phase two is zero.
When the mixture gas flows into adjacent cells of the boundary face, and if the condensation condition is satisfied, the specifically defined gas condenses.
The evaluation formula is w=rho*(pi-psi)/p.
rho is mixture gas density;
pi is condensable gas pressure in the adjacent cell;
psi is condensable gas saturation pressure dependence of cell temperature.
p is mixture gas pressure.

The following is my UDF:
#include "udf.h"
#include "dpm.h"
#include "sg_mphase.h"
#include "mem.h"
#include "sg.h"
#include "surf.h"
#include "cxiface.h"
#include "models.h"
# define dtube 51.e-3
/***********************************************/
/***********mass transfer coefficient******************/
/***********************************************/
DEFINE_MASS_TRANSFER(source,cell,thread,from_index ,from_species_index, to_index, to_species_index)
{
real mc=0.;
real wendu, density, niandu, usudu, vsudu, uv, shijisudu, reshu, scshu, shshu, dliusuanna, km, liusuannaflux;
real A[ND_ND],ds,es[ND_ND],A_by_es,dr0[ND_ND];
real daa=15.03, dab= 37452., dac=0, pn=100000.;
real psi, pliusuanna, pgas;
Thread *gas = THREAD_SUB_THREAD(thread, from_index);
Thread *liq = THREAD_SUB_THREAD(thread, to_index);
Thread *liusuanna = THREAD_SUB_THREAD(thread,from_species_index);
cell_t c;
cell_t c0;
Thread *t0;
Thread *t;
face_t f;

t0=THREAD_T0(thread);
begin_f_loop(f,thread)
{
c0 = F_C0(f,thread);
BOUNDARY_FACE_GEOMETRY(f,thread,A,ds,es,A_by_es,dr 0);
density=C_R(c0,gas);
wendu=C_T(c0,gas);
psi=pn*exp(daa-dab/(wendu+dac));
pliusuanna=C_P(c0,liusuanna);
pgas=C_P(c0,gas);
/*the following functions are used to evaluate some important data for myself*/
niandu=4.4184*(pow(10,-7))*(pow(C_T(c0,gas),0.66666667));
usudu=C_U(c0,gas);
vsudu=C_V(c0,gas);
uv=pow(usudu,2)+pow(vsudu,2);
shijisudu=pow(uv,0.5);
reshu=C_R(c0,gas)*shijisudu*dtube/niandu;
scshu=niandu/C_R(c0,t0)/dtube;
shshu=0.3+0.62*pow(reshu,(1/2))*pow(scshu,(1/3))/pow(1+0.4/(pow(scshu,(2/3))),0.25)*pow((1+pow((reshu/282000),0.625)),0.8);
dliusuanna=1.7434*pow(10,(-9))*(pow(C_T(c0,gas),1.5));
km=shshu*dliusuanna/dtube;
if(wendu>1150)
{
if(pliusuanna>psi)
{
mc=(pliusuanna-psi)*pgas/density;
}
else
{
mc=C_R(c0,liusuanna);
}
}
else
{
mc=C_R(c0,liusuanna);
}
}
end_f_loop(f,thread)

return (mc);
}

when i compiled it, it works, and it is used to

Define-Phase-Interaction


but when i initialized it ,the error encountered:
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()

I really do not know what is wrong with my UDF.
Maybe some thread is used in an inaccurate way?
Could some friends give me help?
Thank you very much!
And my email is wwt650420@sina.com.cn and wwtmwtd@hotmail.com.


All times are GMT -4. The time now is 07:48.