Data mining¶
Read¶
Local data¶
All data of the simulation are accessible from python; when you open the Inspector, blue labels of various data can be clicked – left button for getting to the documentation, middle click to copy the name of the object (use Ctrl-V
or middle-click to paste elsewhere). The interesting objects are among others (see Omega for a full list):
-
Engines are accessed by their index (position) in the simulation loop:
O.engines[0] # first engine O.engines[-1] # last engine
Note
The index can change if O.engines is modified. Labeling introduced in the section below is a better solution for reliable access to a particular engine.
-
Bodies are identified by their id, which is guaranteed to not change during the whole simulation:
O.bodies[0] # first body [b.shape.radius for b in O.bodies if isinstance(b.shape,Sphere)] # list of radii of all spherical bodies sum([b.state.mass for b in O.bodies]) # sum of masses of all bodies numpy.average([b.state.vel[0] for b in O.bodies]) # average velocity in x direction
-
Generalized forces (forces, torques) acting on each particle. They are (usually) reset at the beginning of each step with ForceResetter, subsequently forces from individual interactions are accumulated in InteractionLoop. To access the data, use:
O.forces.f(0) # force on #0 O.forces.t(1) # torque on #1
-
Interactions are identified by ids of the respective interacting particles (they are created and deleted automatically during the simulation):
O.interactions[0,1] # interactions of #0 with #1 O.interactions[1,0] # the same object O.bodies[0].intrs() # all interactions of body #0 for i in O.bodies[12].intrs(): print (i.isReal,i.id1,i.id2) # get some info about interactions of body #12 [(i.isReal,i.id1,i.id2) for i in O.bodies[12].intrs()] # same thing, but make a list
Labels¶
Engines and functors can be labeled, which means that python variable of that name is automatically created.
Yade [1]: O.engines=[
...: NewtonIntegrator(damping=.2,label='newtonCustomLabel')
...: ]
...:
Yade [2]: newtonCustomLabel.damping=.4
Yade [3]: O.engines[0].damping # O.engines[0] and newtonCustomLabel are the same objects
Out[3]: 0.4
Yade [4]: newtonCustomLabel==O.engines[0] # O.engines[0] and newtonCustomLabel are the same objects