How to write equation into UDF?
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...
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)"):
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].
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 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??
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;
/* For each Cell you loop over you perform calculation and store */
u = C_U_G(c, ct);
v = C_V_G(c, ct);
w = C_W_G(c, ct);
Answer = u + v - w;
/* This stores the calculation */
C_UDMI(c,ct,0) = Answer;
Be careful C_U_G(c, ct) returns dU/dx where  tells the macros you want dx, i.e.,  = y and  z (google them!). Similarly C_V_G is for V and C_W_G for W components of velocity.
Thank you very much Daniel Tanner
i will try to rewrite it.
Thank you again.:)
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??
(1) X= shear_rate*a/b
(2) X= C_UDMI(c,ct,0)*a/b
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)
int P1 = ...;
dS[eqn] = -abs_coeff;
source = abs_coeff *(4.* SIGMA_SBC * pow(C_T(c,t),4.) - C_UDSI(c,t,P1));
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
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.
|All times are GMT -4. The time now is 02:45.|