Turbulent Dispersion Model (Burns et al)

 Register Blogs Members List Search Today's Posts Mark Forums Read

 June 7, 2021, 03:16 #2 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,723 Rep Power: 28 Code: ```# include "udf.h" DEFINE_VECTOR_EXCHANGE_PROPERTY(burnetal,cell,mixture,liquid,solid,Ftdvector) { Thread *thread_l, *thread_s; real rho_l,rho_s,Sigmapq,alpha_l,alpha_s,term,Ftd,Ctd,K,pq; real px,py,pz,sx,sy,sz,Kpq; thread_l=THREAD_SUB_THREAD(mixture,liquid); thread_s=THREAD_SUB_THREAD(mixture,solid); /* Calculation of Gradients */ alpha_l=C_VOF(cell, thread_l); /* liquid phase volume fraction */ alpha_s=C_VOF(cell, thread_s); /* Solid Phase Volume fraction */ rho_l=C_R(cell,thread_l); rho_s=C_R(cell,thread_s); Kpq=alpha_l*rho_l*C_K(cell, thread_l)+alpha_s*rho_s*C_K(cell, thread_s); Ctd=1; Sigmapq=.9; term=Ctd*Kpq*C_MU_T(cell,thread_l)/(rho_l*Sigmapq); px=C_VOF_G(cell,thread_l)[0]/alpha_l; py=C_VOF_G(cell,thread_l)[1]/alpha_l; pz=C_VOF_G(cell,thread_l)[2]/alpha_l; sx=C_VOF_G(cell,thread_s)[0]/alpha_s; sy=C_VOF_G(cell,thread_s)[1]/alpha_s; sz=C_VOF_G(cell,thread_s)[2]/alpha_s; /* Calculation of the Final Expression */ Ftdvector[0]=term*(px-sx); Ftdvector[1]=term*(py-sy); Ftdvector[2]=term*(pz-sz); Message0("\n%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t %f\t%f\t%f\t%f\t%f\t%f\t%f\t",Ftdvector[0],Ftdvector[1],Ftdvector[2],Ctd,term,px,py,pz,sx,sy,sz,alpha_l,alpha_s,Kpq,C_MU_T(cell,thread_l),C_K(cell, thread_l),C_K(cell, thread_s)); }``` compile Prantik Das likes this. __________________ best regards ****************************** press LIKE if this message was helpful

 June 7, 2021, 09:30 Floating Point Exception #3 New Member   Join Date: Jun 2021 Posts: 4 Rep Power: 2 Getting Error at Node 0: floating point exception error. Divergence detected in AMG solver: pressure correction Stabilizing k to enhance linear solver robustness. Stabilizing epsilon to enhance linear solver robustness. Stabilizing vof-1 to enhance linear solver robustness. Divergence detected in AMG solver: vof-1 Error at host: floating point exception Error at Node 0: floating point exception Error: floating point exception Error Object: #f while using this UDF

 June 7, 2021, 19:49 #4 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,723 Rep Power: 28 you are printing most variables into console, check their values. if the values are wrong, fix it __________________ best regards ****************************** press LIKE if this message was helpful

 June 8, 2021, 01:17 #5 Senior Member   Join Date: Nov 2013 Posts: 1,867 Rep Power: 23 In general: a UDF is correct if I it does what you want. So if you want to know if it is correct: try it. If it works, be happy, if it does not, fix it. I don't understand the tendency to put code on a forum and ask other people if it is correct... Just try it! And if, like in your case, you get errors: mention that! __________________ "The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".