Professional Documents
Culture Documents
※
第3讲
L3.2
概要
• Abaqus 输出数据库
• 自动后处理任务
• 外部数据的后处理
• 实例
• 习题
L3.4
Abaqus 输出数据库
• 输出数据库对象模型中的一部分: 模型数据和结果数据
场数据
历史数据
Abaqus 输出数据库
• 打开输出数据库
from odbAccess import *
odb = session.openOdb(r'd:\smith\data\axle.odb')
• 分析步对象
• Abaqus 分析包含一个或多个分析步
• 每个分析步对应一个分析类型
• 访问分析步
crushStep = odb.steps['Crush']
• 框架对象(Frame object)
• 每个分析步包含一系列框架,框架将每个增量步的结果输出到数据库中。
• 在频率提取分析和特征值屈曲分析中,每个特征模态都单独保存为一个
框架。
L3.6
Abaqus 输出数据库
• 访问 crushStep 分析步的最后一个框架
crushFrame = crushStep.frames[-1]
• 场变量输出对象
• 场变量输出对象包含一系列场变量值(例如,所有单元每个积分点的应力
张量)
• 每个场变量值包含许多信息,例如:
elementLabel, nodeLabel, position, face,
integrationPoint, sectionPoint, type, data, magnitude,
mises, tresca, press, inv3, maxPrincipal, midPrincipal,
etc.
Abaqus 输出数据库
• 场变量输出(应力)
stress = crushFrame.fieldOutputs['S']
• 输出应力结果
stress = odb.steps['Crush'].frames[-1].fieldOutputs['S']
L3.8
Abaqus 输出数据库
• 对于给定的场变量输出对象 stress,提取其结果非常简单:
for stressValue in stress.values:
print stressValue.mises
• 采用 getSubset 方法,可以得到模型中一定区域的更多结果,并将返回
另外一个场变量输出对象。
• getSubset()中的自变量包括位置、截面点、区域、局部坐标系。
• getSubset()中位置(position)这个自变量中的可能值包括:
INTEGRATION_POINT, NODAL, ELEMENT_NODAL, CENTROID.
Abaqus 输出数据库
• 场变量输出对象支持数学运算
• 张量和矢量运算
• 例如: stress1 + stress2
2.*stress
• 运算后还需计算不变量
• 所有的操作必须是相容的,例如:
• stress + disp 运算操作将抛出异常;
• 积分点的数据(INTEGRATION_POINT data)不能与单元节点
数据( ELEMENT_NODAL data )一起运算;
• 需要在保存数据所在的坐标系下进行运算操作
• 运算操作符包括: +, -, *, /, abs(), acos(), asin(), atan(), cos(),
degreeToRadian(), exp(), exp10(), log(), log10(), power(),
radianToDegree(), sin(), sqrt(), tan()
L3.10
Abaqus 输出数据库
• HistoryRegion 对象
• 在 HistoryRegion 对象中,包含单个点所有历史输出请求的结果数据或
者模型某个区域所有的计算结果(例如能量)。
• 历史输出区域指的是模型中特定的点或区域。根据输出数据的类型,历史
输出区域一般包括下列几种情况:
• 节点
• 积分点
• 某个区域
• 材料点
• 访问历史输出所在区域
endPoint = crushStep.historyRegions['end point']
Abaqus 输出数据库
• 历史输出(HistoryOutput )对象
• HistoryRegion 中包含多个历史输出对象。历史输出对象包含分析步中
特定点或区域所有时间间隔上的输出结果,例如 ((t1, U21), (t2, U22),
etc.).
• 访问历史输出
u2Deflection = endPoint.historyOutputs['U2']
• 给定历史输出对象 u2Deflection 后,提取结果非常简单。
for time, value in u2Deflection.data:
print 'Time:', time, 'U2 deflection:', value
L3.12
Abaqus 输出数据库
• 历史输出对象支持数学运算操作
• 与历史输出对象类似,场输出(FieldOutput)对象也支持数学运算操作
• 例子(计算矢量的大小)
mag = 0
componentLabels = ('U1', 'U2', 'U3')
for label in componentLabels:
mag = mag + power(endPoint.historyOutput[label], 2.)
mag = sqrt(mag)
• 很显然,运算操作只能计算数值,而不能对时间操作。
Abaqus 输出数据库(odbAccess.py)
• 一个完整的实例 (打印节点集中每个节点的位移数据)
import odbAccess
odb = session.openOdb('indentfoam_std_visco_2.odb')
# Create a variable that refers to the last frame of the first step.
lastFrame = odb.steps['Step-1'].frames[-1]
# Create a variable that refers to the displacement 'U' in the last frame of the first step.
displacement = lastFrame.fieldOutputs['U']
# Create a variable that refers to the node set 'PUNCH' located at the center of the
# hemispherical punch. The set is associated with the part instance 'PART-1-1'.
center = odb.rootAssembly.instances['PART-1-1'].nodeSets['PUNCH']
# Create a variable that refers to the displacement of the node set in the last frame of the
# first step.
centerDisplacement = displacement.getSubset(region=center)
L3.14
Abaqus输出数据库
# Finally, print some field output data from each node in the node set
# (a single node in this example).
for v in centerDisplacement.values:
print 'Position = ', v.position
print 'Type = ', v.type
print 'Node label = ', v.nodeLabel
print 'X displacement = ', v.data[0]
print 'Y displacement = ', v.data[1]
print 'Displacement magnitude =', v.magnitude
odb.close()
Position = NODAL
Type = VECTOR
Node label = 1000
X displacement = -8.05730572321e-034
Y displacement = -76.4923706055
Displacement magnitude = 76.4923706055
Abaqus 输出数据库
• 输出数据库的缺陷
• 输出数据库中的数据不可以被删除
• 工作区(Workaround): 创建一个新的 .odb 文件,写入的数据将
从 .odb 文件中拷贝。
• 每次仅允许一个客户写入。
• 为防止损坏,文件被锁定。
• 从输出数据库中读入的数据是向后兼容的。
• 新版本的 Abaqus 可以读入较早版本的输出数据库文件。
• 向输出数据库中写出数据不是向后兼容的。
• 新版本的 Abaqus 不可以往较早版本的输出数据库中写出数据。
自动后处理任务
自动后处理任务
L3.18
自动后处理任务
• 可视化命令
• 在视口中显示输出数据库:
odb = session.openOdb('viewer_tutorial.odb')
vp = session.viewports['Viewport: 1']
vp.setValues(displayedObject=odb)
• 绘制 PEEQ 等值线图:
od = vp.odbDisplay
od.setPrimaryVariable(variableLabel='PEEQ',
outputPosition=INTEGRATION_POINT)
od.display.setValues(plotState=(CONTOURS_ON_DEF,))
自动后处理任务
• 注释命令
• 图注
vp.plotAnnotation(
mdb.Text(name='test run', offset=(70, 110),
text= 'Test Run #146'))
• 打印命令
• 在 .png 文件中打印当前视口及注释
session.pngOptions.setValues(imageSize=(750, 400))
session.printOptions.setValues(rendition=COLOR,
vpDecorations=OFF, vpBackground=OFF)
session.printToFile(fileName='stress', format=PNG,
canvasObjects=(vp,))
L3.20
自动后处理任务(autopostprocessing.py)
• 将上述所有内容组在一起
# A script to plot contours of the equivalent plastic strain on the deformed shape of the final
# frame in an output database and save the image to a .png file:
import odbAccess
from abaqus import *
from abaqusConstants import *
import visualization
# Assign a variable to the ODB in the current viewport.
vp = session.viewports[session.currentViewportName]
odb = vp.displayedObject
# Change background color to white.
session.graphicsOptions.setValues(backgroundColor='#FFFFFF')
# Make the last step and frame the current step and frame.
lastStepIndex = len(odb.steps)-1
lastFrameIndex = len(odb.steps.values()[-1].frames)-1
vp.odbDisplay.setFrame(step=lastStepIndex,
frame=lastFrameIndex)
自动后处理任务
L3.22
自动后处理任务
L3.24
外部数据的后处理
外部数据的后处理
• 创建部件
myPart = odb.Part(name='My Part',
embeddedSpace=THREE_D, type=DEFORMABLE_BODY)
• 在部件中加入节点和单元
nodeData = ( (1, 1, 0, 0), (2, 2, 0, 0),
(3, 2, 1, 0.1), (4, 1, 1, 0.1),
(5, 2,-1,-0.1), (6, 1,-1,-0.1), )
myPart.addNodes(nodeData=nodeData, nodeSetName='nset-1')
elementData = ((1, 1,2,3,4),
(2, 6,5,2,1),)
myPart.addElements(elementData=elementData, type='S4',
elementSetName='eset-1')
L3.26
外部数据的后处理
• 创建部件实体
myInstance = odb.rootAssembly.Instance(name='My Instance',
object=myPart)
• 创建分析步
myStep = odb.Step(name='My Step', description='',
domain=TIME, timePeriod=1.0)
• 创建框架
myFrame = myStep.Frame(frameId=1, frameValue=0.1,
description='')
外部数据的后处理
• 创建场变量的输出
uField = myFrame.FieldOutput(name='U',
description='Displacements', type=VECTOR)
• 定义场变量输出
nodeLabels = (1, 2, 3, 4, 5, 6)
nodeDisplacements = (
(1.0,2.0,3.0), (4.0,5.0,6.0), (7.0,8.0,9.0),
(10.0,11.0,12.0), (13.0,14.0,15.0), (16.0,17.0,18.0) )
uField.addData(position=NODAL, instance=myInstance,
labels=nodeLabels, data=nodeDisplacements)
实例
• 数据文件及其对应的X-Y图
L3.30
实例 3-1: 绘制外部数据的X-Y图
def plotExternalData(fileName):
# Extract the data from the file
file = open(fileName)
lines = file.readlines()
pxy = lines[0].split(',')
pxy = [x.strip() for x in pxy]
plotName, xAxisTitle, yAxisTitle = pxy
data = []
for line in lines[1:]:
data.append(eval(line))
实例: 绘制外部数据的X-Y图
if __name__ == '__main__':
plotExternalData('scr_xyplot.dat')
L3.32
实例3-2: 同一图中显示多个框架
实例 3-2: 同一图中显示多个框架
L3.34
• 在单元场变量输出中找极大极
小值
• 在所有分析步的所有框架
中找到Mises应力的极大
极小值
• 在信息提示区中打印出现
极大极小值的位置及其出
现的时间.
• 将出现极值的单元在图中
显示出来.
实例 3-3: 在ODB文件中查询极大极小值
import visualization
import displayGroupOdbToolset as dgo
vp = session.viewports[session.currentViewportName]
odb = vp.displayedObject
if type(odb) != visualization.OdbType:
raise 'An odb must be displayed in the current viewport.'
maxValue = None
stressOutputExists = FALSE
for step in odb.steps.values():
print 'Processing step:', step.name
for frame in step.frames:
try:
stress = frame.fieldOutputs['S']
stressOutputExists = TRUE
except KeyError: # Skip frames with no stress output
continue
L3.36
实例 3-3: 在ODB文件中查询极大极小值
实例 3-3: 在ODB文件中查询极大较极小值
#Color the element Red where the max von Mises stress occurs
leaf = dgo.Leaf(ALL_SURFACES)
vp.odbDisplay.displayGroup.remove(leaf)
leaf = dgo.LeafFromElementLabels(
partInstanceName=maxValue.instance.name,
elementLabels=(maxValue.elementLabel,) )
vp.setColor(leaf=leaf, fillColor='Red')
vp.odbDisplay.commonOptions.setValues(
renderStyle=FILLED,
elementShrink=ON, elementShrinkFactor=0.15)
vp.odbDisplay.display.setValues(plotState=(UNDEFORMED,))
L3.38
实例 3-4: 管形截面的挠度
• 这是一个优化实例:
• 对管形截面悬臂梁进行 Standard 分析
• 读入输出数据库文件并找到端点的挠度值
• 如果挠度值过大,就增加壁厚,重新对梁提交分析作业。
实例 3-4: 管形截面的挠度
import odbAccess
import visualization # only for display purposes
thickness = 0.004 # m
maxAllowableDeflection = 0.025 # m
jobName = "Tube%03d"%(thickness*1000)
mdb.Job(name=jobName, model='Model-1')
mdb.jobs[jobName].submit()
mdb.jobs[jobName].waitForCompletion() # wait for analysis to complete
L3.40
实例 3-4: 管形截面的挠度(pipeoptimization.py)
L3.42
习题 3-1:线性叠加
习题 3-2: 创建输出数据库