通过mode=“solver/meshing”可以选择需要打开的模式,如果不进行定义的话默认打开求解器模式
import ansys.fluent.core as pyfluent
solver_session = pyfluent.launch_fluent(mode="solver")#求解器
meshing_session = pyfluent.launch_fluent(mode="meshing")#Fluent Meshing
基础求解设置
求解设置主要定义的是下图中标记的部分,我们一般常用的设置为2D/3D模式选择、双精度模式以及求解核心数。通过PyFluent实现上述功能只需要在launch_fluent()函数中添加功能名称+选项即可。
例如设置求解模式为双精度,2D,4核心,代码如下所示
import ansys.fluent.core as pyfluent
solver_session = pyfluent.launch_fluent(mode='solver',
precision='double',
version='2d',
processor_count=4,
show_gui=True)
如果不进行定义,其默认为双精度、3D、1核心.
TUI命令及转换
TUI命令在早期版本的Fluent中十分常用,使用TUI可以在Fluent中实现一定程度的自动化。
在PyFluent中同样可以使用TUI命令运行各项功能,无需额外的学习成本,需要注意的是PyFluent中无法识别缩写的TUI命令。
例如我们使用TUI定义边界条件
/define/boundary_conditions/set/velocity-inlet
定义velocity-inlet-5的温度为293.15k
/define/boundary-conditions/set/velocity-inlet velocity-inlet-5 () temperature no 293.15 quit
在PyFluent中的格式如下所示,注意符号使用上与TUI的差异
from ansys.fluent.core import launch_fluent
solver_session = launch_fluent(mode="solver")
tui = solver_session.solver.tui
tui.define.boundary_conditions.set.velocity_inlet(
"velocity-inlet-5", [], "temperature", "no", 293.15, "quit"
)
另外一个例子,在TUI中修改单位
/define/units
pressure
"Pa"
而在PyFluent中为
tui.define.units("pressure", '"Pa"')
最后总结以下TUI 命令转PyFluent规则
1.路径元素中的每个连字符(-)都转换为下划线(_)
2.路径元素中的问号都需要删除。