• Lacey__Wang
    了解作者
  • C/C++
    开发工具
  • 2KB
    文件大小
  • rar
    文件格式
  • 1
    收藏次数
  • 10 积分
    下载积分
  • 26
    下载次数
  • 2020-06-21 11:10
    上传日期
Fluent UDF 激光焊接 VOF追踪自由界面 灵活添加各种源项
laser welding.rar
  • wang.cpp
    7.5KB
内容介绍
//质量传输 DEFINE_MASS_TRANSFER(liq_gas_source,cell,thread,from_index,from_species_index,to_ind ex,to_species_index) { real x[ND_ND]; real m_lg,a,b; //m_lg蒸发速率 real T_SAT=3200.; Thread *liq=THREAD_SUB_THREAD(thread,from_index); //质量减少 Thread *gas=THREAD_SUB_THREAD(thread,to_index); //质量增多 C_CENTROID(x,cell,thread); a=x[0],b=x[1]; m_lg=0.; if (C_T(cell,liq)>=T_SAT) { m_lg=-1.0*C_VOF(cell,liq)*C_R(cell,liq)*fabs(C_T(cell,liq)-T_SAT)/T_SAT; //液相温度高于蒸发温度,液相向气相质量转移 } if ( (C_T(cell, gas) < T_SAT)) { m_lg =1.0*C_VOF(cell,gas)*C_R(cell,gas)* fabs(T_SAT-C_T(cell,gas))/T_SAT; //气相温度低于蒸发温度,气相向液相质量转移 } C_UDMI(cell,thread,0)=6.34e6*m_lg; return (m_lg); } //能量传输 DEFINE_SOURCE(enrg_transfer, cell, mix_th, dS, eqn) { real source; Thread *pri_th; pri_th=THREAD_SUB_THREAD(mix_th, 0);//主相为gas,ID=0;第二相为fluid,Id=1 source=C_UDMI(cell,mix_th,0); //能量传输吗?源项=编号为0的在mix_th中的UDM dS[eqn]=0.; return source; } //程序二 处理气\液界面表面张力问题 DEFINE_PROPERTY(sfc,c,t) { real x[ND_ND]; real T,sf; T = C_T(c,t); C_UDMI(c,t,7)=0; //编号为7的UDM? sf=1.2-1e-4*(T-1727);//σ(T)=σm-Г_表面张力温度系数(T-T_m) T_m熔化温度 return sf; } //程序三 用于获取体积分数梯度 #include "udf.h" #define CON 1 DEFINE_ADJUST(store_gradient, domain) { Thread *t; Thread **pt; cell_t c; int phase_domain_index = 0.;//第一相的phase_domain_index是 0 primary phase Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index); //获得第一相的指针 { Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL); Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL); Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate); //这些固定用法 mp_thread_loop_c (t,domain,pt) if (FLUID_THREAD_P(t)) Thread *ppt = pt[phase_domain_index]; begin_c_loop (c,t) { C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0];//获得fluid VOF梯度 UDM=0 x方向的梯度 } end_c_loop (c,t) Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL); } } //程序四 自定义电势标量方程源项 DEFINE_SOURCE(mhd_phi_source,c,t,dS,eqn) { real source; Thread *thread_g; thread_g=THREAD_SUB_THREAD(t,0); //getting phase thread pointer *t:pointer to mixture level thread; 0:primary phase(Fluid) source=0; dS[eqn]=0; return source; } //程序五 自定义气相粘度 DEFINE_PROPERTY(cell_viscosity,c,t) { real vs; real temp1=C_T(c,t); if (temp1<=10000.0) vs=1.78887e-5+3.50148e-8*temp1-1.04883e-12*temp1*temp1; else if (temp1<=30000.0) vs=0.00376*exp(-temp1/3963.59514)-1.9376e-7; else vs=5.6e-6; return vs; } //程序六 自定义气相比热 DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi) //Ar的材料属性 分段插值 { real cp; if (T<=6000.0) cp=5.2082e2; else if (T<=6300.0) cp=-3.14557e6+784.60361*T-0.07597*T*T+3.57832e-6*T*T*T-8.2105e-11*T*T*T*T+7.35682 e-16*T*T*T*T*T; else if (T<=1.4e4) cp=-50405.56498+23.48401*T-0.00391*T*T+2.74738e-7*T*T*T-6.68657e-12*T*T*T*T; else if (T<=30000.0) cp=-3.27824E6+815.01643*T-0.07872*T*T+3.70094E-6*T*T*T-8.48038E-11*T*T*T*T+7.591 51E-16*T*T*T*T*T; else cp=6.4464e3; return cp; } //程序七 自定义气相热导率 //插值 DEFINE_PROPERTY(ktc,c,t) { real tc; real temp2=C_T(c,t); if ( temp2<=300.0) tc=1.77e-2; else if (temp2<=400.0) tc=2.23e-2; else if (temp2<=500.0) tc=2.65e-2; else if (temp2<=600.0) tc=3.03e-2; else if (temp2<=700.0) tc=3.38e-2; else if (temp2<=800.0) tc=3.70e-2; else if (temp2<=900.0) tc=4.01e-2; else if (temp2<=1000.0) tc=4.31e-2; else if (temp2<=1.5e4) tc=0.1038*exp(temp2/4557.64224)-0.16532; else if (temp2<=30000.0) tc=1.36682-3.97531e-5*temp2+5.42035e-9*temp2*temp2; else tc=5.07; return tc; } //程序八 自定义气相电导率 DEFINE_DIFFUSIVITY(UDS_cndcvty0,c,t,i) //插值 { real elec; real temp4=C_T(c,t); if ( temp4<=1500.0) elec=1e-6; else if (temp4<=3400.0) elec=2e-5; else if (temp4<=4600) elec=-0.0043072+(1179.0/(719.23*sqrt(1.57)))*exp(-2*((temp4-5061.8)/719.23)*((temp4-5061.8) /719.23)); else if (temp4<=21000.0) elec=-7561.28558+1.25508*temp4-1.77812e-5*temp4*temp4; else if (temp4<=30000.0) elec=-61302.23403+9.21582*temp4-3.88865e-4*temp4*temp4+5.3953e-9*temp4*temp4*temp4; else elec=1.1e5; return elec; } //程序九 求解电流密度、感应磁场 DEFINE_ADJUST(mhd_adjust,d) { Thread *t; cell_t c; thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDMI(c,t,4)=- C_UDMI(c,t,10)* C_UDSI_G(c,t,0)[0];//Jx=σ*Ex C_UDMI(c,t,5)=- C_UDMI(c,t,10)* C_UDSI_G(c,t,0)[1];//Jy=σ*Ey C_UDMI(c,t,9)=C_UDSI_G(c,t,1)[0]-C_UDSI_G(c,t,0)[1];//Bz } end_c_loop(c,t) } } //程序十 电弧产生的焦耳热 DEFINE_SOURCE(mhd_energy_source,c,t,dS,eqn) { real source; Thread *pri_th,*sec_th; pri_th=THREAD_SUB_THREAD(t,0); sec_th=THREAD_SUB_THREAD(t,1); source=(C_UDSI_G(c,t,0)[0]*C_UDSI_G(c,t,0)[0]+C_UDSI_G(c,t,0)[1]*C_UDSI_G(c,t,0)[1])*( 1*C_VOF(c,pri_th)+7.7e5*C_VOF(c,sec_th)); dS[eqn]=0; return source; } //程序十一 X方向磁矢位方程源项 DEFINE_SOURCE(magsrc_x,c,t,dS,eqn) { real source; source=-1.257e-6*C_UDMI(c,t,20)*C_UDSI_G(c,t,3)[0]; //uo*Jx dS[eqn]=0; return source; } //程序十二 Y方向磁矢位方程源项 DEFINE_SOURCE(magsrc_y,c,t,dS,eqn) { real source; source=-1.257e-6*C_UDMI(c,t,20)*C_UDSI_G(c,t,3)[1]; //uo*Jy dS[eqn]=0; return source; } //程序十三 电弧产生的X方向洛伦兹力 DEFINE_SOURCE(mhd_xmomentum_source,c,t,dS,eqn)//Fx=Bz*Jy { real source; source=(C_UDSI_G(c,t,5)[0]-C_UDSI_G(c,t,4)[1])*C_UDMI(c,t,18); C_UDMI(c,t,15)=source; dS[eqn]=0; return source; } //程序十四 电弧产生的Y方向洛伦兹力 DEFINE_SOURCE(mhd_ymomentum_source,c,t,dS,eqn)//Fy=-Bz*Jx { real source; source=-(C_UDSI_G(c,t,5)[0]-C_UDSI_G(c,t,4)[1])*C_UDMI(c,t,17); C_UDMI(c,t,16)=source; dS[eqn]=0; return source; } //程序十五 提取激光深熔点焊时的熔池速度矢量 #include"udf.h" DEFINE_ADJUST(store_gradient4, domain) { Thread *t; Thread **pt; cell_t c; int phase_domain_index = 1; //secondary phase:Fluid Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index); mp_thread_loop_c (t,domain,pt) if (FLUID_THREAD_P(t)) { Thread *ppt = pt[phase_domain_index]; begin_c_loop { C_UDMI(c,t,11)=C_U(c,ppt); C_UDMI(c,t,12)=C_V(c,t); } else { C_UDMI(c,t,11)=0; C_UDMI(c,t,12)=0; } } end_c_loop (c,t) } } //程序十六 提取焊接速度为 0.05m/s 时的熔池速度矢量 #include"udf.h" DEFINE_ADJUST(store_gradient4, domain) { Thread *t; Thread **pt; cell_t c; int phase_domain_index = 1; Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index); mp_thread_loop_c (t,domain,pt) if (FLUID_THREAD_P(t)) { Thread *ppt = pt[phase_domain_index]; begin_c_loop (c,t) { if (C_VOF(c,ppt)>0.5) { C_UDMI(c,t,11)=C_U(c,ppt)-0.05; C_UDMI(c,t,12)=C_V(c,t); C_UDMI(c,t,13)=C_W(c,t); } else { C_UDMI(c,t,11)=0; C_UDMI(c,t,12)=0; C_UDMI(c,t,13)=0; } } end_c_loop (c,t) } }
评论
  • wsws121 2020-11-05 18:28:17
    b不符
  • mikejwg 2020-08-28 20:00:40
    与说明不符合。
相关推荐