currently I use the UDF to calculate the DPM concentration in the domain, I set particles uniformly distributed in the domain and use an air conditioner and an air purifier to dilute the particles in the domain (outlet set as escape condition and wall set as trap condition), in my UDF code it only consider the total particle number to calculate the concentration so the concentration remains the same at each time step, I don't know how to consider the trap and escape particles into the code so that the concentration can decrease as time passed. Can someone give me help? The following code is my UDF:
/*Particle mass concentration calculation*/
/*Using the particles-in-the-box method*/
/*Author: Bill Hsu*/
#include "udf.h" /*The header file*/
#include "dpm.h"
DEFINE_EXECUTE_AT_END(get_dpm_conc) /*Calculate the flow quantities at the end of an iteration in a steady state run, or at the end of a time step in a transient run*/
{
Domain *d; /*Defined domain pointer*/
Thread *t; /*Defined thread pointer*/
cell_t c; /*cell identifier*/
d = Get_Domain(1);
Injection *I; /*Defined injection pointer*/
Particle *p; /*Defined particle pointer */
Injection *Ilist = Get_dpm_injections(); /*Get the list of all the injections*/
thread_loop_c(t, d) /*Reset the value of UDMI each time*/
{
begin_c_loop(c, t)
{
C_UDMI(c, t, 0) = 0;
}
end_c_loop(c,t)
}
loop(I, Ilist) /*loop over all the particles from a given injection*/
{
loop(p, I->p_init) /*loop over all the particles in transient simulation*/
{
c = P_CELL(p);
t = P_CELL_THREAD(p);
C_UDMI(c, t, 0) += P_N(p) * P_MASS(p) / C_VOLUME(c, t);/*The calculation of particle concentration*/
}
}
}
I expect the concentration can decrease as time passes because my simulation is a dilute process.