Fluent UDF代码编写

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

  • 4
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Quincy.Liu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值