Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

How to get node positions from odb file

Status
Not open for further replies.

wja365

Bioengineer
Nov 1, 2013
12
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.
 
Replies continue below

Recommended for you

you can request the COORD output, and use that one, or read them from the input file.
Probably the COORD one is easier to implement in your script (just the same line as the mises, but change S to COORD)
 
Thanks, exactly what I needed.
 
This does not work the way I would have expected.

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?
 
Ahh. You have to make a field output request for COORD before running the job!

 
If you only want the undeformed node locations, you can also get them from:

session.odbs[name].steps[name].frames.fieldOutputs[name].values.instance.nodes
 
Thanks for your suggestions. I'm new to python/abaqus; it's a steep learning curve!

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.
 
Loop over all the elements:

element = "somestuffspecifictoyoursetup".instance.elements # e.g. odb.steps['step1'].frames[-1].fieldOutputs['S'].values[0].instance.elements
#get the connectivity
nodes = element.connectivity
center = 0
for i in nodes:
center+="somestuffspecifictoyoursetup".instance.nodes.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
 
I have the first part of the code working (looping through elements, calculating center of each element). However, the node locations printed out in my python code do not match the node locations in Abaqus/CAE when I probe the nodes. As an example, node 491 (according to my code) has the same coordinate values as node 512 when I probe in Abaqus\CAE. There appears to be a consistent offset of 21 in the node numbers between probing values and the python output (I probed several nodes to compare). In contrast, my python code and probing of elements matches- they appear to have the same nodes assigned to the same element; only the node coordinates are different Any idea why this might be the case? Is my code correctly assigning the coordinates of the nodes?

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!
 
My bad, python starts numbering at 0, abaqus at 1. (so normally the difference should be 1 and not 21 though)
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
 
That works. Thank you for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor