← Back to team overview

yade-users team mailing list archive

Re: Time Series Forcing implementation in python

 

Sorry about that, but I will post with a reply now.

I have not yet made your most recently recommended changes, but here is my
current script that you requested:


o=Omega()

o.initializers=[

    StandAloneEngine('PhysicalActionContainerInitializer'),


MetaEngine('BoundingVolumeMetaEngine',[EngineUnit('InteractingSphere2AABB'),EngineUnit('InteractingBox2AABB'),EngineUnit('MetaInteractingGeometry2AABB')])
    ]


thrAxRad=1

velocities=[10.1,10.2,10.7,9.1,8.2,7.5,6.1] # velocities
times=[0.1,.3,.4,.6,.8,1.0,1.2] # t at which the velocities were measures
assert(len(velocities)==len(times))
subscribers=[126,127,128,129,130,131,132,133]

def applyForces():
    bex=BexContainer()
    for b in O.bodies:

f=3,1,2,1,4,3,5,2,1,5,4,3,7,.2,1,3,2,6,3,2,3,3,4,3,5,7,8,6,7,3,1,2,1,2,3,1,2,1,.1,.3,1,.4,2,3,4,3,3,3,3
#hypothetical forces for testing
        bex.addForce(b.id,f)


o.engines=[

    StandAloneEngine('PhysicalActionContainerReseter'),


    MetaEngine('BoundingVolumeMetaEngine',[
        EngineUnit('InteractingSphere2AABB'),
        EngineUnit('InteractingBox2AABB'),
        EngineUnit('MetaInteractingGeometry2AABB')]),

    StandAloneEngine('PersistentSAPCollider'),

    MetaEngine('InteractionGeometryMetaEngine',[

EngineUnit('InteractingSphere2InteractingSphere4SpheresContactGeometry'),

EngineUnit('InteractingBox2InteractingSphere4SpheresContactGeometry')]),


MetaEngine('InteractionPhysicsMetaEngine',[EngineUnit('SimpleElasticRelationships')]),

    StandAloneEngine('ElasticContactLaw'),

    DeusExMachina('GravityEngine',{'gravity':[0,0,-9.81]}),



##DeusExMachina('InterpolatingSpiralEngine',{'times':times,'angularVelocities':velocities,'wrap':True,'slope':thrAxRad,'subscribedBodies':subscribers,'axisPt':[0,0,0],'axis':[0,0,-1],'label':'driver'}),


##DeusExMachina('ForceEngine',{'subscribedBodies':[126,127,128,129,130,131,132,133],'force':[0,5000,0]}),


StandAloneEngine('PeriodicPythonRunner',{'iterPeriod':1,'command':'applyForces()'}),


    MetaEngine('PhysicalActionDamper',[
        EngineUnit('CundallNonViscousForceDamping',{'damping':0.2}),
        EngineUnit('CundallNonViscousMomentumDamping',{'damping':0.2})]),

    MetaEngine('PhysicalActionApplier',[
        EngineUnit('NewtonsForceLaw'),
        EngineUnit('NewtonsMomentumLaw'),]),




MetaEngine('PhysicalParametersMetaEngine',[EngineUnit('LeapFrogPositionIntegrator')]),


MetaEngine('PhysicalParametersMetaEngine',[EngineUnit('LeapFrogOrientationIntegrator')]),]

from yade import utils
import math

x0=0
y0=0
z0=0
rad=.004
nrow=18
ncol=24
xb=x0
yb=y0
zb=z0
xp=x0+rad
yp=y0+(math.sqrt(3)/3)*rad
zp=z0+(2*rad*math.sqrt(0.66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667))
xs=xp
ys=yp
zs=zp

space=3
nprow=6
npcol=8

#generate particle bed:
for i in range(1,(nrow+1)):
    for j in range(1,(ncol+1)):

o.bodies.append(utils.sphere([xb,yb,zb],rad,dynamic=False,color=[0,1,0],young=30e9,poisson=.3,density=2111.31))
        xb=xb+(2*rad)
    yb=yb+math.sqrt(3)*rad
    xb=x0+((i-(math.floor(i/2))*2)*rad)

#generate dynamic particles:
for i in range(1,(nprow+1)):
    for j in range(1,(npcol+1)):

o.bodies.append(utils.sphere([xs,ys,zs],rad,dynamic=True,color=[1,0,0],young=30e9,poisson=.3,density=2111.31))
        xs=xs+((2*rad)*space)
    ys=ys+(math.sqrt(3)*rad*space)
    xs=xp+(((i-(math.floor(i/2))*2)*rad)*space)


o.dt=.2*utils.PWaveTimeStep()

o.save('/tmp/a.xml.bz2');

from yade import qt
qt.Controller()


2009/3/24 Václav Šmilauer <eudoxos@xxxxxxxx>

>
>  I added the periodicpythonrunner to my code, but I am not sure how to
>> define BexContainter().  When I run the simulation, it gives the error:
>> "NameError: global name 'BexContainer' is not defined".
>>
>>
> Oh, my fault. You should say O.actions to get a BexContainer object, which
> then accepts addForce etc methods. Make sure you run at least r1727 where I
> added the addForce method.
>
>> Also, when I use the interpolatingspiralengine in my code, it gives the
>> error: "RuntimeError: ClassFactory::create - cannot create class named:
>> InterpolatingSpiralEngine".
>>
> DeusExMachina("InterpolatingSpiralEngine") works fine here. Can you post
> your code (whole script preferrably).
>
>> Additionally, with the interpolating spiral
>> engine, I am not sure what velocities you are referring to.  Should
>> these instead be the same forces I apply in periodicpythonrunner?  Also,
>> I do not know what 'thrAxRad' should be in that engine.
>>
>>
> Have a look at InterpolatingSpiralEngine header, in
> pkg/common/Engine/DeusExMachina/RotationEngine.hpp, all parameters are
> commented. thrAxRad is a leftover variable, it should be some number,
> simply. I hope it is clearer now.
>
> Vaclav.
>
> (PS. please can you, when replying to mails, use the Reply function of your
> mail client instead of just pasting the subject to a new message? Messages
> are threaded not according to subject but following the In-Reply-To: header
> which contains ID of the message you are replying to.)
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
> More help   : https://help.launchpad.net/ListHelp
>

References