yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #00750
Re: Move a wall and plot (force, displacement) in a Python simulation
>
> If anyone can help me on Python. I have modified the script in
> Python to generate a cylindrical packing written by Vaclav.
> I added with the facet, a wall at top (execute the attached file)
> in order to realize a uniaxial compaction.
Welcome to the python world! I will do my best...
fichier = open('150_billes.txt','r')
for ligne in fichier.readlines() :
donnees = map(float,ligne.split(","))
o.bodies.append(utils.sphere([donnees[0],donnees[1],donnees[2]],donnees[3],wire=True,color=[random.random(),random.random(),random.random()]))
This you can do easier (since I've been doing that again and again, I've
written a function for that)
utils.spheresFromFile('150_billes.txt',wire=True)
for s in o.bodies:
b.shape['diffuseColor']=[random.random(),random.random(),random.random()]
>
> 1) define this wall (the last facet in my simulation)
> like a dynamic body. ==> b['isDynamic']=True. What is b? It is not a
> number !!!
b is Body instance (o.bodies[id]), you need something like
o.bodies[id]['isDynamic']=True; or you can define wall=o.bodies[wallId],
say wall['isDynamic']=True; this wall variable can be used later
> 2) give a translation velocity at this wall. What is the
> Python line to give a velocity at a body ?
o.bodies[id].phys['velocity']=[velX,velY,velZ]
But that will give it initial velocity, that will be influenced by
collisions etc. If you need constant translation velocity, you have to
use TranslationEngine for that (put it somewhere into your engines,
perhaps after NewtonsDampedLaw):
DeusExMachina('TranslationEngine',{'subscribedBodies':[idWall],'velocity':[x,y,z]})
> 3) plot the applied forces on this wall according to wall
> displacement.
have a look at scripts/simple-scene-graph.py
(http://svn.berlios.de/viewcvs/yade/trunk/scripts/simple-scene-graph.py?view=markup)
and http://yade.wikia.com/wiki/PythonPlotting. Basically, you need an
engine that records the data (PeriodicPythonRunner), a function that
does that (myAddPlotData) and set yade.plot.plots to what you want to plot.
You get the velocity again like wall.phys['velocity'][2] ([2] is for the
z-component).
Have a look at yade.plot.saveGnuplot, that saves your data to file so
that you can plot it with gnuplot once you will have quit yade.
Hope this helps, Vaclav
Follow ups
References