×
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

How to get node positions from odb file

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.

RE: How to get node positions from odb file

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)

RE: How to get node positions from odb file

(OP)
Thanks, exactly what I needed.

RE: How to get node positions from odb file

(OP)
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?

RE: How to get node positions from odb file

(OP)
Ahh. You have to make a field output request for COORD before running the job!

RE: How to get node positions from odb file

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

session.odbs[name].steps[name].frames[i].fieldOutputs[name].values[i].instance.nodes[i]

RE: How to get node positions from odb file

(OP)
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.

RE: How to get node positions from odb file

Loop over all the elements:

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

(OP)
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!

RE: How to get node positions from odb file

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

RE: How to get node positions from odb file

(OP)
That works. Thank you for your help!

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