buctzy_cfd 发表于 2013-9-16 11:40

fluent 模拟蒸发凝结现象出现问题求助!!

蒸发沸腾UDF问题本人正在学做两相流模型模拟蒸发冷凝,想取单元处的饱和压力,根据关系式得到对应的饱和温度,再讲单元处的温度与饱和温度相比较判断是否蒸发凝结,UDF程序如下,但是导入FLUENT中编译通过,不能开始计算,提示Error: Floating point error: invalid number

Error Object: (),想问问大家如何解决?谢谢各位了!
UDF:#include <stdio.h>
#include <math.h>
#include "udf.h"
#include "sg_mphase.h"
#define L 445600
#define TB20.268
#define PB101325
#define R4157
#define b 0.1

DEFINE_SOURCE(liq_src, cell, pri_th, dS, eqn)
{
Thread *mix_th, *sec_th;
real m_dot_l,Psat,T_SAT;
mix_th = THREAD_SUPER_THREAD(pri_th);
sec_th = THREAD_SUB_THREAD(mix_th, 1);
Psat = C_P(cell,pri_th);
T_SAT=1/(1/TB-R*log(Psat/PB)/L);

if(C_T(cell, mix_th)>=T_SAT){
m_dot_l = -b*C_VOF(cell, pri_th)*C_R(cell, pri_th)*
fabs(C_T(cell, pri_th) - T_SAT)/T_SAT;
dS = -b*C_R(cell, pri_th)*
fabs(C_T(cell, pri_th) - T_SAT)/T_SAT;
}
else {
m_dot_l = b*C_VOF(cell, sec_th)*C_R(cell, sec_th)*
fabs(T_SAT-C_T(cell,mix_th))/T_SAT;
dS = 0.;
}
return m_dot_l;
}
DEFINE_SOURCE(vap_src, cell, sec_th, dS, eqn)
{
Thread * mix_th, *pri_th;
real m_dot_v,Psat,T_SAT;
mix_th = THREAD_SUPER_THREAD(sec_th);
pri_th = THREAD_SUB_THREAD(mix_th, 0);
Psat = C_P(cell,pri_th);
T_SAT=1/(1/TB-R*log(Psat/PB)/L);
if(C_T(cell, mix_th)>=T_SAT){
m_dot_v = b*C_VOF(cell, pri_th)*C_R(cell, pri_th)*
fabs(C_T(cell, mix_th) - T_SAT)/T_SAT;
dS = 0.;
}
else {
m_dot_v = -b*C_VOF(cell, sec_th)*C_R(cell, sec_th)*
fabs(T_SAT-C_T(cell,mix_th))/T_SAT;
dS = -b*C_R(cell, sec_th)*
fabs(C_T(cell, sec_th) - T_SAT)/T_SAT;
}
return m_dot_v;

}
DEFINE_SOURCE(enrg_src, cell, mix_th, dS, eqn)
{
Thread *pri_th, *sec_th;
real m_dot,Psat,T_SAT;
pri_th = THREAD_SUB_THREAD(mix_th, 0);
sec_th = THREAD_SUB_THREAD(mix_th, 1);
Psat = C_P(cell,pri_th);
T_SAT=1/(1/TB-R*log(Psat/PB)/L);

if(C_T(cell, mix_th)>=T_SAT){
m_dot = -b*C_VOF(cell, pri_th)*C_R(cell, pri_th)*
fabs(C_T(cell, pri_th) - T_SAT)/T_SAT;
dS = -b*C_VOF(cell, pri_th)*C_R(cell, pri_th)/T_SAT;
}

else {
m_dot = b*C_VOF(cell, sec_th)*C_R(cell, sec_th)*
fabs(T_SAT-C_T(cell,mix_th))/T_SAT;
dS = -b*C_VOF(cell, sec_th)*C_R(cell, sec_th)/T_SAT;}
return L*m_dot;
}
页: [1]
查看完整版本: fluent 模拟蒸发凝结现象出现问题求助!!