mimi0201 |
April 27, 2015 20:24 |
Quote:
Originally Posted by `e`
(Post 543874)
Are you skipping any particle streams (or tracking a single stream)? Perhaps attach a screenshot of the settings you're using?
What UDF are you using and have you enabled this user-defined boundary condition under the DPM boundary conditions?
|
Basically the code is as follows:
Code:
/**reflect*boundary*condition*for*inert*particles**/
#include "udf.h"
#include <stdio.h>
#include "dpm.h"
#include "random.h"
#include "surf.h"
DEFINE_DPM_BC(bc_reflect,p,t,f,f_normal,dim)
{
real alpha; /* angle*of*particle*path*with*face*normal */
real vn = 0.0;
real nor_coeff = 0.8;
real tan_coeff = 0.8;
real normal[3]; /* Array that contains the unit vector which is normal to the face */
real d;
real ke = 0.0;
real NV_VEC(x); /* defines a vector */
int i, idim = dim;
int particle_trap = 0;
FILE *fp = fopen("particle_data.dat","a"); /* open a file named data.txt in read-only mode and assign it to fp */
if(p->type==DPM_TYPE_INERT)
{
alpha = M_PI/2. - acos(MAX(-1.,MIN(1.,NV_DOT(normal,P_VEL(p)) / MAX(NV_MAG(P_VEL(p)),DPM_SMALL))));
if ((NNULLP(t))&&(THREAD_TYPE(t)==THREAD_F_WALL))
F_CENTROID(x,f,t);
for(i=0; i<idim; i++)
{
normal[i] = f_normal[i];
// normal velocity
vn += P_VEL(p)[i]*normal[i];
/*set the particle diameter in microns*/
d = P_DIAM(p);
// normal velocity
P_VEL(p)[i] -= vn*normal[i];
// tangential coefficient of restitution
P_VEL(p)[i] *= tan_coeff;
// reflected normal velocity
P_VEL(p)[i]-=nor_coeff*vn*normal[i];
// new velocity in P_VEL0 of particle
P_VEL0(p)[i]=P_VEL(p)[i];
}
/*calculate the kinetic energy*/
ke = 0.24544 * vn * vn * d * d * d;
ke *= 1e+6;
/* apply the trap condition */
if (ke <= 0.000000001)
{
particle_trap = 1;
//record the informations
fprintf(fp,"%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%d\t%d\n", P_POS(p)[0], P_POS(p)[1], P_POS(p)[2], alpha,vn, P_VEL(p)[0], P_VEL(p)[1], P_VEL(p)[2], ke, p->part_id, particle_trap);
fclose(fp);
return PATH_ABORT; /*trap the particle*/
}
else
{
particle_trap = 0;
//record the informations
fprintf(fp,"%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%11.8lf\t%d\t%d\n", P_POS(p)[0], P_POS(p)[1], P_POS(p)[2], alpha,vn, P_VEL(p)[0], P_VEL(p)[1], P_VEL(p)[2], ke, p->part_id, particle_trap);
fclose(fp);
return PATH_ACTIVE;
}
}
return PATH_ABORT;
}
The idea of the code is to track the particle information when hitting the wall including the position, velocity, kinetic energy etc.
The problem is when i use normal particle injection method (surface injection), everything works fine, particle hitting on the wall several times (record as "0") and finally trapped (record as "1"). (single particle tracking) However, when I use "file" injection, as follows:
Code:
((x y z u v w diameter temperature mass-flow) name)
((0.0 0.0 0.0 0.0 0.0 -5.95 0.00002 293.0 1.0) injection-0:0)
there is only one data generated showing the particle is escaped. which in this code, particles must be trapped cause i didn't set a such high kinetic energy criterion. I'm not sure which part i go wrong.
Please tell me if you need any more information. Really appreciate!
|