Title : Error message : can only concatenate list (not "RotationEngine") to list

Asked by evagb54

Hello everyone,

I am using a program in which particles rotate in a drum (by the rotation of the drum).

I would like to stop the rotation of the drum at a certain point and rotate with respect to the rotation axis of the drum , only the set of all the particles by a certain angle dtetab for a single time step, in order to get the image of the flow after this rotation( angle dtetab).

The code :

from __future__ import print_function
from yade import qt
from yade import plot
from yade import utils, plot, qt
#************************************************************************************************
#Unité de distance

#Diamètre d'une particule en m

d= 0.008

#Angular Velocity (rd/s)
angVel = 40* (2 * pi / 60)

# Diamètre du tambour
rD = 0.5*(50*d)

# Diamètre du cylindre intérieur
rcylint = 0.5*(10*d)

# Profondeur de la cellule
rP = 10*d

# hauteur couche supérieure
alpha=0
rh=alpha*(rD-rcylint) #Hauteur de l'empilement de particules ****

#Coefficient de restitution

e= 15/16

#Period (s)
TangVel = 2*pi/angVel

#*********************************************************************************
O.load('RD-make-packing-yade-cconfi1.gz')
#***************************************************************************************************

id_SphereMat= O.materials.append(ViscElMat(young=1*10**6,poisson=0.7,frictionAngle=0.61,en=15/16,et=1,density=2500))
SphereMat = O.materials[id_SphereMat]

id_BMat = O.materials.append(ViscElMat(young=1e5,poisson=0.37,frictionAngle=0.66,en=0.920,et=1,density=1190))
BMat = O.materials[id_BMat]

def unitSquare():
    """Return square composed of 2 facets in the xy plane, centered at zero with unit extents."""
    import gts
    vv = [gts.Vertex(1,1,0), gts.Vertex(1,-1, 0), gts.Vertex(-1,-1,0), gts.Vertex(-1,1, 0)]
    ee = [gts.Edge(vv[0], vv[1]), gts.Edge(vv[1], vv[2]), gts.Edge(vv[2], vv[3]), gts.Edge(vv[3], vv[0]), gts.Edge(vv[0], vv[2])]
    surf = gts.Surface()
    surf.add(gts.Face(ee[0], ee[1], ee[4]))
    surf.add(gts.Face(ee[2], ee[3], ee[4]))
    return surf

def unitCylinder(nDiv=24):

    import numpy
    from yade import pack
    thetas = numpy.linspace(0, 2 * pi, nDiv, endpoint=True)
    ptsBase = [Vector3(sin(th),cos(th), -1) for th in thetas]
    ptsTop = [p + Vector3(0,0,2) for p in ptsBase]
    return pack.sweptPolylines2gtsSurface([ptsBase, ptsTop])

from yade import pack, timing
cyl = unitCylinder()
sq1 = unitSquare()
sq1.translate(0,0,-1)
cyl.copy(sq1)
sq2 = unitSquare()
sq2.translate(0,0,1)
cyl.copy(sq2)

cyl.scale(rD,rD,rP)

cylint = unitCylinder()
cylint.scale(rcylint,rcylint,rP)

cylIds = O.bodies.append(pack.gtsSurface2Facets(cyl,material=BMat))
cylintIds = O.bodies.append(pack.gtsSurface2Facets(cylint,material=BMat))
O.dt = 0.95*PWaveTimeStep()

itround=int(TangVel/(O.dt))

O.engines = [
        ForceResetter(),
        InsertionSortCollider([
                Bo1_Sphere_Aabb(),
                Bo1_Facet_Aabb(),
        ]),
        InteractionLoop(
                [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],

                [Ip2_ViscElMat_ViscElMat_ViscElPhys()],
                [Law2_ScGeom_ViscElPhys_Basic()] ),

        RotationEngine(rotateAroundZero=True, zeroPoint=(0, 0, 0), rotationAxis=(0, 0,1), angularVelocity=angVel, ids=cylIds, label='rotor'),
        NewtonIntegrator(damping=0, gravity=(0,-10,0)),

        PyRunner(command='checkUnbalanced()', realPeriod=2,label='checker'),
]

