工作路径下用CMD启动fluent(相对路径读写文件)

1、os获取文件路径

path, filename = os.path.split(os.path.abspath(__file__))  # 获取当前文件的路径
os.getcwd()  # 获取当前工作目录
file_path = os.path.abspath(filename) # 获取文件路径

2、提取路径中的盘符信息

disk = os.path.abspath(file_path)[:2]

3、提取fluent路径

fluent_path = “C:\Program Files\ANSYS Inc\v201\fluent\ntbin\win64\fluent”

4、组合cmd命令行(跳转到文件盘符D,跳转到文件路径D:\works,带jou运行4核启动fluent)

'D: && cd D:\works && “C:\Program Files\ANSYS Inc\v201\fluent\ntbin\win64\fluent” 3d -t4 -i test.jou'

意义:在工作路径下启动fluent,读写文件(jou、cas、msh)时可采用相对路径

原文地址:https://www.cnblogs.com/Roye/p/12705536.html