CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

DPM UDF Help

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   February 5, 2019, 14:11
Default DPM UDF Help
  #1
New Member
 
Eanna Kennedy
Join Date: Jan 2019
Posts: 4
Rep Power: 7
Eanna.Kennedy is on a distinguished road
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;
}
Eanna.Kennedy is offline   Reply With Quote

 

Tags
discreet phase modeling, dpm, particle track fluent, udf, user defined function


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 00:58.