pi=3.141592654
dtetab=pi/4
wtetab=dtetab/O.dt

def checkUnbalanced():
    if O.iter<1*itround :
        return

    else:
        RotationEngine.dead=True
        for b in O.bodies:
            if isinstance(b.shape,Sphere):

                O.engines=O.engines + RotationEngine(rotateAroundZero=True, zeroPoint=(0, 0, 0), rotationAxis=(0, 0,1), angularVelocity=wtetab, ids=[b.id], label='rotation')
                O.stopAtIter=1
                O.save('RDsave-yade-cconfiessai.gz')

yade.qt.View()
O.run()

I get this error : can only concatenate list (not "RotationEngine") to list

Can you please help me to solve this error or suggest me another method ? Thanks for your help.

pegbehe

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Karol Brzezinski
Solved:
Last query:
Last reply:
Revision history for this message
Robert Caulk (rcaulk) said :
#1

Hello,

Why are you creating and adding many new RotationEngines. Apparently you add a new engine for every single spherical body in your scene...this is not right.

>>I would like to stop the rotation of the drum at a certain point and rotate with respect to the rotation axis of the drum , only the set of all the particles by a certain angle dtetab for a single time step, in order to get the image of the flow after this rotation( angle dtetab).

Please rephrase this, I do not understand it. It sounds like you want to stop the rotation, and then start the rotation around some new axis of the drum? You only want some of the particles to rotate? This is all quite confusing. It needs to be fully rewritten before anyone can help you here.

Cheers,

Robert

Revision history for this message
evagb54 (pegbehe1) said :
#2

Hello Robert,
Thanks for your answer.

Why are you creating and adding many new RotationEngines. Apparently you add a new engine for every single spherical body in your scene...this is not right.
>>> No I don't want to add a new engine for every single spherical body. I just want to add a new engine that will rotate only the particles.

>>I would like to stop the rotation of the drum at a certain point and rotate with respect to the rotation axis of the drum , only the set of all the particles by a certain angle dtetab for a single time step, in order to get the image of the flow after this rotation( angle dtetab).

Please rephrase this, I do not understand it. It sounds like you want to stop the rotation, and then start the rotation around some new axis of the drum? You only want some of the particles to rotate? This is all quite confusing. It needs to be fully rewritten before anyone can help you here.

>>>> In fact, the particles rotate with the rotation of the drum and I get a flow profile, this is okay.
But in order to do some calculations on the spherical particles, I need to move only the particles (not the drum) with respect to the rotation axis of the drum. This will allow me to change the coordinate of the particles and get the image of the flow profile by a rotation of angle dtetab.
Maybe instead of :
.....
RotationEngine.dead=True
        for b in O.bodies:
            if isinstance(b.shape,Sphere):

                O.engines=O.engines + RotationEngine(rotateAroundZero=True, zeroPoint=(0, 0, 0), rotationAxis=(0, 0,1), angularVelocity=wtetab, ids=[b.id], label='rotation')
                O.stopAtIter=1
                O.save('RDsave-yade-cconfiessai.gz')
....
I had to put :

RotationEngine.dead=True

                O.engines=O.engines + RotationEngine(rotateAroundZero=True, zeroPoint=(0, 0, 0), rotationAxis=(0, 0,1), angularVelocity=wtetab, ids=b.id for for b in O.bodies if isinstance(b.shape,Sphere), label='rotation')
                O.stopAtIter=1
                O.save('RDsave-yade-cconfiessai.gz')

I don't know if it is more clear. Tell me if it is not.
Thanks again.

Revision history for this message
Best Karol Brzezinski (kbrzezinski) said :
#3

Hi,

O.engines is a list, so you need to put new engine in the brackets if uou want to concentrate them with '+' sign.

O.engines = O.engines + [NewEngine]

Cheers,
Karol

Revision history for this message
evagb54 (pegbehe1) said :
#4

Thanks Karol Brzezinski, that solved my question.