CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to use DEFINE-ADJUST macro to simulate microbial growth rate? (https://www.cfd-online.com/Forums/fluent-udf/216641-how-use-define-adjust-macro-simulate-microbial-growth-rate.html)

 shakib April 15, 2019 04:50

How to use DEFINE-ADJUST macro to simulate microbial growth rate?

Hello guys.
Hope you all good
I am trying to solve a microbial growth rate with monod equation. Because of absence of appropriate orders in UDF manual, I tried writing a UDF but i cant see the results as velocity contours in graphic contours.
Best Regards.

/***** UdF for Microbial Growth Rate (Based on Monod Equation) in a Baffled Stirred Tank *****/
#include <udf.h>
{
Domain *domain;/*domain points to domain Thread*/
int ID = 10;/*Number of interior (Fluid) zone*/
cell_t c;/*An integer data type that identifies a particular cell within a cell thread that names "c"*/
real x[ND_ND];/*x Array in 2D contains x&y and in 3D contains x&y&z*/
real mu = 1, s1 = 2, s2 = 3;
const real ks1 = 1, ks2 = 2, mumax = 3;/*Using These 3 Orders to declare consistent variables instead of macros that have been written above*/;
{
{
begin_c_loop_all(c,t)/*Loops Over Cells in a Cell Thread*/
{
C_CENTROID(x, c, t);/*Output results of 3D cell centroid in Array x*/
mu = mumax * ( s1 / ( ks1 + s1 ) ) * ( s2 / ( ks2 + s2 ) );
}
end_c_loop_all(c,t)
}
}
}

 AlexanderZ April 16, 2019 01:18

what this UDF should do from your point of view?
how it can influence flow velocity?

best regards

 shakib April 16, 2019 07:09

1 Attachment(s)
Quote:
 Originally Posted by AlexanderZ (Post 730900) what this UDF should do from your point of view? how it can influence flow velocity? best regards
Thank you for your quick replay :)

This UDF should calculate the Monod equation(the picture is attached below) to specify the concentration of bacterias (instead of velocity of species as a second phase! maybe this will be easier and more helpfull to me in this case) as a flow specie in one phase.

Thanks a lot:)

 AlexanderZ April 17, 2019 01:39

how this equation is connected to transport equation?
other words: how this concentration influence velocity?

if velocity depends on concentration and you want to simulate this -> this is one story, if doesn't -> another one.

by the way, using your coefficients you will get same constant value everywhere in the whole domain

best regards

 shakib April 17, 2019 02:22

1 Attachment(s)
Quote:
 Originally Posted by AlexanderZ (Post 731024) how this equation is connected to transport equation? other words: how this concentration influence velocity? if velocity depends on concentration and you want to simulate this -> this is one story, if doesn't -> another one. by the way, using your coefficients you will get same constant value everywhere in the whole domain best regards
At first, I decided to write a UDF to calculate this equation in two phases that one of them was fluid and the other one was the bacteria that i had to find out bacterias velocity in the stirred tank but now find out that velocity is not a proper solution so changed my procedure to solve the problem in 1 phase (without any velocity parameter!) thus want to find out bacterias concentration as a flow specie like pressure or density in a particular cut plane (like attached picture below).
Thanks a lot for your time.

 AlexanderZ April 17, 2019 02:34

Code:

```/***** UdF for Microbial Growth Rate (Based on Monod Equation) in a Baffled Stirred Tank *****/ #include <udf.h> DEFINE_ADJUST(bacterial_growth, d) { Domain *domain;/*domain points to domain Thread*/ int ID = 10;/*Number of interior (Fluid) zone*/ Thread *t = Lookup_Thread(domain,ID);/*t points to Thread*/ cell_t c;/*An integer data type that identifies a particular cell within a cell thread that names "c"*/ real mu = 1, s1 = 2, s2 = 3; const real ks1 = 1, ks2 = 2, mumax = 3;/*Using These 3 Orders to declare consistent variables instead of macros that have been written above*/; thread_loop_c(t, domain)/*Looping over Cell threads (e.g. fluid and solid) in Domain*/         {         begin_c_loop_all(c,t)/*Loops Over Cells in a Cell Thread*/                 {                 C_UDMI(c,t,0) = mumax * ( s1 / ( ks1 + s1 ) ) * ( s2 / ( ks2 + s2 ) );                 }         end_c_loop_all(c,t)         } }```

C_UDMI(c,t,0) is user define variable, you should allocate memory for it in FLuent GUI
go to User-Defined -> Memory -> Number of UDM locations change from 0 to 1

solve

Now you can make a contour of C_UDMI(c,t,0) (which is mu):
under volume monitors as a field variable select Used Defined Variable and choose memory 0

For more information regarding C_UDMI and UDF look into Ansys Fluent Customization manual

best regards

 shakib April 17, 2019 03:40

Quote:
 Originally Posted by AlexanderZ (Post 731032) Code: ```/***** UdF for Microbial Growth Rate (Based on Monod Equation) in a Baffled Stirred Tank *****/ #include DEFINE_ADJUST(bacterial_growth, d) { Domain *domain;/*domain points to domain Thread*/ int ID = 10;/*Number of interior (Fluid) zone*/ Thread *t = Lookup_Thread(domain,ID);/*t points to Thread*/ cell_t c;/*An integer data type that identifies a particular cell within a cell thread that names "c"*/ real mu = 1, s1 = 2, s2 = 3; const real ks1 = 1, ks2 = 2, mumax = 3;/*Using These 3 Orders to declare consistent variables instead of macros that have been written above*/; thread_loop_c(t, domain)/*Looping over Cell threads (e.g. fluid and solid) in Domain*/         {         begin_c_loop_all(c,t)/*Loops Over Cells in a Cell Thread*/                 {                 C_UDMI(c,t,0) = mumax * ( s1 / ( ks1 + s1 ) ) * ( s2 / ( ks2 + s2 ) );                 }         end_c_loop_all(c,t)         } }``` C_UDMI(c,t,0) is user define variable, you should allocate memory for it in FLuent GUI go to User-Defined -> Memory -> Number of UDM locations change from 0 to 1 solve Now you can make a contour of C_UDMI(c,t,0) (which is mu): under volume monitors as a field variable select Used Defined Variable and choose memory 0 For more information regarding C_UDMI and UDF look into Ansys Fluent Customization manual best regards
Thank you so much!
my problem solved:)

I beg your pardon i have another question:is there any differences between writing UDF for moving reference frame and dynamic mesh in this case? I mean something must change in UDF or not?
Because now i am compiling this udf in MRF and in the future i have to use that in dynamic mesh.

Best regards.

 AlexanderZ April 17, 2019 22:53

You may use it, no modification required
This is one function, for dynamic mesh you will make other function (if needed).
YOu may use in your UDF as many functions as you want.

best regards

 shakib April 20, 2019 01:41

I wish best for you.

Best regards.

 ronak July 8, 2019 03:46

Hi everybody
Do you know how I should fix this error about a define_adjust UDF
'motion_spec': is not a member of 'tv_cell_struct'