UDF for granular flow
Hello, I run a simulation for granular flow and used the non-spherical drag model and everything went fine.
I tried then adding a UDF to see the effect of the aspect ratio and angle of attack but I had this error floating point exception: pressure correction here is my UDF #include "udf.h" #include "cstdlib" #include "cmath" #include "ctime" #include "iostream" #define pi 3.14 DEFINE_DPM_DRAG(particle_drag_force,Re,p) { cell_t c = P_CELL(p); Thread *t = P_CELL_THREAD(p); real mu_g; real cd; real particle_drag_force; real cw_sp; real sph; real diam_cy; real a_s_s; real a_cs; real v; real l; real a_s_c; real cw_sec; real teta; real r; real ar; real diam_eq; /*-----------------------------------------------------------------*/ mu_g = C_MU_L(c,t); diam_eq = P_DIAM(p); /*------------------------------------------------------------------*/ /*compute equivilant diameter using gaussian function to generate random number*/ float sigma = 1.0; float Mi = 1.0; srand(time(0)); float v1= ( (float)(rand()) + 1. )/( (float)(RAND_MAX) + 1. ); float v2= ( (float)(rand()) + 1. )/( (float)(RAND_MAX) + 1. ); ar = ((cos(2*3.14*v2)*sqrt(-2.*log(v1)))*sigma+Mi)*15; /*gaussian function to generate random number*/ sigma = 1.0; Mi = 1.0; srand(time(0)); float v3= ( (float)(rand()) + 1. )/( (float)(RAND_MAX) + 1. ); float v4= ( (float)(rand()) + 1. )/( (float)(RAND_MAX) + 1. ); r = (cos(2*3.14*v4)*sqrt(-2.*log(v3)))*sigma+Mi; /*compute teta*/ teta = 20.* r; a_s_s = pi*diam_eq*diam_eq; a_cs = a_s_s/4.; v = 4.*diam_eq*diam_eq*diam_eq/3.; diam_cy = pow((4.*v/pi/ar), 1/3); l = ar*diam_cy; a_s_c = (pi*pow(diam_cy, 2.)/2.)+(pi*diam_cy*l); sph = a_s_s/a_s_c; cw_sec = ((pi*pow(diam_cy, 2.)/4)*cos(teta*pi/180))+(diam_cy*l*sin(teta*pi/180)); cw_sp = a_cs/cw_sec; /*------------------------------------------------------------------*/ /*compute Cd*/ cd = (8./(Re*sqrt(cw_sp)))+(16./(Re*sqrt(sph)))+(3./(pow(sph, 0.75)*sqrt(Re)))+((0.42*pow(10, 0.4*pow(-log10(sph), 0.2)))/(cw_sp)); particle_drag_force = 18*cd*Re/24; return (particle_drag_force); } I had no problems compiling the UDF. Is the problem with the UDF? controls? mesh? Thanks in advance |
All times are GMT -4. The time now is 00:35. |