I'm trying to plot a runge kutta equation, but it shows an empty value. Where did I go wrong in the logic?
for n in xrange(0,10):
k1 = R*T[n] + g*h[n]
l1 = -1*r*h[n] - a*b*T[n]
k2 = R*(T[n]+k1*not_dt/2) + g*(h[n]+l1*not_dt/2)
l2 = -1*r*(h[n]+l1*not_dt/2) - a*b*(T[n]+k1*not_dt/2)
k3 = R*(T[n]+k2*not_dt/2) + g*(h[n]+l2*not_dt/2)
l3 = -1*r*(h[n]+l2*not_dt/2) - a*b*(T[n]+k2*not_dt/2)
k4 = R*(T[n]+k3*not_dt) + g*(h[n]+l3*not_dt)
l4 = -1*r*(h[n]+l3*not_dt) - a*b*(T[n]+k3*not_dt)
T[n+1] = T[n] + not_dt/6 *(k1+2*k2+2*k3+k4)
h[n+1] = h[n] + not_dt/6 *(l1+2*l2+2*l3+l4)
plt.plot(T[n+i],h[n+i])
Perhaps I try to simplify a bit
T[0] = 11
h[0] = 0
for test in xrange(0, 10):
k1 = T[test] + h[test]
k2 = 2*k1
k3 = 2*k2
T[test+1] = T[test]+k3
h[test+1] = h[test]+k2
print T[test+1], h[test+1]
plt.plot(T[test+1],h[test+1])
I've tried running simplified script above and it gives value for print, but it just wont showed up in plot. So the question is perhaps in the end not related to runge kutta after all, just some logic in plotting. Sorry about that.