I am trying to solve the ODE for a harmonic oscillator using Scipy's odeint solver for different dampening factors.
I'm using the following code, based off of this example:
from scipy.integrate import odeint m = 1 # kg k = 10 # N/m omega = np.sqrt(k / m) def eps(c): return (c / (2 * mass * np.sqrt(kspring/mass))) def calc_deri(y, t, eps, omega): return (y, -eps * omega * y - omega **2 * y) time_vec = np.linspace(0, 8, 80) yinit = (1, 0) plt.figure(figsize=(10, 7)) for c in [1, 2, 3, 4, 5, 6]: eps_c = eps(c) yarr = odeint(calc_deri, yinit, time_vec, args=(eps_c, omega)) plt.plot(time_vec, yarr[:, 0]) plt.show()
My problem is that no matter what combination of
c I use, I always get a set of curves which have very close oscillation frequencies (I can't tell from the plot whether there is no difference at all or whether the difference is so small as to not show on the graph).
Something like this:
But I am hoping to get something that looks more like this:
What am I doing wrong?