yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #01473
Re: Time Series Forcing implementation in python
You are right, the direction of force does not change.
InterpolatingDirectedForceEngine looks like it will work perfectly for my
application! I greatly appreciate you writing this new engine for my
application. I have not yet tested and implemented it in my script because
I still need to compile the new version r1742.
Below is my current script which you requested:
o=Omega()
o.initializers=[
StandAloneEngine('PhysicalActionContainerInitializer'),
MetaEngine('BoundingVolumeMetaEngine',[EngineUnit('InteractingSphere2AABB'),EngineUnit('InteractingBox2AABB'),EngineUnit('MetaInteractingGeometry2AABB')])
]
#def applyForces():
# bex=o.actions
# for b in o.bodies:
# ff=(0,0,f[o.iter%len(f)]) ## x,y components zero, z component is
taken from f based on iteration number wrapped to the length of f
# bex.addF(b.id,ff)
forces,times=[],[]
for line in file('rogerscene2.table'):
if len(line.split())<2: continue # skip empty lines
f,t=[float(s) for s in line.split()]
forces.append(f)
times.append(t)
print forces,times
b=o.bodies
def applyForces():
# find index of the time we are at or just after now in the series
# this is quite suboptimal, since it traverses the array every time
i=0;
while times[i]<o.time:i+=1
# and use force at that index
f=forces[i]
ff=(0,0,f)
bex=o.actions
for b in o.bodies:
bex.addF(b.id,ff)
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,0]}),
#DeusExMachina('ForceEngine',{'subscribedBodies':b,'force':[0,5000,0]}),
StandAloneEngine('PeriodicPythonRunner',{'iterPeriod':1,'command':'applyForces()'}),
MetaEngine('PhysicalActionDamper',[
EngineUnit('CundallNonViscousForceDamping',{'damping':.2}),
EngineUnit('CundallNonViscousMomentumDamping',{'damping':.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.666666666666666666666666666666666666666666666666666666666666666666666666666666666667))
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.dt=0.0034261
o.save('/tmp/a.xml.bz2');
from yade import qt
qt.Controller()
2009/3/31 Václav Šmilauer <eudoxos@xxxxxxxx>
>
> > Ok, now I can read the force data from file, and I believe it is
> > applying the forces to the particles (it now does not give me an error
> > when I run the simulation but the particles do not move).
> >
> Can you send your script over? I think that could be just that too small
> is applied or it changes very fast, so that you visually don't see any
> movement.
>
> > I looked at the LinearInterpolate.hpp file in
> > trunk/pkg/common/Engine/DeusExMachina but I did not see a
> > LinearInterpolate.cpp file.
> It is not an engine, just a function that does the interpolation (ok,
> admittedly it shouldn't be in DeusExMachina directory...). There is no
> such thing as DeusExMachina('LinearInterpolate',...), what would it
> interpolate (force? rotation? mass?).
>
> > If it cannot, do I need to write a new interpolating engine? I
> > imagine this would be written in C++, so could you give me some
> > guidance on how to accomplish this if it is necessary?
> Checkout r1741 from svn, and see scripts/test/interpolating-force.py and
> run it. It should give you an idea.
>
> I created InterpolatingDirectedForceEngine based on the assumption that
> the direction of the force doesn't change (whence "Directed" in the
> name), I hope I got right what you needed.
>
> Regards, Vaclav
>
>
>
> _______________________________________________
> 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
-
Re: Time Series Forcing implementation in python
From: rbarnold, 2009-03-24
-
Re: Time Series Forcing implementation in python
From: Václav Šmilauer, 2009-03-26
-
Re: Time Series Forcing implementation in python
From: Roger, 2009-03-26
-
Re: Time Series Forcing implementation in python
From: Václav Šmilauer, 2009-03-26
-
Re: Time Series Forcing implementation in python
From: Roger Arnold, 2009-03-26
-
Re: Time Series Forcing implementation in python
From: Václav Šmilauer, 2009-03-27
-
Re: Time Series Forcing implementation in python
From: Roger, 2009-03-30
-
Re: Time Series Forcing implementation in python
From: Václav Šmilauer, 2009-03-30
-
Re: Time Series Forcing implementation in python
From: Roger, 2009-03-30
-
Re: Time Series Forcing implementation in python
From: Václav Šmilauer, 2009-03-31