【Python与Fluent的二次开发-TUI及Scheme代码】[Note 2]


前言

Python-Fluent coupled simulation:

Python equals to a client(客户端), and Fluent equals to a server(服务器), combined as a CS model.


一、Fluent配置环境

Enviroment Configuration

First define the working directory of the fluent. *Note the working directory should include the *.msh and *.py file.
在这里插入图片描述
Launch the Fluent as a server. FLUENT_AAS=1&OK
在这里插入图片描述
Then, the three .txt files are generated automatically in the working directory.
在这里插入图片描述

二、Python

1.import 库

ICoFluentUnit provide a set of functions: load and save case or data, set iterations, calculate and so on.
————————————————

Python

import time
import pathlib
import os
import sys
import io
from fluent_corba import CORBA
import AAS_CORBA #import the AAS_CORBA module compiled from CoFluentUnit.idl
import subprocess
from functools import partial

Matlab

orb=initialize_orb();
load_ansys_aas;
FluetnPath = 'Your own fluent work path';
aaS_Path = char(FluetnPath+"aaS_FluentId.txt");
 
ICoFluentUnit = actfluentserver(orb,aaS_Path);
iFluentTuiInterpreter = ICoFluentUnit.getSchemeControllerInstance();
 
ICoFluentUnit.loadCase('XX.cas');
iFluentTuiInterpreter.doMenuCommand('/display/mesh');
% 任务1、获取流体力
fileId = fopen(FluetnPath+"force.txt", 'r');
[force, count] = fscanf(fileId, '%f') ;
fclose(fileId);   
    
% 任务2、运动方程求解位移
[vel_n, dis_n] = calculate_y_motion(force(end), vel, dis);
dis_history = [dis_history,dis_n];
    
% 任务3、将位移传递到fluent中进行迭代求解
set_dis_commnd = strcat("(rpsetvar 'vel_n ", num2str(vel_n), ").");
iFluentTuiInterpreter.execScheme(set_dis_commnd)
————————————————
此代码为CSDN博主「小碗拉面不加香菜~」原文链接:https://blog.csdn.net/weixin_42130488/article/details/122920156



总结

方法。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ANSYS Fluent是一款流体动力学(CFD)仿真软件,可用于模拟和分析流体流动、传热和化学反应等现象。为了满足用户的特定需求,ANSYS Fluent还提供了二次开发的功能,允许用户根据自己的需求进行软件定制和功能扩展。 ANSYS Fluent二次开发指南主要包括以下几个方面的内容: 1. 开发环境搭建:ANSYS Fluent二次开发需要使用特定的编程语言和开发环境。在开发环境搭建中,需要安装相应的编程工具和软件包,并设置相关的环境变量。ANSYS Fluent支持多种编程语言,如C/C++、FORTRAN和Python等。 2. 开发接口介绍:ANSYS Fluent提供了多种开发接口,如UDF(用户定义函数)、TUI(文本用户界面)和APDL(ANSYS Parametric Design Language)等。通过这些接口,用户可以自定义模型、设置边界条件、定义物性和添加新的求解器等。 3. 开发示例和文档:ANSYS Fluent二次开发指南提供了丰富的开发示例和详细的文档,帮助用户理解和掌握二次开发的方法和技巧。这些开发示例可以直接运行,并包含详细的说明和注释,方便用户学习和参考。 4. 调试和优化技巧:在二次开发过程中,可能会出现各种问题和错误。ANSYS Fluent二次开发指南提供了调试和优化的技巧,帮助用户分析和解决问题,并提高开发效率和代码性能。 ANSYS Fluent二次开发指南通过系统化的指导和说明,帮助用户快速入门和掌握二次开发技能,实现对ANSYS Fluent的个性化定制和功能扩展。通过使用二次开发功能,用户可以更加灵活地应用ANSYS Fluent,并满足自己的特定需求。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值