Python编写abaqus后处理脚本(学习笔记)


本节内容参考自书籍《Python语言在Abaqus中的应用》,注意:以下代码为伪代码,仅供参考

1、导入必要的模块,加载后处理odb文件

from abaqus import *
from abaqusConstants import *
from odbAccess import*
import os
odb=openOdb(path='job-1.odb')

2、常用获取模型数据的api

#输出所有部件实例名称,在cae界面能看到结果,该部分代码只能在abaqus command环境下运行
for instanceName in odb.rootAssembly.instances.keys():
    print instanceName

#调用部件实例所有节点集名
print 'Node set=',odb.rootAssembly.instances['PART-1-1'].nodeSets.keys()

#所有单元集名
print 'Element set=',odb.rootAssembly.instances['PART-1-1'].elementSets.keys()

#输出所有材料的名称
allMaterials=odb.materials
for materialName in allMaterials.keys():
    print 'Material Name:',materialName

#输出分析步的关键字
for stepName in odb.steps.keys():
    print stepName

#帧赋值
lastFrame=odb.steps['Step-1'].frames[-1]

#读取场输出数据,列出分析步最后一帧的所有变量
for fieldName in lastFrame.fieldOutputs.keys():
    print fieldName
#输出最后一帧场输出的变量名、描述和成员类型
for f in lastFrame.fieldOutputs.values():
    print f.name,':',f.description
    print 'Type:',f.type
    #对于每个计算值,输出其位置
    for loc in f.locations:
        print 'Position:',loc.position
    print

3、输出odb文件中的位移信息

#获取WALL部分位移---节点集合
wall=odb.rootAssembly.instances['PART-1-1'].nodeSets['WALL']
print(odb.steps['water5'])
lastFrame=odb.steps['water5'].frames[1]
displacement=lastFrame.fieldOutputs['U']
wall_Disp=displacement.getSubset(region=wall)
wall_U=wall_Disp.values
print(len(wall_U))

#位移输出为txt文件
full_path='D:\\abaqus1\\'+'1111111111111.txt'
f=open(full_path,'a+')
for i in [400,800,1200]:
    f.write('%7.4f %7.4f %7.4f ' % (wall_U[i].data[0],wall_U[i].data[1],wall_U[i].data[2]))
f.write('\n')
f.close()

4、输出odb文件中的应力信息

#获取防渗墙wall部分的节点集合,输出应力值
#获取防渗墙的单元集合
wall_1=odb.rootAssembly.instances['PART-1-1'].elementSets['HMPROP_WALL1']
stress=lastFrame.fieldOutputs['S']
wall_Stress=stress.getSubset(region=wall_1)
wall_S=wall_Stress.values
print('wall_S number:',len(wall_S))

# 输出应力
full_path='C:\\abaqus2\\'+'wall_S.txt'
f=open(full_path,'w+')
for i in wall_S:
    f.write('%d %7.4f %7.4f %7.4f \n' % (i.elementLabel,i.mises,i.maxPrincipal,i.minPrincipal))
else:
    f.close()


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM