CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Writing UDF to represent drag equations (https://www.cfd-online.com/Forums/fluent/152210-writing-udf-represent-drag-equations.html)

Dawood Al-Mosuli April 26, 2015 12:53

Writing UDF to represent drag equations
 
Hello,
I am new with using UDF. I tried to write one to represent the drag equations in the attached file for 3 phase flow (1 liquid and 2 solid).

I tried to write one similar (below) to that provided in section 2.4.2 DEFINE_EXCHANGE_PROPERTY in UDF manual [UDF for customizing the default Syamlal drag law in Fluent] , but it doesn't work. It seems that I have a problem with defining inputs [I got error when defining the solid fraction Es].

/************************************************** *************
UDF for customizing the default Syamlal drag law in Fluent
************************************************** **************/

#include "udf.h"

#define pi 4.*atan(1.)
#define diam2 0.000163

DEFINE_EXCHANGE_PROPERTY(custom_drag,cell,mix_thre ad,s_col,f_col)
{
Thread *thread_l, *thread_s;
real x_vel_l, x_vel_s, y_vel_l, y_vel_s, abs_v, slip_x, slip_y,
rho_l, rho_s, mu_l, reyp, afac,
bfac, void_l, vfac, fdrgs, taup, k_g_s;

/* find the threads for the gas (primary) */
/* and solids (secondary phases) */

thread_l = THREAD_SUB_THREAD(mix_thread, s_col);/* gas phase */
thread_s = THREAD_SUB_THREAD(mix_thread, f_col);/* liquid phase*/

/* find phase velocities and properties*/

x_vel_l = C_U(cell, thread_l);
y_vel_l = C_V(cell, thread_l);

x_vel_s = C_U(cell, thread_s);
y_vel_s = C_V(cell, thread_s);

slip_x = x_vel_l - x_vel_s;
slip_y = y_vel_l - y_vel_s;

rho_l = C_R(cell, thread_l);
rho_s = C_R(cell, thread_s);

mu_l = C_MU_L(cell, thread_l);
void_l = C_VOF(cell, thread_l);/* gas vol frac*/


k_g_s =(6 / 27) * (3.6*Es / pow(El,2.0) + pow (El,2.0)) + (0.11 + ( 2*K /(3 * pow(Vs, 2.0))));


return k_g_s;
}




I got the error : Es: undeclared variable
Can any one give me instructions about my mistakes and how to write a correct one.

`e` April 27, 2015 05:02

You should have posted your UDF question in Fluent UDF and Scheme Programming. There are no attached files in your post.

Quote:

Originally Posted by Dawood Al-Mosuli (Post 543798)
I got the error : Es: undeclared variable
Can any one give me instructions about my mistakes and how to write a correct one.

If you have not declared "Es" then this variable is an undeclared variable and you should first declare this variable before attempting to access this variable.


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