# Volumetric Reaction Rate UDF. Inactivation of Clostridium Botulinum

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

 January 10, 2012, 11:07 Volumetric Reaction Rate UDF. Inactivation of Clostridium Botulinum #1 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 5 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, 18:43 #2 Member   Join Date: Nov 2011 Location: Czech Republic Posts: 95 Rep Power: 5 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, 06:30 thanks #3 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 5 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 11:28.

 January 13, 2012, 11:58 #4 Member   Join Date: Nov 2011 Location: Czech Republic Posts: 95 Rep Power: 5 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, 20:22
#5
Senior Member

Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 180
Rep Power: 7
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 14:43. Reason: Variable name correction

 January 23, 2012, 06:49 #6 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 5 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, 08:04 #7 Member   Join Date: Nov 2011 Location: Czech Republic Posts: 95 Rep Power: 5 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, 10:07 #8 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 5 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, 14:43
#9
Senior Member

Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 180
Rep Power: 7
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, 06:51 #10 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 5 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, 10:36 it's working! #11 New Member   Roberto Join Date: Oct 2011 Location: Italy Posts: 17 Rep Power: 5 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, 04:54 #12 Member   Join Date: Feb 2013 Posts: 31 Rep Power: 4 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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post ADI FLUENT 3 June 23, 2014 17:31 Michal Fluent UDF and Scheme Programming 1 January 18, 2013 08:26 m.beh FLUENT 1 October 17, 2011 17:21 jjchristophe Fluent UDF and Scheme Programming 1 July 13, 2010 04:23 Birute Bunkute FLUENT 1 March 25, 2010 16:40

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