Obtain particles' mean diameters at each cell in a spray simulation

In spray simulations, users often want to obtain the particles size distribution. For example, a contour plot of D32 (Sauter Mean diameter) over a plane would be very helpful in understanding the particles' size distribution. Fluent panel (Report/Discrete Phase/Sample) only allows user to obtain particles size distribution and other statistics over a cut plane, which could not provide user any cell-based statistics. The attached udf allows user to get mean diameters (D10, D20, D30 and sauter mean D32) in a spray simulation for each cell.

Attached is a udf to calculate particles mean diameter (including D10, D20, D30 and D32) for each cell. After this udf is hooked up, you can draw the contour of any of the above mean diameters on the graphics window just like any flow variable.

To use this udf, you need to follow the following procedures:

(1) copy this udf "spray-sample.c" to your working directory where Fluent case/data files of a converged spay simulation are saved.

(2) compile that udf and create a udf library: launch Fluent and read in your case/data file; go to the Define/User-Defined/Functions/Compiled
panel, add "spray-sample.c" to the source list, and hit "Build" to generate a udf library. After the library is built, click "Load" button to load in the udf.

(3) Hook up the udf:
a) Go to the Define/User-Defined/Memory panel and set 10 UDMs.
b) Go to the Define/User-Defined/Function Hooks/Adjust and hook up "adjust_spray"
c) Go to the Define/Discrete Phase Model panel to hook up "body_force_spray" to Body Force under User-Defined Functions, and also set Number of Scalars to be "1" in that panel.

(4) Run more iterations. The more iterations you run, more particles will be used to get those statistics.

(5) Draw contour of those mean diameters.

The above procedures give you particles mean diameters at each cell. If you want to know particles mean diameters across a particle cut plane,
let's say D32, you can use the following procedures:

(1) Go to the Report/Surface Integrals to calculate Sum_(n_k*d_k**3): choose "Integral" under Report Type and "User Defined Memory" and
"udf-3" user Field variable, and pick up a cut-plane in the Surface list. Click "Compute" will give you Sum_(n_k*d_k**3).

(2) Calculate Sum_(n_k*d_k**2) in the same panel: choose "User Defined Memory" and "udf-2" user Field variable and click "Compute" to obtain

(3) D32=Sum_(n_k*d_k**3)/Sum_(n_k*d_k**2).

This udf will calculate mean diameter D10, D20, D30 and D32 for all particles
passing thorugh that cell. This udf should be hooked up only after the solution
has converged and you want to obtain particles' statistics. After it's hooked
up, you should run simulation for many iterations in order to get meaningful
statistics. More iterations you run, more sampling particles you will have,
and more accurate results you will get.

Ten User-Defined Memories were used to save the following inforamtion:

C_UDMI(c,t,0): sum (n_k)
C_UDMI(c,t,1): sum (n_k*d_k)
C_UDMI(c,t,2): sum (n_k*d_k*d_k)
C_UDMI(c,t,3): sum (n_k*d_k*d_k*d_k)
C_UDMI(c,t,4): sum (n_k*d_k*d_k*d_k*d_k)
C_UDMI(c,t,5): number of particle parcels passing through that cell
C_UDMI(c,t,6): = D10 = C_UDMI(c,t,1)/C_UDMI(c,t,0) =sum (n_k*d_k)/sum (n_k)
C_UDMI(c,t,7): = D20 = sqrt(C_UDMI(c,t,2)/C_UDMI(c,t,0)) =sqrt(sum (n_k*d_k*d_k)/sum (n_k))
C_UDMI(c,t,8): = D30 = pow(C_UDMI(c,t,3)/C_UDMI(c,t,0),1/3) = pow(sum (n_k*d_k*d_k*d_k)/sum (n_k), 1/3)
C_UDMI(c,t,9): = D32 = C_UDMI(c,t,3)/C_UDMI(c,t,2) =sum (n_k*d_k)/sum (n_k)


#include "udf.h"
#include "surf.h"
#include "dpm.h"

static int counter=0;

DEFINE_ADJUST(adjust_spray, d)
Thread *t;
cell_t c;

if (counter==0)
thread_loop_c (t,d)
begin_c_loop (c,t)
end_c_loop (c,t)

thread_loop_c (t,d)
begin_c_loop (c,t)
C_UDMI(c,t,6) = C_UDMI(c,t,1)/MAX(C_UDMI(c,t,0),DPM_SMALL);
C_UDMI(c,t,7) = sqrt(C_UDMI(c,t,2)/MAX(C_UDMI(c,t,0),DPM_SMALL));
C_UDMI(c,t,8) = pow(C_UDMI(c,t,3)/MAX(C_UDMI(c,t,0),DPM_SMALL),0.333333);
C_UDMI(c,t,9) = C_UDMI(c,t,3)/MAX(C_UDMI(c,t,2),DPM_SMALL);
end_c_loop (c,t)

DEFINE_DPM_BODY_FORCE(body_force_spray, p, i)
Thread *t;
cell_t c;
real num_p, dia;

c = P_CELL(p);
if(P_USER_REAL(p,0) != (float) c)
{num_p = p->number_in_parcel;
dia = p->state.diam;
C_UDMI(c,t,0) += num_p;
C_UDMI(c,t,1) += num_p * dia;
C_UDMI(c,t,2) += num_p * dia * dia;
C_UDMI(c,t,3) += num_p * dia * dia * dia;
C_UDMI(c,t,4) += num_p * dia * dia * dia * dia;
C_UDMI(c,t,5) += 1;
P_USER_REAL(p,0)=(float) c;}

return 0.0;

Show Form
No comments yet. Be the first to add a comment!