Discussion:
[deprecated list] Time Series Forcing implementation in python
Václav Šmilauer
2009-03-19 12:47:56 UTC
Permalink
On a previous post, it was recommended that I use PeriodicRunnerEngine
to apply a time series of forces to particles. Could you instruct me on
how to implement this engine in python? Or, if you have a better way to
implement such a time series, please let me know. However it would not
be feasible to interpolate the data.
How do you have your data given? If it is a time-series, you will
probably have to interpolate, since otherwise the simulation would
depend on the time step. Does the force change at every step? And so on.
For some scenarios, it can be better (from the performance perspective)
to do it in c++, for other it is simpler in python. Then we will be able
to determine the best way to do it.

Regards, Vaclav


_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-21 15:59:50 UTC
Permalink
Yes, the force is different at each time step. The time step between
each force reading varies from about 0.5 seconds to 3 seconds. The
forces do no follow a trend over time, but they are normally
distributed. Please let me know if you need any other information about
the data. I appreciate your assistance.
If the force is different at every step (and every particle), the best
would be to create a DeusExMachina engine that would at each iteration
generate normally distributed force and apply it. The only parameters of
the engine would be subscribedBodies and some parameters of the
distribution. I am not sure what is what you get from the reading every
.5-3 secs.

If you need help with the implementation, let me know. A question of 15
minutes.

Vaclav

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-21 22:43:18 UTC
Permalink
I have consulted with a colleague, we do not think that generating
normally distributed forces would work well for this application. Also,
I found that we have another data set that is linearly interpreted with
a constant time step of about 4ms. The forces applied on each particle
should different at a given time step. Could this time series be
directly fed into yade?
Yes, either from python (which could in turn read it from text file) or
read from text file within the c++ code if the series is very large
(like 1e6 numbers; this is not limitation of python, but of the current
way of passing values from python to yade objects).

As said, for the interpolation, there is no problem, the
linearInterpolate function interpolates efficiently in an ordered manner
on time-values sequences, which is what you need.

How many different values do you need for each step? Do you apply one
interpolated force (to a single or multiple particles) per step?
InterpolatingSpiralEngine::applyCondition sets the interpolated value
and then calls engine that already exists to apply it; it is only this
thin wrapper that has to be written. If the interpolated quantity has
more components (like 3d force), multiple value sequences will be used
with on time sequence.

Did I get it right? Vaclav


_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-22 18:06:27 UTC
Permalink
There will be about 50 dynamic particles in the simulation, and at each
time step, each particle should have a different force from the times
series applied to it. There is only one component of the force. I have
been working only with python so far, and I would prefer to use it
instead of C++. What is the maximum number of data points that could be
used with python?
It would be helpful if you could tell me the syntax for using the
InterpolatingSpiralEngine in python.
You can try in python first and then see if it is fast enough. One of
your engines will be


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

(note that this engine must be before NewtonsDampedLaw) and you do all
the rest in applyForces that you define somewhere before you call
O.run():

def applyForces():
bex=BexContainer()
for b in O.bodies:
f=... # your stuff
bex.addForce(b.id,f)


To see the performance impact, go
http://yade.wikia.com/wiki/Speed_profiling_using_TimingInfo_and_TimingDeltas_classes ; basically you say O.timingEnabled=True before running the simulation and

import yade.timing
timing.stats()

when finished.

----

For InterpolatingSpiralEngine, the syntax is like this:

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=[0,1,2,3,4,5,6]
O.engines=[
#...
DeusExMachina('InterpolatingSpiralEngine',{'times':times,'angularVelocities':velocities,'wrap':True,'slope':thrAxRad,'subscribedBodies':subscribers,'axisPt':[0,0,0],'axis':[0,0,-1],'label':'driver'}),
#...
]

In your case, you would have to pass to your hypothetical engine a list
of readings for each body, probably as list of lists (but that is not
supported at this moment from python to yade, unless you play dirty
tricks that I can show you), and the time points. Reading the data from
file to memory at the point of engine construction would be another
option.

Vaclav


