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

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

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

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2019, 04:50
Angry How to use DEFINE-ADJUST macro to simulate microbial growth rate?
  #1
New Member
 
Shakib
Join Date: Mar 2019
Posts: 10
Rep Power: 3
shakib is on a distinguished road
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.
Please help me in correction of UDF.
Best Regards.

/***** 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 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*/;
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_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)
}
}
}
shakib is offline   Reply With Quote

Old   April 16, 2019, 01:18
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,471
Rep Power: 21
AlexanderZ will become famous soon enough
what this UDF should do from your point of view?
how it can influence flow velocity?

best regards
shakib likes this.
AlexanderZ is offline   Reply With Quote

Old   April 16, 2019, 07:09
Post
  #3
New Member
 
Shakib
Join Date: Mar 2019
Posts: 10
Rep Power: 3
shakib is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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
Attached Images
File Type: png Monod Equation.png (18.5 KB, 6 views)
shakib is offline   Reply With Quote

Old   April 17, 2019, 01:39
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,471
Rep Power: 21
AlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   April 17, 2019, 02:22
Post
  #5
New Member
 
Shakib
Join Date: Mar 2019
Posts: 10
Rep Power: 3
shakib is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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.
Attached Images
File Type: jpg Screenshot (613).jpg (98.5 KB, 6 views)
shakib is offline   Reply With Quote

Old   April 17, 2019, 02:34
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,471
Rep Power: 21
AlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   April 17, 2019, 03:40
Post
  #7
New Member
 
Shakib
Join Date: Mar 2019
Posts: 10
Rep Power: 3
shakib is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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
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.
shakib is offline   Reply With Quote

Old   April 17, 2019, 22:53
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,471
Rep Power: 21
AlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   April 20, 2019, 01:41
Default
  #9
New Member
 
Shakib
Join Date: Mar 2019
Posts: 10
Rep Power: 3
shakib is on a distinguished road
Thank you so much for your advises Mr Alexander, they were very helpful.

I wish best for you.

Best regards.
shakib is offline   Reply With Quote

Old   July 8, 2019, 03:46
Default
  #10
Member
 
Hanye Azimi
Join Date: Oct 2016
Posts: 42
Rep Power: 6
ronak is on a distinguished road
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'
thanks in advance
ronak is offline   Reply With Quote

Reply

Tags
udf code

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
How to define the magnitude of "shear" rate in CFD-Post? khhan0543 Fluent UDF and Scheme Programming 0 January 24, 2017 12:51
Missing math.h header Travis FLUENT 4 January 15, 2009 12:48
How to define a Macro accessing rad intensity Grey FLUENT 0 May 21, 2007 01:12
Free surface boudary conditions with SOLA-VOF Fan Main CFD Forum 10 September 9, 2006 13:24
define my own DEFINE macro? to model pithing naca calogero FLUENT 0 April 10, 2003 06:10


All times are GMT -4. The time now is 22:14.