|
[Sponsors] |
January 28, 2016, 09:52 |
UDF for Polydispersed Particles
|
#1 |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
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 |
|
January 31, 2016, 22:50 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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).
|
|
February 1, 2016, 06:00 |
|
#3 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
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 |
||
February 1, 2016, 06:14 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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 } } |
|
February 1, 2016, 06:44 |
|
#5 |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
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! |
|
February 1, 2016, 19:55 |
|
#6 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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.
|
|
February 2, 2016, 04:09 |
|
#7 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
Souria |
||
January 28, 2019, 15:50 |
|
#8 |
New Member
Tim
Join Date: Jun 2018
Posts: 10
Rep Power: 8 |
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)? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to determine the number of particles injected. | welch | FLUENT | 2 | January 18, 2024 05:08 |
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 |