| 查看: 1862 | 回复: 11 | ||
[求助]
udf编写提示重定义,麻烦大神帮忙看一眼。 已有1人参与
|
||
|
udf编写出了问题,总是提示重定义,却又找不到错误,麻烦大神帮忙看一眼。首先定义了水的几个物理特性(随温度变化),然后实时读取管子的出口温度,结合已知的进口温度,确定定性温度,进而求得NU数及对流换热系数h。 /************************************************************************* * THIS UDF PROGRAM IS PROGRAMMED BY LIU Wenjie ON 11.28.2016 * * IT IS USED FOR THE THERMAL BOUNDARY CONDITIONS OF HEAT EXCHANGER PIPE WALL'S CONVECTIVE HEAT TRANSFER COEFFICIENT(h) **************************************************************************/ #include "udf.h" #define v_wa 0.061 /*铜管(换热管)入口流速*/ #define L 1.2 /*10铜管长度*/ #define W 0.006 /*铜管入口的宽度*/ #define H 0.008 /*铜管入口高度*/ #define T11 307.5 /*冷水入口处的水温*/ real NV_VEC(A); real avg_temp; real sum_T_A=0.0; real sum_A=0.0; Thread *thread_out;/*用于宏在编译过程中的延伸*/ real ruo_wa,cp_wa,lamda_wa,a_wa,mu_wa,nu_wa,alpha_wa; face_t f; cell_t cell; Domain *domain; /********************************************************************************** **** the UDF for the 密度ruo_wa *********************************************************************************** ****/ DEFINE_PROPERTY(ruo_wa,cell,thread) { real temp=C_T(cell,thread); if(temp>30&&temp<40) ruo_wa=(0.1*(992.2-995.7)*(temp-30))+995.7; else ru0_wa=992.2; return ruo_wa; } /********************************************************************************** **** the UDF for 导热系数lamda_wa *********************************************************************************** ****/ DEFINE_PROPERTY(lamda_wa,cell,thread) { real temp=C_T(cell,thread); if(temp>30&&temp<40) lamda_wa=(0.1*(0.635-0.618)*(temp-30))+0.618; else lamda_wa=0.635; return lamda_wa; } /********************************************************************************** **** the UDF for 热扩散率a_wa *********************************************************************************** ****/ DEFINE_PROPERTY(a_wa,cell,thread) { real temp=C_T(cell,thread); if(temp>30&&temp<40) a_wa=(0.1*(0.000000153-0.000000149)*(temp-30))+0.000000149; else a_wa=0.000000153; return a_wa; } /********************************************************************************** **** the UDF for 动力粘度mu_wa *********************************************************************************** ****/ DEFINE_PROPERTY(mu_wa,cell,thread) { real temp=C_T(cell,thread); if(temp>30&&temp<40) mu_wa=(0.1*(0.0006533-0.0008015)*(temp-30))+0.0008015; else mu_wa=0.0006533; return mu_wa; } /********************************************************************************** **** the UDF for 运动粘度nu_wa *********************************************************************************** ****/ DEFINE_PROPERTY(nu_wa,cell,thread) { real temp=C_T(cell,thread); if(temp>30&&temp<40) nu_wa=(0.1*(0.000000659-0.000000805)*(temp-30))+0.000000805; else nu_wa=0.0006533; return nu_wa; } /********************************************************************************** **** the UDF for 体积膨胀系数alpha_wa *********************************************************************************** ****/ DEFINE_PROFERTY(alpha_wa,cell,thread) { real temp=C_T(cell,thread); if(temp>30&&temp<40) alpha_wa=(0.1*(0.000386-0.000305)*(temp-30))+0.000305; else alpha_wa=0.000386; return alpha_wa; } /************************************************************************* the UDF for average temperature ofoutlet求出口平均温度 *************************************************************************/ DEFINE_ADJUST(adjust,d)/*每次迭代都计算一次*/ { domain=Get_Domain(11);/*对domain进行赋值,需改*/ thread_out=Lookup_Thread(domain,20);/*对thread进行赋值,需改*/ begin_f_loop(f,thread_out) { F_AREA(A,f,thread_out); sum_A+=NV_MAG(A);/*32求得出口的累加面积*/ sum_T_A+=NV_MAG(A)*F_T(f,thread_out);/*出口累加面积与对应温度的乘积*/ } end_f_loop(f,thread_out) avg_temp=sum_T_A/sum_A;/*求得出口的平均温度*/ } /************************************************************************* the UDF for convective heat transfer coefficient of inner HEX wall *************************************************************************/ DEFINE_PROFILE(lwj_h,thread,index) { real temp; real prandtl_wa,Re_wa,NU_wa,interequ_wa; real U,S,de; real t; real h_wa;/*h*/ t=RP_Get_Real("flow-time" ;temp=0.5*(T11+avg_temp);/*定性温度,按照常热流壁面去计算*/ U=2*(W+H);/*铜管周长*/ S=W*H;/*铜管断面积*/ de=4*S/U;/*铜管当量直径*/ prandtl_wa=mu_wa*cp_wa/lamda_wa;/*铜管内侧的普朗特数*/ Re_wa=ruo_wa*v_wa*de/mu_wa;/*铜管内侧的雷诺数*/ interequ_wa=Re_wa*prandtl_wa*de/L;/*铜管内侧的中间数*/ if (Re_wa<2300.0) { NU_wa=3.66; if(interequ_wa>10) NU_wa=1.86*pow(interequ_wa,1.0/3.0);/*铜管内侧的努谢尔特数,吕原丽*/ else NU_wa=3.66+0.0668*interequ_wa/(1+0.04*pow(interequ_wa,2.0/3.0));/*铜管内侧 的NU数,吕*/ } else if(Re_wa<10000.0) NU_wa=0.16*pow(Re_wa,2.0/3.0)*pow(prandtl_wa,1.0/3.0)*pow(1+de/L,2.0/3.0);/*铜管 内侧NU*/ else NU_wa=0.023*pow(Re_wa,0.8)*pow(prandtl_wa,0.4);/*铜管内侧的努谢尔特数,;吕原丽 */ h_wa=NU_wa*lamda_wa/de; begin_f_loop(f,thread) {if(temp>C_T(cell,thread)) h_wa=0; F_PROFILE(f,thread,index)=h_wa; } end_f_loop(f,thread) } 谢谢了。 |
» 猜你喜欢
拟解决的关键科学问题还要不要写
已经有10人回复
救命帖
已经有5人回复
限项规定
已经有5人回复
为什么nbs上溴 没有产物点出现呢
已经有9人回复
招博士
已经有3人回复
存款400万可以在学校里躺平吗
已经有35人回复
最失望的一年
已经有18人回复
求推荐博导
已经有4人回复
求推荐英文EI期刊
已经有5人回复
疑惑?
已经有5人回复
【答案】应助回帖
★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
溪柳柳自摇: 金币+10 2016-12-06 10:20:50
感谢参与,应助指数 +1
溪柳柳自摇: 金币+10 2016-12-06 10:20:50
|
能不能先学学C语言编程,把想用的函数help看完再来搞UDF,这错误简单的,,, **************************************************************************/ #include "udf.h" #define v_wa 0.061 /*铜管(换热管)入口流速*/ #define L 1.2 /*10铜管长度*/ #define W 0.006 /*铜管入口的宽度*/ #define H 0.008 /*铜管入口高度*/ #define T11 307.5 /*冷水入口处的水温*/ real NV_VEC(A); real avg_temp; real sum_T_A=0.0; real sum_A=0.0; Thread *thread_out;/*用于宏在编译过程中的延伸*/ face_t f; cell_t cell; Domain *domain; //你真的应该先学学C语言编程,全局变量不是这么用的 /********************************************************************************** **** the UDF for the 密度ruo_wa *********************************************************************************** ****/ DEFINE_PROPERTY(ruo_wa,cell,thread) //UDF的名字,不是变量,好好去看帮助文件 { real temp=C_T(cell,thread); real den; if(temp>30&&temp<40) den=(0.1*(992.2-995.7)*(temp-30))+995.7; else den=992.2; return den; } /********************************************************************************** **** the UDF for 导热系数lamda_wa *********************************************************************************** ****/ DEFINE_PROPERTY(lamda_wa,cell,thread) //同上 { real temp=C_T(cell,thread); real ther; if(temp>30&&temp<40) ther=(0.1*(0.635-0.618)*(temp-30))+0.618; else ther=0.635; return ther; } /********************************************************************************** **** the UDF for 热扩散率a_wa *********************************************************************************** ****/ DEFINE_PROPERTY(a_wa,cell,thread) //。。。。。。 { real temp=C_T(cell,thread); real coef; if(temp>30&&temp<40) coef=(0.1*(0.000000153-0.000000149)*(temp-30))+0.000000149; else coef=0.000000153; return coef; } /********************************************************************************** **** the UDF for 动力粘度mu_wa *********************************************************************************** ****/ DEFINE_PROPERTY(mu_wa,cell,thread) //. { real temp=C_T(cell,thread); real visc; if(temp>30&&temp<40) visc=(0.1*(0.0006533-0.0008015)*(temp-30))+0.0008015; else visc=0.0006533; return visc; } /********************************************************************************** **** the UDF for 运动粘度nu_wa *********************************************************************************** ****/ DEFINE_PROPERTY(nu_wa,cell,thread) { real temp=C_T(cell,thread); //所以说,做个热物性表不好么。。。。。直接自动计算 real vvvv; if(temp>30&&temp<40) vvvv=(0.1*(0.000000659-0.000000805)*(temp-30))+0.000000805; else vvvv=0.0006533; return nu_wa; } /********************************************************************************** **** the UDF for 体积膨胀系数alpha_wa *********************************************************************************** ****/ DEFINE_PROFERTY(alpha_wa,cell,thread) { real temp=C_T(cell,thread); real alpha; if(temp>30&&temp<40) alpha=(0.1*(0.000386-0.000305)*(temp-30))+0.000305; else alpha=0.000386; return alpha; } /************************************************************************* the UDF for average temperature ofoutlet求出口平均温度 *************************************************************************/ DEFINE_ADJUST(adjust,d)/*每次迭代都计算一次*/ { domain=Get_Domain(11);/*对domain进行赋值,需改*/ thread_out=Lookup_Thread(domain,20);/*对thread进行赋值,需改*/ begin_f_loop(f,thread_out) { F_AREA(A,f,thread_out); sum_A+=NV_MAG(A);/*32求得出口的累加面积*/ sum_T_A+=NV_MAG(A)*F_T(f,thread_out);/*出口累加面积与对应温度的乘积*/ } end_f_loop(f,thread_out) avg_temp=sum_T_A/sum_A;/*求得出口的平均温度*/ } /************************************************************************* the UDF for convective heat transfer coefficient of inner HEX wall *************************************************************************/ DEFINE_PROFILE(lwj_h,thread,index) { real temp; real prandtl_wa,Re_wa,NU_wa,interequ_wa; real U,S,de; real t; real h_wa;/*h*/ t=RP_Get_Real("flow-time"; temp=0.5*(T11+avg_temp);/*定性温度,按照常热流壁面去计算*/ U=2*(W+H);/*铜管周长*/ S=W*H;/*铜管断面积*/ de=4*S/U;/*铜管当量直径*/ prandtl_wa=mu_wa*cp_wa/lamda_wa;/*铜管内侧的普朗特数*/ Re_wa=ruo_wa*v_wa*de/mu_wa;/*铜管内侧的雷诺数*/ interequ_wa=Re_wa*prandtl_wa*de/L;/*铜管内侧的中间数*/ if (Re_wa<2300.0) { NU_wa=3.66; if(interequ_wa>10) NU_wa=1.86*pow(interequ_wa,1.0/3.0);/*铜管内侧的努谢尔特数,吕原丽*/ else NU_wa=3.66+0.0668*interequ_wa/(1+0.04*pow(interequ_wa,2.0/3.0));/*铜管内侧的NU数,吕*/ } else if(Re_wa<10000.0) NU_wa=0.16*pow(Re_wa,2.0/3.0)*pow(prandtl_wa,1.0/3.0)*pow(1+de/L,2.0/3.0);/*铜管内侧NU*/ else NU_wa=0.023*pow(Re_wa,0.8)*pow(prandtl_wa,0.4);/*铜管内侧的努谢尔特数,;吕原丽*/ h_wa=NU_wa*lamda_wa/de; begin_f_loop(f,thread) { if(temp>C_T(cell,thread)) // 你什么时候还取了cell的值了? h_wa=0; F_PROFILE(f,thread,index)=h_wa; } end_f_loop(f,thread) } |
8楼2016-12-04 13:07:15
2楼2016-12-04 00:27:10
malasong9471
木虫 (正式写手)
- 应助: 58 (初中生)
- 金币: 7237
- 红花: 29
- 帖子: 639
- 在线: 117.1小时
- 虫号: 4100890
- 注册: 2015-09-25
- 性别: GG
- 专业: 工程热力学
3楼2016-12-04 01:01:24
348683569
铁杆木虫 (著名写手)
- 应助: 6 (幼儿园)
- 金币: 6149.8
- 散金: 10
- 红花: 19
- 帖子: 2249
- 在线: 203.1小时
- 虫号: 1128142
- 注册: 2010-10-21
- 专业: 化学反应工程

4楼2016-12-04 01:04:55
5楼2016-12-04 09:44:05
6楼2016-12-04 09:44:47
7楼2016-12-04 09:45:48
malasong9471
木虫 (正式写手)
- 应助: 58 (初中生)
- 金币: 7237
- 红花: 29
- 帖子: 639
- 在线: 117.1小时
- 虫号: 4100890
- 注册: 2015-09-25
- 性别: GG
- 专业: 工程热力学
|
自己比较一下,你是要物性随温度变化还是返回一个值??? Fluent UDF 第三章 编写UDF_百度文库 http://wenku.baidu.com/view/261fe7235901020207409cdb.html 3.10.1 返回值的函数(Function that Return a Value) 3.10.4修改FLUENT变量的函数(Functions that Modify a FLUENT Variable) |
9楼2016-12-04 14:03:59
|
嘎嘎嘎,蟹蟹你的回复,我已经自己解决了哇!关键是另一个问题,不是所有的物性都可以用udf,举个栗子,定压比热容。所以我把这个删了,把其他的挪进了主程序里 发自小木虫Android客户端 |
10楼2016-12-05 00:17:38













;
回复此楼
