CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

UDF for granular flow

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 28, 2021, 01:36
Post UDF for granular flow
  #1
New Member
 
Habeb Hadad
Join Date: Oct 2021
Posts: 1
Rep Power: 0
habib is on a distinguished road
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
habib is offline   Reply With Quote

Reply

Tags
convergance, ddpm drag law, udf and programming


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run multiple cycle pulsetile flow simulation in Ansys fluent using UDF code? Md Al Amin Sheikh Fluent UDF and Scheme Programming 4 January 28, 2020 12:55
UDF to measure Mass Flow Rate a.lynchy Fluent UDF and Scheme Programming 31 October 4, 2018 15:10
volume flow rate for outlet boundry condition and dfine udf for it raminostadi FLUENT 0 December 24, 2016 02:52
UDF for 3D turbulent fully developed flow howhs Fluent UDF and Scheme Programming 0 August 1, 2013 12:47
UDF for transient pressure inlet, mass flow check at nozzle exit and volumetric heat kokoory FLUENT 0 August 17, 2011 03:07


All times are GMT -4. The time now is 06:02.