当前位置:首页 > 办公文档 > 其它办公文档 > Fluent--UDF-Samples
Fluent实现随时间或坐标变化边界条件的方法注:F_CENTROID(x,f,t)x[0]就是x坐标x[1]就是y坐标x[2]就是z坐标用自定义函数UDF实现速度随时间变化的边界条件以下是velocity.c的内容-----------------------------------------------------------------#includeudf.hDEFINE_PROFILE(inlet_velocity,thread,position){realt,v;face_tf;begin_f_loop(f,thread){t=RP_Get_Real(flow-time);{if(t0&&t=0.15){v=145.3*t+18.2;}elseif(t0.15&&t=0.35){v=-88*t+53.2;}elseif(t0.35&&t=0.69){v=128*t-22.4;}elseif(t=0.69){v=-140*t+162.4;}}F_PROFILE(f,thread,position)=v;}end_f_loop(f,thread)}-----------------------------------------------------------------写好的velocity.c文件放到Fluent工作目录里,如下图所示准备工作完成以后启动Fluent首先要加载UDF用interpreted,具体如下图所示打开如下界面接下来在源文件一栏定位到刚才准备好的.c文件,如下图所示点击interpret,下边的TUI界面会显示interpret的过程之后就可以在设定边界条件时应用UDF选择udfinlet_velocity即可用自定义函数UDF实现温度随时间或坐标变化的边界条件Sample1#includeudf.hDEFINE_PROFILE(temp_inlet,thread,position){face_tf;begin_f_loop(f,thread){realtt=RP_Get_Real(flow-time);realt=1+tt/60;F_PROFILE(f,thread,position)=293+1080*(1-0.325*exp(-0.167*t)-0.675*exp(-2.5*t));}end_f_loop(f,thread)}Sample2#includeudf.hDEFINE_PROFILE(linear_temp,thread,position){face_tf;realx;realy;begin_f_loop(f,thread){F_CENTROID(x,f,thread);y=x;F_PROFILE(f,thread,position)=100*y+273;}end_f_loop(f,thread)}Sample3DEFINE_PROFILE(variable_heat,thread,position){face_tf;realadd_t=20;/*你加上的温度,自己设定*/begin_f_loop(f,thread){F_PROFILE(f,thread,position)=F_T(f,thread)+add_t;}end_f_loop(f,thread)}Sample4#includeudf.hDEFINE_PROFILE(inlet_z_temp,thread,position){realx[ND_ND];realz;face_tf;begin_f_loop(f,thread){F_CENTROID(x,f,thread);z=x[2];F_PROFILE(f,thread,position)=函数;}end_f_loop(f,thread)}用自定义函数UDF实现压力随时间变化的边界条件#includeudf.hDEFINE_PROFILE(pressure_profile,t,i){realx;/*thiswillholdthepositionvector*/realy;face_tf;begin_f_loop(f,t){F_CENTROID(x,f,t);y=x;F_PROFILE(f,t,i)=1.1e5-y*y/(.0745*.0745)*0.1e5;}end_f_loop(f,t)}用自定义函数UDF实现热流密度随时间或坐标变化的边界条件SampleA#includeudf.hDEFINE_PROFILE(heatflux,thread,index){realflow_time=CURRENT_TIME;face_tf;begin_f_loop(f,thread){F_CENTROID(x,f,thread);F_PROFILE(f,thread,index)=20*flow_time+20;}end_f_loop(f,thread)}SampleB#includeudf.h#definePI3.1415926DEFINE_PROFILE(unsteady_Heat_Flux,thread,position){face_tf;begin_f_loop(f,thread){realt=RP_Get_Real(flow-time);F_PROFILE(f,thread,position)=1000*sin(PI*t/12);}end_f_loop(f,thread)}SampleC#includeudf.h#definee2.718281828459#definepi3.1415926#defineF115000.#defineF220000.#definer10.0015#definer20.001DEFINE_PROFILE(heat_flux,t,i){face_tf;realtime=CURRENT_TIME;realu;realF3;realtemp=F_T(f,t);if(temp400.){F_PROFILE(f,t,i)=1.0e7;}elsebegin_f_loop(f,t){u=0.2497+0.001471*temp-2.097e-6*pow(temp,2.0);F3=F1+F2*sin(2*pi*F2*time);if(F30.){F3=0.;}F_PROFILE(f,t,i)=4*pi*F2*F3*u*(pow(r1,3)-pow(r2,3))/(3*pow(r1,2)*(pow(r1,2)-pow(r2,2)));}end_f_loop(f,t)}SampleD#includeudf.hDEFINE_PROFILE(heatflux,t,i){face_tf;reala,r;realx[ND_ND],y[ND_ND],z[ND_ND];begin_f_loop(f,t){F_CENTROID(x,f,t);y[0]=0.0;//假设圆心坐标为(0,0,0),若为其他坐标更改即可。y[1]=0.0;y[2]=0.0;NV_VV(z,=,x,-,y);r=NV_MAG(z);F_PROFILE(f,t,i)=a*r;}end_f_loop(f,t)}SampleE#includeudf.hDEFINE_PROFILE(unsteady,thread,position){face_tf;realt=CURRENT_TIME;begin_f_loop(f,thread){F_PROFILE(f,thread,position)=20+5*sin(10*t);}end_f_loop(f,thread)}
本文标题:Fluent--UDF-Samples
链接地址:https://www.777doc.com/doc-4634485 .html