2.5.2.  DEFINE_DPM_BODY_FORCE

2.5.2.1. Description

You can use DEFINE_DPM_BODY_FORCE to specify a body force other than a gravitational or drag force on the particles.

2.5.2.2. Usage

DEFINE_DPM_BODY_FORCE (name, tp, i)

Argument Type

Description

symbol name

UDF name.

Tracked_Particle *tp

Pointer to the Tracked_Particle data structure which contains data related to the particle being tracked.

int i

An index (0, 1, or 2) that identifies the Cartesian component of the body force that is to be returned by the function.

Function returns

real

There are three arguments to DEFINE_DPM_BODY_FORCE: name, tp, and i. You supply name, the name of the UDF. tp and i are variables that are passed by the ANSYS Fluent solver to your UDF. Your UDF will need to return the real value of the acceleration due to the body force (in m/s2) to the ANSYS Fluent solver.


Important:  Pointer tp can be used as an argument to the macros defined in DPM Macros to specify a body force other than a gravitational or drag force on the particles.


2.5.2.3. Example

The following UDF, named particle_body_force, computes the magnetic force on a charged particle. DEFINE_DPM_BODY_FORCE is called at every particle time step in ANSYS Fluent and requires a significant amount of CPU time to execute. For this reason, the UDF should be executed as a compiled UDF.

In the UDF presented below a charged particle is introduced upstream, into a laminar flow, and travels downstream until = tstart when a magnetic field is applied. The particle takes on an approximately circular path (not an exact circular path, because the speed and magnetic force vary as the particle is slowed by the surrounding fluid).

The macro TP_TIME(tp) gives the current time for a particle traveling along a trajectory, which is pointed to by tp.

/* UDF for computing the magnetic force on a charged particle */
 
 #include "udf.h"
 
 #define Q 1.0   /* particle electric charge  */
 #define BZ 3.0  /* z component of magnetic field */
 #define TSTART 18.0  /* field applied at t = tstart  */
 
 /* Calculate magnetic force on charged particle. Magnetic  */
 /* force is particle charge times cross product of particle */
 /* velocity with magnetic field: Fx= q*bz*Vy, Fy= -q*bz*Vx */
 
 DEFINE_DPM_BODY_FORCE(particle_body_force,tp,i)
 {
     real bforce=0;
     if(TP_TIME(tp)>=TSTART)
      {
       if(i==0) bforce=Q*BZ*TP_VEL(tp)[1];
       else if(i==1) bforce=-Q*BZ*TP_VEL(tp)[0];
      }
     else
       bforce=0.0;
       /* an acceleration should be returned */
     return (bforce/TP_MASS(tp));
 } 

2.5.2.4. Hooking a DPM Body Force UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_DPM_BODY_FORCE is interpreted (Interpreting UDFs) or compiled (Compiling UDFs), the name of the argument that you supplied as the first DEFINE macro argument will become visible in the Discrete Phase Model dialog box in ANSYS Fluent. See Hooking DEFINE_DPM_BODY_FORCE UDFs for details on how to hook your DEFINE_DPM_BODY_FORCE UDF to ANSYS Fluent.


Release 18.2 - © ANSYS, Inc. All rights reserved.