python调用nastran_如何使用Python代碼控制MSC NASTRAN等FEA軟件?

本文讨论了如何使用Python调用MSC NASTRAN进行有限元分析。作者尝试通过`os.system()`启动NASTRAN未成功,并寻求帮助。两个解决方案提出:1) 使用NASTRAN的API进行更高级的交互;2) 创建批处理文件(.bat)并通过Python运行。示例批处理文件内容展示了如何指定参数,如内存分配和输出选项。
摘要由CSDN通过智能技术生成

I would like to run MSC NASTRAN using python. I have seen a similiar function in MATLAB using system('nastran.exe file_name.bdf') #where file_name.bdf is the input file to Run using nastran.

我想使用python運行MSC NASTRAN。我在MATLAB中使用system('nastran.exe file_name.bdf')看到了一個類似的函數#where file_name.bdf是使用nastran運行的輸入文件。

Hence i tried below using python code, but it did not work,

因此我嘗試下面使用python代碼,但它不起作用,

import os

os.system('nastran.exe file_name.bdf')

Could you tell me where i going wrong?

你能告訴我哪里出錯了嗎?

Also, how to give the command line in NASTRAN thru python? Like for example memory allocation for the run, number of cores need to be used for run etc.

另外,如何通過python在NASTRAN中提供命令行?例如,對於運行的內存分配,需要使用核心數量來運行等。

some NASTRAN command lines include, 1. scr=yes delete=f04,log,xdb pause=yes 2. mem=10gb bpool=3gb memorymaximum=14gb sscr=500gb sdball=500gb mode=i8 ...etc.

一些NASTRAN命令行包括,1。scr = yes delete = f04,log,xdb pause = yes 2.mem = 10gb bpool = 3gb memorymaximum = 14gb sscr = 500gb sdball = 500gb mode = i8 ...等。

2 个解决方案

#1

1

I can't speak directly for MSC Nastran, its been a while since I've used it. But most modern FEA programs have an API (application program interface) to allow you to call commands from a external program like python or matlab.

我不能直接為MSC Nastran說話,因為我使用它已經有一段時間了。但是大多數現代FEA程序都有一個API(應用程序接口),允許您從外部程序(如python或matlab)調用命令。

Without an API, you may be limited to using python to start the program from the command line, which is what your code is trying to do. As for how to launch a program from within python, check out this question/answer: How to run application with parameters in Python?

如果沒有API,您可能只能使用python從命令行啟動程序,這是您的代碼嘗試執行的操作。至於如何從python中啟動程序,請查看這個問題/答案:如何在Python中運行帶參數的應用程序?

#2

0

Easy way to run a MSC NASTRAN file is to create a .bat file and run it from python. The format for .bat file is:

運行MSC NASTRAN文件的簡便方法是創建一個.bat文件並從python運行它。 .bat文件的格式為:

An example can be :

一個例子可以是:

C:\MSC.Software\MSC_Nastran\20141\bin\nastran.exe C:\py_nastran_run\example.bdf scr=yes old=no delete=f04,log,xdb

Then include the below line in python script,

然后在python腳本中包含以下行,

status=subprocess.call("runBatch.bat")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值