0

I've seen several examples on the internet of how to get the highest Von Mises stress from an instance. However, in my simulation there are 4 geometries (ie 4 instances) and my code is only evaluating the Von Mises stress in a single instance (disregarding the other three). Can anybody help me?

Put a "for" so that it would call the 4 instances, but even so it still insists on always getting 1 instance.

from abaqus import *
from abaqusConstants import *
from caeModules import *
from driverUtils import executeOnCaeStartup
from odbAccess import *
import numpy
import itertools
import math
import csv

odb = session.openOdb(job_name)
session.viewports['Viewport: 1'].setValues(displayedObject=odb)
assembly = odb.rootAssembly
frame=-1

f2=odb.steps['Step-1'].frames[frame]

max_stress = 0

for name, instance in assembly.instances.items():
    f = f2.fieldOutputs['S'].values[0].instance.elements
    tam_elemento = len(f)
        
    print 'Instance: %s \n Elementos: %d'%(name,tam_elemento)

    for k in range(len(f)):
        element_mises_stress = f2.fieldOutputs['S'].values[k].mises
                 
        if element_mises_stress > max_stress:
            max_stress_element_label = f2.fieldOutputs['S'].values[k].elementLabel
            field_output_stress_object_index = k
            max_stress = element_mises_stress

print 'Mises: %f' % (max_stress)
aynber
  • 22,380
  • 8
  • 50
  • 63

1 Answers1

0

First of all, by default stress is output at the integration points. So, when you write

f2.fieldOutputs['S'].values[k].mises

You are NOT accessing the mises stress for kth element. You are accessing it for some integration point of some element (However, there is way to figure it out what node and what integration point).

Now, to get the maximum mises stress for entire assembly.
You can get the maximum mises stress at integration point and centroid. let's see at the centroid.

import numpy
from abaqusConstants import *

# Getting stress at centroid of each element. 
# The values will be interpolated from integration points to the centroid of an element.
stressTensor = odb.steps['Step-1'].frames[-1].fieldOutputs['S'].getSubset(position=CENTROID)

# getting mises stress from Stress tensor
mStress = stressTensor.getScalarField(invariant=MISES,)

# Now use bulkDataBlocks to access the data as Numpy Array
dat = mStress.bulkDataBlocks[0]

# This has following attributes
print(dat.__members__)
#['baseElementType', 'componentLabels', 'conjugateData', 'data', 'elementLabels', 'instance',
# 'integrationPoints', 'localCoordSystem', 'mises', 'nodeLabels', 'position', 'sectionPoint', 'type']

# Get mises values and find max value
maxMies = numpy.max(dat.data)  # Maximum mises stress

maxIndx = numpy.argmax(dat.data) # Index of Maximum mises stress
elmLabel = stressTensor.values[maxIndx].elementLabel  # Element label of Maximum mises stress
elmInst = stressTensor.values[maxIndx].instance  # instance for the element
Satish Thorat
  • 584
  • 1
  • 5
  • 13