ANSYS FLUENT 计算pmv自定义函数代码

  • 格式:doc
  • 大小:38.50 KB
  • 文档页数:3

/* 使用时将此文档的扩展名改为.c 然后编译到fluent当中 每个参数都有说明 用户可以根据需要调整 调用UDM需要首先设置Define User-Defined Memory... 设置为1即可 此处只存储了一组数据*/

#include "udf.h"

/* Author:wanghao SOUTH CHINA UNIVERSITY of TECHNOLOGY BEEL 2014*/

DEFINE_ON_DEMAND(on_demand_PMVcalc)

{

/*定义real数据类型fluent会转译为float数据类型*/

real t_wh; /*空气温度*/

real speed_u_wh; /* u方向速度分量 */

real speed_v_wh; /* v方向速度分量*/

real speed_w_wh; /* w方向速度分量*/

real RH_wh=40; /* 输入相对湿度 水蒸气饱和时输入100 */

real pa_wh; /*物质质量分数C_YI(c,t,0) 后面通过相对湿度计算水蒸气分压力*/

real icl_wh=0.155; /*服装热阻 在计算时单位不是clo 此处将0.3clo换算成0.05㎡K/W*/

real fcl_wh; /*穿衣服人体外表面与裸体人体表面积之比*/

real tcl_wh; /*服装外表面温度*/

real tcl1_wh;

real tcl2_wh;

real temperary1_wh;

real temperary2_wh;

real hc_wh; /*表面换热系数*/

real tr_wh; /*平均辐射温度 可以后期自己定义*/

real M_wh=69.78; /*新陈代谢量*/

real W_wh=0.0; /*机械做功*/

real a_wh; /*heat loss by radiation refer to

*/

real b_wh; /*heat loss by convection refer to

page24> */

real c_wh; /*heat loss diff.through skin refer to

page24> */

real d_wh; /*heat loss by sweating(comfort) refer to

page24> */

real e_wh; /*latent respiration heat loss refer to

page24> */

real f_wh; /*dry respiration heat loss refer to

page24> */ real L_wh;

real speed_wh;

real PMV_wh;

Domain *d; /* declare domain pointer since it is not passed as an

argument to the DEFINE macro */

Thread *t; /* 声明Thread指针 */

cell_t c;

d = Get_Domain(1); /*这个要置于所有定义的变量之后 Get the domain

using Fluent utility*/

thread_loop_c(t,d) /* Loop over all cell threads in the domain 因为loop是针对每个cell的所以针对cell的计算都要包含到loop里面*/

{

begin_c_loop(c,t)

{

t_wh=C_T(c,t)-273.15; /*获取空气温度 ℃*/

speed_u_wh=C_U(c,t); /*获取u方向速度分量 m/s */

speed_v_wh=C_V(c,t); /*获取v方向速度分量 m/s */

speed_w_wh=C_W(c,t); /*获取w方向速度分量 m/s */

tr_wh=t_wh; /*此处把平均辐射温度近似处理为空气温度 ℃ 可以后期自己定义*/

pa_wh=RH_wh*10*exp(16.6536-4030.183/(t_wh+235));

/*计算水蒸气分压力*/

speed_wh=sqrt(pow(speed_u_wh,2.0)+pow(speed_v_wh,2.0)+pow(speed_w_wh,2.0));

/*计算绝对空气相对速度*/

if (icl_wh<0.078)

fcl_wh=1.00+1.290*icl_wh;

else

fcl_wh=1.05+0.645*icl_wh; /*判断穿衣服人体外表面与裸体人体表面积之比*/

temperary1_wh=2.38*pow(fabs(tcl1_wh-t_wh-273),0.25); /*自然换热系数*/

temperary2_wh=12.1*pow(speed_wh,0.5); /*强迫换热系数*/

if (temperary1_wh

hc_wh=temperary2_wh;

else

hc_wh=temperary1_wh; /*判断表面换热系数

并赋值*/

tcl1_wh=t_wh+273+(35.5-t_wh)/(3.5*icl_wh+0.1); /*计算服装表面温度的初始值*/

tcl2_wh=(308.7-0.028*(M_wh-0)+icl_wh*fcl_wh*hc_wh*(t_wh+273)+icl_wh*0.0000000396*fcl_wh*pow((tr_wh+273),4)-icl_wh*0.0000000396*fcl_wh*pow(tcl1_wh,4))/(1+icl_wh*fcl_wh*hc_wh);/*计算中服装表面温度 K */

while (fabs(tcl1_wh-tcl2_wh)>0.001) /*通过判断差的绝对值进行循环逼近真实值 fabs表示取浮点数据类型的绝对值*/

{

tcl1_wh=tcl2_wh; /*循环过程中把上次的计算结果赋给tcl1_wh做下一次计算*/

temperary1_wh=2.38*pow(fabs(tcl1_wh-t_wh-273),0.25); /*自然换热系数*/

temperary2_wh=12.1*pow(speed_wh,0.5); /*强迫换热系数*/

if (temperary1_wh

hc_wh=temperary2_wh;

else

hc_wh=temperary1_wh; /*判断表面换热系数 并赋值*/

tcl2_wh=(308.7-0.028*(M_wh-0)+icl_wh*fcl_wh*hc_wh*(t_wh+273)+icl_wh*0.0000000396*fcl_wh*pow((tr_wh+273),4)-icl_wh*0.0000000396*fcl_wh*pow(tcl1_wh,4))/(1+icl_wh*fcl_wh*hc_wh);/*计算中服装表面温度 K */

}

tcl_wh=tcl2_wh-273; /*最终的服装表面温度 ℃

*/

a_wh=0.0000000396*fcl_wh*(pow((tcl_wh+273),4.0)-pow((tr_wh+273),4.0));

b_wh=fcl_wh*hc_wh*(tcl_wh-t_wh);

c_wh=0.00305*(5733-6.99*(M_wh-W_wh)-pa_wh);

if((M_wh-W_wh-58.15)>0) d_wh=0.42*(M_wh-W_wh-58.15); else d_wh=0; /*heat loss by

sweating(comfort) refer to */

e_wh=0.000017*M_wh*(5867-pa_wh);

f_wh=0.0014*M_wh*(34-t_wh);

L_wh=M_wh-W_wh-(a_wh+b_wh+c_wh+d_wh+e_wh+f_wh);

PMV_wh=(0.303*exp(-0.036*M_wh)+0.028)*L_wh;

C_UDMI(c,t,0)=PMV_wh; /*调用UDM需要首先设置Define User-Defined Memory... 设置为1即可 此处只存储了一组数据 */

}

end_c_loop(c,t)

}

}