CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Volumetric Reaction Rate UDF. Inactivation of Clostridium Botulinum

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 10, 2012, 11:07
Default Volumetric Reaction Rate UDF. Inactivation of Clostridium Botulinum
  #1
New Member
 
Roberto
Join Date: Oct 2011
Location: Italy
Posts: 17
Rep Power: 15
Robbb is on a distinguished road
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;

}
Robbb is offline   Reply With Quote

Old   January 10, 2012, 18:43
Default
  #2
Member
 
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 15
Sixkillers is on a distinguished road
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).
Sixkillers is offline   Reply With Quote

Old   January 13, 2012, 06:30
Question thanks
  #3
New Member
 
Roberto
Join Date: Oct 2011
Location: Italy
Posts: 17
Rep Power: 15
Robbb is on a distinguished road
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.
Robbb is offline   Reply With Quote

Old   January 13, 2012, 11:58
Default
  #4
Member
 
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 15
Sixkillers is on a distinguished road
You have to use C_T macro to obtain temperature in each cell. Check out the first example, which is exactly what you need.
Sixkillers is offline   Reply With Quote

Old   January 14, 2012, 20:22
Default
  #5
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
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 View Post
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
ComputerGuy is offline   Reply With Quote

Old   January 23, 2012, 06:49
Default
  #6
New Member
 
Roberto
Join Date: Oct 2011
Location: Italy
Posts: 17
Rep Power: 15
Robbb is on a distinguished road
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;
}
Robbb is offline   Reply With Quote

Old   January 23, 2012, 08:04
Default
  #7
Member
 
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 15
Sixkillers is on a distinguished road
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.
Sixkillers is offline   Reply With Quote

Old   January 23, 2012, 10:07
Default
  #8
New Member
 
Roberto
Join Date: Oct 2011
Location: Italy
Posts: 17
Rep Power: 15
Robbb is on a distinguished road
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;
}
Robbb is offline   Reply With Quote

Old   January 23, 2012, 14:43
Default
  #9
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Try changing "Temperature" to "Temp2" or some other name and let us know if that works. See below.

ComputerGuy
Code:
#include "udf.h"

DEFINE_PROFILE(transient_temperature, thread, position)
{
    
real t;
real temp2;
  face_t f;

t=RP_Get_Real("flow-time");
temp2=(75*(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.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 View Post
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;
}
ComputerGuy is offline   Reply With Quote

Old   February 1, 2012, 06:51
Default
  #10
New Member
 
Roberto
Join Date: Oct 2011
Location: Italy
Posts: 17
Rep Power: 15
Robbb is on a distinguished road
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;
}
Robbb is offline   Reply With Quote

Old   February 2, 2012, 10:36
Talking it's working!
  #11
New Member
 
Roberto
Join Date: Oct 2011
Location: Italy
Posts: 17
Rep Power: 15
Robbb is on a distinguished road
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!
Robbb is offline   Reply With Quote

Old   March 20, 2013, 04:54
Default
  #12
Member
 
Join Date: Feb 2013
Posts: 31
Rep Power: 13
cinwendy is on a distinguished road
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!
cinwendy is offline   Reply With Quote

Reply

Tags
inactivation, rate, reaction, udf, volumetric


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF for VR Rate calculation ADI FLUENT 3 June 23, 2014 18:31
UDF molar rate of creation/destruction of species Michal Fluent UDF and Scheme Programming 1 January 18, 2013 08:26
volumetric reaction and energy balance? m.beh FLUENT 1 October 17, 2011 18:21
volume flow rate error in udf jjchristophe Fluent UDF and Scheme Programming 1 July 13, 2010 05:23
UDF for critical strain rate to extinction Birute Bunkute FLUENT 1 March 25, 2010 16:40


All times are GMT -4. The time now is 16:18.