许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  Fluent UDF代码编写:从入门到实战

Fluent UDF代码编写:从入门到实战

阅读数 3
点赞 0
article_banner

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
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空