找回密码
 注册
查看: 2063|回复: 1

求教:udf 输出值错误

[复制链接]
发表于 2010-4-24 14:46:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
我现在在用fluent做一个气液两相流的问题,需要用udf加入一个该体系的曳力系数,我将曳力系数加在相间作用力,我编的udf可以调用,但是算几步后出错,于是我将udf中涉及到的参数全部输出,发现udf调用的气液相密度及气相速度都不是我在fluent中的给定值,而是一个很大的数,正是这些udf所调用参数的异常导致了计算错误,下面是我的udf,请教各位前辈udf调用的参数出错的原因是什么呢?谢谢!
#include "udf.h"
#define Pi 1.*atan(1)
#define diam2 3.e-3
DEFINE_EXCHANGE_PROPERTY(drag_coef,cell,mix_thread,s_col,f_col)
{
Thread *thread_l, *thread_g;
real x_vel_g, x_vel_l, y_vel_g, y_vel_l, abs_v, slip_x, slip_y, density_g, density_l, viscosity_l, re, mo, sf_ts, drag_coef;
/*find the thread for the liquid(primary)and gas(secondary phase)*/
thread_l = THREAD_SUB_THREAD(mix_thread,s_col);/*liquid phase*/
thread_g = THREAD_SUB_THREAD(mix_thread,f_col);/*gas phase*/
/*find phase velocities and properties*/
x_vel_g = C_U(cell, thread_g);
y_vel_g = C_V(cell, thread_g);

x_vel_l = C_U(cell, thread_l);
y_vel_l = C_V(cell, thread_l);

slip_x = x_vel_l - x_vel_g;
slip_y = y_vel_l - y_vel_g;

density_l = C_R(cell,thread_l);
density_g = C_R(cell,thread_g);

viscosity_l = C_MU_L(cell, thread_l);

sf_ts = 0.00430;/*an assumption,need to be confirmed*/

/*compute slip*/

abs_v = sqrt(slip_x*slip_x + slip_y*slip_y);

/*compute re*/

re=density_l*abs_v*diam2/viscosity_l;

/*compute mo*/
mo=9.81*pow(viscosity_l, 4)*(density_l - density_g)/(pow(sf_ts, 3)*pow(density_l, 2));

/*compute drag coefficient and return Cd*/
if(0.5<=re<=5)
   drag_coef = 22.73*pow(re, (-0.849))*pow(mo, 0.020);
else if(5<=re<=50)
   drag_coef = 20.08*pow(re, (-0.636))*pow(mo, 0.046);

return drag_coef;
}

[ 本帖最后由 zoesjtuer 于 2010-4-24 17:25 编辑 ]
发表于 2010-5-3 08:26:32 | 显示全部楼层
好的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表