How to plot damage ratio curve

Asked by Tina Asia

Hi,

I made a particle assembly under uniaxial compression using cohfrictmat and bonded particle model, but can you tell me how to get damage ratio, namely the ratio between failed bonds and all intact bonds before any damage occur.

 Mank thanks.

 Tina

NTU, Singapore

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Luc Scholtès
Solved:
Last query:
Last reply:
Revision history for this message
Luc Scholtès (luc) said :
#1

Hi Tina,

If you are using cohFrictMat, I guess that you are also using cohFrictPhys and Law2_ScGeom6D_CohFrictPhys_CohesionMoment (right?).

In this case, you should be able to loop over interactions at any time of the simulation and count the cohesive/frictional contacts by checking if the cohesionBroken attribute is false (cohesive contact) or true (frictional contact) using lines such as:

nbCohBond=0
for i in O.interactions:
  if not i.isReal : continue # not mandatory
  if i.phys.cohesionBroken==False:
    nbCohBond+=1

You could include these into a function that you would run periodically during your simulation (e.g. using PyrRunner()) and thus get the evolution of the number of cohesive contacts. By running it before your simulation starts, you will then be able to compute the ratio of broken bonds / initial bonds.

I hope it helps

Revision history for this message
Tina Asia (tinaatyade) said :
#2

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.

Revision history for this message
Luc Scholtès (luc) said :
#3

Apparently, you divide something by zero...

Did you check the value of sumCohBonds by printing it before using it in your function damageRatio? Type print sumCohBonds just after its calculation in your script and you should see its value in the terminal.

Actually, did you compute it at iteration 0 of your simulation or at iteration 1? I guess it is null at iteration 0 since the contacts haven't been looped over yet. Try O.step() just before computing sumCohBonds and let me know.

Luc

Revision history for this message
Tina Asia (tinaatyade) said :
#4

Hi Luc,

Thanks for your patience, I adjusted my code and It goes well, but the output is wrong,because the number of broken bonds does not grow gradually with the increase of computation time (number of broken bonds: 1,23,42,32,15...). Here is a segment of my code.

O.step()
# calculate the total intact cohesive bonds
global sumCohBonds
sumCohBonds=0
for b in O.interactions:
    if b.phys.cohesionBroken==True:
        continue
    sumCohBonds+=1
print 'first time:{}'.format(sumCohBonds)

numBroCohBonds=0
def damageRatio():
    for br in O.interactions:
        if br.phys.cohesionBroken==False:
            continue
    numBroCohBonds+=1 # calculate broken bonds
damageRatio=numBroCohBonds/float(sumCohBonds)
print numBroCohBonds,damageRatio
print 'second time:{}'.format(sumCohBonds)

Revision history for this message
Best Luc Scholtès (luc) said :
#5

Hum...

A stupid question but do you initialize numBroCohBonds to zero each time you compute it? What happens if you include a print numBroCohBonds inside your function, just before the loop?

Also, you may need to define numBroCohBonds as a global variable in your function (just add global numBroCohBonds just before the loop).

If this does not work, I could probably have a look at your script to investigate your issue more precisely.

Luc

Revision history for this message
Tina Asia (tinaatyade) said :
#6

Thanks Luc Scholtès, that solved my question.