赞
踩
Python-Fluent coupled simulation:
Python equals to a client(客户端), and Fluent equals to a server(服务器), combined as a CS model.
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.
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
方法。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。