2.5.6.  DEFINE_DPM_INJECTION_INIT

2.5.6.1. Description

You can use DEFINE_DPM_INJECTION_INIT to initialize a particle’s injection properties such as location, diameter, and velocity.

2.5.6.2. Usage

DEFINE_DPM_INJECTION_INIT (name, I)

Argument Type

Description

symbol name

UDF name.

Injection *I

Pointer to the Injection structure which is a container for the particles being created. This function is called twice for each Injection before the first DPM iteration, and then called once for each Injection before the particles are injected into the domain at each subsequent DPM iteration.

Function returns

void

There are two arguments to DEFINE_DPM_INJECTION_INIT: name and I. You supply name, the name of the UDF. I is a variable that is passed by the ANSYS Fluent solver to your UDF.

2.5.6.3. Example

The following UDF, named init_bubbles, initializes particles on a surface injection due to a surface reaction. This function must be executed as a compiled UDF. Note that if you are going to use this UDF in a transient simulation to compute transient particles, you will need to replace loop(p, I->p) with loop(p, I->p_init). Transient particle initialization cannot be performed with a loop over I->p.

/**********************************************************************
   UDF that initializes particles on a surface injection due
   to a surface reaction
 ***********************************************************************/
 
 #include "udf.h"
 #include "surf.h" /* RP_CELL and RP_THREAD are defined in surf.h */
 
 #define REACTING_SURFACE_ID 2
 #define MW_H2 2
 #define STOIC_H2 1
 
 /* ARRHENIUS CONSTANTS */
 #define PRE_EXP 1e+15
 #define ACTIVE 1e+08
 #define BETA 0.0
 
 real arrhenius_rate(real temp)
 {
   return PRE_EXP*pow(temp,BETA)*exp(-ACTIVE/(UNIVERSAL_GAS_CONSTANT*temp));
 }
 
 /* Species numbers. Must match order in ANSYS Fluent dialog box */
 #define HF 0
 
 /* Reaction Exponents */
 #define HF_EXP 2.0
 
 
 /* Reaction Rate Routine used in UDF */
 
 real reaction_rate(cell_t c, Thread *cthread,real mw[],real yi[])
 
 /* Note that all arguments in the reaction_rate function call in your .c source file 
   MUST be on the same line or a compilation error will occur */ 
 {
   real concenHF = C_R(c,cthread)*yi[HF]/mw[HF];
   return arrhenius_rate(C_T(c,cthread))*pow(concenHF,HF_EXP);
 }
 
 real contact_area(cell_t c,Thread *t,int s_id,int *n);
 
 
 DEFINE_DPM_INJECTION_INIT(init_bubbles,I)
 {
   int count,i;
   real area, mw[MAX_SPE_EQNS], yi[MAX_SPE_EQNS];
   /* MAX_SPE_EQNS is an ANSYS Fluent constant in materials.h */
   Particle *p;
   cell_t cell;
   Thread *cthread;
   Material *mix, *sp;
   Message("Initializing Injection: %s\n",I->name);
   loop(p,I->p) /* Standard ANSYS Fluent Looping Macro to get particle
          streams in an Injection */
     {
        cell = PP_CELL(p);  /* Get the cell and thread that
                             * the particle is currently in */
        cthread = PP_CELL_THREAD(p);
        /* Set up molecular weight & mass fraction arrays */
        mix = THREAD_MATERIAL(cthread);
        mixture_species_loop(mix,sp,i)
            {
             mw[i] = MATERIAL_PROP(sp,PROP_mwi);
             yi[i] = C_YI(cell,cthread,i);
            }
       area = contact_area(cell, cthread, REACTING_SURFACE_ID,&count);
       /* Function that gets total area of REACTING_SURFACE faces in
         contact with cell */
       /* count is the number of contacting faces, and is needed
         to share the total bubble emission between the faces  */
        if (count > 0) /* if cell is in contact with REACTING_SURFACE */
          {
           PP_FLOW_RATE(p) = (area *MW_H2* STOIC_H2 *
              reaction_rate(cell, cthread, mw, yi))/
              (real)count; /* to get correct total flow
               rate when multiple faces contact the same cell */
           PP_DIAM(p) = 1e-3;
           PP_RHO(p) = 1.0;
           PP_MASS(p) = PP_RHO(p)*M_PI*pow(PP_DIAM(p),3.0)/6.0;
          }
        else
           PP_FLOW_RATE(p) = 0.0;
         }
     }
 
 real contact_area(cell_t c, Thread *t, int s_id, int *n)
 {
   int i = 0;
   real area = 0.0, A[ND_ND];
   *n = 0;
   c_face_loop(c,t,i)
     {
      if(THREAD_ID(C_FACE_THREAD(c,t,i)) == s_id)
          {
          (*n)++;
         F_AREA(A,C_FACE(c,t,i), C_FACE_THREAD(c,t,i));
         area += NV_MAG(A);
          }
     } return area;
 }

2.5.6.4. Hooking a DPM Initialization UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_DPM_INJECTION_INIT 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 Set Injection Properties dialog box in ANSYS Fluent.

See Hooking DEFINE_DPM_INJECTION_INIT UDFs for details on how to hook your DEFINE_DPM_INJECTION_INIT UDF to ANSYS Fluent.


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