|
[Sponsors] |
May 8, 2009, 05:41 |
How to write equation into UDF?
|
#1 |
New Member
Jane
Join Date: Mar 2009
Posts: 18
Rep Power: 17 |
I want to write the shear rate equation (as shown in attachment) into UDF
But i don't know how to translate the equation into UDF language. Please help me... |
|
May 8, 2009, 07:22 |
|
#2 |
Member
Daniel Tanner
Join Date: Apr 2009
Posts: 54
Rep Power: 18 |
Here is some info to get you started:
1) You can loop over all the cells in your domain and calculate your variables of interest using the UDF at the weblink below (remove the second loop "begin_f_loop(f,t)"): http://www.cfd-online.com/Forums/flu...cent-wall.html 2) At each cell you calculate your equation and can save it in user defined memory (C_UDMI). There are macros that will help by allowing you to access the cell velocity gradient variables. Read the UDF manual or type Cell Macros in to google. The macros will have the form: C_U_G(c,t)[i], C_V_G(c,t)[i], C_W_G(c,t)[i]. |
|
May 8, 2009, 09:09 |
|
#3 |
New Member
Jane
Join Date: Mar 2009
Posts: 18
Rep Power: 17 |
Thank you Daniel Tanner
i've tried to write the equation to the UDF but there are still have something that i'm not understand. i define the u, v, w as: real shear_rate; real u = C_U_G(cell, thread); real v = C_V_G(cell, thread); real w = C_W_G(cell, thread); when i compiled the UDF file, then fluent show the below messages ..\..\src\viscosity1SR.c(23) : error C2440: 'initializing' : cannot convert from 'real *' to 'real' ..\..\src\viscosity1SR.c(24) : error C2440: 'initializing' : cannot convert from 'real *' to 'real' ..\..\src\viscosity1SR.c(25) : error C2440: 'initializing' : cannot convert from 'real *' to 'real' the number 23,24,25 refer to u, v, w that i define above. why the messages show cannot convert from 'real *' to 'real', what should i define the u, v, w?? |
|
May 8, 2009, 10:04 |
|
#4 |
Member
Daniel Tanner
Join Date: Apr 2009
Posts: 54
Rep Power: 18 |
It's worth browsing UDF examples on the net to figure out how they are structured. It will be something like this:
real u, v, w; thread_loop_c(ct, d) { begin_c_loop(c,ct) { /* For each Cell you loop over you perform calculation and store */ u = C_U_G(c, ct)[1]; v = C_V_G(c, ct)[1]; w = C_W_G(c, ct)[1]; Answer = u + v - w; /* This stores the calculation */ C_UDMI(c,ct,0) = Answer; } end_c_loop(c,ct) } } Be careful C_U_G(c, ct)[0] returns dU/dx where [0] tells the macros you want dx, i.e., [1] = y and [2] z (google them!). Similarly C_V_G is for V and C_W_G for W components of velocity. Good luck. |
|
May 8, 2009, 10:52 |
|
#5 |
New Member
Jane
Join Date: Mar 2009
Posts: 18
Rep Power: 17 |
Thank you very much Daniel Tanner
i will try to rewrite it. Thank you again. |
|
May 9, 2009, 21:58 |
|
#6 |
New Member
Jane
Join Date: Mar 2009
Posts: 18
Rep Power: 17 |
if i want to calculate another equation that require shear rate value, so which shear rate or C_UDMI(c,ct,0) i need to taking account into 2nd equation??
eg. (1) X= shear_rate*a/b or (2) X= C_UDMI(c,ct,0)*a/b |
|
May 10, 2009, 21:49 |
|
#7 |
New Member
Jane
Join Date: Mar 2009
Posts: 18
Rep Power: 17 |
i have some question about "return" function in the UDF writing.
for example i found most of the equation in UDF end with eg. "return X" like eg. from fluent documentation: DEFINE_SOURCE(p1_source, c, t, dS, eqn) { real source; int P1 = ...; dS[eqn] = -abs_coeff; source = abs_coeff *(4.* SIGMA_SBC * pow(C_T(c,t),4.) - C_UDSI(c,t,P1)); return source; } why we need to put return for the equation??? if no return function for equation, what would happen??? Please explain for me....i cannot found the reason in fluent documentation....help Last edited by Jane; May 11, 2009 at 00:02. |
|
May 15, 2009, 16:32 |
|
#8 | |
Member
Join Date: Mar 2009
Location: Istanbul, Turkiye
Posts: 47
Rep Power: 17 |
Hi,
in your example, source term is being calculated and store in variable source. but you have to pass the value of source into fluent solver. thus in most of the functions/macros you add return XXX pass your calculation result (value of source in this example) into the FLUENT solver. Quote:
|
||
August 29, 2023, 03:23 |
How to write two reaction rates equations in UDF
|
#9 |
Member
George Corner
Join Date: Dec 2016
Posts: 30
Rep Power: 10 |
Hello,
I want to know how to write two reaction rates in a single UDF. I mean two reaction rate equations (Volumetric rate) in UDF. In the UDF manual (April 2009 p: 8-38), there is an example only for one reaction rate, but I am wondering how to extend it to two or more. Thanks a lot. |
|
August 30, 2023, 00:03 |
|
#10 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
make the second reaction rate macro with other name
__________________
best regards ****************************** press LIKE if this message was helpful |
|
August 30, 2023, 05:53 |
|
#11 |
Member
George Corner
Join Date: Dec 2016
Posts: 30
Rep Power: 10 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 22:38 |
how to write UDF to define 2 profiles at inlet? | emma | FLUENT | 5 | January 30, 2011 06:22 |
UDF to write a data file | lichun Dong | FLUENT | 2 | August 4, 2005 12:21 |
UDF (write a data file) problem | lichun Dong | FLUENT | 2 | July 29, 2005 12:39 |
how to write a udf about roatation of rigid. | ccgwin | FLUENT | 3 | December 11, 2002 09:14 |