CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Access Density (https://www.cfd-online.com/Forums/fluent/38066-access-density.html)

Allan Walsh September 30, 2005 12:37

Access Density
 
I'm trying to use a UDF for a custom reaction rate in Fluent 6.2 under Windows.

I tried the sample version from the manual which wouldn't work - the old ACCESS VIOLATION.... error.

After several rounds of debugging, I found that it crashed when it tried to access the variable for the gas density C_R(c,t). The UDF could access C_T(c,t) or C_P(c,t) for the cell temperature or cell pressure with no problem. (I've included a few lines of code from my crude debugging at the end of this message). If I gave it a gas density, it worked fine. (For the gas material property, in density the ideal gas law was specified).

And, if I included other UDFs in the libudf.dll, such as one to calculate particles, it could access C_R(c,t) in other UDFs with no problems.

I submitted this through Fluent's web help portal but did not get very far - they were waiting for me to send them the code.

Anyone have any ideas what I'm doing wrong?

DEFINE_VR_RATE(cvol_reac_rate,c,t,r,wk,yk,rate,rr_ t) { real ci, prod; int i;

/* Calculate Arrhenius reaction rate */

prod = 1.;

CX_Message("temp: %f\n", C_T(c,t));

CX_Message("dens: %f\n", C_R(c,t));

for(i = 0; i < r->n_reactants; i++)

{

//CX_Message("mw %f ri %10.6g\n", wk[r->reactant[i]],yk[r->reactant[i]]);

ci = 0.22 * yk[r->reactant[i]] / wk[r->reactant[i]];

//ci = C_R(c,t) * yk[r->reactant[i]] / wk[r->reactant[i]];

//CX_Message("cr %f ci %10.6g\n", C_R(c,t),ci);

prod *= pow(ci, r->exp_reactant[i]);

} *rate = r->A * exp( - r->E / (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) *

pow(C_T(c,t), r->b) * prod;

*rr_t = *rate;

/* No "return..;" value. */ }

RoM October 2, 2005 05:31

Re: Access Density
 
I have tried the VR_RATE macro in fluent 6.1 under windows and it worked well. What models do have activated? I used it together with species transport (finite rate/eddy dissipation), standard k-e, dpm, p1-radiation and incompressible ideal gas law for the mixture. Do you you need compressibility effects? If not try incompressible ideal gas law. If everything failes you can still calculate the cell density from the mixture molecular weight (through yk and wk) and C_T and C_P.

Good Luck

RoM

Allan Walsh October 3, 2005 18:43

Re: Access Density
 
Thanks for the comments. Yes, I should have mentioned I was actually using incompressible ideal gas law. I checked other laws which still crashed when trying to access density.

The density is available in the VR_RATE UDF for other models I've developed. I'm still concerned about compatibility issues between V6.1 and 6.2 other than the obvious problem of V6.2 UDF's needing the lib name as well as udf name. Compatibility problem's I've encountered include pathline display crashes if boundaries are described by udf's and reaction mechanism is not copied for all volumes when doing a read-bc. Didn't have these problems in V6.1. Unfortuately, they all give the same generic ACCESS_VIOLATION... error.

Oh well, Fluent support is now working on my access density problem.

RoM October 4, 2005 07:55

Re: Access Density
 
I tried your udf on my system, no crashes. It sounds strange that you encounter so much problems. I use lots of udf and had no problems with the update from 6.1 to 6.2 . Did you update your INCLUDE system var? Maybe the compiler still uses the old header files.

RoM



All times are GMT -4. The time now is 17:21.