Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Division by Zero problem

Status
Not open for further replies.

skatemaverick86

Mechanical
Joined
Dec 2, 2015
Messages
4
Location
IT
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

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()
 
Can you put an If...., then... statement in? If denominator equals zero, do not solve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top