CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Error inputting udf into fluent for mass source (http://www.cfd-online.com/Forums/fluent-udf/100553-error-inputting-udf-into-fluent-mass-source.html)

ejvikings April 26, 2012 21:42

Error inputting udf into fluent for mass source
 
In fluent, I'm modeling the 2-D combustion of a leaf. I made a mesh in gambit that includes a small face around the leaf that is zoned as a fluid to allow mass sources in Fluent.

My problem is that I have tried to use a udf for the source term of h20 being volatilized but I always get the result "Error, Segmentation Violation". It works if I just put in a constant value for the source term of H20.

Here's a copy of the UDF that I was trying to use:

#include "udf.h"
DEFINE_PROFILE(massrelease_h2o,thread,index)
{
face_t f;
real x[ND_ND]; /* this will hold the position vector */
real y;
real ti = CURRENT_TIME; /* Current time step */
/* inputs for leaf */
real tig, d, th, SurfA, pi;
real a1, b1, ae, be, dmH2O, value, total;
tig=3.0; /* Time when ignition occurs - devolatilization starts */
d=0.02736; /* diameter of leaf [m] - must go with FLUENT */
th=0.0005; /* thickness of leaf [m] - must go with FLUENT */
pi=3.141592654;
SurfA=2.*(pi*(d/2.)*(d/2.))+pi*d*th;
a1=0.483620247554468; /* Water */
b1=0.0824661144389419;
ae=0.87330029071108;
be=0.277540639452865;
total=51.027;
if ((ti-tig)<0.) {
dmH2O=a1*b1*exp(-b1*ti);
}
else {
dmH2O=ae*be*exp(-be*ti);
}
value=total*dmH2O/SurfA/1000.;
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
y = x[1];
F_PROFILE(f,thread,index)=value;
}
end_f_loop(f,thread)
/* printf("H2O=%f\n",value); */
}


Any help would be greatly appreciated!!


All times are GMT -4. The time now is 02:20.