CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to use UDF to deine surface reaction rate (https://www.cfd-online.com/Forums/fluent-udf/216623-how-use-udf-deine-surface-reaction-rate.html)

kimi_hao April 14, 2019 06:49

How to use UDF to deine surface reaction rate
 
I'm following the example in UDF Manual.
The given UDF code is as below:
#include "udf.h"
DEFINE_SR_RATE(my_rate,f,t,r,mw,yi,rr)
{
Thread *t0=t->t0;
cell_t c0=F_C0(f,t);
double sih4 = yi[0]; /* mass fraction of sih4 at the wall */
double si2h6 = yi[1];
double sih2 = yi[2];
double h2 = yi[3];
double ar = yi[4]; /* mass fraction of ar at the wall */
double rho_w = 1.0, site_rho = 1.0e-6, T_w = 300.0;
double si_s = yi[6]; /* site fraction of si_s*/
double sih_s = yi[7]; /* site fraction of sih_s*/
T_w = F_T(f,t);
rho_w = C_R(c0,t0)*C_T(c0,t0)/T_w;
sih4 *= rho_w/mw[0]; /* converting of mass fractions to molar concentrations */
si2h6 *= rho_w/mw[1];
sih2 *= rho_w/mw[2];
h2 *= rho_w/mw[3];
ar *= rho_w/mw[4];
si_s *= site_rho; /* converting of site fractions to site concentrations */
sih_s *= site_rho;
if (STREQ(r->name, "reaction-1"))
*rr = 100.0*sih4;
else if (STREQ(r->name, "reaction-2"))
*rr = 0.1*sih_s;
else if (STREQ(r->name, "reaction-3"))
*rr = 100*si2h6*si_s;
else if (STREQ(r->name, "reaction-4"))
*rr = 1.0e10*sih2;
}


I have finished the compiled and function Hooks

In boundary conditions, I have activated “Reaction” in "Species" card of the reaction surface.
But how to give the different "*rr" to desire reactants ?

adleiva95 May 26, 2020 16:58

Hello!

Could you solve it?
I'm having just the exact problem as you

Greetings

vinerm May 27, 2020 04:24

Reaction Identification
 
Reaction rates are not identified by reactants but by reactions and that can taken care of within the UDF by comparing the names against the reaction. E.g., in the code you commented upon, name is compared against each of the four reactions and each one has different value of rate.


All times are GMT -4. The time now is 05:59.