_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-24 20:02:45 UTC
Permalink
I added the periodicpythonrunner to my code, but I am not sure how to
"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
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
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-26 09:55:56 UTC
Permalink
Yes, I would be glad for you to add my script to the example scripts
once I get it working. I hope others will be able to learn from it.
I realized that I do not have r1727. I was able to download revision
r1730, but I do not think it is working,
I meant r1727 or later, of course.
because when I run the simulation I still get: "'ActionContainer'
object has no attribute 'addF' ".
Can you run yade -h? It will give list of compilation options at the
end. If it contains BEX_CONTAINER, then it is OK. If not, however, I
added addF to the old ActionContainer so that you can use it as well now
(you need r1731 at least for that)... I hope it will compile, I cannot
test now... Let me know.

I would like to convert all engines to BexContainer soon, as it is much
faster a allows for parallelization, but it is not crucial at this moment.

Regards, Vaclav


_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-26 19:03:55 UTC
Permalink
I would like to go ahead and update to the current revision (r1732 I
think) so I can be sure I have everything I need. What procedure
should I follow to accomplish this?
$ svn up # update sources
$ scons # recompile and install what changed

HTH


_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-27 06:07:44 UTC
Permalink
I would also like to read my times series of forces from a file. Is
there a python function that will accomplish. In the script examples I
saw multi.py that is supposed to read some values from a file, but it
didn't read from the file when I ran the simulation. I was wondering
how to use this function (or another one) properly to obtain forces
from file.
Do it just like you would in python:

forces,times=[],[]
for line in
file('your.text.file.with.2.numbers.per.line.separated.by.whitespace')
if len(line.split())<2: continue # skip empty lines
f,t=[float(s) for s in line.split()]
forces.append(f)
times.append(t)

def applyForce():
# 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=force[i]

V.



_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-30 05:15:26 UTC
Permalink
Post by Václav Šmilauer
forces,times=[],[]
for line in
file('your.text.file.with.2.numbers.per.line.separated.by.whitespace')
if len(line.split())<2: continue # skip empty lines
f,t=[float(s) for s in line.split()]
forces.append(f)
times.append(t)
# 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=force[i]
Using the method above, yade will read my force data from file, but it
will not apply it to the particles. (I know that it is reading the
force data properly because I have it print the force data from the
file). I do not get an error when I run the simulation, but the
particles do not move. I have tried larger magnitudes of forces to be
sure that the particles would move if exposed to the applied force.
Also, I am now running revision 1732.
well, you have to apply the force after f=force[i] in applyForce(), like
we had that before! Something like

for id in bodiesIWantToApplyForceTo:
O.actions.addF(id,f)
Post by Václav Šmilauer
Second, when I use InterpolatingSpiralEngine, I get the following
error: "RuntimeError: Number sequence argument required." The
arguements for this engine include an angular velocity time series,
but I have no knowledge of this data. Therefore I do not understand
why I need this engine. Perhaps I should use a different
interpolating engine?
I meant it as an example of interpolating engine. Of course it serves
you for nothing as you don't need spiral motion. As said, once you're
clear about what you need, no problem to write an engine LIKE that for
your case.

Vaclav


_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Václav Šmilauer
2009-03-31 20:28:53 UTC
Permalink
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
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Roger
2009-04-01 14:49:30 UTC
Permalink
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()
Post by Václav Šmilauer
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>
Unsubscribe : https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
More help : https://help.launchpad.net/ListHelp
Roger
2009-03-30 21:18:29 UTC
Permalink
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). Based on my understanding of the
program, they do not move because I now need an interpolating engine to
interpolate between each point to make integration possible.

I looked at the LinearInterpolate.hpp file in
trunk/pkg/common/Engine/DeusExMachina
but I did not see a LinearInterpolate.cpp file. I think this engine would
serve my purposes, but I can't get python to recognize it. (I tried calling
DeusExMachina('LinearInterpolate',....). Can python currently run the
engine?

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?

