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]
Thank you very much for your help.
CodePudding user response:
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.