UDF for Polydispersed Particles
Dear everyone, I try to write an UDF to introduce my own particle size distribution, which is a lognormal 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 
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).

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,(sp1))/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+(dmaxdmin)/((real)n1); Q2=d(dmaxdmin)/((real)n1); if(d<=dmin){ return (1Yd((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 
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) 
I try to apply a distribution to the diameter size , according to this functin (A modified RosinRammler distribution) :
Y(d) = c*sp*(pow(d,(sp1))/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! 
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.

Quote:
Souria 
Quote:
Could you post an elementary example (e.g. 20 diameters each at 5%mass perhaps)? 
All times are GMT 4. The time now is 06:56. 