yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #28535
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
孙灿 posted a new comment:
>It says, that O.bodies[arg] expects "arg" to be int, but actually it is Body.
>To solve it, put arg.id (Body.id as int)
I try to output b The type of id is found to be 'int' instead of 'body'.
When using the li() function, I output the type of the body in for body
in shuzu: again, which is still 'int'. Why does' that O. bodies [arg]
expect "arg" to be int, but actually it is Body. 'still occur.
>Moreover, I have no problem with both codes you have posted..
In the previous code, I put the functions outside checkUnbalanced() (I
manually input the functions). Because the error is in li(), you can't
find an error by clicking Run. Now I have readjusted the code as
follows:
#Material constants(1)
Density1 = 1836
FrictionAngle1 = 5
PoissonRatio1 = 0.4
Young1 = 1e8
Damp = 0.5
AvgRadius1 = 0.05
N_particles = 10000
#Material constants(23)
Density23 = 2000
FrictionAngle23 = 27
PoissonRatio23 = 0.35
Young23 = 1e9
Damp = 0.5
AvgRadius1 = 0.05
N_particles = 10000
#Wall constants
WDensity = 0
WFrictionAngle = 0.0
WPoissonRatio = 0.1
WYoung = 50e9
#time calculation
startT = O.time
endT = O.time
timeSpent = endT - startT
mat1 = O.materials.append(FrictMat(young = Young1, poisson = PoissonRatio1, frictionAngle = radians(FrictionAngle1), density = Density1))
mat2 = O.materials.append(FrictMat(young = Young23, poisson = PoissonRatio1, frictionAngle = radians(FrictionAngle1), density = Density1))
WallMat = O.materials.append(FrictMat(young = WYoung, poisson = WPoissonRatio, frictionAngle = radians(WFrictionAngle)))
from yade import pack,plot
O.bodies.append(geom.facetBox((0.05, 15, 15), (0.5, 15, 15), wallMask=63,material=WallMat))
sp = pack.SpherePack()
sp.makeCloud(Vector3(0.05,0,0),Vector3(0.05,30,30), rMean=0.3, rRelFuzz=0)
sp.toSimulation(material = mat1)
(xdim,ydim,zdim)= aabbDim()
print("Height is ",zdim)
for b in O.bodies:
if isinstance(b.shape,Sphere):
b.state.blockedDOFs='ZxY'
b.shape.color=(0,0,1.)
circleRadius=2
circleCenter = Vector3(0.05,15,6)
circleRadius1=2.5
#myEngine.dead = True
O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(gravity=(0, 0, -9.81), damping=0.4),
PyRunner(command='checkUnbalanced()', realPeriod=2,label="myEngine"),
PyRunner(command='addPlotData()', iterPeriod=100)
]
O.dt = 0.5 * PWaveTimeStep()
O.trackEnergy = True
shuzu=[]
def checkUnbalanced():
if unbalancedForce() < .0001:
O.pause()
zMax = max(b.state.pos[2] for b in O.bodies if isinstance(b.shape,Sphere))
print("Z ",zMax)
ceng = zMax-0.4
for b in O.bodies:
if isinstance(b.shape,Sphere):
#b.state.blockedDOFs='zxy'
b.state.vel=(0,0,0)
b.state.angVel=(0,0,0)
if b.state.pos[2]>ceng:
print(b.id,b.state.pos)
#a=int(b.id)
#print(type(b.id))
shuzu.append(b.id)
print(type(b.id))
#selectedSpheres+=(b,)
print(shuzu)
#zMax = max(b.state.pos[2] for b in O.bodies)
#zMax = max(b.state.pos[2] for b in O.bodies)
#print("Z ",zMax)
#(xdim,ydim,zdim)= aabbDim()
#print("Height is ",zdim)
li()
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()
def li():
for body in shuzu:
print(type(body))
#body.mat = mat2
O.bodies[body].material = mat2
for intr in body.intrs():
O.interactions.erase(intr.id1,intr.id2)
printInfo()
def addPlotData():
plot.addData(i=O.iter, unbalanced=unbalancedForce(), **O.energy)
def duqu():
for i in shuzu:
b = O.bodies[i]
print("voila",i,b.state.pos)
def wadong1():
for b in O.bodies:
d = (b.state.pos - circleCenter).norm()
if d < circleRadius:
O.bodies.erase(b.id)
O.saveTmp()
from yade import qt
qt.Controller()
qt.View()
--
You received this question notification because your team yade-users is
an answer contact for Yade.