读取流程如下:
from abaqus import *
from abaqusConstants import *
以上语句使脚本可以访问基本的 Abaqus 对象以及 Abaqus 脚本接口中定义的所有符号常量。
import visualization
此语句提供对在 Abaqus/CAE (Abaqus/Viewer) 中复制可视化模块功能的命令的访问。
myViewport = session.Viewport(name='Superposition example')
此语句在会话中创建一个名为“Superposition example”的新视口。 新视口被分配给变量 myViewport。 视口的原点和大小采用默认值。
odbPath = 'viewer_tutorial.odb'
此语句创建教程输出数据库的路径。
myOdb = session.openOdb(path=odbPath)
此语句使用路径变量 odbPath 打开输出数据库并将其分配给变量 myOdb。
myViewport.setValues(displayedObject=myOdb)
此语句在视口中显示输出数据库的默认绘图。
firstStep = myOdb.steps['Step-1']
secondStep = myOdb.steps['Step-2']
这些语句将输出数据库中的第一步和第二步分配给变量 firstStep 和 secondStep。
frame1 = firstStep.frames[-1]
frame2 = secondStep.frames[-1]
这些语句将第一步和第二步的最后Frame分配给变量 frame1 和 frame2。 在 Python 中,索引 0 指的是序列中的第一项。 –1 的索引指的是序列中的最后一项。
displacement1 = frame1.fieldOutputs['U']
displacement2 = frame2.fieldOutputs['U']
这些语句将第1步和第2步画面中的位移场输出分配给变量displacement1 和displacement2。
stress1 = frame1.fieldOutputs['S']
stress2 = frame2.fieldOutputs['S']
类似地,这些语句将第一步和第二步最后一帧的应力场输出分配给变量stress1 和stress2。
deltaDisplacement = displacement2 - displacement1
该语句从两步的最后一帧中减去位移场输出,并将结果场输出放入新变量 deltaDisplacement 中。
deltaStress = stress2 - stress1
类似地,该语句减去应力场输出并将结果放入变量 deltaStress 中。
myViewport.odbDisplay.setDeformedVariable(deltaDisplacement)
该语句使用我们之前创建的位移场输出变量 deltaDisplacement 来设置变形变量。 这是 Abaqus 将用来显示变形模型形状的变量。
myViewport.odbDisplay.setPrimaryVariable(field=deltaStress,
outputPosition=INTEGRATION_POINT,
refinement=(INVARIANT, 'Mises'))
该语句使用我们的应力场输出变量 deltaStress 来设置主要变量。 这是 Abaqus 将在等高线或符号图中显示的变量。
myViewport.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
最后的语句将绘图状态设置为在变形模型形状上显示等高线图。
"""
odbExample.py
Script to open an output database, superimpose variables
from the last frame of different steps, and display a contour
plot of the result.
"""
from abaqus import *
from abaqusConstants import *
import visualization
myViewport = session.Viewport(name='Superposition example',
origin=(10, 10), width=150, height=100)
# Open the tutorial output database.
myOdb = visualization.openOdb(path='viewer_tutorial.odb')
# Associate the output database with the viewport.
myViewport.setValues(displayedObject=myOdb)
# Create variables that refer to the first two steps.
firstStep = myOdb.steps['Step-1']
secondStep = myOdb.steps['Step-2']
# Read displacement and stress data from the last frame
# of the first two steps.
frame1 = firstStep.frames[-1]
frame2 = secondStep.frames[-1]
displacement1 = frame1.fieldOutputs['U']
displacement2 = frame2.fieldOutputs['U']
stress1 = frame1.fieldOutputs['S']
stress2 = frame2.fieldOutputs['S']
# Find the added displacement and stress caused by
# the loading in the second step.
deltaDisplacement = displacement2 - displacement1
deltaStress = stress2 - stress1
# Create a Mises stress contour plot of the result.
myViewport.odbDisplay.setDeformedVariable(deltaDisplacement)
myViewport.odbDisplay.setPrimaryVariable(field=deltaStress,
outputPosition=INTEGRATION_POINT,
refinement=(INVARIANT, 'Mises'))
myViewport.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
参考: