Exporting droplet/particle statistics within the domain

Currently, there is no simple way of determining important spray statistics such as mass flux, size distributions, characteristic sizes (e.g., Sauter Mean Diameter), or size/velocity correlations. The UDF below will write to a file the flow time, position, velocity, particle size, and number of particles in each parcel crossing a plane defined by the user.
A plane (or line in 2-D) should be defined by the user and then the UDF hooked through the Report -> Discrete Phase -> Sample panel in the GUI. The UDF will work for 2-D and 3-D cases, and the user has the option to delete the droplets from the domain at the completion of the time step in which they cross the sample plane. This can be useful if the spray downstream of the sample plane is not of interest and need not be tracked.

/************************************************************************************************/
/* Discrete_phase_sample.c */
/* */
/* Sample discrete phase size and velocity distributions within the domain. */
/* */
/* This UDF will sample the size and velocity of discrete phase particles at */
/* selected planes downstream of the injection. For 2D axisymmetric */
/* simulations it is assumed that droplets/particles are being */
/* sampled at planes (lines) corresponding to constant x. For 3D simulations */
/* the sampling planes correspond to constant z. */
/* */
/* To remove particles from the domain after they have been sampled, change */
/* the value of REMOVE_PARCELS to TRUE. In this case, particles will be */
/* deleted following the time step in which they cross the plane. */
/* This is useful when sampling a spray immediately in front of an injector and */
/* you don't wish to track then further downstream. */
/* */
/* The UDF can be hooked through the Sample Trajectories panel in the GUI */
/* (Report > DiscretePhase... > Sample). */
/* */
/* NOTE: This UDF works with unsteady simulations and steady simulations that */
/* include droplet break-up or collisions (the discrete phase must be tracked */
/* in an unsteady manner). */
/* */
/* NOTE: Updated July 2006 for Fluent 6.3 */
/* */
/************************************************************************************************/

#include "udf.h"

#define REMOVE_PARTICLES FALSE

DEFINE_DPM_OUTPUT(Discrete_phase_sample,header,fp,p,t,plane)
{

#if RP_2D

real flow_time = solver_par.flow_time;
real y;

if(header)
par_fprintf_head(fp," #Time[s] R [m] X-velocity[m/s] W-velocity[m/s] R-velocity[m/s] Drop Diameter[m] Number of Drops Temperature [K] Initial Diam [m] Injection Time [s] n");

if(NULLP(p))
return;

if (rp_axi && (sg_swirl || rp_ke))
y = MAX(sqrt(SQR(p->state.pos[1]) + SQR(p->state.pos[2])),DPM_SMALL);
else
y = p->state.pos[1];

#if PARALLEL
par_fprintf(fp,"%d %d %e %f %f %f %f %e %e %f %e %f n",
p->injection->try_id, p->part_id, P_TIME(p), y,p->state.V[0],p->state.V[1],p->state.V[2],P_DIAM(p),p->number_in_parcel, P_T(p), P_INIT_DIAM(p), p->time_of_birth);
#else
par_fprintf(fp,"%e %f %f %f %f %e %e %f %e %f n",
P_TIME(p), y,p->state.V[0],p->state.V[1],p->state.V[2],P_DIAM(p),p->number_in_parcel, P_T(p), P_INIT_DIAM(p), p->time_of_birth);
#endif /* PARALLEL */
#else

real flow_time = solver_par.flow_time;
real r, x, y;

if(header)
par_fprintf_head(fp," #Time[s] R [m] x-velocity[m/s] y-velocity[m/s] z-velocity[m/s] Drop Diameter[m] Number of Drops Temperature [K] Initial Diam [m] Injection Time [s] n");

if(NULLP(p))
return;

x = p->state.pos[0];
y = p->state.pos[1];
r = sqrt(SQR(x) + SQR(y));

#if PARALLEL
par_fprintf(fp,"%d %d %e %f %f %f %f %e %e %f %e %f n",
p->injection->try_id, p->part_id, P_TIME(p), r,p->state.V[0],p->state.V[1],p->state.V[2],P_DIAM(p),p->number_in_parcel,P_T(p), P_INIT_DIAM(p), p->time_of_birth);
#else
par_fprintf(fp,"%e %f %f %f %f %e %e %f %e %f n",
P_TIME(p), r,p->state.V[0],p->state.V[1],p->state.V[2],P_DIAM(p),p->number_in_parcel,P_T(p), P_INIT_DIAM(p), p->time_of_birth);
#endif /* PARALLEL */

#endif


#if REMOVE_PARCELS
p->stream_index=-1;
#endif
}





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