Ansys Learning Forum › Forums › Discuss Simulation › Fluids › Ansys Fluent UDF: DEFINE_DPM_BC › Reply To: Ansys Fluent UDF: DEFINE_DPM_BC
August 8, 2024 at 4:22 pm
kiran.purushothamakeshavan
Subscriber
Thanks for your reply.
The issue was that I did not build the udf from x86_x64 VS prompt. After opening fluent from Visual Studio prompt UDF seems to be loading without issues.
However, I have an issue where the particles in my model seem to not stick to the boundary. below I’ve copied the UDF for your reference.
I expected to see certain particles bounce while the rest of them to stick to the surface, here I do not see the particles bounce or stick.
#include “udf.h”
#include “dpm.h”
#include “math.h”
#define Rho_air 1.225 /* Air density in kg/m^3 */
#define Cd 0.47 /* Drag coefficient for a sphere */
#define mu 0.5 /* Coefficient of friction */
/* Define your boundary condition function */
DEFINE_DPM_BC(particle_bc, p, t, f, normal, dim)
{
real V = sqrt(P_VEL(p)[0] * P_VEL(p)[0] + P_VEL(p)[1] * P_VEL(p)[1] + P_VEL(p)[2] * P_VEL(p)[2]); /* Velocity magnitude in m/s */
real radius = P_DIAM(p) / 2.0;
real A = M_PI * radius * radius; /* M_PI is a constant for π */
/* Get the thread and cell pointers */
Thread *t0 = P_CELL_THREAD(p);
cell_t c0 = P_CELL(p);
/* Get local pressure at the particle’s location */
real P_local = C_P(c0, t0);
/* Calculate aerodynamic force Fa */
real Fa = 0.5 * Rho_air * A * Cd * V * V;
/* Calculate normal force Fn */
real Fn = P_local * A;
/* Calculate frictional force Ff */
real Ff = mu * Fn;
/* Coefficient of restitution */
real e;
if (Fa > Ff)
{
/* Particle needs to bounce with a coefficient of restitution of 1 */
e = 1.0;
/* Update the particle velocity to simulate the bounce */
for (int i = 0; i < dim; i++)
{
P_VEL(p)[i] = -e * P_VEL(p)[i];
}
return PATH_ACTIVE; /* No adhesion */
}
else
{
/* Particle sticks to the boundary with a coefficient of restitution of 0 */
// e = 0.0;
/* Update the particle velocity to simulate sticking */
for (int i = 0; i < dim; i++)
{
P_VEL(p)[i] = 0;
}
P_USER_REAL(p, 0) = 1.;
return PATH_ACTIVE; /* Adhesion */
}
}
Can you please comment on the code?