Thank you,
Roger
Post by Václav Šmilauer
Post by Václav Šmilauer
forces,times=[],[]
for line in
file('your.text.file.with.2.numbers.per.line.separated.by.whitespace')
Post by Václav Šmilauer
if len(line.split())<2: continue # skip empty lines
f,t=[float(s) for s in line.split()]
forces.append(f)
times.append(t)
# 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=force[i]
Using the method above, yade will read my force data from file, but it
will not apply it to the particles. (I know that it is reading the
force data properly because I have it print the force data from the
file). I do not get an error when I run the simulation, but the
particles do not move. I have tried larger magnitudes of forces to be
sure that the particles would move if exposed to the applied force.
Also, I am now running revision 1732.
well, you have to apply the force after f=force[i] in applyForce(), like
we had that before! Something like
O.actions.addF(id,f)
Post by Václav Šmilauer
Second, when I use InterpolatingSpiralEngine, I get the following
error: "RuntimeError: Number sequence argument required." The
arguements for this engine include an angular velocity time series,
but I have no knowledge of this data. Therefore I do not understand
why I need this engine. Perhaps I should use a different
interpolating engine?
I meant it as an example of interpolating engine. Of course it serves
you for nothing as you don't need spiral motion. As said, once you're
clear about what you need, no problem to write an engine LIKE that for
your case.
Vaclav
_______________________________________________
Mailing list: https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
Unsubscribe : https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
More help : https://help.launchpad.net/ListHelp
Roger
2009-03-30 02:29:15 UTC
Permalink
Post by Václav Šmilauer
forces,times=[],[]
for line in
file('your.text.file.with.2.numbers.per.line.separated.by.whitespace')
if len(line.split())<2: continue # skip empty lines
f,t=[float(s) for s in line.split()]
forces.append(f)
times.append(t)
# 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=force[i]
Using the method above, yade will read my force data from file, but it will
not apply it to the particles. (I know that it is reading the force data
properly because I have it print the force data from the file). I do not
get an error when I run the simulation, but the particles do not move. I
have tried larger magnitudes of forces to be sure that the particles would
move if exposed to the applied force. Also, I am now running revision 1732.

Second, when I use InterpolatingSpiralEngine, I get the following error:
"RuntimeError: Number sequence argument required." The arguements for this
engine include an angular velocity time series, but I have no knowledge of
this data. Therefore I do not understand why I need this engine. Perhaps I
should use a different interpolating engine?

Thank you for your continuing help.

Roger
Roger Arnold
2000-01-01 01:32:10 UTC
Permalink
I would also like to read my times series of forces from a file. Is
there a python function that will accomplish. In the script examples I
saw multi.py that is supposed to read some values from a file, but it
didn't read from the file when I ran the simulation. I was wondering
how to use this function (or another one) properly to obtain forces
from file.

Thank you for all your help.

Roger
Post by Václav Šmilauer
I would like to go ahead and update to the current revision (r1732
I think) so I can be sure I have everything I need. What procedure
should I follow to accomplish this?
$ svn up # update sources
$ scons # recompile and install what changed
HTH
_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-***@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Roger
2009-03-26 18:08:46 UTC
Permalink
I would like to go ahead and update to the current revision (r1732 I think)
so I can be sure I have everything I need. What procedure should I follow
to accomplish this?

Thanks,
Roger
Yes, I would be glad for you to add my script to the example scripts once
I get it working. I hope others will be able to learn from it.
I realized that I do not have r1727. I was able to download revision
r1730, but I do not think it is working,
I meant r1727 or later, of course.
because when I run the simulation I still get: "'ActionContainer' object
has no attribute 'addF' ".
Can you run yade -h? It will give list of compilation options at the end.
If it contains BEX_CONTAINER, then it is OK. If not, however, I added addF
to the old ActionContainer so that you can use it as well now (you need
r1731 at least for that)... I hope it will compile, I cannot test now... Let
me know.
I would like to convert all engines to BexContainer soon, as it is much
faster a allows for parallelization, but it is not crucial at this moment.
Regards, Vaclav
_______________________________________________
Mailing list: https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
Unsubscribe : https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
More help : https://help.launchpad.net/ListHelp
Roger
2009-03-25 02:42:34 UTC
Permalink
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()
I added the periodicpythonrunner to my code, but I am not sure how to
"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
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>
Unsubscribe : https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
More help : https://help.launchpad.net/ListHelp
Roger
2009-03-26 01:03:40 UTC
Permalink
Yes, I would be glad for you to add my script to the example scripts once I
get it working. I hope others will be able to learn from it.

