Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract data from .odb file for each time increment of Step-1

Status
Not open for further replies.

Eleo

Mechanical
Mar 2, 2015
26
I have written below a code in python to extract data (PHILSM values) from the output file (.odb) at Time increment=10.
How to write a recursive loop in the code in order to extract data (PHILSM values) from the odb.file for Time increment 0, 1,2,3,..., 100 ? Thank you.


from odbAccess import *
from abaqusConstants import *
from odbMaterial import *
from odbSection import *
odb = openOdb(path='Job-1.odb')
myAssembly = odb.rootAssembly

for stepName in odb.steps.keys():
print stepName
step1 = odb.steps.values()[0]
print step1.name

Frame = odb.steps['Step-1'].frames[10]

for fieldName in Frame.fieldOutputs.keys():
print fieldName

# Script to print the name, description, and type members
# for each field output value in the last frame,

for f in Frame.fieldOutputs.values():
print f.name, ':', f.description
print 'Type: ', f.type


# Script to extract and print the PHILSM value.
for loc in f.locations:
print 'Position:',loc.position
print
displacement=Frame.fieldOutputs['PHILSM']
fieldValues=displacement.values

for v in fieldValues:
print 'PHILSM= %6.4f' % (v.data)
 
Replies continue below

Recommended for you

You need to add an outer loop that runs through the frames. Frame 0 is time increment 0.
 
What would be the code to add in this particular case ?
 
Generically, it would look something like this:

for x in outerloop:
for y in innerloop:
do something
 
I wrote the code below in order to display the frame names, but get the error message 'expected an indented block'. What would be the appropriate code to display each frame ?

allFrames = odb.steps['Step-1'].frames.keys()
for j in range(len(allFrames)):
frame=odb.steps['Step-1'].frames[j]
print frame
 
You just have to use

for x in odb.steps['Step-1'].frames:
do something​

x would be the current frame in each loop
 
How to display the attributes of OdbFrameArray ?
 
I tried the code written below but it does not work. I want to extract the PHILSM for each frame

for stepName in odb.steps.keys():
print stepName
step1 = odb.steps.values()[0]
print step1.name

#These two lines below work ok and display each frame with their values
for frame in step1.frames:
print frame

for f in step1.frames.fieldOutputs.values():
print f.name, ':', f.description
print 'Type: ', f.type

## Script to extract and print node and PHILSM value.
for loc in f.locations:
print 'Position:',loc.position
print displacement=frame.fieldOutputs['PHILSM']
fieldValues=displacement.values

#for v in fieldValues:
print 'Node = %d PHILSM= %6.4f' % (v.nodeLabel,v.data)
 
Python syntax expects indentation for each for loop, ie

for frames in step.frames:
do something
for vals in values:
do something else
 
Scripting Users Guide 9.5.10 An example of reading field data from an output database

With some minor modifications it print out U_mag of one node for each frame.
Code:
from odbAccess import *

odb = openOdb(path='viewer_tutorial.odb')

center = odb.rootAssembly.instances['PART-1-1'].    nodeSets['PUNCH']

print '\n****************'

for x in odb.steps['Step-1'].frames:

    displacement = x.fieldOutputs['U']
    centerDisplacement = displacement.getSubset(region=center)

    for y in centerDisplacement.values:
        print x.description
        print 'Displacement magnitude =', y.magnitude
        print '\n'

odb.close()
 
In the last line of the program below, what is the keywords to put instead of frame.description[1] and y.frame.description in order to display the name and value of Step Time in order to have on each line:
the TimeStep, Node and Philsm values

for frame in odb.steps['Step-1'].frames:
displacement = frame.fieldOutputs['PHILSM']
for y in displacement.values:
#print frame.description
print ' frame.description[1]=%6.4f,Node = %d PHILSM =%6.4f',(y.frame.description,y.nodeLabel, y.data)
print '\n'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor