Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Check out the variables in the line of code which is giving you problems:

s.velocity = s.velocity +((1.6e-22)*cos(w*t)*dt)

It looks like one of the arrays is empty.

You can see this problem in a distilled case like:

import numpy as np
np.array([1,1,1]) * np.array([])

Which gives the error:

ValueError: operands could not be broadcast together with shapes (3) (0)
> <ipython-input-165-1fc37b5acfae>(1)<module>()
----> 1 np.array([1,1,1]) * np.array([])

A couple more examples:

In [169]: np.array([1,1,1]) * np.array([2.5, 1.0]) 
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-169-37890460fbb0> in <module>()
----> 1 np.array([1,1,1]) * np.array([2.5, 1.0])

ValueError: operands could not be broadcast together with shapes (3) (2)

In [170]: np.array([1,1,1]) * np.array([2.5]) 
Out[170]: array([ 2.5,  2.5,  2.5])