ABAQUS 中调用或者执行 Python 脚本有两种方法。
第一种方法,首先编写 Python 脚本文件,例如按照下面的代码编写 Python 脚本,实现批处理任务:
from ABAQUS import * from abaqusConstants import * import job import winsound jobname=['Job-1','Job-2','Job-3'] for subjob in jobname: mdb.JobFromInputFile(name=subjob,inputFileName=subjob+'.inp', numCpus=2,numDomains=2) mdb.jobs[subjob].submit() mdb.jobs[subjob].waitForCompletion() winsound.Beep(1000,1000)
简单的解释下,首先导入所需的模块备用,然后通过 for 循环遍历使用 submit() 方法提交所有的任务,其中涉及定义任务名称,cpu 和 domain 数量;waitForCompletion() 用于等待计算完成。
然后,通过 ABAQUS Command 提交运行,输入 ABAQUS CAE nogui=xxx.py 即可,运行结果如图所示。
第二种方法,直接通过 ABAQUS 界面运行 run script 运行 *.py 文件,运行结果如下:
Job Job-1: Analysis Input File Processor completed successfully. Job Job-1: ABAQUS/Standard completed successfully. Job Job-1: completed successfully. Job Job-2: Analysis Input File Processor completed successfully. Job Job-2: ABAQUS/Standard completed successfully. Job Job-2: completed successfully.