← 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

孙灿 posted a new comment:
Sorry, I know why my published code always has indentation errors.
The code is as follows (it should work this time):

#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)
        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)
O.saveTmp()

from yade import qt
qt.Controller()
qt.View()

>Isn't the error different? like "AttributeError: 'int' object has no attribute 'intrs'"?
No, it will still report errors mentioned above.

>compare your current code (levels of the for loops) with #4
Yes, I found an error (for intr in body. intrs():) with indentation error. I changed it in the code mentioned above.

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