高级UDF示例

更新时间:2024-01-11 06:37:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

高级UDF示例

#include\

/* Constant Parameters */

#define N_WALLS 15 /* Total number of walls to consider */ #define RR 6 #define VP 3.5

#define TW 25.0 /* Water temperature*/ #define SMALL_T 1.0

/* Wall Parameter Lists */

/* wall name must coorespond to its ID,sied type,roler number,roler diameter,etc */

char *w_name[]={\

\int w_ID[]={24,26,25,21,23,22,18,20,19,15,17,16,12,14,13}; int w_side[]={0,1,2,0,1,2,0,1,2,0,1,2,0,1,2}; int w_n_roler[]={0,1,1,0,6,6,0,7,7,0,5,5,0,5,5};

real w_d_roler[]={0.,0.08,0.08,0.,0.13,0.13,0.,0.13,0.13,0.,0.13,0.13,0.,0.13,0.13};

real w_W[N_WALLS]={270.,270.,270.,364.,364.,364.,240.,240.,240.,128.,128.,128.,0.,0.,0.}; real w_L[N_WALLS]={0.}; real w_A[N_WALLS]={0.}; real w_T[N_WALLS]={0.}; real w_Q[N_WALLS]={0.};

/* Get index of the specified wall thread in the wall list */

int get_wall_index(int t_id) { int w_idx=-1,i; for(i=0;i

/* Calculate Averaged Wall Parameters:Area,Mean Temperature,Mean Distance to Entry Point */

int calc_wall_para(Thread *t) {

#if !RP_HOST int t_id,w_idx,i; real sum,sum_a,sum_f,sum_l; real y,z,l,T_avg; face_t f; real A[ND_ND],x[ND_ND],area,T;

/* locate the thread in the wall thread ID list */ t_id=THREAD_ID(t); if(w_idx!=-1) {

/* found the thread ID in the list. calculate the area weighted mean temperature */ sum=sum_a=sum_f=sum_l=0; begin_f_loop(f,t) { F_CENTROID(x,f,t); F_AREA(A,f,t); area=NV_MAG(A); T=F_T(f,t)-273; sum_a+=area; sum+=(area*T); sum_f+=1.; /* calc distance to level */ y=x[1]; z=x[2]; l=RR*asin(fabs(z)/RR); sum_l+=l; } end_f_loop(f,t); #if RP_NODE PRF_GRSUM4(sum,sum_a,sum_l,sum_f); #endif/* RP_NODE*/ T_avg=sum/sum_a; w_T[w_idx]=T_avg; w_A[w_idx]=sum_a; w_L[w_idx]=sum_l/sum_f+0.4; } return w_idx; #endif /*!RP_HOST*/ }

/* Calculate Total Heat Transfer on each Wall */

real calc_wall_heat(int w_idx) { int i=w_idx; real two_a=0.,r,alpha,h,w_q; real Q1=0.,Q2=0.,Q3=0.,Q4=0.; /* 1:Roler heat transfer */ if(w_n_roler[i]!=0) { if(w_L[i]<4.) { two_a=-0.3116+4.6105*w_L[i]; } else two_a=-0.3116+4.6105*4.; Q1=w_n_roler[i]*(two_a*w_d_roler[i]*0.5/360.*11513.7*pow(w_T[i],0.7556)*

pow(VP,-0.2010)*pow(two_a,-0.1639));

} else { two_a=0.; Q1=0.; }

/* 2:Water cooling */ if(w_side[i]!=0) { w_q=w_W[i]/60./2./w_A[i]; if(w_T[i]>900.) { h=1.095e15*pow(w_T[i],-4.15)*pow(w_q,0.75); } else if(w_T[i]>500.&&w_T[i]<=900.) { h=3.78e6*pow(w_T[i],-1.34)*pow(w_q,0.785); } else h=3.78e6*pow(500.,-1.34)*pow(w_q,0.785); Q2=w_A[i]*h*(w_T[i]-TW); } else Q2=0.; }

/* 3: Air cool and radiation */

Q3=w_A[i]*0.8*5.67e-8*(pow(w_T[i]+273,4.)-pow(TW+273,4.));

/* 4: Water evaporation */

if(w_side[i]==0||w_side[i]==1) alpha=0.39; else alpha=0.;

Q4=alpha/(1.-alpha)*(Q1+Q2+Q3);

/* Total heat (excluding radiation) */

w_Q[i]=Q1+Q2+Q4;

return two_a; }

/* Calculate and Display Total Heat Transfer,Heat Transfer Coefficient for each Wall*/

DEFINE_ON_DEMAND(cc_calc_heat) {

#if !RP_HOST Domain *domain=Get_Domain(1); Thread *t;

#endif /*!RP_HOST*/ int i; real two_a; if(!Data_Valid_P()) return;

#if !RP_HOST

/*Calculate mean wall parameters*/ thread_loop_f(t,domain) { if(BOUNDARY_FACE_THREAD_P(t)) i=calc_wall_para(t); }

#endif /*!RP_HOST*/

/*Calculate and display total heat transfer for each zone surface*/ Message0(\ for (i=0;i

DEFINE_PROFILE(cc_heat_tran,t,pos) { #if !RP_HOST Thread *t0=THREAD_T0(t); cell_t c0; face_t f; int w_idx; real two_a,h,q,T_w;

/*Calculate averaged wall parameters and get wall index*/ w_idx=calc_wall_para(t); if(w_idx!=-1) /*Check wall index*/ {

/*Calculate wall total heat transfer*/ two_a=calc_wall_heat(w_idx); /*Calculate wall heat flux*/ q=w_Q[w_idx]/w_A[w_idx];

/*Calculate effective wall heat transfer coefficient*/ /*method 1:use this for all faces on the thread*/ h=w_Q[w_idx]/(w_A[w_idx]*(w_T[w_idx]-TW)); /*Loop over all face on wall thread*/ begin_f_loop(f,t) { T_w=F_T(f,t)-273.;

/*method 2:calculate h for each face*/ // h=q/MAX(SMALL_T,(T_w-TW)); /*Assign heat transfer coefficient to F_PROFILE*/ F_PROFILE(f,t,pos)=h;

/*Store heat transfer coefficient on a User Defined Memory*/ if(NNULLP(THREAD_STORAGE(t0,SV_UDM_I))&&sg_udm!=0) { c0=F_C0(f,t); C_UDMI(c0,t0,0)=-h; } } end_f_loop(f,t); } #endif /*!RP_HOST*/ }

本文来源:https://www.bwwdw.com/article/ouso.html

Top