Lesson 15: Mechanical Engineering Diagrams — \(T\)-\(s\) Cycles & Shear/Moment (\(V\)-\(M\)) Plots
The “Boring Stuff” Problem: Drawing Clean Power-Cycle & Beam Diagrams by Hand
In Thermodynamics I/II (ME 200 &
ME 300) and Statics/Solids,
sketching an accurate Rankine \(T\)-\(s\)
diagram or Shear/Bending Moment (\(V\)-\(M\))
diagram by hand leaves critical values blurry—and re-drawing it after
moving a load or changing condenser pressure is painful.
In this lesson, you will build three signature engineering diagrams programmatically directly from physics and course CSV tables:
- Ideal Regenerative/Superheated Rankine Cycle \(T\)-\(s\)
Diagram overlaid onto the actual steam dome
(
ME200_Saturated_Water_Temp_Table.csv), - Cantilever/Simply-Supported Beam Shear Force \(V(x)\) and Bending Moment \(M(x)\) Diagram with shaded area and annotated peak moment,
- NACA Airfoil / Finite-Wing Drag Polar (\(C_L\) vs \(C_D\)) showing peak range \((L/D)_{\max}\) tangent!
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path
# Diagram 1 (ME 200 / ME 300): Steam Rankine Cycle T-s Diagram with Real Saturation Dome
sat_p = next(p for p in [Path("datasets/ME200_Saturated_Water_Temp_Table.csv"), Path("../datasets/ME200_Saturated_Water_Temp_Table.csv")] if p.exists())
sat = np.loadtxt(sat_p, delimiter=",", skiprows=1)
T_dome, P_dome, sf, sg = sat[:, 0], sat[:, 1], sat[:, 5], sat[:, 9]
# Superheated Ideal Rankine Cycle: P_cond = 0.1 bar (45.8 C), P_boiler = 80 bar (295 C sat, superheat to 500 C)
s1, T1 = 0.649, 45.8 # Pump inlet: saturated liquid at 0.1 bar
s2, T2 = 0.649, 46.5 # Pump outlet: slight T rise (compressed liquid at 80 bar)
s2f, T2f = 3.207, 295.0 # Saturated liquid at 80 bar (economizer end)
s2g, T2g = 5.743, 295.0 # Saturated vapor at 80 bar (evaporator end)
s3, T3 = 6.724, 500.0 # Turbine inlet: superheated 80 bar, 500 C
s4, T4 = 6.724, 45.8 # Ideal turbine exhaust inside dome
s_cyc = [s1, s2, s2f, s2g, s3, s4, s1]
T_cyc = [T1, T2, T2f, T2g, T3, T4, T1]
fig, ax = plt.subplots(figsize=(7.5, 4.8))
ax.plot(sf, T_dome, "-", color="#94a3b8", lw=2, label="Saturation Dome")
ax.plot(sg, T_dome, "-", color="#94a3b8", lw=2)
ax.plot(s_cyc, T_cyc, "o-", color="#dc2626", lw=2.3, markersize=6, label="Ideal Rankine Cycle (80 bar / 500 C)")
ax.fill(s_cyc, T_cyc, color="#fecaca", alpha=0.25, label="Net Specific Work $w_{\\mathrm{net}} = \\oint T\\,ds$")
labels = [("1 (Cond Out)", (s1, T1), (-15, -18)),
("2f", (s2f, T2f), (-22, 6)),
("2g", (s2g, T2g), (-20, 8)),
("3 (Turb In)", (s3, T3), (8, -4)),
("4 (Exhaust)", (s4, T4), (8, -12))]
for txt, xy, ofs in labels:
ax.annotate(txt, xy=xy, xytext=ofs, textcoords="offset points", fontsize=8.5, fontweight="bold")
ax.set_title("Superheated Steam Rankine Power Cycle on Real Water $T$-$s$ Dome")
ax.set_xlabel("Specific Entropy $s$ [kJ/(kg$\\cdot$K)]")
ax.set_ylabel("Temperature $T$ [$^\\circ$C]")
ax.set_ylim(0, 560)
ax.grid(True, alpha=0.3)
ax.legend(loc="upper left", fontsize=8.5)
fig.tight_layout()
# Diagram 2 (Statics & Solid Mechanics): Shear Force V(x) & Bending Moment M(x) Diagram
# Simply supported shaft of length L = 4.0 m: Uniform load w = 3.0 kN/m + Point load P = 10 kN at a = 2.5 m
L, w, P, a = 4.0, 3.0, 10.0, 2.5
R_B = (w * L * (L / 2.0) + P * a) / L
R_A = w * L + P - R_B
x = np.linspace(0.0, L, 801)
V = R_A - w * x - np.where(x >= a, P, 0.0)
M = R_A * x - 0.5 * w * (x ** 2) - np.where(x >= a, P * (x - a), 0.0)
idx_max = np.argmax(M)
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(7.6, 5.4), sharex=True)
ax1.plot(x, V, "-", color="#0284c7", lw=2)
ax1.fill_between(x, V, 0, color="#bae6fd", alpha=0.45)
ax1.axhline(0, color="#0f172a", lw=1)
ax1.set_ylabel("Shear $V(x)$ [kN]")
ax1.set_title(f"Beam V-M Diagrams ($R_A = {R_A:.2f}$ kN, $R_B = {R_B:.2f}$ kN)")
ax1.grid(True, alpha=0.3)
ax2.plot(x, M, "-", color="#dc2626", lw=2)
ax2.fill_between(x, M, 0, color="#fecaca", alpha=0.45)
ax2.axhline(0, color="#0f172a", lw=1)
ax2.plot(x[idx_max], M[idx_max], "ko", markersize=6)
ax2.annotate(f"$M_{{\\max}} = {M[idx_max]:.2f}$ kN$\\cdot$m at x = {x[idx_max]:.2f} m",
xy=(x[idx_max], M[idx_max]), xytext=(x[idx_max]-1.1, M[idx_max]*0.45),
arrowprops=dict(arrowstyle="->"), fontsize=9, fontweight="bold")
ax2.set_xlabel("Beam Position $x$ [m]")
ax2.set_ylabel("Bending Moment $M(x)$ [kN$\\cdot$m]")
ax2.grid(True, alpha=0.3)
fig.tight_layout()
Notice that super clean
np.where(x >= a, P * (x - a), 0.0) trick—that is
Macaulay’s singularity step function coded cleanly in
one vectorized NumPy line!
Practice Questions (Concept Check)
- Why does the shaded loop area \(\oint T\,ds\) on a Rankine \(T\)-\(s\) diagram equal net cycle work?
- Look at
np.where(x >= a, P * (x - a), 0.0)—why does this produce a slope jump (corner) in \(M(x)\) and a vertical drop in \(V(x)\) right at \(x = a\)? - Why did we pass
sharex=Truewhen stacking ShearV(x)directly above MomentM(x)? - What does
textcoords="offset points"do insideax.annotate?
Guided
Practice Problem 1 (Worked Self-Check): Parabolic Wing Drag Polar &
Max \((L/D)\) Tangent
(Fluid Mechanics)
Using parabolic polar \(C_D = C_{D,0} +
\frac{C_L^2}{\pi e AR}\) (CD0 = 0.024,
AR = 8.0, e = 0.85), sweep \(C_L \in [0, 1.5]\), plot \(C_D\) vs \(C_L\), draw the tangent line from the
origin \((0, 0)\) touching the curve
right at optimal glide \(C_L^* =
\sqrt{C_{D,0}\pi e AR}\), and mark \((L/D)_{\max}\).
Hint: Slope of ray from origin is CL / CD = L / D
The ray passing through the origin that just grazes the polar curve has maximum slope \((L/D)_{\max}\)!
# Worked Practice Problem 1 Solution: Wing Drag Polar & Origin Tangent
CD0, AR, e = 0.024, 8.0, 0.85
CL = np.linspace(0.0, 1.5, 200)
CD = CD0 + (CL ** 2) / (np.pi * e * AR)
CL_opt = np.sqrt(CD0 * np.pi * e * AR)
CD_opt = 2.0 * CD0
LD_max = CL_opt / CD_opt
fig, ax = plt.subplots(figsize=(6.8, 4.4))
ax.plot(CD, CL, "-", color="#0284c7", lw=2.3, label="Parabolic Drag Polar")
ax.plot([0, CD_opt * 1.4], [0, CL_opt * 1.4], "--", color="#dc2626", lw=1.6, label=f"Max $(L/D)_{{\\max}} = {LD_max:.1f}$ Ray")
ax.plot(CD_opt, CL_opt, "ko", markersize=7)
ax.annotate(f"Opt Glide ($C_L={CL_opt:.2f}, C_D={CD_opt:.3f}$)", xy=(CD_opt, CL_opt),
xytext=(CD_opt + 0.02, CL_opt - 0.25), arrowprops=dict(arrowstyle="->"), fontsize=9)
ax.set_title("3D Finite Wing Aerodynamic Drag Polar (Fluids Module 7)")
ax.set_xlabel("Total Drag Coefficient $C_D$"); ax.set_ylabel("Lift Coefficient $C_L$")
ax.set_xlim(0, 0.14); ax.set_ylim(0, 1.55); ax.grid(True, alpha=0.3); ax.legend(); fig.tight_layout()
End-of-Chapter Practice Problems (Try Yourself!)
- Ideal Otto Cycle \(P\)-\(V\)
Diagram (
ME 200): For compression ratio \(r = 9.0\) (\(V_1 = 0.5\text{ L}, P_1 = 100\text{ kPa}, T_1 = 300\text{ K}, T_3 = 2000\text{ K}, k = 1.4\)), plot all 4 processes (isentropic compression1->2curved, constant-\(V\)2->3, isentropic expansion3->4curved,4->1) and shade net cycle work. - Mohr’s Circle Stress Diagram
(
Solid Mechanics): Plot the circular locus \((\sigma_n(\theta), \tau_{nt}(\theta))\) for plane stress \(\sigma_x = 90\text{ MPa}, \sigma_y = -30\text{ MPa}, \tau_{xy} = 40\text{ MPa}\) and annotate \(\sigma_1, \sigma_2, \tau_{\max}\). - Pipe HGL & EGL Step Drop
(
Fluid Mechanics): Plot both Energy Grade Line and Hydraulic Grade Line along a 3-section pipe with a sudden expansion at \(x = 30\text{ m}\).