CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   Reaction Rate in UDF (

mahdi August 5, 2007 06:17

Reaction Rate in UDF
hello all I try to write a code for a raction rate to use as UDF, but when I iterate it in fluent I see the following Error.

Error: divergence detected in AMG solver: species-0 Error Object: ()

I change the URF to arrive the minimum but this error dont disappear.

Can anyone help me?

Thanks in advance

The code is:

#include "udf.h" #include "math.h"

#define A1 4.225e15 #define A2 1.955e06 #define A3 1.02e015

#define ACH4 6.65e-4 #define AH2O 1.77e05 #define ACO 8.23e-5 #define AH2 6.12e-9

#define E1 -240.1 #define E2 67.130

#define dHCH4 -38.28 #define dHH2O 88.680 #define dHCO -70.65 #define dHH2 -82.90

#define dH1 224.0 #define dH2 -37.3 #define dH3 187.5

#define R 0.008314 DEFINE_VR_RATE(Reaction_Rate,c,t,r,mole_weight,spe cies_mf,Rate,rr_t) {

real T = C_T(c, t); real Pb = C_P(c, t); real yCH4 = species_mf[0]; real yH2O = species_mf[1]; real yCO = species_mf[2]; real yH2 = species_mf[3]; real yCO2 = species_mf[4];

double P,PCH4,PH2O,PCO,PH2,PCO2,k1,k2,KCH4,KH2O,KCO,KH2,K 1,K2,DEN,Rate1,Rate2;

P = Pb / 101325; //Conversion of paskal to bar; PCH4 = yCH4 * P; PH2O = yH2O * P; PCO = yCO * P; PH2 = yH2 * P; PCO2 = yCO2 * P;

k1 = A1 * exp (-E1/R/T); k2 = A2 * exp (-E2/R/T);

KCH4=ACH4 * exp (-dHCH4/R/T); KH2O=AH2O * exp (-dHH2O/R/T); KCO =ACO * exp (-dHCO/R/T); KH2 =AH2 * exp (-dHH2/R/T);

K1 = exp (-22819.024/T+7.951*(log(T))-0.004354*T+0.00000036067*(pow(T,2))+(4850/(pow(T,2)))-24.78); K2 = exp (5870.4418/T+1.86*(log(T))-0.00027*T-58200/(pow(T,2))-18.00628);

if (FLUID_THREAD_P(t) && THREAD_VAR(t).fluid.porous) {




*Rate = Rate1 - Rate2; } else

*Rate = 0;

*rr_t = *R1CO; }

cg August 7, 2007 05:27

Re: Reaction Rate in UDF
This chemistry looks stiff. Try using the DEFINE_NET_REACTION rate with the Stiff Chemistry Laminar solver.

mahdi August 7, 2007 08:31

Re: Reaction Rate in UDF
Hi cg very Thanks

But when I use it have some another error from my code. The rete is nonlinear and I use "DEFINE_VR_RATE". Could you help me please, becouse I dont use "DEFINE_NET_REACTION" yet in a code.

The reaction I use is nonlinear.

Thanks in advance

All times are GMT -4. The time now is 19:26.