← Back to team overview

yade-users team mailing list archive

Re: [Question #432617]: How to plot damage ratio curve

 

Question #432617 on Yade changed:
https://answers.launchpad.net/yade/+question/432617

    Status: Answered => Open

Tina Asia is still having a problem:
Thanks Luc,

According to your code, I wrote the following script, but got an error (File "impact.py", line 104, in <module>
    damageRatio=numBroCohBonds/sumCohBonds
ZeroDivisionError: integer division or modulo by zero)

Here is a segment of my code:

#calculate total intact cohesive bonds
global sumCohBonds
sumCohBonds=0
for b in O.interactions: 
    if b.phys.cohesionBroken==True:
        continue
    sumCohBonds+=1

#define a function to calculate broken cohesive bonds
global damageRatio
numBroCohBonds=0
def damageRatio():
    for b in O.interactions:
        if not b.isReal:
            continue 
        if b.phys.cohesionBroken==True:
            numBroCohBonds+=1
damageRatio=numBroCohBonds/sumCohBonds
plot.saveDataTxt('data/damageratio.txt')

#define a function to plot damage ratio
def addPlotData(): 
    plot.addData(t=O.time,dr=damageRatio)
plot.plots={'t':('dr')}
plot.plot()


Thanks in advance.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.