|
[Sponsors] |
trying to calculate PMV, PPD and PD in fluent using UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 21, 2007, 05:25 |
trying to calculate PMV, PPD and PD in fluent using UDF
|
#1 |
Guest
Posts: n/a
|
I have just started learning fluent and needed to calculate PMV,PPD and PD. I want to know if anyone has already has this kind of UDF?
I tried to write a interpreted progrem for this progrem. But the compile is unsuccessful. The message I got from fluent is as follows: C:\Fluent.Inc tbin tx86\cpp.exe -IC:\Fluent.Inc\fluent6.1.22/src -IC:\Fluent.Inc\fluent6.1.22/cortex/src -IC:\Fluent.Inc\fluent6.1.22/client/src -IC:\Fluent.Inc\fluent6.1.22/multiport/src -I. -DUDFCONFIG_H="<udfconfig.h>" C:\Documents and Settings\chunying.CITYUMD\Desktop 1\PPD.c.txt Error: C:\Documents and Settings\chunying.CITYUMD\Desktop\1\PPD.c.txt: line 1: parse error. Following is my progrem. Could you please tell me the mistakes I made? There must be a alot. Thank you! #include "udf.h" DEFINE_ADJUST(pd_myudf,domain) { Thread *t; cell_t c; thread_loop_c(c,domain) begin_c_loop(c,t) { real t_myudf=C_T(c,t)-273.15; real speed_u_myudf=C_U(c,t); real speed_v_myudf=C_V(c,t); real speed_w_myudf=C_W(c,t); real turbu_k=C_K(c,t); real mh2o_myudf=C_YI(c,t,1); /*mass friction of h2o 1????*/ real clo=0.55; real icl=0.155*clo; /*clothing insulation*/ real tr_myudf=t_myudf; real M_myudf=58.0; /*metabolism, w/m2*/ real W_myudf=0.0; real p_myudf=101325; /*calculate pd_myudf*/ /*external work, w/m2*/ real speed_myudf=sqrt(speed_u_myudf**2.0+speed_v_myudf* *2.0+speed_w_myudf**2.0); /*magnitude of speed*/ if (speed_myudf<0.05) speed_myudf=0.05; /*for speed<0.05,use speed=0.05*/ turbu_tu=100.0*(2.0*turbu_k)**0.5/speed; pd_myudf(c,t)=(34-t_myudf)(speed_myudf-0.05)**0.62*(3.14+0.37*speed_myudf*turbu_tu); if (pd_myudf(c,t)>1) pd_myudf(c,t)=1; /*for pd_myudf>1, use pd_myudf=1*/ /*Calculate pmv_myudf*/ pa_myudf=29*mh2o_myudf/(18+11mh2o_myudf)*p_myudf; { if (icl_myudf<0.078) fcl_myudf=1.00+1.290*icl_myudf; else fcl_myudf=1.05+0.645*icl_myudf; } /*Calculate fcl*/ tcl1_myudf=40; tcl2_myudf=35.7-0.025*(M_myudf-W_myudf)-icl_myudf*(0.0000000396*fcl_myudf*((tcl1_myudf+273 )**4-(tr_myudf+273)**4)+fcl_myudf*hc_myudf*(tcl1_myudf-t_myudf); if (tcl1_myudf-tcl2_myudf>0.000001) { tcl1_myudf=tcl2_myudf; temperary1_myudf=2.38*pow((tcl1_myudf-t_myudf),0.25) temperary2_myudf=12.1*pow(speed_myudf,0.5) { if (temperary1_myudf<temperary2_myudf) hc_myudf=temperary2_myudf; else hc_myudf=temperary1_myudf; } /*Calculate hc*/ tcl2_myudf=35.7-0.025*(M_myudf-W_myudf)-icl_myudf*(0.0000000396*fcl_myudf*((tcl1_myudf+273 )**4-(tr_myudf+273)**4)+fcl_myudf*hc_myudf*(tcl1_myudf-t_myudf); } tcl_myudf=tcl2_myudf; /*iterate to calculate tcl*/ a_myudf=0.0000000396*fcl_myudf(pow((tcl_myudf+273) ,4.0)-pow((tr_myudf+273),4.0); b_myudf=fcl_myudf*hc_myudf(tcl_myudf-t_myudf); c_myudf=0.00305*(5733-6.99*(M_myudf-W_myudf)-pa_myudf; d_myudf=0.42*(M_myudf-W_myudf-58.15); e_myudf=0.000017*M_myudf*(5867-pa_myudf); f_myudf=0.0014*M_myudf*(34-t_myudf); /*for a shorter formula of L_myudf*/ L_myudf=M_myudf-W_myudf-(a_myudf+b_myudf+c_myudf+d_myudf+e_myudf+f_myudf); pmv_myudf(c,t)=(0.303exp(-0.036M_myudf)+0.028)L_myudf; /*Calculate ppd_myudf*/ ppd_myudf(c,t)=100.0-95.0exp(-0.03353*POW(pmv_myudf(c,t),4.0)-0.2179*POW(pmv_myudf(c,t),2.0)); } end_c_loop(c,t) } return Thank you very much! |
|
December 28, 2010, 21:32 |
|
#2 |
New Member
Join Date: Aug 2009
Posts: 18
Rep Power: 17 |
Hi Chun Ying,
I came across your post recently. I suppose your problem is solved? |
|
December 17, 2014, 17:33 |
|
#3 |
Member
James
Join Date: Jan 2014
Posts: 38
Rep Power: 12 |
Hello,
I am also a beginner in fluent and looking for UDF of PMV and PPD for Fluent. If you have solved it and could share, I would be really thankful for the help. My email is: Prad.aryal@gmail.com Regards, Prad |
|
January 2, 2015, 02:26 |
|
#4 |
New Member
Zeng Liyue
Join Date: Sep 2014
Posts: 21
Rep Power: 12 |
I've been working on this these days...but couldn't get through. Would you please share your udf? Thanks a lot~
|
|
February 7, 2019, 06:14 |
thermal comfort program
|
#5 |
New Member
hasna
Join Date: Feb 2019
Posts: 6
Rep Power: 7 |
Currently, I am experiencing the same problem I would be grateful if someone can help me to overcome this problem.
|
|
February 22, 2019, 14:05 |
pmv-ppd
|
#6 |
New Member
Join Date: Oct 2018
Posts: 3
Rep Power: 8 |
Hello, Can you help me? Can you send me your udf(ppd-pmv) in ansys? How can introduce in ansys? Where introduce this file ?(sepideh.bazari.7@gmail.com)
|
|
February 23, 2019, 02:36 |
|
#7 |
Senior Member
Join Date: Sep 2017
Posts: 130
Rep Power: 9 |
I'm not going to write any UDF for you but about "Loading" (not introduce) your UDF, you have two choice. Compile or interpret it. Go to function menu and do everything you need. Suggest you to compile it if your simulation is heavy.
|
|
May 20, 2019, 09:07 |
please refer this.
|
#8 |
New Member
Join Date: May 2015
Posts: 2
Rep Power: 0 |
Code:
/* 使用时将此文档的扩展名改为.c 然后编译或解释到fluent当中 每个参数都有说明 用户可以根据需要调整 调用UDM需要首先设置Number of User-Defined Memory Locations(注意不是存储在Node节点) 设置为3,此处存储了三组数据,分别为PMV,PPD,DR */ /*user define memory 0变量为PMV*/ /*user define memory 1变量为PPD*/ /*user define memory 2变量为DR*/ #include "udf.h" /* Author:wanghao SOUTH CHINA UNIVERSITY of TECHNOLOGY BEEL 2014*/ /* Author:zhanghongliang DALIAN UNIVERSITY of TECHNOLOGY FIE 2019*/ /*增加计算DR值(吹风感系数)和PPD值代码 2019*/ DEFINE_ON_DEMAND(PMV_PPD_DR_calc) { /*定义real数据类型fluent会转译为real数据类型*/ #if !RP_HOST real t_wh; /*空气温度,℃*/ real speed_u_wh; /* u方向速度分量,m/s */ real speed_v_wh; /* v方向速度分量,m/s*/ real speed_w_wh; /* w方向速度分量,m/s*/ real speed_wh; /* 三个方向的和速度,m/s*/ real re_zhhl; /* 雷诺数*/ real rho_zhhl; /* 空气密度*/ real mu_zhhl; /*动力粘度系数*/ real diam_zhhl=3.0; /*房间特征长度,置换通风取房间高度,根据实际情况修改*/ real tu_zhhl; /* 湍动强度,10%~60%之间,混合通风默认40%,置换通风默认20%*/ real RH_wh=40.0; /* 输入相对湿度 水蒸气饱和时输入100 */ real pa_wh; /*水蒸气分压力 后面通过相对湿度计算水蒸气分压力,pa*/ 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; /*表面换热系数,w/m2K*/ real tr_wh; /*平均辐射温度 可以后期自己定义,℃*/ real M_wh=69.78; /*新陈代谢量,W*/ real W_wh=0.0; /*机械做功,W*/ real a_wh; /*heat loss by radiation refer to<EN ISO 7730:2005 page24> */ real b_wh; /*heat loss by convection refer to<EN ISO 7730:2005 page24> */ real c_wh; /*heat loss diff.through skin refer to<EN ISO 7730:2005 page24> */ real d_wh; /*heat loss by sweating(comfort) refer to<EN ISO 7730:2005 page24> */ real e_wh; /*latent respiration heat loss refer to<EN ISO 7730:2005 page24> */ real f_wh; /*dry respiration heat loss refer to<EN ISO 7730:2005 page24> */ real L_wh; real PMV_wh; /*计算所得PMV值*/ real PPD_zhhl; /*计算所得PPD值*/ real DR_zhhl; /*计算所得DR(吹风感系数)值*/ Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */ Thread *t; /* 声明Thread指针 */ cell_t c; /* 声明cell_t变量,用于循环宏 */ d = Get_Domain(1); /*!!!!!这个要置于所有定义的变量之后 Get the domain using Fluent utility,单相流取值为1*/ thread_loop_c(t,d) /* Loop over all cell threads in the domain 因为loop是针对每个cell的所以针对cell的计算都要包含到loop里面*/ { begin_c_loop(c,t) { /*计算PMV值--------------------------------------------------------------------------------------------*/ 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.0*exp(16.6536-4030.183/(t_wh+235.0)); /*计算水蒸气分压力*/ 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.0+1.290*icl_wh; else fcl_wh=1.05+0.645*icl_wh; /*判断穿衣服人体外表面与裸体人体表面积之比*/ tcl1_wh=t_wh+273.0+(35.5-t_wh)/(3.5*icl_wh+0.1); /*计算服装表面温度的初始值*/ tcl2_wh=(308.7-0.028*(M_wh-W_wh)+icl_wh*fcl_wh*hc_wh*(t_wh+273.0)+icl_wh*0.0000000396*fcl_wh*pow((tr_wh+273.0),4.0)-icl_wh*0.0000000396*fcl_wh*pow(tcl1_wh,4.0))/(1.0+icl_wh*fcl_wh*hc_wh);/*计算中服装表面温度 K */ temperary1_wh=2.38*pow(fabs(tcl2_wh-t_wh-273.0),0.25); /*自然换热系数*/ temperary2_wh=12.1*pow(speed_wh,0.5); /*强迫换热系数*/ if (temperary1_wh<temperary2_wh) hc_wh=temperary2_wh; else hc_wh=temperary1_wh; /*判断表面换热系数 并赋值*/ 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),0.25); /*自然换热系数*/ temperary2_wh=12.1*pow(speed_wh,0.5); /*强迫换热系数*/ if (temperary1_wh<temperary2_wh) hc_wh=temperary2_wh; else hc_wh=temperary1_wh; /*判断表面换热系数 并赋值*/ tcl2_wh=(308.7-0.028*(M_wh-0.0)+icl_wh*fcl_wh*hc_wh*(t_wh+273.0)+icl_wh*0.0000000396*fcl_wh*pow((tr_wh+273.0),4.0)-icl_wh*0.0000000396*fcl_wh*pow(tcl1_wh,4.0))/(1.0+icl_wh*fcl_wh*hc_wh);/*计算中服装表面温度 K */ } tcl_wh=tcl2_wh-273.0; /*最终的服装表面温度 ℃ */ a_wh=0.0000000396*fcl_wh*(pow((tcl_wh+273.0),4.0)-pow((tr_wh+273),4.0)); b_wh=fcl_wh*hc_wh*(tcl_wh-t_wh); c_wh=0.00305*(5733.0-6.99*(M_wh-W_wh)-pa_wh); if((M_wh-W_wh-58.15)>0.0) d_wh=0.42*(M_wh-W_wh-58.15); else d_wh=0.0; /*heat loss by sweating(comfort) refer to<EN ISO 7730:2005 page24> */ e_wh=0.000017*M_wh*(5867.0-pa_wh); f_wh=0.0014*M_wh*(34.0-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; /*计算PPD值--------------------------------------------------------------------------------------------*/ PPD_zhhl=100.0-95.0*exp(-0.03353*pow(PMV_wh,4.0)-0.2179*pow(PMV_wh,2.0)); /*计算DR值---------------------------------------------------------------------------------------------*/ if(speed_wh<0.05) speed_wh=0.05; rho_zhhl=C_R(c,t); mu_zhhl=C_MU_L(c,t); re_zhhl=rho_zhhl*speed_wh*diam_zhhl/mu_zhhl; /*计算雷诺数*/ //tu_zhhl=0.16*pow(re_zhhl,-0.125); tu_zhhl=20.0; DR_zhhl=(34.0-t_wh)*pow((speed_wh-0.05),0.62)*(0.37*speed_wh*tu_zhhl+3.14); if(DR_zhhl>100.0) DR_zhhl=100.0; /*UDM设置---------------------------------------------------------------------------------------------*/ /*调用UDM需要首先设置Number of User-Defined Memory Locations,该值设置为3*/ C_UDMI(c,t,0)=PMV_wh; C_UDMI(c,t,1)=PPD_zhhl; C_UDMI(c,t,2)=DR_zhhl; } end_c_loop(c,t) } #endif } |
|
|
|