Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

2 (exercises). SDOF Systems — Forced Vibration & the Frequency Response Function

ISAE-SUPAERO

🟩 Complete every # TODO. Solution: 02_SDOF_ForcedVibration_FRF.ipynb.

Recall H(s)=X(s)/F(s)=1/(ms2+cs+k)H(s)=X(s)/F(s)=1/(ms^2+cs+k), and with r=ω/ωnr=\omega/\omega_n: X(jω)F(jω)=1/k(1−r2)+2jζr\dfrac{X(j\omega)}{F(j\omega)} = \dfrac{1/k}{(1-r^2)+2j\zeta r}.

import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
import control
from scipy.integrate import solve_ivp

plt.rcParams["figure.figsize"] = (7, 4.2)
plt.rcParams["axes.grid"] = True

Exercise “Ex1” — amplitude and phase vs. frequency ratio

🟩 For ζ=0.1,…,1.0\zeta=0.1,\ldots,1.0 in steps of 0.1, plot ∣kX/F∣|kX/F| (log-log) and the phase in degrees (semi-log-x) vs. r=ω/ωn∈[0.1,10]r=\omega/\omega_n \in [0.1, 10].

r = np.logspace(-1, 1, 400)
zetas = np.arange(0.1, 1.01, 0.1)

fig, axes = plt.subplots(2, 1, figsize=(7, 8), sharex=True)
for zeta in zetas:
    H = ...  # TODO: complex FRF k*X/F as a function of r and zeta
    mag = ...  # TODO
    phase_deg = ...  # TODO
    axes[0].loglog(r, mag, "k-", alpha=0.3 + 0.7 * zeta / zetas.max())
    axes[1].semilogx(r, phase_deg, "k-", alpha=0.3 + 0.7 * zeta / zetas.max())

axes[0].set_ylabel(r"$|kX/F|$")
axes[1].set_ylabel("Phase [deg]")
axes[1].set_xlabel(r"Frequency ratio $r=\omega/\omega_n$")
plt.tight_layout()
plt.show()

Exercise “Ex2a” — same FRF with python-control

🟩 Build sys = control.tf(num, den) for H(s)=1/(ms2+cs+k)H(s)=1/(ms^2+cs+k) with m=1,k=1,ζ=0.1m=1,k=1,\zeta=0.1, and plot its Bode diagram.

m, k = 1.0, 1.0
zeta = 0.1
c = ...  # TODO

den = ...  # TODO
num = ...  # TODO
sys = ...  # TODO
print(sys)

# TODO: control.bode_plot(...)

Exercise — sinusoidal forcing and resonance (undamped)

🟩 Implement the general solution of x¨+ωn2x=f0cos⁡ωt\ddot x + \omega_n^2 x = f_0\cos\omega t with the special resonant case ω=ωn\omega=\omega_n handled separately (amplitude growing as tsin⁡ωtt\sin\omega t).

def undamped_forced_response(t, wn, w, f0, x0, v0):
    if np.isclose(w, wn):
        A1, A2 = ..., ...  # TODO
        return ...  # TODO
    A2 = ...  # TODO
    A1 = ...  # TODO
    return ...  # TODO


wn = 1.0
t = np.linspace(0, 60, 3000)

fig, ax = plt.subplots()
for w, label in [(0.7, r"$\omega=0.7\,\omega_n$"), (1.0, r"$\omega=\omega_n$ (resonance)")]:
    x = undamped_forced_response(t, wn, w, f0=1.0, x0=0.0, v0=0.0)
    ax.plot(t, x, label=label)
ax.legend()
plt.show()

Exercise “H2” (handwritten) — Laplace transform table

🟥 Fill in the table by hand first. Then verify every entry with sympy.laplace_transform.

t_s, s_s, a_s, b_s, n_s = sp.symbols("t s a b n", positive=True)

entries = {
    "a": ...,        # TODO
    "sin(b*t)": ..., # TODO
    "cos(b*t)": ..., # TODO
    "t**n": ...,     # TODO
    "exp(-a*t)": ...,  # TODO
}
for name, f in entries.items():
    F = sp.laplace_transform(f, t_s, s_s, noconds=True)
    print(f"{name:<16}{sp.simplify(F)}")

Exercise “laplaceEx1” — recover the particular solution

🟩 Take X(s)=F0s(ms2+k)(s2+ω2)X(s) = \dfrac{F_0 s}{(ms^2+k)(s^2+\omega^2)} and use sympy.inverse_laplace_transform to invert it. Show it reduces to xp(t)=f0ωn2−ω2cos⁡ωtx_p(t)=\dfrac{f_0}{\omega_n^2-\omega^2}\cos\omega t once k=mωn2k=m\omega_n^2.

m_s, k_s, F0_s, w_s = sp.symbols("m k F0 omega", positive=True)
X_s = ...  # TODO
x_t = ...  # TODO
x_t

Exercise — “Doing physics” — four canonical cases

🟩 Using solve_ivp, reproduce and plot the response for:

  1. m=1,c=0,k=4m=1,c=0,k=4, x0=1,v0=0x_0=1,v_0=0, no force.

  2. m=1,c=0,k=4m=1,c=0,k=4, driven at ω=2\omega=2 (its natural frequency), zero ICs.

  3. m=1,c=0.5,k=4m=1,c=0.5,k=4, driven at ω=2\omega=2, zero ICs.

  4. m=1,c=0.5,k=4m=1,c=0.5,k=4, driven at ω=3\omega=3, zero ICs.

Comment on each: which one keeps growing? Which one saturates? Why?

def sdof_forced_ode(t, y, m, c, k, F0, w):
    x, v = y
    f = F0 * np.cos(w * t)
    return [v, (f - c * v - k * x) / m]


cases = [
    dict(name="(1) Free SHM", m=1, c=0, k=4, F0=0, w=0, x0=1, v0=0, tmax=20),
    dict(name="(2) Resonance, no damping", m=1, c=0, k=4, F0=1, w=2, x0=0, v0=0, tmax=40),
    dict(name="(3) Resonance, with damping", m=1, c=0.5, k=4, F0=1, w=2, x0=0, v0=0, tmax=40),
    dict(name="(4) Off-resonance, with damping", m=1, c=0.5, k=4, F0=1, w=3, x0=0, v0=0, tmax=40),
]

# TODO: loop over cases, solve_ivp each one, and plot on a 4x1 subplot grid