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

UDF for Polydispersed Particles

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By souria
  • 1 Post By `e`

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 28, 2016, 09:52
Default UDF for Polydispersed Particles
  #1
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 9
souria is on a distinguished road
Dear everyone, I try to write an UDF to introduce my own particle size distribution, which is a log-normal distribution : I write this few lines and I need some help or remarks to make my UDF works. Thanks a lot.

This is the UDF :

******************************************
#include "dpm.h"


#include "udf.h"
#include "dpm.h"



DEFINE_DPM_INJECTION_INIT(Polydisperse_Particle, I)
{
static Injection *injcetion;
nbdiam = I->number_diameters;
static int nbdiam = 2600; /* nombre de diamètres par injection*/
real Yd(real d, real dMed, real Etype, real dmin, real dmax, real dmoy){
/*Yd(diamétre, diamètre median, ecart type)*/
/*Xm(diametre,I->min_diam,I->max_diam,I->mean_diam,I->spread_parameter,I->number_diameters);*/

real diam=d;
real dmin=2;
real dmax=220;
real dmoy=5;
real a=1; /* coefficient*/
real b=2; /* coefficient*/
real c=3; /* coefficient*/
real Etype=2.5; /* ecart type*/
real dMed=19; /* diamter median*/
real term1, term2, term3;
term1=pow(log(d/dMed),2);
term2=exp(-pow(1/2*Etype,2)*terme1);


return 1/d*e*(squart(2*pi))*term2;
}




}

****************************************
Souria
Cheers
tbraun84 likes this.
souria is offline   Reply With Quote

Old   January 31, 2016, 22:50
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 14
`e` is on a distinguished road
What errors are you receiving (if any)? What is your expected distribution of particle diameters and what distribution are you actually getting? Lastly, add a trailing dot for all real numbers (for example "1./d" instead of "1/d" to avoid type casting errors).
`e` is offline   Reply With Quote

Old   February 1, 2016, 06:00
Default
  #3
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 9
souria is on a distinguished road
Quote:
Originally Posted by `e` View Post
What errors are you receiving (if any)? What is your expected distribution of particle diameters and what distribution are you actually getting? Lastly, add a trailing dot for all real numbers (for example "1./d" instead of "1/d" to avoid type casting errors).
Thanks for yoour reply.
Here is my new version :

#include "udf.h"
#include "dpm.h"



DEFINE_DPM_INJECTION_INIT(Polydisperse_Particle, I)
{
static Injection *injcetion;
static int nbdiam = 20; /* diameternumber*/


real Yd(real d, real dmoy, real sp, real c, real p); {
/*Yd(diamétre, diamètre median, ecart type)*/
/*Xm(diametre,I->min_diam,I->max_diam,I->mean_diam,I->spread_parameter,I->number_diameters);*/
real c=1019;
real sp=1.46;
real dmoy=93.24;
real d=P_DIAM(p);
return c*sp*(pow(d,(sp-1))/pow(dmoy,sp))*exp(-pow(d,sp)/pow(dmoy,sp));
}

real Xm(real d, real dmin, real dmax, real dmoy, real sp, int n);{
real Q1, Q2;
real dmin=200;
real dmax=233;
real sp=1.46;
real d=P_DIAM(p);

Q1=d+(dmax-dmin)/((real)n-1);
Q2=d-(dmax-dmin)/((real)n-1);
if(d<=dmin){
return (1-Yd((dmin+Q1)/2, dmoy,sp));
}
else{
if(d>=dmax){
return Yd((dmax+Q2)/2,dmoy,sp);
}
else{
return (Yd((Q1+d)/2,dmoy,sp)-Yd((d+Q1)/2,dmoy,sp));
}
}
}

I got these errors :
* undeclared identifier : n, dmoy, p
*Error 'Yd' too few arguent to call.


Thanks for your help.

Souria
souria is offline   Reply With Quote

Old   February 1, 2016, 06:14
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 14
`e` is on a distinguished road
I'm not sure what you're trying to achieve with the Yd() functions etc. To modify the diameters of particle parcels, you can loop over the injection streams and change the diameter. For example (steady particle simulation):

Code:
DEFINE_DPM_INJECTION_INIT(polydisperse_particles,I)
{
    Particle *p;
    loop(p, I->p)
    {
        P_DIAM(p) = 20.; // apply a polydispersed distribution function here
    }
}
`e` is offline   Reply With Quote

Old   February 1, 2016, 06:44
Default
  #5
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 9
souria is on a distinguished road
I try to apply a distribution to the diameter size , according to this functin (A modified Rosin-Rammler distribution) :

Y(d) = c*sp*(pow(d,(sp-1))/pow(dmoy,sp))*exp(-pow(d,sp)/pow(dmoy,sp));

c= constant
sp=spread number =constant
dmoy=constant
d=particle diametre

but I don't know how to decalare this in the begining of my UDF!
souria is offline   Reply With Quote

Old   February 1, 2016, 19:55
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 14
`e` is on a distinguished road
If you're having trouble coding the distribution then use existing code online, for example a C++ code is available here and you could change the code to fit your modified distribution.
tbraun84 likes this.
`e` is offline   Reply With Quote

Old   February 2, 2016, 04:09
Default
  #7
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 9
souria is on a distinguished road
Quote:
Originally Posted by `e` View Post
If you're having trouble coding the distribution then use existing code online, for example a C++ code is available here and you could change the code to fit your modified distribution.
Thanks for the information.

Souria
souria is offline   Reply With Quote

Old   January 28, 2019, 15:50
Default
  #8
New Member
 
Tim
Join Date: Jun 2018
Posts: 7
Rep Power: 4
tbraun84 is on a distinguished road
Quote:
Originally Posted by souria View Post
Thanks for the information.

Souria
I'm sorry but I'm very new to C language and UDF's. How did you (or how can I) get from the distribution function [Cumulative %wt =y(d)] to the actual assignment of P_DIAM for each stream, ensuring that the final distribution matches?

Could you post an elementary example (e.g. 20 diameters each at 5%-mass perhaps)?
tbraun84 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 08:37
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
UDF for sampling particles from multiple injections JaC Fluent UDF and Scheme Programming 0 March 31, 2010 11:43
How to define a parabolic velocity inlet of particles with UDF zumaqiong FLUENT 2 February 22, 2010 10:46
how to determine the number of particles injected. welch FLUENT 1 November 1, 2005 06:11


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