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