How to get node positions from odb file
How to get node positions from odb file
(OP)
How do I access the original coordinates of nodes using Python?
I am attempting to write a python script to output the average and maximum Mises stress within a certain 3D area. The area I am interested in is a box from [X,Y,Z]start to [X,Y,Z]end. How can I test if, in the undeformed position, the nodes are within the area I am interested in?
Thanks in advance.
I am attempting to write a python script to output the average and maximum Mises stress within a certain 3D area. The area I am interested in is a box from [X,Y,Z]start to [X,Y,Z]end. How can I test if, in the undeformed position, the nodes are within the area I am interested in?
Thanks in advance.





RE: How to get node positions from odb file
Probably the COORD one is easier to implement in your script (just the same line as the mises, but change S to COORD)
RE: How to get node positions from odb file
RE: How to get node positions from odb file
I'm trying to read from a filedOutput, right? It does not seem to like "COORD". Here is the relevant code:
#all of the coordinate data from the first frame of Step1
location = frame1.fieldOutputs['COORD']
#all of the Mises stress data from the last frame of Step1
stress = frame2.fieldOutputs['S']
It works fine for 'S', but I get a keyError for 'COORD'. Is COORD a field output? Should I be reading in something other than a fieldOutput?
RE: How to get node positions from odb file
RE: How to get node positions from odb file
session.odbs[name].steps[name].frames[i].fieldOutputs[name].values[i].instance.nodes[i]
RE: How to get node positions from odb file
I can figure out the average, max and min stress in my element set using my python code. But I cannot figure out how to perform the same calculation on a subset of the entire element set. This subset will be defined by geometry, as I described in my original question. It's the syntax that is giving me trouble- it's not a complicated idea. I cannot figure out how to access an element, its initial centroid location (start of a step), and then its final stress value (end of the step). Yes, I've read through the Abaqus Scripting User's Manual.
Can anyone give me some help with the python syntax to access the starting location of the centroid of each element in an element set, test the X,Y,Z location of the element centroid, and if it's within my region of interest, spit out the Mises stress at the centroid at the end of the step? Thanks.
RE: How to get node positions from odb file
element = "somestuffspecifictoyoursetup".instance.elements[i] # e.g. odb.steps['step1'].frames[-1].fieldOutputs['S'].values[0].instance.elements[i]
#get the connectivity
nodes = element.connectivity
center = 0
for i in nodes:
center+="somestuffspecifictoyoursetup".instance.nodes[i].coordinates
center = center/len(nodes)
to get the centroid stress the easiest is to just ask for it in output (POSITION=CENTROIDAL), else you have to use the shape functions and that's annoying.
Then your 'values' i.e.
odb.steps['step1'].frames[-1].fieldOutputs['S'].values
will have len() = nr of elements, and normally they are numbers 0 - len().
So just perform a test on the center, and add the mises value to a list, and average
RE: How to get node positions from odb file
Here is a snippet of my code:
myElementSet = assembly.instances['PART-1-1'].elementSets['C56NUCLEUS'].elements
for i in myElementSet:
nodes=i.connectivity
element=i.label
center=0
for j in nodes:
if(element==304):
print j, assembly.instances['PART-1-1'].nodes[j].coordinates # check that the node numbers and coordinates for one element
center+=frame1.fieldOutputs['S'].values[0].instance.nodes[j].coordinates
center_point=np.array(center/len(nodes))
if(element==304):
print center_point
Thanks again for your help!
RE: How to get node positions from odb file
But maybe in your case, for whatever reason, node labels and the position in the list differ by 21.
Anyway, what will definitely work is to use
frame1.fieldOutputs['S'].values[0].instance.getNodeFromLabel(j).coordinates
RE: How to get node positions from odb file