# Volumetric Reaction Rate UDF. Inactivation of Clostridium Botulinum

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

 January 10, 2012, 10:07 Volumetric Reaction Rate UDF. Inactivation of Clostridium Botulinum #1 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 14 Hello everyone. I need to create an UDF for a volumetric reaction (inactivation of clostridium botulinum) alive Botulinum -> dead Botulinum I'd like to model the reaction as function of D, decimal death time: lnC2/C1=k(t2-t1) where k= 2.303/D. This is the udf I created, is it correct? #include "udf.h" #define D 12.6 DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rate, rr, D) { real s1 = species_mf[0]; real mw1 = mole_weight[0]; *rate=(2.303/D)*s1*mw1; *rr = rate; }

 January 10, 2012, 17:43 #2 Member   Join Date: Nov 2011 Location: Czech Republic Posts: 97 Rep Power: 14 Hi! 1) Macro DEFINE_VR_RATE should have 8 arguments but you've got 9 (D is extra). 2) Be sure that rate/rr variable is in units kmol/(m3*s).

 January 13, 2012, 05:30 thanks #3 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 14 Thank you very much. It seems to work like this: #include "udf.h" DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rr) { real s1 = species_mf[0]; real mw1 = mole_weight[0]; *rr=(2.303/12.6)*s1*mw1; } Another question: Now I need to insert a -temperature dependent- value of D (which is constant in this udf and is 12.6 ). The dependence is D=12.6/ 10^((T-121)/10) How can I insert it? Last edited by Robbb; January 13, 2012 at 10:28.

 January 13, 2012, 10:58 #4 Member   Join Date: Nov 2011 Location: Czech Republic Posts: 97 Rep Power: 14 You have to use C_T macro to obtain temperature in each cell. Check out the first example, which is exactly what you need.

January 14, 2012, 19:22
#5
Senior Member

Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
Assuming your equation requires units of Kelvin, try:

Code:
```#include "udf.h"
DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rr)
{
real temp=C_T(c,t);
real D=12.6/pow(10.0,((temp-121.0)/10.0));
real s1 = species_mf[0];
real mw1 = mole_weight[0];
*rr=(2.303/D)*s1*mw1;
}```
ComputerGuy

Quote:
 Originally Posted by Robbb Thank you very much. It seems to work like this: #include "udf.h" DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rr) { real s1 = species_mf[0]; real mw1 = mole_weight[0]; *rr=(2.303/12.6)*s1*mw1; } Another question: Now I need to insert a -temperature dependent- value of D (which is constant in this udf and is 12.6 ). The dependence is D=12.6/ 10^((T-121)/10) How can I insert it?

Last edited by ComputerGuy; January 23, 2012 at 13:43. Reason: Variable name correction

 January 23, 2012, 05:49 #6 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 14 Ok, thanks! Now I should define, together with this udf, a variation of temperature wich is Temperature = (75*(1-exp(-0.06*t))+298); is it like this: #include "udf.h" DEFINE_PROFILE(transient_temperature, thread, position) { float t; float Temperature; face_t f; t = RP_Get_Real("flow-time"); Temperature = (75*(1-exp(-0.06*t))+298); begin_f_loop(f, thread) { F_PROFILE(f, thread, position) = Temperature; } end_f_loop(f, thread) } DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rr) { real temperature=C_T(c,t); real D=12.6/pow(10.0,((temperature-294.0)/10.0)); real s1 = species_mf[0]; real mw1 = mole_weight[0]; *rr=(2.303/D)*s1*mw1; }

 January 23, 2012, 07:04 #7 Member   Join Date: Nov 2011 Location: Czech Republic Posts: 97 Rep Power: 14 I am assuming that you want to set variable temperature (depending on time) on a boundary. In that case your UFD looks correct, but I would use "real" data type instead of "float" to preserve calculation precision portability. In addition, I would use macro CURRENT_TIME instead of RP_Get_Real("flow-time"), but this is just a matter of personal taste.

 January 23, 2012, 09:07 #8 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 14 Yes I want to set variable temperature (depending on time) on a boundary. Now it's almost working.. :P but interpreting the udf, fluent says "Temperature definition shadows previous definition" this is the one I'm using now: #include "udf.h" DEFINE_PROFILE(transient_temperature, thread, position) { real t; real Temperature; face_t f; t=RP_Get_Real("flow-time"); Temperature=(75*(1-exp(-0.06*t))+298); begin_f_loop(f, thread) { F_PROFILE(f, thread, position) = Temperature; } end_f_loop(f, thread) } DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rr) { real Temp=C_T(c,t); real D=12.6/pow(10.0,((Temp-294.0)/10.0)); real s1 = species_mf[0]; real mw1 = mole_weight[0]; *rr=(2.303/D)*s1*mw1; }

