The following script can extract additional parameters:
userscript_odb.py
Script to open an output database named tennis.odb, extract specific
parameters from the database, and write them to an ASCII file.
usage:
abaqus python userscript_odb.py
"""
#
import odbAccess
from odbAccess import *
import __main__
import operator
#
# S T A R T
#
if __name__ == '__main__':
odbName = 'tennis.odb'
# check if odb file needs version upgrade
needsUpgrade = odbAccess.isUpgradeRequiredForOdb(upgradeRequiredOdbPath=odbName)
if(needsUpgrade):
odbAccess.upgradeOdb (existingOdbPath=odbName,upgradedOdbPath='upgradedOdb')
myOdb=openOdb('upgradedOdb.odb',readOnly=True)
else:
myOdb = openOdb(odbName,readOnly=True)
steps = myOdb.steps
paramsFile = open ('user_params.txt','w')
#access and print steps for key in steps.keys():
step = steps[key]
print 'Processing Step:', step.name
#extract a history output array
historyRegions = step.historyRegions
for key2 in historyRegions.keys():
historyRegion = historyRegions[key2]
# compute history location to append to the parameter
historylocation = ""
try:
historyposition = historyRegion.position
if(historyposition == NODAL):
historypoint = historyRegion.point
historynode = historypoint.node
historynodelabel = historynode.label
historylocation = "_" + str(historynodelabel)
if(historyposition == INTEGRATION_POINT):
historypoint = historyRegion.point
historyelement = historypoint.element
historyelementlabel = historyelement.label
historylocation = "_" + str(historyelementlabel)
if(historyposition == WHOLE_ELEMENT):
historypoint = historyRegion.point
historyelement = historypoint.element
historyelementlabel = historyelement.label
historylocation = "_" + str(historyelementlabel)
if(historyposition == WHOLE_REGION):
historylocation = ""
if(historyposition == WHOLE_MODEL):
historylocation = ""
except:
historylocation = ""
historyOutputs = historyRegion.historyOutputs
for key3 in historyOutputs.keys():
historyOutput = historyOutputs[key3]
paramsFile.write(str(step.name.replace('-','_'))
+ "__" + str(historyOutput.description.replace(' ','_')) +
str(historylocation) + "\t" + str(historyOutput.data) + "\n")
try:
values = map(operator.itemgetter(1),historyOutput.data)
paramsFile.write(str(step.name.replace('-','_'))
+ "__Max__" + str(historyOutput.description.replace(' ','_')) +
str(historylocation) + "\t" + str(max(values)) + "\n")
paramsFile.write(str(step.name.replace('-','_'))
+ "__Min__" + str(historyOutput.description.replace(' ','_')) +
str(historylocation) + "\t" + str(min(values)) + "\n")
except:
pass
#close params file
paramsFile.close()