# How to use UDF to deine surface reaction rate

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

 April 14, 2019, 07:49 How to use UDF to deine surface reaction rate #1 New Member   郝晨睿 Join Date: Apr 2019 Posts: 3 Rep Power: 3 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 ?

 May 26, 2020, 17:58 #2 New Member   Adrián Leiva Join Date: Oct 2019 Posts: 2 Rep Power: 0 Hello! Could you solve it? I'm having just the exact problem as you Greetings

 May 27, 2020, 05:24 Reaction Identification #3 Senior Member     Vinerm Join Date: Jun 2009 Location: Nederland Posts: 2,948 Blog Entries: 1 Rep Power: 31 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. __________________ Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.