skatemaverick86
Mechanical
- Dec 2, 2015
- 4
Hi everyone,
I am trying to calculate the stress triaxiality (Triax = -PRESS/MISES) through a python script in order to create a new odb field output Triax but I am stuck with the "division by zero" error given by the attached script. Do you have any idea on how to bypass this problem? Of course the problem is given by the division of PRESS and MISES field output in fact when I multiply them instead of dividing the script runs w/o errors.
Thank you in advance
Federico
I am trying to calculate the stress triaxiality (Triax = -PRESS/MISES) through a python script in order to create a new odb field output Triax but I am stuck with the "division by zero" error given by the attached script. Do you have any idea on how to bypass this problem? Of course the problem is given by the division of PRESS and MISES field output in fact when I multiply them instead of dividing the script runs w/o errors.
Thank you in advance
Federico
from abaqusConstants import *
from odbAccess import *
# ******************************************************************************
# Modify the next variables accordingly:
odbPath = "C:\\Users\\MODELLO2A047.odb" # path to output database
# ******************************************************************************
odb = session.openOdb(name=odbPath,readOnly=FALSE)
allSteps = session.odbData[odbPath].steps.keys()
for i in range(len(allSteps)):
step = odb.steps[allSteps]
allFrames = session.odbData[odbPath].steps[allSteps].frames.keys()
for j in range(len(allFrames)):
frame = step.frames[j]
eqstress = frame.fieldOutputs['S'].getScalarField(MISES)
hydrostatic = frame.fieldOutputs['S'].getScalarField(PRESS)
try:
Triax = -hydrostatic/eqstress
except ZeroDivisionError:
newField = frame.FieldOutput(name='Triax', description='Stress Triaxiality', field=Triax)
print 'stepName = ', allSteps, ' frameNumber = ', allFrames[j]
odb.save()
odb.close()
from odbAccess import *
# ******************************************************************************
# Modify the next variables accordingly:
odbPath = "C:\\Users\\MODELLO2A047.odb" # path to output database
# ******************************************************************************
odb = session.openOdb(name=odbPath,readOnly=FALSE)
allSteps = session.odbData[odbPath].steps.keys()
for i in range(len(allSteps)):
step = odb.steps[allSteps]
allFrames = session.odbData[odbPath].steps[allSteps].frames.keys()
for j in range(len(allFrames)):
frame = step.frames[j]
eqstress = frame.fieldOutputs['S'].getScalarField(MISES)
hydrostatic = frame.fieldOutputs['S'].getScalarField(PRESS)
try:
Triax = -hydrostatic/eqstress
except ZeroDivisionError:
newField = frame.FieldOutput(name='Triax', description='Stress Triaxiality', field=Triax)
print 'stepName = ', allSteps, ' frameNumber = ', allFrames[j]
odb.save()
odb.close()