当前位置:   article > 正文

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

pyfluent


前言

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

总结

方法。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/120800
推荐阅读
相关标签
  

闽ICP备14008679号