“If you want to find the secrets of the universe, think in terms of energy, frequency, and vibration.”
(Nikola Tesla)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
import math import numpy as np import matplotlib.pyplot as plt from scipy.optimize import fmin pi=math.pi f=6.0 # f, Hz T=1/f #T, s omega=2.0*pi*f # Hz g=386.100 # in/s^2 def func_a(angle,a0,phase): # a0 = acceleration maginitude, g # phase, deg phase_rad=phase*pi/180.0 a=a0*np.cos(omega*angle-phase_rad) return a def func_d(angle,d0,phase): # a0 = acceleration maginitude, g # phase, deg d=d0*np.cos(omega*angle-phase*pi/180.0) return d n=200 x=np.linspace(0.0, T, num=n) a0_1=10.0 phase_1=30.0 d0_1=a0_1*g/omega**2 plt.plot(x,func_a(x,a0_1,phase_1),label="Accel 1") a0_2=8.0 phase_2=25.0 d0_2=a0_2*g/omega**2 plt.plot(x,func_a(x,a0_2,phase_2),label="Accel 2") plt.title('Acceleration in time domain') plt.xlabel('Frequency, Hz') plt.ylabel('Acceleration, g') plt.legend(loc="lower right") plt.grid() plt.savefig("ex419_1_res100.png", dpi=100) plt.savefig("ex419_1_res200.png", dpi=200) plt.show() plt.plot(x,func_d(x,d0_1,phase_1),label="Accel 1") plt.plot(x,func_d(x,d0_2,phase_2),label="Accel 2") plt.title('Displacement in time domain') plt.xlabel('Frequency, Hz') plt.ylabel('Displacement, in') plt.legend(loc="lower right") plt.grid() plt.savefig("ex419_2_res100.png", dpi=100) plt.savefig("ex419_2_res200.png", dpi=200) plt.show() plt.plot(x,func_d(x,d0_1,phase_1),label="Disp 1") plt.plot(x,func_d(x,d0_2,phase_2),label="Disp 2") plt.title('Displacement in time domain') plt.xlabel('Frequency, Hz') plt.ylabel('Displacement, in') plt.legend(loc="lower right") def delta(x): d = func_d(x,d0_1,phase_1) - func_d(x,d0_2,phase_2) return d plt.plot(x,delta(x),label="Relative disp") plt.title('Relative displacement in time domain') plt.xlabel('Frequency, Hz') plt.ylabel('Displacement, in') max_x = fmin(lambda x: -delta(x), 0.01) max_y=delta(max_x[0]) print("x_max=",max_x[0],"y_max=",max_y) plt.scatter(max_x, max_y, color='r', zorder=1,label="Max diff") plt.axvline(x=max_x,color='r', linestyle='--') plt.legend(loc="lower right") plt.grid() plt.savefig("ex419_3_res100.png", dpi=100) plt.savefig("ex419_3_res200.png", dpi=200) plt.show() |
Recent Comments