Changing joint frictional properties for specific bodies later

Asked by Christoph Tuitz

Hi,

I defined the material properties for the whole assembly and want to change the jointFrictionAngle for specific particles afterwards.
Looping through the spheres and changing the colour works great, but I cannot achieve it for the jointFrictionAngle.

Thanks

for o in O.bodies:
   if isinstance(o.shape,Sphere):

      ## seperate assembly
       if o.state.pos[1]>(dimModele/2) :
   o.shape.color=(1,0,1)
  o.JCFpmMat.jointFrictionAngle = radians(80)
 else:
  o.shape.color=(0,0,1)
   o.JCFpmMat.jointFrictionAngle = radians(80)

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Christoph Tuitz
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

bodies has their material attribute, accessible as
b.material
or
b.mat
You can change it easily:
b.mat.jointFrictionAngle = whatever

b.mat is a reference to already instantiated material, so you can achieve the same by e.g.
O.materials[0].jointFrictionAngle = whatever
or
###
mat = JCFpmMat(...)
...
mat.jointFrictionAngle = whatever
###
(depending on how you use materials in the script)

However (!!!):
- note1: b.mat is a reference to existing Material instance, possibly (most likely) shared among other particles. If you modify it from one particle, it will affect all other particles sharing this material
- note2: it will have no effect on existing interactions

solution of note1 (if undesired): assign new material to the bodies (it will leave the existing material untouched for the rest of particles)
###
newMat = JCFpmMat(...)
for b in bodiesToBeUpdated:
   b.material = newMat
###

solution of note2 (if undesired): loop over O.interactions and modify i.phys accordingly
###
for i in O.interactions:
   if i.id1 in idsToBeUpdated or i.id2 in idsToBeUpdated:
      i.phys.someAttribute = someValue
###

cheers
Jan

Revision history for this message
Christoph Tuitz (t-chris3) said :
#2

Hi Jan, awesome works perfectly!

Revision history for this message
Christoph Tuitz (t-chris3) said :
#3

Thanks again!

Revision history for this message
Wang Benxin (yushujinshan) said :
#4

Hi Jan,

I encountered a similar problem. When I change the material for some existing bodies using the following code, the simulation cannot go through. It note that 'python argument types in None.None(Body, function)'. There is an error with the b.material= newMat. Could you please tell me how can I deal with it?

for b in bodiesToBeUpdated:
   b.material = newMat

Best regards,
Benxin

Revision history for this message
Jan Stránský (honzik) said :
#5

Hello Benxin,
please open a new question, as your problem (an error) is different from the original question (how to do something).
Thanks
Jan