Post reply

Note: this post will not display until it's been approved by a moderator.

Message icon:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: hit alt+s to submit/post or alt+p to preview

Topic Summary

Posted by: william
« on: August 29, 2012, 11:21:03 AM »

You can get an estimated solid volume fraction in a cell by diving discrete phase concentration with particle density (assuming that all particles have the same density).

This will be:


You may get a value greater than 1 in certain regions if your case involves dense discrete phase flow.
Posted by: tue1984
« on: August 29, 2012, 10:35:04 AM »

William: Thanks. Fortunately, I have fixed the compiling issue and it works for me now. One more question though: how do you get the particle volume or volume fraction in every cell? Is it C_VOF(c,t)?

Posted by: william
« on: August 29, 2012, 09:00:03 AM »

You will have to compile the UDF you can not run it as interpreted because it uses variables.
You will need to sort out the issues with compiling.
Posted by: tue1984
« on: August 29, 2012, 06:17:21 AM »

I figured out an easier way to compute the volume flux which is multiplying the volume fraction with the particle velocity.

William: since I have some problems with compiling udf on my computer at work, I have tried to interpret it but Fluent gave me several errors, e.g., "parse error" for the static variable, "undeclared variables P_CELL", etc. Is there any way to modify your udf so that it can be interpreted? If yes, please let me know how. Thanks.
Posted by: tue1984
« on: August 28, 2012, 07:48:08 PM »

Thank you! I realize how the particle velocities can be computed now.

Is there any way that we can compute the particle volume flux or particle mass flux per area for every cell face on a given surface and then write that down as a 2D contour plot? This would be very useful because particle volume flux per area is the variable that is normally measured in the experiments with Phase Doppler Particle Analyzer.

Posted by: william
« on: August 28, 2012, 06:23:17 PM »

You will need to define additional UDMs for this purpose.

The particle velocities at cells can be stored using:

P_VEL(p)[0] ---> x component of particle velocity
P_VEL(p)[1] ---> y component of particle velocity
P_VEL(p)[2] ---> z component of particle velocity

Posted by: tue1984
« on: August 28, 2012, 04:18:09 PM »

Hi William,

Your UDF is really useful. Could you please extend it so that one can compute the following variables at every cell:

1. All particle velocity components u, v and w.

2. Volume flux (m3/s/m2) which is defined as: particle volume/time interval/cell area

Thank you, Tue.
Posted by: william
« on: April 25, 2012, 10:11:10 AM »

The following udf code allows to get mean diameters (D10, D20, D30 and sauter mean D32) in a spray simulation for each cell. To use this udf, you need to follow the following procedures:

(1) copy this udf 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;
Posted by: infocfd
« on: April 25, 2012, 10:08:30 AM »

I am running a Fluent CFD simulation with lagrangian discrete phase particles of varying sizes in a spray. I want to calculate mean particle size/diameter in each cell. Can it be done in Fluent?