14.11.10

Creating an animation of X-Y path plots in Abaqus/CAE

Question
I would like to create an animation of X-Y path plots in Abaqus/CAE. How can I do this?
Answer
(The following applies to Versions 6.3 and higher.)
While Abaqus/CAE does not currently have the capability to animate X-Y path plots,
freeware products exist that allow a sequence of .png files to be combined into an
animation. A script has been included with this answer to automate the creation of the
necessary .png files. Programs such as VideoMach can be used to create the animation.
Note that by listing the above shareware program, Abaqus, Inc. is in no way endorsing
the product. It is merely offered as an example of the type of image processing software
that is openly available.
For a given output database and path, the script will create an X-Y plot along the path and
print it to a file. The first and last steps to be considered for the animation must be
specified; files will be created for each frame in each step, including the bounding steps.
To create the series of .png files, complete the following steps:
1. Start Abaqus/CAE and open the output database (.odb) file of interest.
2. Select
Tools ® Path ® Create
and create the desired path.
3.
Select
File ® Run Script
and select createAni.py
4.
When prompted, enter:
The name of the output database file. It is not necessary to include the .odb
extension.
The name of the path to be used in creating the animation. Only one path
can be used per animation.
The minimum and maximum values for the Y-axis of the X-Y plots.
The first and last step numbers to be included.
5. The .png files will be created in the directory from which Abaqus/CAE was started.
Notes
1.The X-axis plot limits are set by the length of the path. The length of the path could
change over the course of the analysis, and subsequently the X-axis limits could
change through the animation.
2.Care must be taken when setting the upper and lower bounds on the Y-axis. If they
are set too high or too low an error will be issued as none of the plot will be visible
(Abaqus/Viewer does not allow the creation of an empty plot).
3.The script is currently hard coded to plot Mises stress. To plot a different variable,
lines 20-22 must be edited. Please consult:
'setPrimaryVariable,' Section 32.1.5 of the Abaqus 6.9 or 6.10 Scripting
Reference Manual

createAni.py
=========================================
from abaqus import *
from visualization import *
import os
import displayGroupOdbToolset as dgo

# implemented as a function in order to return easily after cancelling

def createPlots():

odbName = getInput('What is the name of the odb file?')

if odbName == None:
return

if odbName[-4:] != '.odb':
odbName = odbName + '.odb'

pathName = getInput('What is the name of the path to use?')

if pathName == None:
return

vp = session.viewport[session.currentViewportName]
odb = session.openOdb(odbName)

vp.setValues(displayedObject=odb)

# use the next statement to define the field value (setPrimaryVariable - 28.1.8 Scripting reference manual)
vp.odbDisplay.setPrimaryVariable(variableLabel='S',
outputPosition=INTEGRATION_POINT,
refinement=(INVARIANT,'Mises'))

# get y values from user, x values defined automatically by length of path
temp = getInput('What is the min value for the y-axis?')

if temp == None:
return
yMin = float(temp)

temp = getInput('What is the max value for the y-axis?')

if temp == None:
return

yMax = float(temp)

vp.viewportAnnotationOptions.setValues(legend=OFF,
legendBox=OFF)

session.printOptions.setValues(rendition=COLOR,
vpDecorations=OFF,
vpBackground=OFF)

steps = odb.step.keys()

plots = session.xyPlots.keys()
numplots = len(plots)
plotname = 'XYPlot-'+str(numplots + 1)

try:
xyp = session.XYPlot(name=plotname)
except:
raise ValueError,'ERROR: Creating XYPlot object'

xyp.xyPlotOptions.setValues(yAxisMinAutoCompute=OFF,
yAxisMinValue=yMin,
yAxisMaxAutoCompute=OFF,
yAxisMaxValue=yMax)

print 'The following steps exist: ',steps

stepList = getInput('Enter the first and last step numbers to include, separated by a colon')

if stepList == None:
return

stepList= string.replace(stepList, ':',",")
stepList=eval('range(-1+%s)'%stepList)

stepCount = 0
fCount = 0
for i in stepList:
key = steps[i]
frames = odb.step[key].frame
frameLen = len(frames)
for j in range(frameLen):
print i, j,
if fCount < 10:
fName = 'pic_00%s.png'%fCount
elif fCount < 100:
fName = 'pic_0%s.png'%fCount
else:
fName = 'pic_%s.png'%fCount

print fName
fCount = fCount + 1
vp.odbDisplay.setFrame(step=i,
frame=j )
pth = session.path[pathName]
xy=XYDataFromPath(name='Temp-1', path=pth, includeIntersections=FALSE,
shape=DEFORMED, labelType=TRUE_DISTANCE)
xyp.Curve('Temp-1', xy)
xyp.setValues(curvesToPlot=('Temp-1', ))
vp.setValues(displayedObject=xyp)
session.printToFile(fileName=fName,
format=PNG,
canvasObjects=(vp,))

stepCount = stepCount + 1

# Call the function

createPlots()

没有评论: