[ANSYS, Inc. Logo] return to home search
next up previous contents index

2.5.6 DEFINE_DPM_INJECTION_INIT



Description


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



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.



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 and can be used only on UNIX and Linux systems. 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 = P_CELL(p);   /* Get the cell and thread that the particle
                         is currently in   */
  cthread = P_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 */
  {
   P_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 */
   P_DIAM(p) = 1e-3;
   P_RHO(p) = 1.0;
   P_MASS(p) = P_RHO(p)*M_PI*pow(P_DIAM(p),3.0)/6.0;
  }
  else
   P_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;
}



Hooking a DPM Initialization UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE_DPM_INJECTION_INIT is interpreted (Chapter  4) or compiled (Chapter  5), 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 Section  6.4.6 for details on how to hook your DEFINE_DPM_INJECTION_INIT UDF to ANSYS FLUENT.


next up previous contents index Previous: 2.5.5 DEFINE_DPM_HEAT_MASS
Up: 2.5 Discrete Phase Model
Next: 2.5.7 DEFINE_DPM_LAW
Release 12.0 © ANSYS, Inc. 2009-01-14