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
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
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