🟩 Complete every # TODO. Solution: 06_ContinuousSystems_RodsAndBeams.ipynb.
import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
from scipy.optimize import brentq, fsolve
plt.rcParams["figure.figsize"] = (7, 4.2)
plt.rcParams["axes.grid"] = TrueExercise (handwritten) — rods, separation of variables¶
🟥 Write in , separate into two ODEs, and show that for a fixed-free rod (, ) the natural frequencies are with .
🟩 Plot the first 3 mode shapes .
c, L = 1.0, 1.0
n_modes = 3
beta_n = ... # TODO: array of beta_n*L for n=1,2,3
omega_n = ... # TODO
x = np.linspace(0, L, 300)
fig, ax = plt.subplots()
for n in range(n_modes):
g = ... # TODO
ax.plot(x, g / np.max(np.abs(g)), label=f"mode {n+1}")
ax.legend()
plt.show()Exercise “Characteristic.m” — clamped-free beam eigenvalues¶
🟩 Solve both visually (plot vs. )
and numerically (scipy.optimize.brentq) for the first three roots. Compare to
.
betaL = np.linspace(0, 10, 2000)
fig, ax = plt.subplots()
ax.plot(betaL, np.cos(betaL), label=r"$\cos(\beta L)$")
ax.plot(betaL, -1 / np.cosh(betaL), label=r"$-1/\cosh(\beta L)$")
def char_eq(bl):
return ... # TODO: cos(bl)*cosh(bl) + 1
roots = []
for lo, hi in [(1, 3), (4, 5), (7, 8)]:
r = ... # TODO: brentq(...)
roots.append(r)
print(roots)Exercise “EX9” — mode shapes for a real cantilever¶
🟩 For , ,mm, ,mm, ,mm, ,Pa, compute , , , the natural frequencies (compare to 88.6, 555.2, 1554.7 rad/s), and plot the first three normalized mode shapes using
rho, L_beam, b, t_beam, E = 2750.0, 0.340, 0.022, 0.002, 7e10
A = ... # TODO
I = ... # TODO
m = ... # TODO
betaL_roots = np.array(roots)
beta = ... # TODO
omega = ... # TODO
print(omega)
def W_mode(x, beta, L):
sigma = ... # TODO
return ... # TODO
x = np.linspace(0, L_beam, 300)
# TODO: plot the 3 mode shapesHomework 7 — free-free beam & cantilever with a tip mass¶
🟦 Part 1. For a free-free beam ( at both ends), show the characteristic equation is and find the first four non-trivial roots (compare to 4.730, 7.853, 10.996, 14.137).
def char_eq_ff(bl):
return ... # TODO
roots_ff = []
for lo, hi in [(4, 5), (7, 8), (10, 11), (14, 15)]:
roots_ff.append(...) # TODO
print(roots_ff)🟦 Part 2. For a clamped-free beam with a tip point mass (no rotary inertia), the natural boundary conditions at are and .
🟩 Using sympy, build the general solution , eliminate via the clamped conditions at , form the
determinant of the two conditions, and non-dimensionalize with ,
. Then find how the fundamental root varies with , and check
the two limits: (plain clamped-free, ) and
(a simple oscillator, , from ).
L_s, beta_s, EI_s, M_s, m_s, C3, C4 = sp.symbols("L beta EI M m C3 C4", positive=True)
x_s = sp.symbols("x", positive=True)
W_full = ... # TODO: general clamped-free solution with C1=-C3, C2=-C4
Wpp_full = sp.diff(W_full, x_s, 2)
Wppp_full = sp.diff(W_full, x_s, 3)
eqM = ... # TODO
eqV = ... # TODO
Mat = sp.Matrix([[sp.diff(eqM, C3), sp.diff(eqM, C4)],
[sp.diff(eqV, C3), sp.diff(eqV, C4)]])
det_full = sp.simplify(Mat.det())
lam, gam = sp.symbols("lambda gamma", positive=True)
char_expr = ... # TODO: non-dimensionalize (remember m_s is an arbitrary positive scale)
# TODO: lambdify, scan gamma in [1e-6, 100], find the fundamental root for each, and plot
# against the two limiting cases