🟩 Complete every # TODO. Solution: 03_Duhamel_Impulse_BaseExcitation.ipynb.
import numpy as np
import matplotlib.pyplot as plt
import control
from scipy.integrate import solve_ivp
plt.rcParams["figure.figsize"] = (7, 4.2)
plt.rcParams["axes.grid"] = TrueExercise — implement the impulse response function¶
🟩 , with .
def impulse_response(t, m, zeta, wn):
wd = ... # TODO
return ... # TODO
m, wn, zeta = 1.0, 1.0, 0.01
t = np.linspace(0, 40, 2000)
fig, ax = plt.subplots()
ax.plot(t, impulse_response(t, m, zeta, wn))
plt.show()Exercise “Ex2B” — simulate the response to a sine input¶
🟩 Build sys = control.tf(...) for , , and use control.forced_response
to simulate the response to over 80 s (t=np.linspace(0,80,4000)).
m, k = 1.0, 1.0
zeta = 0.1
c = ... # TODO
sys = ... # TODO
t = np.linspace(0, 80, 4000)
f = ... # TODO
t_out, x_out = ... # TODO
fig, ax = plt.subplots()
ax.plot(t_out, x_out)
plt.show()Exercise — cross-check with a direct Duhamel convolution¶
🟩 Compute h = impulse_response(t, m, zeta, wn) and use numpy.convolve(f, h)[:len(t)]*dt
to evaluate the Duhamel integral directly. Compare to x_out above (they should agree once the
transient has died out).
dt = t[1] - t[0]
h = ... # TODO
x_duhamel = ... # TODO
# TODO: plot x_out and x_duhamel together and print the max difference for t>10sExercise — base excitation transmissibility¶
🟥 Handwritten. Starting from with , derive:
🟩 Then plot both transmissibilities vs. for several values of , and mark the crossover at .
r = np.linspace(0.01, 4, 800)
fig, axes = plt.subplots(1, 2, figsize=(11, 4.2))
for zeta in [0.05, 0.1, 0.25, 0.5, 0.7, 1.0]:
TR = ... # TODO
axes[0].plot(r, TR, label=rf"$\zeta={zeta}$")
axes[1].plot(r, r**2 * TR, label=rf"$\zeta={zeta}$")
plt.show()Exercise — tuned Dynamic Vibration Absorber¶
🟩 Complete two_mass_frf (2x2 dynamic-stiffness matrix inversion) for a primary mass
with an attached absorber (and light damping ), forced harmonically on
the primary mass. Tune and show the anti-resonance notch that appears for
several mass ratios .
def two_mass_frf(w, mp, kp, ma, ka, cp=0.0, ca=0.0):
Zp = ... # TODO
Za = ... # TODO
K11, K12 = ..., ... # TODO
K21, K22 = ..., ... # TODO
det = ... # TODO
Xp = ... # TODO
return Xp
mp, kp = 1.0, 1.0
w = np.linspace(0.2, 2.0, 2000)
fig, ax = plt.subplots()
ax.semilogy(w, np.abs(1.0 / (-mp * w**2 + kp)), label="No absorber")
for mass_ratio in [0.05, 0.1, 0.2]:
ma = mass_ratio * mp
ka = ... # TODO: tuned absorber stiffness
Xp = two_mass_frf(w, mp, kp, ma, ka, cp=0.0, ca=0.02 * ka)
ax.semilogy(w, np.abs(Xp), label=rf"$m_a/m_p={mass_ratio}$")
ax.legend()
plt.show()