#include "udf.h" ‘包括常规宏 #include "sg_mphase.h" ‘包括体积分数宏CVOF(C,T) #define T_SAT 373 ‘定义蒸发温度100℃ #define LAT_HT 1.e3 ‘定义蒸发潜热J/Kg DEFINE_SOURCE(liq_src, cell, pri_th, dS, eqn) ‘液相质量源项UDF { Thread *mix_th, *sec_th; ‘定义计算区线指针 real m_dot_l; ‘定义液相质量转移 kg/(m2.s) 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) ‘如果混合区的单元温度高于蒸发温度。质量转移由液相向气相转移,吸热,质量转移量前有负号 { 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; } else { 相反,气相向液相转移则放热 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 } |