×
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

Export Stress and element ID from Abaqus using a Python script

Export Stress and element ID from Abaqus using a Python script

Export Stress and element ID from Abaqus using a Python script

(OP)
I would like to export Cauchy stresses and Element IDs from a generic .odb

I have written this entry level Python script that writes stresses to a .txt file:

----------------------CODE START------------------------------------
from odbAccess import *

# open the result contatinig output database .odb
odb = openOdb(path='path to .odb') # enter path e.g. as C:\SIMULIA\Temp\...file.odb

# define the step for data export
lastFrame = odb.steps['name of last frame'].frames[-1] # enter 'name of last frame' e.g. as defaults "Step-1", "Step-2" or any generic name you prescribed in the Step manager

# define field outputs
stress=lastFrame.fieldOutputs['S']
# define variable stress in the frame of interest e.g. last frame (all applicable fieldOutputs['?'] are defined in Step manager -> define field output

# create and write to a file
file = open('name of results file.txt', 'w') # create and write to a named file in your work directory
file.write('S11 \t\t S22 \t\t S12 \n') # write first line for coloumn labeling - \t tab \n newline

# go throug all stress values and write to the .txt file
for S in stress.values:

file.write('%.1f\t\t %.1f\t\t %.1f\t\t \n' % (S.data[0], S.data[1], S.data[3]))
# first part defines formating, S.data[i] defines value from stress.value i=0 -> Sxx, i=1-> Syy etc. This example is for surface element with no inplane loading [indent]therefore S.data[2]->Szz=0

file.close() # close the file
----------------------CODE END------------------------------------

My output is:
S11 S22 S12
-117.8 -284.5 -20.1
-130.6 -286.6 -15.8
-129.5 -285.5 -19.8
-108.1 -253.9 -30.0
-54.7 -158.3 -62.5
54.7 158.3 -62.5
108.1 253.9 -30.0
129.5 285.5 -19.8
etc. and it starts with mesh Element ID 1 and so on. Is there a way to append a coloumn of mesh Element ID like so:

ELEMENT ID S11 S22 S12
1 -117.8 -284.5 -20.1
2 -130.6 -286.6 -15.8
3 -129.5 -285.5 -19.8
4 -108.1 -253.9 -30.0
etc. ?

Any help would be much appreciated

RE: Export Stress and element ID from Abaqus using a Python script

in CAE you can open an .odb file and use Report -> Field Output to write a text file that includes element ID and whatever field output you need.

If you need to script it you can check the journal file for the python commands.

RE: Export Stress and element ID from Abaqus using a Python script

S.elementLabel

Please refer to the documentation, it quite clearly shows you the list of members under the fieldvalue object.

RE: Export Stress and element ID from Abaqus using a Python script

(OP)
Thanks cooken. S.elementLabel was exactly what I nedded.

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