|
[Sponsors] |
February 5, 2019, 14:11 |
DPM UDF Help
|
#1 |
New Member
Eanna Kennedy
Join Date: Jan 2019
Posts: 4
Rep Power: 7 |
I am trying to calculate the standard deviation of particles about the centre of a channel at a sampling plane near the exit and I am having trouble getting my UDF to work. The UDF compiles and loads fine, but it causes fluent to crash when i try to run it. I have included my code below. I think the problem is probably due to the need to loop through all particles in a Macro that doesn't take in any DPM arguments. Any advice would be really appreciated. Thanks.
#include "udf.h" #include "dpm.h" #include "surf.h" #include "dpm_types.h" #include "dpm_laws.h" /************************************************** ****************/ /* UDF records Standard Deviation of all particles on a plane */ /************************************************** ****************/ double Standard_Deviation = 0.0; /* intitialise standard deviation as global variable*/ /*Creates Output Parameter Standard Deviation*/ DEFINE_REPORT_DEFINITION_FN(standard_deviation) { return Standard_Deviation; } DEFINE_ON_DEMAND(Get_Particle_Positions) { double d = 0.0; double y = 0.0; double z = 0.0; double dbar = 0.0; double deviation = 0.0; double counter = 0.0; int zone_ID = 3; /* initialise zone id for sampling plane*/ Thread *c_thread; /* c_thread is declared as a variable */ Domain *domain; /* domain is declared as a variable */ Tracked_Particle *tp; /* tp declared as identifier for tracked particles */ cell_t c; /* c declared as identifier for cells */ domain = Get_Domain(1); /* returns fluid domain pointer */ c_thread = Lookup_Thread(domain,zone_ID); tp = 0; /* Loop calculates sum of particle-to-centre distances, allows mean distance to be calculated later*/ begin_c_loop(c, c_thread) /* loops over cells in a cell thread */ { while(NULLP(tp)){ /* checks that tp points to actual particle*/ y = TP_POS0(tp)[1]; z = TP_POS0(tp)[2]; d += sqrt((y*y) + (z*z)); tp ++; counter ++; }; } end_c_loop(c, c_thread) dbar = d / counter; /* calculate mean particle-to-centre distance*/ tp = 0; /* reset particle pointer*/ /* Loop to calculate sum of squared particle-to-mean distances */ begin_c_loop(c, c_thread) { while(NULLP(tp)){ /* checks that tp points to actual particle*/ y = TP_POS0(tp)[1]; z = TP_POS0(tp)[2]; d = sqrt((y*y) + (z*z)); deviation += pow((dbar - d), 2); tp ++; }; } end_c_loop(c, c_thread) Standard_Deviation = deviation / counter; } |
|
Tags |
discreet phase modeling, dpm, particle track fluent, udf, user defined function |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF | acasas | CFD Freelancers | 1 | January 23, 2015 07:26 |
Add Mass to a Particle with UDF (DPM) | sega | Fluent UDF and Scheme Programming | 6 | October 24, 2013 22:14 |
please help me. i have question about the UDF at the DPM | motallebi | FLUENT | 0 | July 6, 2009 11:27 |
Velocity of Fluid @ different positions of Particle in DPM using UDF | pmghadge | FLUENT | 1 | June 16, 2009 19:11 |
UDF DPM injection | M.A. Rakib | FLUENT | 0 | June 13, 2000 08:28 |