UDF案例

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

©2008ANSYS,Inc.Allrightsreserved.1ANSYS,Inc.ProprietaryFLUENTUDF案例飞昂软件技术(上海)有限公司ANSYSFLUENTCHINA2008-12©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary内容概要•UDS——低Re湍流模型添加•动网格•DegassingBoundary(多相流)•用户自定义的DragLaw(多相流)©2008ANSYS,Inc.Allrightsreserved.3ANSYS,Inc.ProprietaryUDS——低Re湍流模型添加©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary问题描述•通过UDF添加低雷诺数模型,AKNmodel(Abe,Kondoh,Nagano(IJHMT,1995))•需要添加k和epsion两个方程壁面边界条件:©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary需要用到的数据宏•密度C_R(c,t)•层流黏度C_MU_L(c,t)•湍动能C_UDSI(c,t,TKE)•湍流耗散率C_UDSI(c,t,TDR)•平均速度应变率C_STRAINRATE_MAG(c,t)•湍流黏度C_MU_T(c,t)©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现#include“udf.h”constrealC_MU=0.09;constrealSIG_TDR=1.4;constrealSIG_TKE=1.4;constrealC1_D=1.5;constrealC2_D=1.9;Constrealf_1=1.;/*User-definedScalars*/enum{TKE,TDR,N_REQUIRED_UDS};realy_star(cell_tc,Thread*t){returnC_R(c,t)*pow(C_UDSI(c,t,TDR)*C_MU_L(c,t)/C_R(c,t),0.25)*C_WALL_DIST(c,t)/C_MU_L(c,t);}realRe_t(cell_tc,Thread*t){returnC_R(c,t)*C_UDSI(c,t,TKE)*C_UDSI(c,t,TKE)/C_MU_L(c,t)/C_UDSI(c,t,TDR);}©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现realf_mu(cell_tc,Thread*t){returnSQR(1.-exp(-y_star(c,t)/14.))*(1.+5./pow(Re_t(c,t),0.75)*exp(-SQR(Re_t(c,t)/200.)));}realf_2(cell_tc,Thread*t){returnSQR(1.0-exp(-y_star(c,t)/3.1))*(1.-0.3*exp(-SQR(Re_t(c,t)/6.5)));}©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现•K方程源项•线性化DEFINE_SOURCE(tke_source,c,t,dS,eqn){realrho_Pk,rho_epsilon;rho_Pk=C_MU_T(c,t)*C_STRAIN_RATE_MAG(c,t)*C_STRAIN_RATE_MAG(c,t);rho_epsilon=SQR(C_R(c,t))*C_MU*f_mu(c,t)*C_UDSI(c,t,TKE)*C_UDSI(c,t,TKE)/C_MU_T(c,t);dS[eqn]=-2.*SQR(C_R(c,t))*C_MU*f_mu(c,t)*C_UDSI(c,t,TKE)/C_MU_T(c,t);returnrho_Pk-rho_epsilon;}2ktPS1/22ijijSSS22()kktkSPSCf**2ktSkdSeqnCfk©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现•Epsilon方程源项及其线性化DEFINE_SOURCE(tdr_source,c,t,dS,eqn){realPk,source;Pk=C_MU_T(c,t)/C_R(c,t)*SQR(C_STRAIN_RATE_MAG(c,t));dS[eqn]=C1_D*f_1*Pk/C_UDSI(c,t,TKE)-2.*C_R(c,t)*C_UDSI(c,t,TDR)*f_2(c,t)*C2_D/C_UDSI(c,t,TKE);source=C_R(c,t)*C_UDSI(c,t,TDR)/C_UDSI(c,t,TKE)*(f_1*C1_D*Pk-C2_D*f_2(c,t)*C_UDSI(c,t,TDR));returnsource;}1122112212kkSfCPfCkdSeqnfCPfCk©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现•扩散项DEFINE_DIFFUSIVITY(ke_diffusivity,c,t,i)realdiff;realmu_t;intnscalar=i;mu_t=C_R(c,t)*C_MU*f_mu(c,t)*C_UDSI(c,t,TKE)*C_UDSI(c,t,TKE)/C_UDSI(c,t,TDR);if(nscalar==TKE)diff=mu_t/SIG_TKE+C_MU_L(c,t);elsediff=mu_t/SIG_TDR+C_MU_L(c,t);returndiff;}©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现•返回湍流黏度DEFINE_TURBULENT_VISCOSITY(turbVis,c,t){realmu_t;mu_t=C_R(c,t)*C_MU*f_mu(c,t)*SQR(C_UDSI(c,t,TKE))/C_UDSI(c,t,TDR);returnmu_t;}©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现•壁面边界条件DEFINE_PROFILE(tdr_wall,thread,position){realxw[ND_ND],xc[ND_ND],delta[ND_ND],dy;face_tf;cell_tc0;Thread*t0=THREAD_T0(thread);begin_f_loop(f,thread){c0=F_C0(f,thread);C_CENTROID(xc,c0,t0);F_CENTROID(xw,f,thread);NV_VV(delta,=,xc,-,xw);dy=NV_MAG(delta);F_PROFILE(f,thread,position)=2.*(C_MU_L(c0,t0)/C_R(c0,t0))*C_UDSI(c0,t0,TKE)/SQR(dy);}end_f_loop(f,thread);}©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现©2008ANSYS,Inc.Allrightsreserved.14ANSYS,Inc.Proprietary动网格UDF案例©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary问题运动•绿色的阀体作定速转动•黄色膜片作随时间做正/余旋的变形•动网格区域–阀体——DEFINE_CG_MOTION–膜片——DEFINE_GRID_MOTION–上部壁面——DEFINE_GEOM©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.ProprietaryDEFINE_CG_MOTION•阀体转动#defineomega1.0DEFINE_CG_MOTION(butterfly_flex_UDF,dt,cg_vel,cg_omega,time,dtime){cg_vel[0]=0.0;cg_vel[1]=0.0;cg_vel[2]=0.0;cg_omega[0]=0.0;cg_omega[1]=0.0;cg_omega[2]=omega;}©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.ProprietaryDEFINE_GRID_MOTIONDEFINE_GRID_MOTION(moving_arc,domain,dt,time,dtime){Thread*tf=DT_THREAD(dt);face_tf;Node*node_p;realalpha,theta,x,ymag,yfull,y;intn;SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));alpha=omega*CURRENT_TIME;theta=2.0*alpha+3.0*M_PI/2.0;begin_f_loop(f,tf){f_node_loop(f,tf,n){node_p=F_NODE(f,tf,n);if(NODE_POS_NEED_UPDATE(node_p)){NODE_POS_UPDATED(node_p);x=NODE_X(node_p);ymag=sqrt(R*R-x*x)+0.03;yfull=ymag-0.1;y=-0.1+yfull*sin(theta);NODE_Y(node_p)=y;}}}end_f_loop(f,tf);}©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.ProprietaryDEFINE_GEOM#defineR0.109DEFINE_GEOM(plane,domain,dt,position){position[1]=R;}©2008ANSYS,Inc.Allrightsreserved.19ANSYS,Inc.ProprietaryDegassingBoundary©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary问题描述•多相流问题中,出于计算的目的,同一个边界,有时希望对其中某个相是出口,对其它相则是墙或是进口等边界。•本例中:–下部边界是气体的进口,液滴的出口进口:气体和液滴的混合相气体进口液滴出口气体液滴出口©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary思路•对于气相,底部面是标准的进口。•对液滴相,靠近底部的最近一层网格需要添加一个汇,以达到质量守恒。•主相无需作出调整。gasdropletstSsecsecsec©2008ANSYS,Inc.Allrightsreserved.ANSYS,Inc.Proprietary程序实现DEFINE_SOURCE(degassing_source,cell,thread,dS,eqn){realsource;Thread*tm=THREAD_SUPER_THREAD(thread);source=-C_R(cell,thread)*C_VOF(cell,thread)/CURRENT_TIMESTEP;C_UDMI(cell,tm,0)=source;dS[eqn]=-C_R(cell,thread)/CURRENT_TIMESTEP;return

1 / 29
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功