CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Macro for my equation (https://www.cfd-online.com/Forums/fluent-udf/192975-macro-my-equation.html)

aravind vashista September 14, 2017 15:43

Macro for my equation
 
Hii all,
i am simulating 3D supersonic flow for air and hydrogen. I want to know the mixing efficiency for the present case. The mixing efficiency is defined as follows;
∫▒((Y_f ρu)dA)/((yρu)dA)
Where
y_f={ y, y<y_s
y_s* ((1-y))⁄(1-y_s ), y>y_s
y_s is the species mass fraction and
ρ is the density
u is the velocity.
please help in finding the right macroname to define above equations. i have the basic idea of writing the code for udf, my only concern is to find the right macro to define above scalar equation.
Every UDF's are defined using DEFINE_MACRONAME(udf_name, passed-in variables) (say for example: DEFINE_PROFILE, to specify boundry conditions). I am unable to find this right Macroname.

AlexanderZ September 14, 2017 23:57

ANSYS Fluent Customization Manual:

3.2.3.6. Flow Variable Macros for Cells
For each cell in domain you can easily got the value of ->
density by C_R(c,t)
velocity by C_U(c,t);C_V(c,t);C_W(c,t)

Could you explain in details, what is the problem with case, you had described.

Best regards

aravind vashista September 15, 2017 00:44

Thank you Alexander, and i understood how to access Macros for Cell Flow Variables.
Sir in ANSYS FLUENT UDF's are defined using Functions which are supplied by Ansys Fluent in the name DEFINE_Macros contained within the header udf.h header (example: DEFINE_PROFILE, which helps in giving user defined boundary conditions (say parabolic inlet velocity profile)). In my case i am unable to find right Macroname to right my equation. please help me in finding correct Macroname (DEFINE_MACRONAME(udf_name, passed-in variables)).
Thank you

AlexanderZ September 15, 2017 01:45

Quote:

Originally Posted by aravind vashista (Post 664421)
Thank you Alexander, and i understood how to access Macros for Cell Flow Variables.
Sir in ANSYS FLUENT UDF's are defined using Functions which are supplied by Ansys Fluent in the name DEFINE_Macros contained within the header udf.h header (example: DEFINE_PROFILE, which helps in giving user defined boundary conditions (say parabolic inlet velocity profile)). In my case i am unable to find right Macroname to right my equation. please help me in finding correct Macroname (DEFINE_MACRONAME(udf_name, passed-in variables)).
Thank you

So first of all you should read ANSYS Fluent Customization Manual

In few words, there are several ways, how you can execute UDF functions:
1. DEFINE_ON_DEMAND function is executed once you manually click execute on demand in GUI of Fluent. In tutorials there is an example 2.2.9.DEFINE_ON_DEMAND
2. DEFINE_ADJUST executes at every iteration and is called at the beginning of every iteration before transport equations are solved. So you should put your functions inside this adjust_function body. See 2.2.1.DEFINE_ADJUST
3. DEFINE_EXECUTE_AT_END is executed at the end of an iteration in
a steady-state run, or at the end of a time step in a transient run. See 2.2.3.DEFINE_EXECUTE_AT_END

Depends on your algorithm you may choose one of this macros and put your functions inside.
Read tutorial, there are good enough example

Best regards

aravind vashista September 15, 2017 02:12

Quote:

Originally Posted by AlexanderZ (Post 664423)
So first of all you should read ANSYS Fluent Customization Manual

In few words, there are several ways, how you can execute UDF functions:
1. DEFINE_ON_DEMAND function is executed once you manually click execute on demand in GUI of Fluent. In tutorials there is an example 2.2.9.DEFINE_ON_DEMAND
2. DEFINE_ADJUST executes at every iteration and is called at the beginning of every iteration before transport equations are solved. So you should put your functions inside this adjust_function body. See 2.2.1.DEFINE_ADJUST
3. DEFINE_EXECUTE_AT_END is executed at the end of an iteration in
a steady-state run, or at the end of a time step in a transient run. See 2.2.3.DEFINE_EXECUTE_AT_END

Depends on your algorithm you may choose one of this macros and put your functions inside.
Read tutorial, there are good enough example

Best regards

Thank you Alexander:)
i will go through the manual and try to implement my code based on ur suggestions.
:)

wkf111222 May 21, 2023 23:24

Quote:

Originally Posted by aravind vashista (Post 664426)
Thank you Alexander:)
i will go through the manual and try to implement my code based on ur suggestions.
:)

hello sir, have you solved your problem? I have to calculate the mixing efficiency now. And would you kindly share your code with me?


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