yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #21295
[Question #685903]: 'ValueError: shape mismatch' when plotting
New question #685903 on Yade:
https://answers.launchpad.net/yade/+question/685903
Hello,
I am using Yade 2018.02b on a Virtual Box machine running Ubuntu 18.04.3 LTS. The host machine runs Windows 10.
I was trying to learn how to plot using the first tutorial given in the YADE tutorial page. (The one with a ball bouncing on another ball). I followed the commands given about plotting in the section Data mining. It works for a sometime then gives an error.
There was a post with a similar error. It recommended increasing iterPeriod in PyRunner by a few orders of magnitude. All it did was delay when the error occured
The code is given below
# basic simulation showing sphere falling ball gravity,
# bouncing against another sphere representing the support
# DATA COMPONENTS
# add 2 particles to the simulation
# they the default material (utils.defaultMat)
O.bodies.append([
# fixed: particle's position in space will not change (support)
sphere(center=(0,0,0),radius=.5,fixed=True),
# this particles is free, subject to dynamics
sphere((0,0,2),.5)
])
# FUNCTIONAL COMPONENTS
# simulation loop -- see presentation for the explanation
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom()], # collision geometry
[Ip2_FrictMat_FrictMat_FrictPhys()], # collision "physics"
[Law2_ScGeom_FrictPhys_CundallStrack()] # contact law -- apply forces
),
# Apply gravity force to particles. damping: numerical dissipation of energy.
NewtonIntegrator(gravity=(0,0,-9.81),damping=0.1)
]
# set timestep to a fraction of the critical timestep
# the fraction is very small, so that the simulation is not too fast
# and the motion can be observed
O.dt=.5e-4*PWaveTimeStep()
# save the simulation, so that it can be reloaded later, for experimentation
O.saveTmp()
from yade import plot
plot.plots={'t':('coordNum','unForce',None,'Ek')} # kinetic energy will have legend on the right as indicated by None separator.
O.trackEnergy=True
def addPlotData():
# this function adds current values to the history of data, under the names specified
plot.addData(t=O.time,Ek=utils.kineticEnergy(),coordNum=utils.avgNumInteractions(),unForce=utils.unbalancedForce())
O.engines+=[PyRunner(command='addPlotData()',iterPeriod=2000)]
plot.plots={'t':('coordNum','unForce',None,'Ek')}
plot.plot()
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
***********************************************************************************************************************
The error that I get is given below
Unhandled exception in thread started by <function liveUpdate at 0x7f45b3db18c0>
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/usr/lib/x86_64-linux-gnu/yade/py/yade/plot.py in liveUpdate(timestamp)
506 for ax in axes:
507 try:
--> 508 ax.relim() # recompute axes limits
509 ax.autoscale_view()
510 except RuntimeError: pass # happens if data are being updated and have not the same dimension at the very moment
/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in relim(self, visible_only)
1936 for line in self.lines:
1937 if not visible_only or line.get_visible():
-> 1938 self._update_line_limits(line)
1939
1940 for p in self.patches:
/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in _update_line_limits(self, line)
1799 Figures out the data limit of the given line, updating self.dataLim.
1800 """
-> 1801 path = line.get_path()
1802 if path.vertices.size == 0:
1803 return
/usr/lib/python2.7/dist-packages/matplotlib/lines.pyc in get_path(self)
955 """
956 if self._invalidy or self._invalidx:
--> 957 self.recache()
958 return self._path
959
/usr/lib/python2.7/dist-packages/matplotlib/lines.pyc in recache(self, always)
665 y = self._y
666
--> 667 self._xy = np.column_stack(np.broadcast_arrays(x, y)).astype(float)
668 self._x, self._y = self._xy.T # views
669
/home/intern/.local/lib/python2.7/site-packages/numpy/lib/stride_tricks.pyc in broadcast_arrays(*args, **kwargs)
257 args = [np.array(_m, copy=False, subok=subok) for _m in args]
258
--> 259 shape = _broadcast_shape(*args)
260
261 if all(array.shape == shape for array in args):
/home/intern/.local/lib/python2.7/site-packages/numpy/lib/stride_tricks.pyc in _broadcast_shape(*args)
191 # use the old-iterator because np.nditer does not handle size 0 arrays
192 # consistently
--> 193 b = np.broadcast(*args[:32])
194 # unfortunately, it cannot handle 32 or more arguments directly
195 for pos in range(32, len(args), 31):
ValueError: shape mismatch: objects cannot be broadcast to a single shape
--
You received this question notification because your team yade-users is
an answer contact for Yade.