I'm trying to solve a set of coupled differential equations using scipy.integrate.odeint
. However when I try to run the program I get the following error:
TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe' odepack.error: Result from function call is not a proper array of floats.
Here is the code I use:
V = "v**2/2*log(1+x**2 + (y/a)**2 + (z/c)**2)"
var = ['x','y','z']
def afleiden(func, var):
f = sympify(func)
partAfg = [f.diff(var[i]) for i in range(len(var))]
return partAfg
init=[0.3,0.2,0.9,0.2,0.6,0.7]
def func(rv, t, pot, var):
return rv[3:6] + afleiden(pot,var)
# rv is a list with 6 elements of witch the last 3 are part of the diff equations
t = np.arange(0,10,0.01)
y = odeint(func, init, t, args=(V, var,))
Could it be because the equations from afleiden
are calculated using Sympy and thus probably sypmpy
expressions? If so, is there anything i can do about it? I tried using lambdify but that didn't work out.