沸腾换热UDF【转载】
#include
"udf.h"
#include
"sg_mphase.h"
#define T_SAT
373
#define LAT_HT
1.e3
DEFINE_SOURCE(liq_src, cell, pri_th,
dS, eqn)
{
Thread *mix_th,
*sec_th;
mix_th =
THREAD_SUPER_THREAD(pri_th);
sec_th = THREAD_SUB_THREAD(mix_th,
1);
if(C_T(cell,
mix_th)>=T_SAT)
{
m_dot_l = -0.1*C_VOF(cell, pri_th)*C_R(cell, pri_th)* fabs(C_T(cell, mix_th) - T_SAT)/T_SAT;
dS[eqn] = -0.1*C_R(cell,
pri_th)*fabs(C_T(cell, mix_th) -
T_SAT)/T_SAT;
偏导
}
else
{、
m_dot_l = 0.1*C_VOF(cell,
sec_th)*C_R(cell, sec_th)*
fabs(T_SAT-C_T(cell,mix_th))/T_SAT;
dS[eqn] = 0.;//由于是气相向液相转移,所以液相的质量源项对质量转移的偏导为零
}
return m_dot_l;
}
DEFINE_SOURCE(vap_src, cell, sec_th, dS, eqn) //气相质量源项 UDF
{
Thread * mix_th, *pri_th; real m_dot_v;
mix_th = THREAD_SUPER_THREAD(sec_th); //指向混合区的第二相即气相的指针
pri_th = THREAD_SUB_THREAD(mix_th, 0); 指向单相控制区的液相的指针,液相为主相
if(C_T(cell,
mix_th)>=T_SAT)
{
m_dot_v = 0.1*C_VOF(cell, pri_th)*C_R(cell, pri_th)*fabs(C_T(cell, mix_th) - T_SAT)/T_SAT; dS[eqn] = 0.;'由于是液相向气相转移,所以气相的质量源项对来自液相的质量转移的偏导为零
}
else
{
m_dot_v = -0.1*C_VOF(cell, sec_th)*C_R(cell, sec_th)* fabs(T_SAT-C_T(cell,mix_th))/T_SAT;
//如果指向混合区的单元温度小于蒸发温度,气相向液相的质量转移,气相失 dS[eqn] = -0.1*C_R(cell, sec_th)* fabs(C_T(cell, mix_th) - T_SAT)/T_SAT;
//由于是气相向液相转移,所以气相的质量源项对自身的质量转移的偏导不为零
}
return m_dot_v;
}
DEFINE_SOURCE(enrg_src, cell, mix_th, dS, eqn) //混合模型能量源项 UDF
{
Thread *pri_th, *sec_th;
real m_dot;
pri_th = THREAD_SUB_THREAD(mix_th, 0);//指向混合区的液相的指针 sec_th = THREAD_SUB_THREAD(mix_th, 1); //指向混合区的气相的指针
if(C_T(cell, mix_th)>=T_SAT) //如果混合区的单元温度高于蒸发温度。质量转移由液相向气相转移,吸热,质量转 移量前有负号
{
else
m_dot = -0.1*C_VOF(cell, pri_th)*C_R(cell, pri_th)*fabs(C_T(cell, mix_th) - T_SAT)/T_SAT; dS[eqn] = -0.1*C_VOF(cell, pri_th)*C_R(cell, pri_th)/T_SAT;
}
{
m_dot = 0.1*C_VOF(cell, sec_th)*C_R(cell, sec_th)*fabs(T_SAT-C_T(cell,mix_th))/T_SAT; dS[eqn] = 0.1*C_VOF(cell, sec_th)*C_R(cell, sec_th)/T_SAT;}
return LAT_HT*m_dot; //气化潜热与质量转移率相乘得能量源项 W/m3
}