点击蓝字|关注我们
需求说明
Fluent非常强大的日志脚本功能,可以自动化任何仿真设置和操作。
Fluent提供文本用户命令(TUI命令)和界面用户命令(GUI命令),两者都是基于Scheme语言编写。对于大多数Fluent的GUI操作,都有一个相关的TUI命令对应,而有很多其他的操作只能通过TUI命令完成,本文只介绍TUI相关命令。
与UDF,expression,scheme区别
•UDF
‐基于C/C++的二次开发程序
‐可用于修改物理模型、初始化、增强后处理、增加物理模型等
‐有丰富的文档和案例
‐需要有一定的C/C++基础 ‐ANSYS不提供常规的技术支持
典型UDF代码如下
DEFINE_PROFILE(pressure_profile,t,i)
{
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y = x[1];
F_PROFILE(f,t,i) = 1.1e5 - y*y/(.0745*.0745)*0.1e5;
}
end_f_loop(f,t)
}
•Scheme
‐本身是一种脚本化的编程语言
‐Fluent的GUI(Cortex)基于/内置了Scheme解释器
‐可用于控制Fluent运行的过程
‐可用于开发用户界面
‐可用于与求解器/UDF通讯
‐可以集成Journal命令
‐只有很少的帮助文档
‐需要有较强的Scheme基础
‐ANSYS不提供常规的技术支持
典型scheme语言如下
(define my-iterate
(lambda (mark-temp)
(if (< (pick-a-real "/re/vi/max solid () temperature no" 1) mark-temp)
(begin
(ti-menu-load-string "/so/dti 1 20")
(my-iterate mark-temp)))))
•Expression
‐可以取代部分UDF、Scheme、Journal的功能,但不能完全取代
‐更加易用、易学
‐是一种基于Python的解释型的声明式语言 ‐功能 ‐指定与时间、迭代步、位置、求解变量相关的复杂的边界条件和源项
‐基于时间和迭代步指定不同的模型和求解器设置
典型expression语句如下
Vmax*(5.0*exp(t-0.3 [s]/2.8 [s]))
•Custom Field Function
‐用户定义的一个计算公式
‐基于三维网格上的信息进行计算!!!
‐可用于后处理和初始化
‐帮助文档中有丰富的说明 ‐非常易于学习
用户自定义函数界面如下

•Journal/TUI
‐是包含一系列Fluent命令流的文本
‐包含GUI和TUI两种类型,但GUI使用受限较大,本文不讲
‐可用于控制/自动化Fluent的过程
‐可以嵌套使用
‐缺乏一些复杂的控制功能,例如:•循环 •判断…
‐可与Scheme结合使用
‐非常易于学习
‐有丰富的文档资料
‐甚至无需文档,用户只需在Fluent的TUI中简单尝试即可理解掌握
典型的TUI命令如下
/file/read-case-data test.case
/solve/set/under-relaxation/mom 0.2
/solve/set/under-relaxation/pressure 0.4
/solve/iterate 200
/file/write-case-dat result.cas
TUI使用介绍






燃烧室自动化案例演示


































;; This journal is writen by wenming jing of Ansys China, plz contact wenming.jing@ansys.com for help
;; read case/mesh
/file/read-case combustor.msh.h5
;; confirm overwrite
/file/confirm-overwrite? yes
;;choose steady
define/models/steady?
;;activate energy equation
define/models/energy? yes yes yes
;;choose rke turbulence model
define/models/viscous/ke-realizable? yes
;;define operating conditions
define/operating-conditions/operating-pressure 101325 gravity yes 0 -9.8 0 q
;; combustion model setting
define/models/species/partially-premixed-combustion? yes yes no yes 101325 no no 0.1 315 500 yes "jet-a
" 1 0 "n2" 0 0.767 "o2" 0 0.233 , , , yes 15 200 0.25 0.25 20 298 no "combustor.pdf" yes
;;DPM model setting
define/models/dpm/interaction/coupled-calculations? yes
define/models/dpm/interaction/dpm-iteration-interval 30
define/models/dpm/interaction/update-dpm-sources-every-flow-iteration? no
define/models/dpm/unsteady-tracking no
/define/models/dpm/numerics/tracking-parameters 50000 no 5
;;DPM injection setting
define/models/dpm/injections/create-injection , yes droplet yes surface diesel-liquid fuelinlet () no no no no no no jet-a
no 0 0 10 0.0001 315 0.01 ;;read injection file
;;/file/read-injections injection-file
;; inletair1 setting
define/boundary-conditions/velocity-inlet inletair1 , , , , , 40 , , , 500 , , , , , , , , , , , ,
;;another way inletair1 setting
;;define/boundary-conditions/set/velocity-inlet inletair1 () vmag no 31 temperature no 319 fmean no 0 premixc no 0 fvar no 0 q
;; inletair2 setting
define/boundary-conditions/velocity-inlet inletair2 , , , , , 30 , , , 500 , , , , , , , , , , , ,
;; fuelinlet setting
define/boundary-conditions/velocity-inlet fuelinlet , , , , , 15 , , , 300 , , , , , , , , 1 , , ,
;; outlet setting
define/boundary-conditions/pressure-outlet outlet , , 0 , 800 , , , , , 5 10 , 0 , , , , , , , , ,
;; wall setting
define/boundary-conditions/wall mainbody:1 , , , , , , 0 , , , , , , , , , , , , , , , ,
;;hybrid initialization
solve/initialize/hyb-initialization
;;report definition
solve/report-definitions/add max-temp volume-max zone-names mainbody , field temperature report-type volume-max q
;;add report to plot and file
solve/report-plot/add max-temp plot-instantaneous-values? yes report-defs max-temp () q
solve/report-files/add max-temp report-defs max-temp () write-instantaneous-values? yes file-name max-temp.out q
;;define a surface plane
display/surface/plane-surface midplane zx-plane 0
;;setting up midplane velocity contour
display/objects/create contour midplane-velocity field velocity-magnitude surfaces-list midplane , q
;;setting up midplane velocity vector
display/objects/create vector midplane-v-vector field velocity-magnitude surfaces-list midplane , q
;;setting up auto save
/file/auto-save/ case-frequency if-case-is-modified data-frequency 1000 retain-most-recent-files yes root-name combustor
;;freeze specify equation
/solve/set/equations/premixed no
;;activate permixed equation
/solve/set/equations/premixed no
;; solve for 200 iteration
solve/iterate 100
;;activate specify equation
/solve/set/equations/premixed yes
;;patch temperature
solve/patch mainbody () temperature 3000
;;patch progress variable
solve/patch mainbody () premixc 1
;; solve for 1000 iteration
solve/iterate 1000
以往相关文章
上述案例所用网格链接如下:https://pan.baidu.com/s/1i_o2017vMjajq2cmaMO88g
提取码:q5ns

求分享

求点赞

求在看
本篇文章来源于微信公众号: Ansys 流体大本营
评论前必须登录!
注册