×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Error Division by Zero problem

Error Division by Zero problem

Error Division by Zero problem

(OP)
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[i]]
allFrames = session.odbData[odbPath].steps[allSteps[i]].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[i], ' frameNumber = ', allFrames[j]
odb.save()
odb.close()

RE: Error Division by Zero problem

Can you put an If...., then... statement in? If denominator equals zero, do not solve.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources