import numpy as np
import matplotlib.pyplot as plt
from resonance.linear_systems import FourStoryBuildingSystem
This gives a bit nicer printing of large NumPy arrays.
np.set_printoptions(precision=5, linewidth=100, suppress=True)
%matplotlib inline
sys = FourStoryBuildingSystem()
M, C, K = sys.canonical_coefficients()
L = np.linalg.cholesky(M)
K_tilde = np.linalg.inv(L) @ K @ np.linalg.inv(L.T)
evals, evecs = np.linalg.eig(K_tilde)
ws = np.sqrt(evals)
ws
sys.constants['amplitude'] = 100 # N
sys.constants['frequency'] = ws[0] # rad/s
def push_floor(amplitude, frequency, time):
return 0, 0, 0, amplitude * np.sin(frequency * time)
sys.forcing_func = push_floor
traj = sys.forced_response(50)
traj.plot(subplots=True);
sys.animate_configuration(fps=10)
sys.constants['amplitude'] = 100 # N
sys.constants['frequency'] = ws[3] # rad/s
def push_floor(amplitude, frequency, time):
return 0, 0, 0, amplitude * np.sin(frequency * time)
sys.forcing_func = push_floor
traj = sys.forced_response(50)
traj.plot(subplots=True);
sys.animate_configuration(fps=10)
sys.constants['amplitude'] = 100 # N
sys.constants['frequency'] = ws[2] # rad/s
def push_floor(amplitude, frequency, time):
return 0, 0, amplitude * np.sin(frequency * time), 0
sys.forcing_func = push_floor
traj = sys.forced_response(50)
traj.plot(subplots=True);
sys.animate_configuration(fps=10)