← Back to team overview

yade-users team mailing list archive

Re: [Question #703571]: How to reset the stiffness of the particles at a later stage?

 

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

Jan Stránský proposed the following answer:
MWE atttached below.

Bodies:
======
to change body stiffness, assign new material.
(In general) do not do b.mat.young=newValue, since b.mat is (usually) shared among more particles and you would change young to them, too.

Interactions:
==========
Changing material has no effect on existing interactions.
One approach is to delete / erase existing interactions (completely or just those belonging to relevant particles). New interactions are created the very next step, reflecting new material.

This approach is not sufficient if you need "interaction history" (e.g. concerning friction).
Then you can use another approach - access interactions and change the values directly:
###
for i in body.intrs:
    i.phys.kn = newValue
###

MWE:
=====
####
mat1 = FrictMat(young=1)
mat2 = FrictMat(young=2)
spheres = s1,s2,s3,s4 = [sphere((x,0,0),.75,fixed=True,material=mat1) for x in (1,2,3,4)]

O.bodies.append(spheres)
O.engines = [
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb()]),
    InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    NewtonIntegrator(),
]
O.dt = 0

def printInfo():
    print("=============")
    print("step",O.iter)
    for i,body in enumerate(O.bodies):
        print("body",i,"young",body.mat.young)
    for i,intr in enumerate(O.interactions):
        print("interaction",intr.id1,intr.id2,"kn",intr.phys.kn)

O.step()
printInfo()

selectedSpheres = (s3,s4)
for body in selectedSpheres:
    body.mat = mat2
    for intr in body.intrs():
        O.interactions.erase(intr.id1,intr.id2)

O.step()
printInfo()
####

Cheers
Jan

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