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

Fluent crashes upon calculation due to UDF

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 2, 2023, 06:08
Default Fluent crashes upon calculation due to UDF
  #1
New Member
 
Nicholas Alberg
Join Date: Feb 2023
Posts: 1
Rep Power: 0
Nicholas_A is on a distinguished road
Hi,


I'm using the Ansys Fluent multiphase DPM model to investigate particle focusing in microchannels. For this, I've written an UDF to incorporate the net lift force acting on the particles (see below). However, after compiling and hooking my UDF, Fluent crashes and exits upon starting the calculations with following error messages:


By only adding a couple lines of code at a time and running the simulation, I was able to determine the lines causing the problem. The problem is caused by following lines where I try to fetch the fluid velocities:


Ufx = C_U(c,t); /* local fluid x-velocity in cell */
Ufy = C_V(c,t); /* local fluid y-velocity in cell */
Ufz = C_W(c,t); /* local fluid z-velocity in cell */


When I replace the velocities by constants, the UDF works and Fluent doesn't crash or exit the simulation. Does anyone have an idea as to why these lines are causing the problem? I've posted the full UDF below.


Thanks in advance


Full UDF:


/* UDF for computing the lateral displacement of particle suspended in fluid flow*/
#include "udf.h"
#include "mem.h" /* cell indexing header */
#include "dpm.h" /* particle properties even though declared in the macro arguments */
#include
DEFINE_DPM_BODY_FORCE(net_lift_force,p,i)
{
/* declaration of variables */
double w, Dh, Ufx, Ufy, Ufz, Gx, Gy, Gz, rho, a, Fx, Fy, Fz, FL,
c_volume, Renx, Reny, Renz, crDh, mu, aUfx, aUfy,
aUfz, Clx, Cly, Clz;
cell_t c = P_CELL(p); /* the cell initialization in which the particle is present*/
Thread *t = P_CELL_THREAD(p); /* thread initialization */
c_volume = C_VOLUME(c,t); /* Volume of cell particle is currently in */
Dh = 0.000013929; /* Hydraulic diameter of channel */
crDh = pow(c_volume, (1./3.)); /* Hydraulic diameter of cell */
mu = 0.001003; /* dynamic viscosity of water at 20C */
rho = C_R(c,t); /* local density of fluid in cell */
Ufx = C_U(c,t); /* local fluid x-velocity in cell */
Ufy = C_V(c,t); /* local fluid y-velocity in cell */
Ufz = C_W(c,t); /* local fluid z-velocity in cell */
aUfx = fabs(Ufx); /* absolute local fluid x-velocity in cell */
aUfy = fabs(Ufy); /* absolute local fluid y-velocity in cell */
aUfz = fabs(Ufz); /* absolute local fluid z-velocity in cell */
/* local Reynolds number calculation*/
Renx = (rho*aUfx*crDh)/mu;
Reny = (rho*aUfy*crDh)/mu;
Renz = (rho*aUfz*crDh)/mu;
/* Determination of lift coefficient based on local Reynolds number */
if(Renx<15.)
Clx = 0.5;
else
Clx = 3.4368*(pow(Renx, -0.714));
if(Reny<15.)
Cly = 0.5;
else
Cly = 3.4368*(pow(Reny, -0.714));
if(Renz<15.)
Clz = 0.5;
else
Clz = 3.4368*(pow(Renz, -0.714));

/* Calculate ratio of local velocity to hydraulic diameter */
Gx = (Ufx)/Dh;
Gy = (Ufy)/Dh;
Gz = (Ufz)/Dh;
a = P_DIAM(p); /* particle diameter */
/* Lift force magnitude calculation */
Fx = Clx*rho*pow(Gx,2)*pow(a,4);
Fy = Cly*rho*pow(Gy,2)*pow(a,4);
Fz = Clz*rho*pow(Gz,2)*pow(a,4);
/* Lift force vector calculation as resultant of shear rate tensor */
if (i==0)
{
FL = (Fy+Fz);
}
else if (i==1)
{
FL = (Fx+Fz);
}
else if (i==2)
{
if (P_POS(p)[2]>0.0000075)
{
FL = Fx+Fy;
}
else
{
FL = -(Fx+Fy);
}
}
else
FL = 0;
return (FL/P_MASS(p));
}
Nicholas_A is offline   Reply With Quote

Reply

Tags
dpm bodyforce, fluent - udf - parallel, simulation crash

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
FLUENT UDF for parallelization Cooper24 FLUENT 0 August 27, 2021 11:55
Passing udf value to fluent durg Fluent UDF and Scheme Programming 2 February 11, 2019 12:55
A Problem of Fluent Interpreted UDF: parse error knight Fluent UDF and Scheme Programming 25 August 16, 2018 10:26
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 13:41
Calculation of lift/drag coefficient by FLUENT UDF rsarma Fluent UDF and Scheme Programming 0 August 5, 2015 05:16


All times are GMT -4. The time now is 11:17.