CAPE Forum
Ansys => Fluent => Topic started by: moloy_kb on May 29, 2012, 07:32:48 AM
-
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??
-
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;
}
-
Thnks.. It works
-
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.
-
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 );
}
}