I realized that I do not have r1727. I was able to download revision r1730,
but I do not think it is working, because when I run the simulation I still
get: "'ActionContainer' object has no attribute 'addF' ". I am new to
open-source code, as well as yade, so I am not sure if I am doing this
correctly.

Thanks,
Roger
Post by Václav Šmilauer
bex=BexContainer()
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 <http://b.id>,f)
OK, I tried.
1. bex=O.actions, I already told you.
2. bex.addF(b.id,f) is the correct thing, not addForce (my fault)
3. you are adding the whole f to the body, which is not what you want (it
f=1,2,3,4,5,6,7.... # hypothetical
bex=O.actions
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)
It adds the same force to all bodies though at each iteration, but you can
change that easily. Maybe you don't want to apply that force to all bodies,
but just the red ones? Then do something like
redParticles=[]
# generate dynamic particles function here
redParticles+=o.bodies.append(utils.sphere([xs,ys,zs],rad,dynamic=True,color=[1,0,0],young=30e9,poisson=.3,density=2111.31))
# O.bodies.append returns id of the body that you add to
redParticles, which will be list of ids at the end
ff=...
bex.addF(id,ff)
HTH, Vaclav
PS. what you sent runs about 5x slower with the python engine. But it is
good to make a prototype like that, then the idea is clear and it can be
easily written in c++.
PPS. Yade imports everything from math module automatically (sqrt, floor
etc)
PPPS. Once you script works, would it be OK to put it under examples in the
source tree?
rbarnold
2009-03-19 03:01:53 UTC
Permalink
On a previous post, it was recommended that I use PeriodicRunnerEngine
to apply a time series of forces to particles. Could you instruct me on
how to implement this engine in python? Or, if you have a better way to
implement such a time series, please let me know. However it would not
be feasible to interpolate the data.

Thank you,

Roger Arnold
--
This message was sent from Launchpad by the user
rbarnold (https://launchpad.net/~rbarnold12)
using the "Contact this team" link on the yade-users team page.
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
rbarnold
2009-03-20 19:16:41 UTC
Permalink
Thank you for your quick reply.

Yes, the force is different at each time step. The time step between
each force reading varies from about 0.5 seconds to 3 seconds. The
forces do no follow a trend over time, but they are normally
distributed. Please let me know if you need any other information about
the data. I appreciate your assistance.

Roger
--
This message was sent from Launchpad by the user
rbarnold (https://launchpad.net/~rbarnold12)
using the "Contact this team" link on the yade-users team page.
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
rbarnold
2009-03-22 17:06:32 UTC
Permalink
There will be about 50 dynamic particles in the simulation, and at each
time step, each particle should have a different force from the times
series applied to it. There is only one component of the force. I have
been working only with python so far, and I would prefer to use it
instead of C++. What is the maximum number of data points that could be
used with python?

It would be helpful if you could tell me the syntax for using the
InterpolatingSpiralEngine in python.

Thank you again for your help

Roger
--
This message was sent from Launchpad by the user
rbarnold (https://launchpad.net/~rbarnold12)
using the "Contact this team" link on the yade-users team page.
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
rbarnold
2009-03-21 20:25:59 UTC
Permalink
I have consulted with a colleague, we do not think that generating
normally distributed forces would work well for this application. Also,
I found that we have another data set that is linearly interpreted with
a constant time step of about 4ms. The forces applied on each particle
should different at a given time step. Could this time series be
directly fed into yade?

Thank you,

Roger
--
This message was sent from Launchpad by the user
rbarnold (https://launchpad.net/~rbarnold12)
using the "Contact this team" link on the yade-users team page.
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
rbarnold
2009-03-24 19:49:56 UTC
Permalink
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".

Also, when I use the interpolatingspiralengine in my code, it gives the
error: "RuntimeError: ClassFactory::create - cannot create class named:
InterpolatingSpiralEngine". 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.

I know I have a lot of questions, but I greatly appreciate your help.

Thank you,

Roger
--
This message was sent from Launchpad by the user
rbarnold (https://launchpad.net/~rbarnold12)
using the "Contact this team" link on the yade-users team page.
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Loading...