January 23, 2012, 13:43
#9
Senior Member

Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
Try changing "Temperature" to "Temp2" or some other name and let us know if that works. See below.

ComputerGuy
Code:
```#include "udf.h"

{

real t;
real temp2;
face_t f;

t=RP_Get_Real("flow-time");
temp2=(75*(1-exp(-0.06*t))+298);

{
}
}

DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rr)
{
real Temp=C_T(c,t);
real D=12.6/pow(10.0,((Temp-294.0)/10.0));
real s1 = species_mf[0];
real mw1 = mole_weight[0];
*rr=(2.303/D)*s1*mw1;
}```

Quote:
 Originally Posted by Robbb Yes I want to set variable temperature (depending on time) on a boundary. Now it's almost working.. :P but interpreting the udf, fluent says "Temperature definition shadows previous definition" this is the one I'm using now: #include "udf.h" DEFINE_PROFILE(transient_temperature, thread, position) { real t; real Temperature; face_t f; t=RP_Get_Real("flow-time"); Temperature=(75*(1-exp(-0.06*t))+298); begin_f_loop(f, thread) { F_PROFILE(f, thread, position) = Temperature; } end_f_loop(f, thread) } DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rr) { real Temp=C_T(c,t); real D=12.6/pow(10.0,((Temp-294.0)/10.0)); real s1 = species_mf[0]; real mw1 = mole_weight[0]; *rr=(2.303/D)*s1*mw1; }

 February 1, 2012, 05:51 #10 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 14 I'm using this one but it doesn't seem to work: #include "udf.h" DEFINE_PROFILE(transient_temperature, thread, position) { real t; real temp2; face_t f; t=RP_Get_Real("flow-time"); temp2=(100*(1-exp(-0.06*t))+298); begin_f_loop(f, thread) { F_PROFILE(f, thread, position) = temp2; } end_f_loop(f, thread) } DEFINE_VR_RATE(user_rate, c, t, r, mole_weight, species_mf, rr) { real Temp=C_T(c,t); real D=12.6/pow(10,((Temp-294)/10)); real s1 = species_mf[0]; real mw1 = mole_weight[0]; *rr=(2.303/D)*s1*mw1; }

 February 2, 2012, 09:36 it's working! #11 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 14 I guess it was a problem of units. It works like this: #include "udf.h" DEFINE_PROFILE(transient_temperature, thread, position) { real t; real Temperature; face_t f; t=RP_Get_Real("flow-time"); Temperature=(75*(1-exp(-0.06*t))+298); begin_f_loop(f, thread) { F_PROFILE(f, thread, position) = Temperature; } end_f_loop(f, thread) } DEFINE_VR_RATE(user_rate7,c,t,r,mw,yi,rr,rr_t) { real temperatura, s1, mw1; temperatura=394.0; temperatura=C_T(c,t); s1 = yi[0]; mw1 = mw[0]; *rr=(2.303/(12.6/pow(10,((temperatura-394.0)/10.0))))*(s1/mw1)*922; } thanks everyone!

 March 20, 2013, 03:54 #12 Member   Join Date: Feb 2013 Posts: 31 Rep Power: 13 Hi Robbb and everyone here, My simulation requirement leads me to this post. The reaction kinetics I want to simulate is similar to the very first one in this thread. Can any kind soul tell me how to incorporate the interpreted UDF into calculation? I interpreted my UDF and included it in function hook, then....? because... nothing happens. Thanks a lot in advance!

 Tags inactivation, rate, reaction, udf, volumetric