0

I am trying to extract the max principal stresses and strains (S and E) of a node from the .odb. I simulated a beam submitted to mechanical fatigue. I am new to Abaqus scripting so I was trying to print the stress S11 value from a specific node. What I was not expecting is that after running the script, I found two different values for the same node. I decided to print the coordinates and they match. I understand that the node belongs to two elements, but shouldn't the value be the same? Am I missing something? Could someone please explain why this is happening?

# data_extraction.py

from abaqus import *
from odbAccess import *
from abaqusConstants import *
from odbSection import *
import odb

mypath = 'C:/Users/jjb21183/Desktop/Mauro/Abaqus/Exercise-MasterShiWang/T3/'     
myodb = 'Job-M4.odb'       
odb = openOdb(path = mypath+myodb)

lastframe = odb.steps['Step-1'].frames[-1]

stress = lastframe.fieldOutputs['S']

elementAmount = len(stress.values[0].instance.elements)

myinstance = odb.rootAssembly.instances['PART-1-1']

for i in range(0, elementAmount):    
    element = myinstance.elements[i]
    for j in range(0, 8):
        nodes = element.connectivity[j] 
        N = myinstance.nodes[nodes-1]
        nodeCoordinateX = N.coordinates[0]
        nodeCoordinateY = N.coordinates[1]
        nodeCoordinateZ = N.coordinates[2]
        # l1 = [nodeCoordinateX, nodeCoordinateY, nodeCoordinateZ]
        # print l1
        if (nodeCoordinateX == 4.0 and nodeCoordinateY == 10.0 and nodeCoordinateZ == 0.0):     
            el_stress = stress.getSubset(region = element)
            print [nodeCoordinateX, nodeCoordinateY, nodeCoordinateZ]
            print el_stress.values[0].data[0]  

Output of my code

Thank you very much for your help.

  • Not answering the question but a side note, you should not do `nodeCoordinateX == 4.0` but recode something close to isclose(https://docs.python.org/3.5/library/math.html#math.isclose) function added to python in 3.5 version. – ndclt Oct 20 '21 at 12:35
  • Thank you for the comment but I am coding in Python 2.7. Could you explain exactly what do you mean? I do not understand. – Mauro Arcidiacono Oct 20 '21 at 12:41
  • If there is some computation done on the nodeCoordinateX variable, you could have a value of 4.00000000001 which you might consider as equal to 4.0 but the computer won't. For solving this, you should code a isclose function like shown in this answer: https://stackoverflow.com/a/33024979/11832127. – ndclt Oct 20 '21 at 12:46
  • Thank you, I just created a function for that. I still have the same problem. I do not understand why the output is two different stress values. – Mauro Arcidiacono Oct 20 '21 at 14:37

1 Answers1

2

Actually, you are NOT looking at the Nodal value, but you are looking at the value at Integration Point. Abaqus calculate the results at the Integration Points. And because the Integration points are at different location, the values are different.
To get the nodal stress or strain results, you can use session.writeFieldReport commmand. This command write the field output data for entities displayed on the screen to a file.
So, to show desired nodes on the screen, create leaf object and show on screen.

import displayGroupOdbToolset as dgo
leaf = dgo.LeafFromNodeSets(nodeSets=('Node_Set', ))
session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)

or you can create leaf object from node labels also,

import displayGroupOdbToolset as dgo
leaf = dgo.LeafFromModelNodeLabels(nodeLabels=(('PART-1-1', ('10', '11','12')),))
session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)

where, 'Node_Set' is node set and '10', '11','12' are the node labels. And now you can use writeFieldReport command as

session.writeFieldReport(fileName='outData.dat', append=ON, 
    sortItem='Node Label', odb=odb, step=0, frame=1, outputPosition=NODAL, 
    variable=(('S', INTEGRATION_POINT, ((INVARIANT, 'Max. Principal'), )), ))

For more details, please check the Scripting Guide for Abaqus.

Satish Thorat
  • 584
  • 1
  • 5
  • 13