CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Turbulent Dispersion Model (Burns et al) (https://www.cfd-online.com/Forums/fluent-udf/236596-turbulent-dispersion-model-burns-et-al.html)

Prantik Das June 6, 2021 11:54

Turbulent Dispersion Model (Burns et al)
 
Is my UDF for Burns et al model right or wrong ?

# include "udf.h"
DEFINE_VECTOR_EXCHANGE_PROPERTY(burnetal,cell,mixt ure,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;
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);
printf("\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));
}

AlexanderZ June 7, 2021 03:16

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 June 7, 2021 09:30

Floating Point Exception
 
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

AlexanderZ June 7, 2021 19:49

you are printing most variables into console, check their values.
if the values are wrong, fix it

pakk June 8, 2021 01:17

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!


All times are GMT -4. The time now is 16:43.