Hi, it seems like i need some help, cause i dont realy know to do.
I have some code(ode func and ode solver func):
import numpy as np
import matplotlib.pyplot as plt
from numba import njit
import numba as nb
@njit(cache = True)
def pend(t, y, b, c):
theta, omega = y
dydt = np.array([omega, -b*omega - c*np.sin(theta)])
return dydt
@njit
def rungeStep(f, t, y0, tau, params):
k1 = tau * f(t, y0, *params)
k2 = tau * f(t + tau/2, y0 + k1 / 2, *params)
k3 = tau * f(t + tau/2, y0 + k2 / 2, *params)
k4 = tau * f(t + tau, y0 + k3, *params)
return (k1 + 2 * k2 + 2 * k3 + k4) / 6
@njit(cache = True)
def integrate(f, t0, y0, tEnd, h, params):
ys = [list(y0)]
t = [t0]
while t0 <= tEnd:
y0 += rungeStep(f, t0, y0, h, params)
t0 += h
ys.append(list(y0))
t.append(t0)
return np.array(t), np.array(ys).T
args = (0.25, 5)
y0 = np.array([np.pi - 0.1, 0.0])
%timeit integrate(pend, 0, y0, 10, 1., args)
It works well, but i cant run it if i change args type from tuple to list for example. It works only for tuples.
Can you help me how can i solve this problem. And may be anyone can give me advance how to make it faster if it possible. Thank you in advance!