CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

UDF Access violation

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2011, 18:31
Default UDF Access violation
  #1
New Member
 
John
Join Date: Nov 2010
Posts: 11
Rep Power: 15
therandomestname is on a distinguished road
Hello all:

This is my first time using UDFs. I wrote a UDF for a volumetric reaction rate. It compiles, but gives me an access violation every time I try to run the simulation with it hooked in. It is pretty basic, the only tricky thing about it is that the rate formula uses the mole fraction, X, rather than the mass fraction. Does an access violation mean that there is a problem with the way the UDF is written or could it be a computer problem?

Here is the code:

#include"udf.h"
DEFINE_VR_RATE(co_combust,c,t,r,mw,yi,rr,rr_t)
{
real mw_mix = 0;
real yx = 0;
real mwx = 0;
real xfuel = 0;
real xo2 = 0;
real mole_con_fuel = 0;
real mole_con_o2 = 0;
int i = 0;
real *rate = 0;
for (i = 0; i < r->n_reactants; i++)
{
yx = yi[r->reactant[i]];
mwx = mw[r->reactant[i]];
mw_mix = mw_mix + yx * mwx;
}
xfuel = yi[r->reactant[0]]*mw_mix / mw[r->reactant[0]];
xo2 = yi[r->reactant[1]]*mw_mix / mw[r->reactant[1]];
mole_con_fuel = xfuel * C_P(c,t) / (UNIVERSAL_GAS_CONSTANT * C_T((c,t));
mole_con_o2 = xo2 * C_P(c,t) / (UNIVERSAL_GAS_CONSTANT * C_T(c,t));
*rate = -59.8 * pow(C_P(c,t), 0.3) * C_T(c,t) * mw[r->reactant[0]] * pow(xfuel, 0.5) * xo2 * exp( -12200 / C_T(c,t));
}
therandomestname is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
specified shear at wall - temperature gradient - UDF - access violation error senD Fluent UDF and Scheme Programming 9 September 18, 2014 08:29
udf error : access violation butterfly007 Fluent UDF and Scheme Programming 2 June 1, 2012 12:01
UDF problem (ACCESS VIOLATION) Jorge Poyatos FLUENT 5 March 16, 2009 09:02
Urgent! Access violation of UDF using VOF Rucy FLUENT 0 January 9, 2006 05:01
Error (ACCESS VIOLATION) with UDF Ale FLUENT 2 May 28, 2002 03:50


All times are GMT -4. The time now is 12:41.