Python extracts field information of ODB files in abaqus

How to extract the field information of the ODB file in abaqus, the following describes the displacement field as an example. This needs to be explained briefly. After reading the explanation, look at the source code.
1. Decoding
This line is a must in the file and cannot be deleted, otherwise it cannot be decoded and an error will be reported

# -* - coding:UTF-8 -*-

2. Read ODB and load step
Here the openOdb function comes from odbAccess, so we need to import the library

from odbAccess import*# 打开odb的库

The following reading path is drawn up by yourself. Generally, it is under the working path you set. You can copy it to other folders, but note that it must be an English path, and then read the loading step. Generally, we will reduce the strength. Load the reduction field for gravity occasions. What I read here is the reduction field. 'Reduce' is the name of the loading step I set when modeling. It needs to be matched. If you don’t remember to check the inp file, you will know it, as shown below
insert image description here
insert image description here

odb=openOdb(path='Job-1.odb')# 读取odb
step1=odb.steps['Reduce']# 读取odb.折减用Load和Reduce

3. Select the time to read.
insert image description here
How many format files we want to check? We can check the length of step1.frames, or directly check the numbers in the above picture. We generally only need to look at the final result, so we use step1.frames here [-1]

len(step1.frames)

4. Reading field
I am drawing a two-dimensional section, so only x and y are available. If it is a three-dimensional Z direction, it is v.data[2]

for v in displacementValues_last:#这里保存最后一步的位移场
    DISP.append([v.nodeLabel,v.data[0],v.data[1]])# 节点编号,X位移,Y位移,Z位移

5. Save our field variable
Here we should pay attention, do not put it in the working directory of our model, it cannot be saved.

with open('E:\\abaqus_field\\field.txt', 'w') as f:
    for i in DISP:
        i=(','.join(str(j) for j in i))
        f.write(str(i) + '\n')

Save the result
The first column is the node needs, followed by the displacement number
insert image description here
6 in the x and y directions. Finally, the extracted result and the result cloud image on abaqus
seem to have a problem. It may be that there is a problem with the coordinates I extracted. Follow-up It needs to be corrected.
Note that
the final code file must be run in the script run in abaqus. This file must be placed in the English path, otherwise it cannot be found.
insert image description hereinsert image description here

complete code

#!/user/bin/python
# -* - coding:UTF-8 -*-
# 功能:读取变形位移

import numpy as np# 可输出txt文件
from odbAccess import*# 打开odb的库
import os
import sys

odb=openOdb(path='Job-1.odb')# 读取odb
step1=odb.steps['Reduce']# 读取odb.折减用Load和Reduce

firstFrame=step1.frames[0]# 第一帧
lastFrame=step1.frames[-1]# 最后一帧 # 读取odb.step.frames

# 第一帧
displacement_first=firstFrame.fieldOutputs['U'] # 读取odb.step.frames.fieldOutputs
displacementValues_first=displacement_first.values# 读取odb.step.frames.fieldOutputs.values

# 最后一帧
displacement_last=lastFrame.fieldOutputs['U']# 读取odb.step.frames.fieldOutputs
displacementValues_last=displacement_last.values# 读取odb.steps.frames.fieldOutputs.values

# txt文件导出
DISP = []
for v in displacementValues_last:#这里保存最后一步的位移场
    DISP.append([v.nodeLabel,v.data[0],v.data[1]])# 节点编号,X位移,Y位移,Z位移
    #DISP.append(v.data)# X位移,Y位移,Z位移
    # print DISP
# np.savetxt('DISP.txt',DISP)
with open('E:\\abaqus_field\\field.txt', 'w') as f:
    for i in DISP:
        i=(','.join(str(j) for j in i))
        f.write(str(i) + '\n')
odb.close

Guess you like

Origin blog.csdn.net/self_Name_/article/details/127472586