I keep getting the error
TypeError: 'numpy.float64' object is not callable"
I thought I have been careful to not repeat variables within functions etc., but this error keeps popping up whenever I try to execute
scipy.integrate.odeint(doublepend,fnaught,t,args=(L,9.81,M))
I'm not sure what's going on. See below for the rest of the code.
import scipy as scipy
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import math as mt
import numpy as np
def singlepend(thetarray,time,Length,gravity,mass):
import numpy as np
theta,delatheta=y
dtheta=np.zeros_like(y)
#theta solved
dtheta[0]=deltatheta
dtheta[1]=(g/L)*np.sin(theta)
return dy
def doublepend(y,tim,Langles,g,Mangles):
import numpy as np
thetanaught,deltatheta,phinaught,deltaphi=y
mtheta,mphi=Mangles
print mtheta
Ltheta,Lphi=Langles
dy=np.zeros_like(y)
#theta solved
dy[0]=deltatheta
dy[1]=-mphi*np.sin(thetanaught-phinaught)*((deltatheta**2)*np.cos(thetanaught-phinaught)+(deltaphi**2)*Lphi/Lphi)/(mtheta+mphi*(1-np.cos(thetanaught-phinaught)*np.cos(thetanaught-phinaught)))\
+mphi*g*np.sin(phinaught)*np.cos(thetanaught-phinaught)/(Ltheta*(mtheta+mphi*(1-np.cos(thetanaught-phinaught)*np.cos(thetanaught-phinaught))))\
-(mtheta+mphi)*g*np.sin(thetanaught)/(Ltheta*(mtheta+mphi*(1-np.cos(thetanaught-phinaught)*np.cos(thetanaught-phinaught))))
#phi solved
dy[2]=deltaphi
dy[3]=mphi*(deltaphi**2)*np.sin(thetanaught-phinaught)/(mtheta+mphi*(1-np.cos(thetanaught-phinaught)*np.cos(thetanaught-phinaught)))\
+(mtheta+mphi)*g*np.sin(thetanaught)*np.cos(thetanaught-phinaught)/(Lphi*(mtheta+mphi*(1-np.cos(thetanaught-phinaught)*np.cos(thetanaught-phinaught))))\
(mtheta+mphi)*Ltheta*(deltatheta**2)*np.sin(thetanaught-phinaught)/(Lphi*(mtheta+mphi*(1-np.cos(thetanaught-phinaught)*np.cos*(thetanaught-phinaught))))\
-(mtheta+mphi)*g*np.sin(phinaught)/(Lphi*(mtheta+mphi*(1-np.cos(thetanaught-phinaught)*np.cos(thetanaught-phinaught))))
return dy
#initial conditions
m1=1
m2=1
L1=1
L2=1
M=(m1,m2)
L=(L1,L2)
phi1naught=np.array(np.pi/2)
phi2naught=np.array(np.pi/2)
phi1dotnaught=np.array(0)
phi2dotnaught=np.array(0)
fnaught=(phi1naught,phi1dotnaught,phi2naught,phi2dotnaught)
t=np.linspace(0,20,100001)
f=scipy.integrate.odeint(doublepend,fnaught,t,args=(L,9.81,M))
I realize that I do not need to import numpy multiple times. I am designing those functions to become a small library of functions to be used later as examples.
*np.cos*in your code. Doesn't look right, does it? And if you look at the break from the line before to that line you'll find closing parentheses immediately followed by opening ones. What does that suggest to you?