CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Volumetric Reaction Rate UDF. Inactivation of Clostridium Botulinum (http://www.cfd-online.com/Forums/fluent-udf/96011-volumetric-reaction-rate-udf-inactivation-clostridium-botulinum.html)

Robbb January 10, 2012 11:07

Volumetric Reaction Rate UDF. Inactivation of Clostridium Botulinum
 
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;

}

Sixkillers January 10, 2012 18:43

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).

Robbb January 13, 2012 06:30

thanks
 
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?

Sixkillers January 13, 2012 11:58

You have to use C_T macro to obtain temperature in each cell. Check out the first example, which is exactly what you need.

ComputerGuy January 14, 2012 20:22

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 (Post 339161)
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?


Robbb January 23, 2012 06:49

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;
}

Sixkillers January 23, 2012 08:04

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.

Robbb January 23, 2012 10:07

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 January 23, 2012 14:43

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 (Post 340627)
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 February 1, 2012 06:51

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 February 2, 2012 10:36

it's working!
 
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!

cinwendy March 20, 2013 04:54

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!


All times are GMT -4. The time now is 08:48.