Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Export Stress and element ID from Abaqus using a Python script

Status
Not open for further replies.

PeteTranc

Automotive
Feb 5, 2013
25
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 defines value from stress.value i=0 -> Sxx, i=1-> Syy etc. This example is for surface element with no inplane loading
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
 
Replies continue below

Recommended for you

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.
 
S.elementLabel

Please refer to the documentation, it quite clearly shows you the list of members under the fieldvalue object.
 
Thanks cooken. S.elementLabel was exactly what I nedded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor