print(parameters['omega_d'], T_drive, T_drive * 150, parameters['kappa']) step = 0.001 lim = 500 num = int(lim / step) times = np.linspace(0, lim, num + 1) y_0 = [1.9, -1.3] etas = np.linspace(0, 92, 375) velocities = [] for i in range(len(etas)): parameters['eta'] = etas[i] yvals = RK4(pendulumTorque, y_0, times, parameters) print(i) limit = int(num // 2) for t in times[limit:]: k = int(np.where(times == t)[0]) init = parameters['eta'] * np.cos( parameters['omega_d'] * times[k - 2] + parameters['delta']) * np.sin(yvals[k - 1, 0]) fin = parameters['eta'] * np.cos(parameters['omega_d'] * times[k] + parameters['delta']) * np.sin( yvals[k, 0]) if init * fin <= 0: #print(init, fin) vel = np.abs(yvals[k - 1, 1])
observables['kappa'] = 0. observables['eta'] = 0. observables['omega_0'] = np.sqrt((observables['M']*g*l)/I) N = 500 times = np.linspace(0., 10., N+1) phi_0 = np.pi/20 phidot_0 = 0. initial_conditions = np.array([phi_0, phidot_0]) yvals = RK4(pendulum, initial_conditions, times, observables) smol = phi_0*np.cos(observables['omega_0']*times) ''' plt.plot(times, yvals[:,0], '-', c='r', label='Calculated Angular Displacement') plt.plot(times, smol, '--', c='b', label='Small Angle Approximation') plt.legend(loc=2) plt.title('Time Evolution of Simple Harmonic Pendulum')
parameters['delta'] = 0. T = (2 * np.pi) / parameters['omega_0'] step = 0.001 lim = 100 num = int(lim / step) times = np.linspace(0, lim, num + 1) initialvals = np.linspace(np.pi / 15, np.pi / 1.1, 3) phi_in = 1.9 vel_in = 1.2 y_0 = np.array([phi_in, vel_in]) yvals = RK4(pendulum, y_0, times, parameters) plotargs = pp.Plot_Arguments colors = [ 'orange', 'red', 'turquoise', 'coral', 'crimson', 'magenta', 'blueviolet', 'darkslategrey', 'royalblue' 'darkgreen', 'maroon', 'greenyellow', 'coral', 'orangered', 'salmon' ] initialvals = [np.pi / 20, np.pi / 4, np.pi / 2, np.pi / 1.01] plotargs['loc'] = 4 plotargs['color'] = colors[0] plotargs['lineshape'] = '-' plotargs['title'] = '' plotargs['titlesize'] = 18
T = (2 * np.pi) / parameters['omega_0'] step = 0.001 lim = 5 num = int(lim / step) times = np.linspace(0, lim, num + 1) initialvals = np.linspace(np.pi / 15, np.pi / 1.1, 3) phi_in = 0 vel_in = 0 y_0 = np.array([phi_in, vel_in]) yvals = RK4(pendulum, y_0, times, parameters) plotargs = pp.Plot_Arguments colors = [ 'orange', 'red', 'coral', 'crimson', 'magenta', 'crimson', 'blueviolet', 'darkslategrey', 'royalblue' 'darkgreen', 'crimson', 'maroon', 'greenyellow', 'coral', 'orangered', 'turquoise', 'salmon' ] initialvals = [np.pi / 20, np.pi / 4, np.pi / 2, np.pi / 1.01] plotargs['loc'] = 4 plotargs['color'] = colors[0] plotargs['lineshape'] = '-' plotargs[
parameters['delta'] = 0. T = (2 * np.pi) / parameters['omega_0'] step = 0.001 lim = 50 num = int(lim / step) times = np.linspace(0, lim, num + 1) initialvals = np.linspace(np.pi / 15, np.pi / 1.1, 3) phi_in = 2.4 vel_in = -1.3 y_0 = np.array([phi_in, vel_in]) yvals = RK4(pendulum, y_0, times, parameters) plotargs = pp.Plot_Arguments colors = [ 'orange', 'red', 'turquoise', 'coral', 'crimson', 'magenta', 'blueviolet', 'darkslategrey', 'royalblue' 'darkgreen', 'maroon', 'greenyellow', 'coral', 'orangered', 'salmon' ] plotargs['loc'] = 4 plotargs['color'] = colors[0] plotargs['lineshape'] = '-' plotargs['title'] = '' plotargs['titlesize'] = 18 plotargs['labelsize'] = 12