Author Topic: Particle injection in DPM  (Read 1517 times)

Offline moloy_kb

  • Newbie
  • *
  • Posts: 19
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Particle injection in DPM
« on: May 29, 2012, 07:32:48 AM »
Advertisement
Dear all,
I am doing the unsteady DPM calculation and there I want to inject particle in the domain at every alternate particle time step. How to do it??

Offline william

  • Full Member
  • ***
  • Posts: 151
  • Reputation: +14/-0
  • Know it, share it.
    • View Profile
Re: Particle injection in DPM
« Reply #1 on: May 30, 2012, 10:50:19 AM »
You can use following UDF to track unsteady particles using user-specified time-interval. At the time of the next injection, the accumulated particles mass will be injected
There will be fewer particles but the particle mass will be preserved.

#include "udf.h"
#define RELEASE_STEP 5e-3
static real sum_inj = 0.0;
DEFINE_ADJUST  (update,  domain)
{
real  pflow;
if ( first_iteration )
{
pflow        =  get_mdot_prt(tm);
sum_inj += mdot*tmspsz;
}
}
DEFINE_DPM_INJECTION_INIT  (init_prt_tm,  I)
{
Particle *p;
real      tm, tmspsz, flowrate;
tm           =  RP_Get_Real("flow-time");
tmspsz   =  RP_Get_Real("physical-time-step");
flowrate  =  sum_inj/tmspsz;
loop(p,I->p_init)
{
p->flow_rate  = flowrate;
}
if ((tm+tmspsz) >= I->unsteady_start)
I->unsteady_start  +=  RELEASE_STEP;
sum_inj =  0.0;
}

Offline moloy_kb

  • Newbie
  • *
  • Posts: 19
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Re: Particle injection in DPM
« Reply #2 on: June 08, 2012, 07:46:13 AM »
Thnks.. It works

Offline sfotovati

  • Newbie
  • *
  • Posts: 8
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Re: Particle injection in DPM
« Reply #3 on: June 17, 2012, 01:51:08 AM »
hi William,

I wrote the following UDF to add the effects of other particles on the tracked particles as a body force.

DEFINE_DPM_BODY_FORCE(partbf,p,i)
{
   double bforce=0., Bc=0.;
   Thread *t;
    cell_t c;
   
   Particle *pi;

   t = P_CELL_THREAD(p);
    c = P_CELL(p);

   if (Data_Valid_P())
   {
   begin_particle_cell_loop(pi,c,t)
   {
         Bc+=P_MASS(pi);
   }
   end_particle_cell_loop(pi,c,t)
   }


    bforce=Bc/PMASS(p)+1.;         /*i component, x,y,or z component force*/ 
    return bforce;  /*return the acceleration*/
}

as I run it, it gives "FLUENT received fatal signal (ACCESS_VIOLATION)" error. I believe it is because of "begin_particle_cell_loop" macro. Do you have any idea why this happens? How can I use "begin_particle_cell_loop" macro properly?

Thank you very much for your help.

Sean.
Sean

Offline william

  • Full Member
  • ***
  • Posts: 151
  • Reputation: +14/-0
  • Know it, share it.
    • View Profile
Re: Particle injection in DPM
« Reply #4 on: June 19, 2012, 08:38:40 AM »
Here is an example of how you can implement begin_particle_cell_loop:


/***********************************************************
   DPM Spray Collide Example UDF
************************************************************/
#include "udf.h"
#include "dpm.h"
#include "surf.h"
DEFINE_DPM_SPRAY_COLLIDE(man_spray_collide,tp,p)
{
  /* non-physical collision UDF that relaxes the particle */
  /* velocity and diameter in a cell to the mean over the */
  /* specified time scale t_relax */

  const real t_relax = 0.001; /* seconds */

  /* get the cell and Thread that the particle is currently in */
  cell_t c  = RP_CELL(&(tp->cCell));
  Thread *t = RP_THREAD(&(tp->cCell));

  /* Particle index for looping over all particles in the cell */
  Particle *pi;

  /* loop over all particles in the cell to find their mass */
  /* weighted mean velocity and diameter */
  int i;
  real u_mean[3]={0.}, mass_mean=0.;
  real d_orig = tp->state.diam;
  real decay = 1. - exp(-t_relax);
  begin_particle_cell_loop(pi,c,t)
    {
      mass_mean += pi->state.mass;
      for(i=0;i<3;i++)
        u_mean += pi->state.V*pi->state.mass;
    }
  end_particle_cell_loop(pi,c,t)

  /* relax particle velocity to the mean and diameter to the */
  /* initial diameter over the relaxation time scale t_relax */
  if( mass_mean > 0. )
    {
      for(i=0;i<3;i++)
        u_mean /= mass_mean;
      for(i=0;i<3;i++)
        tp->state.V += decay*( u_mean - tp->state.V );
      tp->state.diam += decay*( P_INIT_DIAM(tp) - tp->state.diam );
      /* adjust the number in the droplet parcel to conserve mass */
      tp->number_in_parcel *= CUB( d_orig/tp->state.diam );
    }
}