def plot_eval(): #### Eigenvalue plot ##### u2 = arange(-30, 30.01, 0.01, dtype=complex) n = len(u1) eval = zeros((n,3), dtype=complex) for i, u in enumerate(u1): eval[i] = rd.evals(u, (g, r)) mnmx = array([min([min(eval[:,1].imag), min(eval[:,1].real)]), max([max(eval[:,0].real), max(eval[:,0].imag)])]) cs = rd.critical_speed((g,r)) cs = array([cs, cs]) plt.figure() plt.plot(u2, eval[:,0].real, 'r', label='Re($\lambda_0$)') plt.plot(u2, eval[:,1].real, 'b', label='Re($\lambda_1$)') plt.plot(u2, eval[:,0].imag, 'r:', label='Im($\lambda_0$)') plt.plot(u2, eval[:,1].imag, 'b:', label='Im($\lambda_1$)') plt.plot(cs, mnmx, 'g:', linewidth=2) plt.plot(-cs, mnmx, 'g:', linewidth=2) plt.title('Eigenvalues of linearized EOMS about upright steady configuration,\n'+ 'm=%.4f kg, r=%.4f m'%(m,r)) plt.xlabel('$u_2$ [rad / s] Spin rate') plt.axis('tight') plt.grid() plt.legend(loc=0) plt.show()
def plot_eval(): #### Eigenvalue plot ##### u2 = arange(-30, 30.01, 0.01, dtype=complex) n = len(u1) eval = zeros((n, 3), dtype=complex) for i, u in enumerate(u1): eval[i] = rd.evals(u, (g, r)) mnmx = array([ min([min(eval[:, 1].imag), min(eval[:, 1].real)]), max([max(eval[:, 0].real), max(eval[:, 0].imag)]) ]) cs = rd.critical_speed((g, r)) cs = array([cs, cs]) plt.figure() plt.plot(u2, eval[:, 0].real, 'r', label='Re($\lambda_0$)') plt.plot(u2, eval[:, 1].real, 'b', label='Re($\lambda_1$)') plt.plot(u2, eval[:, 0].imag, 'r:', label='Im($\lambda_0$)') plt.plot(u2, eval[:, 1].imag, 'b:', label='Im($\lambda_1$)') plt.plot(cs, mnmx, 'g:', linewidth=2) plt.plot(-cs, mnmx, 'g:', linewidth=2) plt.title( 'Eigenvalues of linearized EOMS about upright steady configuration,\n' + 'm=%.4f kg, r=%.4f m' % (m, r)) plt.xlabel('$u_2$ [rad / s] Spin rate') plt.axis('tight') plt.grid() plt.legend(loc=0) plt.show()
# Eigenvalue plot #plot_eval() # states = [q1, q2, q3, q4, q5, u1, u2, u3] # q1, q2, q3 are Body Fixed (Euler) 3-1-2 angles # q1: Yaw / heading angle # q2: Lean angle # q3: Spin angle # q4, q5 are N[1], N[2] Inertial positions of contact point # u1, u2, u3 are the body fixed components of angular velocity # Gravity is in the positive N[3] direction (into the ground) # Specify the initial conditions of the coordinates lean = 0.1 qi = [pi/4, lean, 0.0, .001, 0.001] cs = rd.critical_speed((g,r)) # Initial condition above critical speed: ui = [.1, cs[0]*2.1, 0.0] ui = [.1, cs[0], 0.0] # Initial condition below critical speed: ui = [.1, cs[0]*.6, 0.0] animate_steady = False xi = set_ics(qi, ui, animate_steady) # Integration time ti = 0.0 ts = 0.001 tf = 1.0 t = arange(ti, tf+ts, ts) n = len(t) # Integrate the differential equations
# Eigenvalue plot #plot_eval() # states = [q1, q2, q3, q4, q5, u1, u2, u3] # q1, q2, q3 are Body Fixed (Euler) 3-1-2 angles # q1: Yaw / heading angle # q2: Lean angle # q3: Spin angle # q4, q5 are N[1], N[2] Inertial positions of contact point # u1, u2, u3 are the body fixed components of angular velocity # Gravity is in the positive N[3] direction (into the ground) # Specify the initial conditions of the coordinates lean = 0.1 qi = [pi / 4, lean, 0.0, .001, 0.001] cs = rd.critical_speed((g, r)) # Initial condition above critical speed: ui = [.1, cs[0] * 2.1, 0.0] ui = [.1, cs[0], 0.0] # Initial condition below critical speed: ui = [.1, cs[0] * .6, 0.0] animate_steady = False xi = set_ics(qi, ui, animate_steady) # Integration time ti = 0.0 ts = 0.001 tf = 1.0 t = arange(ti, tf + ts, ts) n = len(t) # Integrate the differential equations