kiran.purushothamakeshavan
Bbp_participant

Okay I get this, but how do I get the particle to stick on the wall?

1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process / visualise the results?

2. What do you think I must do to model particle trajectory after colliding with the boundary?

3. From the below UDF I do not see a text file being generated to run my simulation, what could be the reason?

#include “udf.h”
#include “dpm.h”
#include “math.h”
#include “mem.h”
#include

#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 */
    FILE * fp1 ;

    real alpha;  /* angle of particle path with face normal */
    real vn=0.;
    real nor_coeff = 1.;
    real tan_coeff = 0.3;
    //real normal[3];
    int i, idim;
    real NV_VEC(x);

    real radius = P_DIAM(p) / 2.0;
    real A = M_PI * radius * radius;  /* M_PI is a constant for π */

    /* Get the face pressure */
    real P_local = F_P(f, t);

    /* 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;

    if (Fa > Ff)
    {
        /* Particle needs to bounce with a coefficient of restitution of 1 */
              /* Compute normal velocity. */
      for(i=0; i
       
        vn += P_VEL(p)[i]*normal[i];

      /* Subtract off normal velocity. */
      for(i=0; i
        P_VEL(p)[i] -= vn*normal[i];

      /* Apply tangential coefficient of restitution. */
      for(i=0; i
        P_VEL(p)[i] *= tan_coeff;

      /* Add reflected normal velocity. */
      for(i=0; i
        P_VEL(p)[i] -= nor_coeff*vn*normal[i];  

      /* Store new velocity in P_VEL0 of particle */
      for(i=0; i
        P_VEL0(p)[i] = P_VEL(p)[i];

      fp1=fopen ( “Impact.txt” , “a” ) ;
      fprintf( fp1 , “%f %f %f %f\n”, Fa, Ff, radius, P_local);
      fclose( fp1 );

      return PATH_ACTIVE;

    }
    else
    {
        /* Particle sticks to the boundary */
        for (int i = 0; i < dim; i++)
        {
            P_VEL(p)[i] = 0; /* Set velocity to zero */
        }

        P_USER_REAL(p, 0) = 1.0; /* Optionally set a user-defined variable to indicate sticking */

        /* Save the impingement location */
        P_USER_REAL(p, 1) = P_POS(p)[0];  /* X-coordinate */
        P_USER_REAL(p, 2) = P_POS(p)[1];  /* Y-coordinate */
        P_USER_REAL(p, 3) = P_POS(p)[2];  /* Z-coordinate */

        P_USER_REAL(p, 4) = 1.0;  /* Mark as stuck */

        return PATH_ABORT; /* Stop tracking the particle */
    }
}