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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 5, 2019, 15: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

Old   February 10, 2019, 20:07
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Eanna,


I don't see in your code anything that finds a particle-pointer and puts it into *tp. So, you initialize "tp = 0;", and then test whether it is a NULLP pointer. If it *is* a null pointer, you go ahead and use it -- I would have thought the opposite would make more sense, although then your code would then (correctly) report that it found no particles.


You need to find a way to loop over DPM parcels. As it turns out, parcels' connection to fluid cells is one-way: parcels know which cell they are in, but cells do not know which parcels they contain. (This is not always true. For some spray models, and for DEM, you might find a loop called begin_particle_cell_loop. Typically, though, the information required for this loop is not maintained, or even allocated.)


So, please go and look for a particle loop, probably involving "loop(p,I->p)" and "Get_dpm_injections". Sorry, I don't have a good reference to recommend at the minute.



Good luck!
Ed
obscureed is offline   Reply With Quote

Old   February 13, 2019, 10:20
Default
  #3
New Member
 
Eanna Kennedy
Join Date: Jan 2019
Posts: 4
Rep Power: 7
Eanna.Kennedy is on a distinguished road
Hi Ed,

Thanks for the reply!

I have changed the code significantly since I posted originally and it calculates the standard deviation of particles correctly. However I plan to use direct optimization to minimise the the standard deviation of particles near the exit plane.

I tried your suggestion of using loop(p, p->I) but it appears that it couldn't access the particle information unless I ran a dpm sample report at first.

At the moment I am using a DEFINE_DPM_OUTPUT macro to save particle positions to an array that I then use for calculations inside a DEFINE_REPORT_DEFINITION_FN. This means that I need to run a dpm sample report for every design point. Do you have any advice on how I could automate this? Or how i can access the necessary particle information without having to run a sample report first?

Thanks again,
Eanna
Eanna.Kennedy is offline   Reply With Quote

Old   February 14, 2019, 12:25
Default
  #4
New Member
 
Djamila
Join Date: May 2016
Location: Algeria
Posts: 16
Rep Power: 10
djamila77 is on a distinguished road
Quote:
Originally Posted by Eanna.Kennedy View Post
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;
}
Thank you
can you help me to write the Nusselt UDF for the following formula
Nu=\frac{-1}{q_{cond}}\int_{0}^{L}\frac{\partial T}{\partial y}dx
djamila77 is offline   Reply With Quote

Old   February 14, 2019, 12:28
Question Help
  #5
New Member
 
Djamila
Join Date: May 2016
Location: Algeria
Posts: 16
Rep Power: 10
djamila77 is on a distinguished road
Hi there,
please I need a help

I need to know how I can applied the coupled and the uncoupled cas for the natural convection and radiation by fluent
djamila77 is offline   Reply With Quote

Reply

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 08:26
Add Mass to a Particle with UDF (DPM) sega Fluent UDF and Scheme Programming 6 October 24, 2013 23:14
please help me. i have question about the UDF at the DPM motallebi FLUENT 0 July 6, 2009 12:27
Velocity of Fluid @ different positions of Particle in DPM using UDF pmghadge FLUENT 1 June 16, 2009 20:11
UDF DPM injection M.A. Rakib FLUENT 0 June 13, 2000 09:28


All times are GMT -4. The time now is 18:22.