CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Help with UDF (http://www.cfd-online.com/Forums/fluent-udf/109949-help-udf.html)

 ashrawage November 30, 2012 18:02

Help with UDF

Hello everyone,
i have compiled the following UDF for density, thermal conductivity and viscosity.
But i am getting the access violation error.
Now I know what it is but i am not sure how to best deal with it.

the UDF for density is given below as an example. It compiled without a hitch. but the minute i initialize i get that error. Do you guys see any flaws or can give any tips regarding this issue??

Sincere thanks

#include "udf.h"

/* Date: 11/15/2012
Density of supercritcal water at pressure line of 24MPa*/

DEFINE_PROPERTY(density, c, t)
{
real rho;
int i;
int N1 = 8;
real aa[8]={9.057256850332234e+011, -1.004223127586313e+010, 4.771729301474036e+007,
-1.259615031360143e+005, 1.994987699191794e+002, -0.189575891223812,
1.000789828768001e-004, -2.264203358260640e-008};
int N3 = 8;
real cc[8]={1.213009600498309e+010, -1.184275708420463e+008, 4.952997273974567e+005,
-1.150308037299205e+003, 1.602192564936295, -0.001338350280787,
6.208057950195209e-007, -1.233583438752835e-10};

real Temp = C_T(c, t);

/* Inorder to prevent the solution to collapse in case the temperature of the system goes below the ranges provided
the following steps were taken to limit the values to a constant quantity*/

if ( Temp < 618.0)
rho = 640.0;
else if (Temp > 773.0)
rho = 84.0;

/* curve fits are put together below */
/* ********************************************* */
if (Temp >= 618.0 && Temp <= 650.0)
{
rho = aa[7];
for ( i=N1-2; i >=0; i--)
rho = rho*Temp + aa[i];
}
else if ( Temp > 650.0 && Temp <= 654.0 )
rho = (-5.3517 * Temp + 6949.9 )* Temp -2.2559e+006;
else if ( Temp > 654.0 && Temp <= 773.0 )
{
rho = cc[7];
for ( i=N3-2; i >=0; i--)
rho = rho*Temp + cc[i];
}

/* return density calculated by the curve fits */
return rho;

}

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