1.UDF修改入口速度矢量,以模拟俯仰
DEFINE_PROFILE可以定义随空间坐标或时间变化的边界条件或单元区域条件。
可以自定义的变量有:
— 速度、压力、温度、湍流动能、湍流耗散率
— 质量流量
— 质量流量与物理流动时间的函数
— 组分质量分数(组分运输)
— 体积分数(多相模型)
— 壁面热条件(温度、热流、生热率、传热系数和外部发射率等)
— 壳层发热率
— 壁面粗糙度条件
— 壁面剪切和应力条件
— 孔隙率
— 多孔阻力方向矢量
— 壁面粘附接触角(VOF多相模型)
/*******************************************************************
#include "udf.h"
/* Define constants in SI units */
#define RE 10000 /* Reynolds number */
#define VISC 1.7894E-5 /* viscosity, N*s/m^2 */
#define DENS 1.225 /* density, kg/m^3 */
#define CHORD 0.2921 /* chord length, m */
#define NDPR 0.2 /* Non-dimensional pitch rate */
/* Define global variables */
static real aoa, aoa_old, prate, aprate, Vmag, t_o, t;
static int ts, ts_old;
DEFINE_PROFILE(x_velocity, thread, position)
{
face_t f;
Vmag = (RE*VISC)/(DENS*CHORD); /*Velocity magnitude*/
aprate = (NDPR*Vmag)/CHORD; /*Asymptotic pitching rate*/
t_o = (0.5*CHORD)/Vmag; /*Time at which the pitch rate has reach 99% of asymptotic pitching rate*/
t = CURRENT_TIME;
ts = N_TIME;
/* Define the variable pitching rate in rad/s */
prate = aprate*(1-exp((-4.6*t)/t_o));
/* Initialize aoa_old if this is first time step. */
if (t == 0)
{aoa_old = 0;}
if (ts > ts_old)
{
/* Calculate current aoa */
aoa = aoa_old + (t*prate);
}
else
{
aoa = aoa_old;
}
/* Loop through the inlet boundary and assign x velocity component */
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = Vmag*cos(aoa);
}
end_f_loop(f, thread)
}
DEFINE_PROFILE(y_velocity, thread, position)
{
face_t f;
/* Loop through the inlet boundary and assign y velocity component */
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = Vmag*sin(aoa);
}
end_f_loop(f, thread)
FILE * fp;
fp = fopen ("aoahistory.txt", "a");
fprintf(fp, "%d %e %e %e \n", ts, t, aoa_old, aoa);
fclose(fp);
/* current aoa becomes aoa_old */
aoa_old = aoa;
/* current timestep becomes t_old */
ts_old = ts;
}
2.DEFINE_ZONE_MOTION
Fluent中利用DEFINE_ZONE_MOTION宏定义区域的运动。该宏的形式:
DEFINE_ZONE_MOTION(name,omega,axis,origin,velocity,time,dtime)
其中参数:
name:symbol name。UDF名称,用户自己定义。
omega:real *omega。旋转角速度指针,默认值为0。
axis:real axis[3]。旋转轴向量数组。在2D平面模型中,默认值为(0 0 0);对于2D轴对称模型,默认值为(1 0 0)
origin:real origin[3]。旋转轴原点。默认值(0 0 0)
velocity:real velocity[3]。平移速度向量,默认值为(0 0 0)
time:real time。当前时间
3.参考文章
DEFINE_PROFILE