Files
MechanicalNotes/错题本/_scripts/gen_q001.py
T
Yimu f7730a13db 新增错题本体系,录入 Q001(飞轮转动惯量与角速度极值位置)
- 错题本/:一题一文件 + 总索引(登记表/状态跟踪/录题模板)
- Q001:审题关键 + 破题主线 + 完整解答 + 易错点 + 变式 + 重做记录
  2800 W 按「阻力段平均功率」解读,J_F = 2.5 kg·m^2
- images/q001-omega-t.png:按能量方程严格求解的 ω-t 曲线
- README 与 笔记/00-总索引 增加错题本入口
2026-11-13 14:36:47 +08:00

100 lines
4.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""Q001 飞轮:一个循环内主轴角速度变化曲线(严格按 omega^2 线性分段求解)
口径:2800 W = 阻力在工作段 5 s 内的平均功率"""
import os
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
OUT = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "images")
# ---- 题给参数 ----
T, t1 = 7.0, 5.0
Pr = 2800.0 # 阻力在工作段内的平均功率
Wr = Pr * t1 # 14 000 J
Pd = Wr / T # 2000 W(稳定运转:循环内输入功 = 阻力功)
J = 2.5 # kg*m^2
wmax, wmin = 108.0, 92.0
P_net_load = Pd - Pr # -800 W
P_net_idle = Pd # +2000 W
assert abs(P_net_load * t1 + P_net_idle * (T - t1)) < 1e-9
def omega(t):
tc = t % T
if tc <= t1:
return np.sqrt(wmax ** 2 + 2 * P_net_load / J * tc)
return np.sqrt(wmin ** 2 + 2 * P_net_idle / J * (tc - t1))
t = np.linspace(0, 2 * T, 2000)
w = np.array([omega(x) for x in t])
fig, ax = plt.subplots(figsize=(8.6, 4.7))
for k in range(2):
ax.axvspan(k * T, k * T + t1, color="#f7d9bd", alpha=0.85, lw=0, zorder=0)
ax.axvspan(k * T + t1, (k + 1) * T, color="#cfe0f2", alpha=0.9, lw=0, zorder=0)
ax.plot(t, w, color="#1f4e79", lw=2.6, zorder=3)
ax.axhline(100, color="#808080", lw=1.1, ls=(0, (5, 3)), zorder=2)
for tt, ww in [(5, wmin), (7, wmax), (12, wmin), (14, wmax)]:
ax.plot([tt], [ww], "o", ms=7, mfc="#c00000", mec="white", mew=1.2, zorder=5)
for tt in [5, 7, 12, 14]:
ax.axvline(tt, color="#9a9a9a", lw=0.9, ls=":", zorder=1)
ax.annotate("卸载瞬间(阻力作用结束)\n" + r"$\omega_{\min}=92\ \mathrm{rad/s}$",
xy=(5, wmin), xytext=(5.45, 85.2),
fontsize=10.5, color="#c00000", ha="left", va="bottom",
arrowprops=dict(arrowstyle="-|>", color="#c00000", lw=1.2,
shrinkA=3, shrinkB=5, connectionstyle="arc3,rad=-0.2"))
ax.annotate("加载瞬间(空转段结束)\n" + r"$\omega_{\max}=108\ \mathrm{rad/s}$",
xy=(7, wmax), xytext=(7.5, 110.3),
fontsize=10.5, color="#c00000", ha="left", va="bottom",
arrowprops=dict(arrowstyle="-|>", color="#c00000", lw=1.2,
shrinkA=3, shrinkB=5, connectionstyle="arc3,rad=0.2"))
ax.text(0.15, 113.2, r"$\Delta W_{\max}=\frac{1}{2}J\left(\omega_{\max}^{2}-\omega_{\min}^{2}\right)=4000\ \mathrm{J}$",
fontsize=11.5, color="#2e7d32", ha="left", va="top")
ax.annotate("", xy=(14.28, wmax), xytext=(14.28, wmin),
arrowprops=dict(arrowstyle="<|-|>", color="#2e7d32", lw=1.6),
annotation_clip=False)
ax.text(14.95, 100.9, r"$\omega_m=100$", fontsize=11, color="#4d4d4d", ha="left", va="bottom")
handles = [Patch(facecolor="#f7d9bd",
label="阻力做功段 $5\\,\\mathrm{s}$:" +
r"$P_{\mathrm{net}}=P_d-P_r=-800\ \mathrm{W}$(亏功,$\omega\downarrow$)"),
Patch(facecolor="#cfe0f2",
label="空转段 $2\\,\\mathrm{s}$:" +
r"$P_{\mathrm{net}}=+2000\ \mathrm{W}$(盈功,$\omega\uparrow$)")]
ax.legend(handles=handles, loc="upper center", bbox_to_anchor=(0.5, -0.16),
ncol=2, frameon=False, fontsize=10.0, handlelength=1.6, columnspacing=1.8)
ax.set_xlim(0, 14.6)
ax.set_ylim(84, 114)
ax.set_xticks([0, 5, 7, 12, 14])
ax.set_xticklabels(["0", "$5$", "$7=T$", "$12$", "$14=2T$"], fontsize=11)
ax.set_xlabel("时间 $t\\,/\\,\\mathrm{s}$", fontsize=12, labelpad=4)
ax.set_ylabel(r"主轴角速度 $\omega\,/\,(\mathrm{rad\cdot s^{-1}})$", fontsize=12)
ax.tick_params(axis="y", labelsize=11)
ax.set_yticks([85, 90, 92, 95, 100, 105, 108, 110])
ax.set_yticklabels(["85", "90", "92", "95", "100", "105", "108", "110"])
ax.grid(axis="y", color="#e2e2e2", lw=0.8, zorder=0)
for s in ("top", "right"):
ax.spines[s].set_visible(False)
fig.tight_layout()
out = os.path.join(OUT, "q001-omega-t.png")
fig.savefig(out, dpi=300, bbox_inches="tight", facecolor="white")
print("saved:", out)
print("Pd=%.1f Pr=%.1f dW=%.0f" % (Pd, Pr, abs(P_net_load) * t1))
print("omega(0)=%.3f omega(5)=%.3f omega(7)=%.3f" % (omega(0), omega(5), omega(7)))