yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #10982
[Question #263780]: Changing the material while running
New question #263780 on Yade:
https://answers.launchpad.net/yade/+question/263780
Hi all!
I want to change the material of certain spheres while running the program, and here is my script:
from yade import pack
frict=O.materials.append(FrictMat(young=1e6,
poisson=0.3,
density=2600))
con=O.materials.append(CpmMat(young=1e6,
poisson=0.3,
epsCrackOnset=0.1,
relDuctility=0,
density=2600))
floor=utils.wall(position=(0,0,0), axis=2, material=frict)
O.bodies.append(floor)
sp1=pack.SpherePack()
sp1.makeCloud((-0.5,-0.5,1),(0.5,0.5,2),rMean=0.05,rRelFuzz=0.2)
m = sp1.toSimulation(material=con) #defining the lower cube of spheres
sp2=pack.SpherePack()
sp2.makeCloud((-0.25,-0.5,3),(0.75,0.5,4),rMean=0.05,rRelFuzz=0.2)
n = sp2.toSimulation(material=con) #defining the upper cube of spheres
for i in m:
O.bodies[i].shape.color = (1,1,1)
O.engines=[ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.7), Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=1.7), Ig2_Wall_Sphere_ScGeom()],
[Ip2_CpmMat_CpmMat_CpmPhys(), Ip2_FrictMat_CpmMat_FrictPhys()],
[Law2_ScGeom_CpmPhys_Cpm(), Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(damping=0.3, gravity=(0,0,-9.81)),
PyRunner(command = "change()", iterPeriod = 300,label = "checker")
]
O.dt=0.5*utils.PWaveTimeStep()
def change():
for i in n:
if O.bodies[n].state.pos[2] <= 1: #when two cubes collide
for i in n:
O.bodies[n].material.label = frict #here I want to change the upper cube's material from CpmMat to FrictMat
checher.command = "done()"
return
def done():
return
The error message is:
ArgumentError Traceback (most recent call last)
/usr/bin/yadedaily in <module>()
/usr/bin/yadedaily in change()
38 def change():
39 for i in n:
---> 40 if O.bodies[n].state.pos[2] <= 1:
41 for i in n:
42 O.bodies[n].material.label = frict
ArgumentError: Python argument types in
BodyContainer.__getitem__(BodyContainer, list)
did not match C++ signature:
__getitem__(pyBodyContainer {lvalue}, int)
I am wondering whether an object's material can be changed while the program is running .
Thanks!
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.