# Damage value from cpm model

Dear all,

I would like to obtain the scalar damage value (omega=0-1) from cpm model without using VTK recorder.

Afterthat, I wanted to colour the spheres based on damage value using scalarOnColorScale function. which requres,

yade._utils.

Parameters:

x (float) – scalar value which the function applies to.

xmin (float) – minimum value for the color scale, with a return value of (0,0,1) for x ≤xmin, i.e. blue color in RGB.

xmax (float) – maximum value, with a return value of (1,0,0) for x ≥xmax, i.e. red color in RGB.

Returns:

a Vector3 depending on the relative position of x on a [xmin;*xmax*] scale.

How can I get this x(float) parameter for this case?

Previously I have added the colour to fully debonded/damaged bonds using following code running inside pyRunner,

def colorspheres():

for i in O.interactions:

if hasattr(i.phys, 'isCohesive'):

if i.phys.isCohesive == 0:

a=i.id1

b=i.id2

O.bodies[

O.bodies[

But now I want to color the spheres based on their damage value not only the fully damaged value

Could you please help me on this?

## Question information

- Language:
- English Edit question

- Status:
- Solved

- For:
- Yade Edit question

- Assignee:
- No assignee Edit question

- Solved by:
- Jan Stránský

- Solved:
- 2020-05-20

- Last query:
- 2020-05-20

- Last reply:
- 2020-05-20

Jérôme Duriez (jduriez) said : | #1 |

Are you asking what YADE attribute could correspond to a "sphere damage value" in the CPM ?

Or what is the use of scalarOnColorSc

chanaka Udaya (chanaka-udaya) said : | #2 |

>>Are you asking what YADE attribute could correspond to a "sphere damage value" in the CPM ?

When one spheres are interacting another sphere It will create a interaction. If two spheres are in tension, when it exceeds the elastic limit subjected to damage and this damage value is varying from 0 to 1.

For instance, I want to print this damage value in the terminal

>>Or what is the use of scalarOnColorSc

based on the O.interactions ,I can extract the particle ids corresponding to the interaction. If I can obtain the scalar damage value corresponding to a particular interaction, I can color the two spheres based on this damage value with time.

Like this,in this case rotation

for b in O.bodies:

b.shape.

Jan Stránský (honzik) said : | #3 |

Hello,

you can try b.state.normDmg [1] (which is not damage, but rather residual strength [2,3], which is somewhat more intuitive to interpret).

Needs CpmStateUpdater [4] to be run before to have the value updated.

> based on the O.interactions ,I can extract the particle ids

or the other way around, based on body, you can extract interactions:

###

intrs = b.intrs() # [5]

avgDmg = sum(i.phys.omega for i in intrs) / len(b.intrs)

b.shape.color = scalarOnColorSc

###

cheers

Jan

[1] https:/

[2] https:/

[3] https:/

[4] https:/

[5] https:/

chanaka Udaya (chanaka-udaya) said : | #4 |

Thanks Jan Stránský, that solved my question.