×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Extracting data from Abaqus OBD file using python, only reads one file

Extracting data from Abaqus OBD file using python, only reads one file

Extracting data from Abaqus OBD file using python, only reads one file

(OP)
Good Afternoon

I'm new to scripting, or any sort of programming and am trying to write a script to extract the displacements and load from a set of nodes in an Abaqus OBD file, as I have about 1000 files to extract data from. I have searched Google/these forums but haven't yet found a solution.

I have managed through adapting the .rpy file and guess work/Google/books to get to the stage where I can open my files, and read them however rather than print the data from 1.odb, 2.odb, 3.odb etc, it just prints the data from one of the files three times. I have included a line that prints the name of the file, and it appears to open all the files in the directory but just not output the correct data.

I would be very grateful if someone with Python/Abaqus experience could have a look and tell me where I have gone wrong and how to remedy this. I have tried changing the indentation to see if that helps, but to no avail.

The file is attached, and runs fine (excluding above error) though File>Run Script in 6.7 however doesn't like being run in command line.

Any input greatly appreciated.

CODE

### import required modules  
import sys, os
from abaqus import *
from abaqusConstants import *
from caeModules import *
from driverUtils import executeOnCaeStartup
#
### point it at the files:
#
FOLDER = '/home/myfolder'
#
os.chdir(FOLDER)
for filename in os.listdir('.'):
    #
    #
            #f = open('/home/files.txt','a')
            #print >>f, filename
    ### open abaqus module
    #
            executeOnCaeStartup()
           Mdb()
    ### open file, set view
          o1 = session.openOdb(
                name=filename)
         session.viewports['Viewport: 1'].setValues(displayedObject=o1)
        session.viewports['Viewport: 1'].view.setValues(nearPlane=43.3078,
            farPlane=76.6444, width=38.4285, height=19.2364, cameraPosition=(-22.5167,
                5.17008, 48.8967), cameraUpVector=(-0.602818, -0.140808, -0.785356))
          odb = session.odbs[filename]
    ### extract reaction force
        session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=(('RF',
                NODAL, ((COMPONENT, 'RF2'), )), ), nodeSets=('LOADY', ))
    ### extract displacements
         odb = session.odbs[filename]
         session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=(('U',
                NODAL, ((COMPONENT, 'U1'), )), ), nodeSets=('XEXPPOS-VERT', ))
         odb = session.odbs[filename]
         session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=(('U',
                NODAL, ((COMPONENT, 'U3'), )), ), nodeSets=('Z-EXPPOS-TRANS', ))
    ### assign data to variable
         x0 = session.xyDataObjects['RF:RF2 PI: BCC_FCC-1 N: 8']
          x1 = session.xyDataObjects['U:U1 PI: BCC_FCC-1 N: 14']
          x2 = session.xyDataObjects['U:U1 PI: BCC_FCC-1 N: 17']
          x3 = session.xyDataObjects['U:U1 PI: BCC_FCC-1 N: 23']
           x4 = session.xyDataObjects['U:U1 PI: BCC_FCC-1 N: 25']
           x5 = session.xyDataObjects['U:U3 PI: BCC_FCC-1 N: 16']
    ### report data
        session.xyReportOptions.setValues(minMax=ON)
        session.writeXYReport(
            fileName='/home/data.rpt',
            xyData=(x0, x1, x2, x3, x4, x5))

RE: Extracting data from Abaqus OBD file using python, only reads one file

Hi,

Getting hints from the .rpy file could help, but this is not the way to learn Abaqus Scripting Interface.

I suggest reading Abaqus Scripting User's Manual, in particular: "Using the ABAQUS Scripting Interface to access an output database"

Some remarks on your code:

Mdb() - creates a new model database, not necessary for opening .odb files.

executeOnCaeStartup() - this a function typically defined in the abaqus_v6.env environment file for customizing CAE. You should not execute it in your script.

Your code assumes that there are only .odb files in the folder.

You should close the .odb file once you are done with it.

And most important:

Make sure that your code is indented correctly.

You can always can include "print" statements to see what is going on in the code, for example you can include a print at the beginning of the loop and one at the end.

odb = session.odbs[filename] is repeated. Actually, I think you do not even need this, because:
o1 = session.openOdb(name=filename) should make o1 a reference to the odb object you open.

Best,


 

RE: Extracting data from Abaqus OBD file using python, only reads one file

(OP)
Thanks; have had a further attempt but it's still misbehaving. I think the problem is caused by the command session Odb and session.odbs being used, and I don't think session.odbs is taking the updated file.
 
Does anyone have any ideas on how to adapt the code to re-assign this value?

Many Thanks

PH  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources