Datasets:
Upload folder using huggingface_hub (part 11)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- scipy/ballistic_pendulum/071/video.mp4Added+3
- scipy/ballistic_pendulum/081/cot.jsonAdded+112
- scipy/ballistic_pendulum/081/params.jsonAdded+9
- scipy/ballistic_pendulum/081/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/081/video.mp4Added+3
- scipy/ballistic_pendulum/103/cot.jsonAdded+112
- scipy/ballistic_pendulum/103/params.jsonAdded+9
- scipy/ballistic_pendulum/103/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/103/video.mp4Added+3
- scipy/ballistic_pendulum/196/cot.jsonAdded+112
- scipy/ballistic_pendulum/196/params.jsonAdded+9
- scipy/ballistic_pendulum/196/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/196/video.mp4Added+3
- scipy/ballistic_pendulum/233/cot.jsonAdded+112
- scipy/ballistic_pendulum/233/params.jsonAdded+9
- scipy/ballistic_pendulum/233/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/233/video.mp4Added+3
- scipy/ballistic_pendulum/238/cot.jsonAdded+112
- scipy/ballistic_pendulum/238/params.jsonAdded+9
- scipy/ballistic_pendulum/238/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/238/video.mp4Added+3
- scipy/ballistic_pendulum/284/cot.jsonAdded+112
- scipy/ballistic_pendulum/284/params.jsonAdded+9
- scipy/ballistic_pendulum/284/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/284/video.mp4Added+3
- scipy/ballistic_pendulum/296/cot.jsonAdded+112
- scipy/ballistic_pendulum/296/params.jsonAdded+9
- scipy/ballistic_pendulum/296/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/296/video.mp4Added+3
- scipy/ballistic_pendulum/300/cot.jsonAdded+112
- scipy/ballistic_pendulum/300/params.jsonAdded+9
- scipy/ballistic_pendulum/300/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/300/video.mp4Added+3
- scipy/ballistic_pendulum/370/cot.jsonAdded+112
- scipy/ballistic_pendulum/370/params.jsonAdded+9
- scipy/ballistic_pendulum/370/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/370/video.mp4Added+3
- scipy/ballistic_pendulum/389/cot.jsonAdded+112
- scipy/ballistic_pendulum/389/params.jsonAdded+9
- scipy/ballistic_pendulum/389/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/389/video.mp4Added+3
- scipy/ballistic_pendulum/464/cot.jsonAdded+112
- scipy/ballistic_pendulum/464/params.jsonAdded+9
- scipy/ballistic_pendulum/464/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/464/video.mp4Added+3
- scipy/ballistic_pendulum/565/cot.jsonAdded+112
- scipy/ballistic_pendulum/565/params.jsonAdded+9
- scipy/ballistic_pendulum/565/simulation_code.pyAdded+107
- scipy/ballistic_pendulum/565/video.mp4Added+3
- scipy/ballistic_pendulum/591/cot.jsonAdded+112
123version https://git-lfs.github.com/spec/v1oid sha256:e65b5547217d660dff6dc94d3f9fa3b52218332dbb4840f31907fdd953edf24esize 17540123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.278 kg moves horizontally at v_b=6.067 m/s and embeds itself in a stationary block of mass M=0.626 kg hanging from a rigid massless rod of length L=1.323 m. After the perfectly inelastic impact at t \\approx 0.327 s, the loaded pendulum (combined mass m+M=0.903 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.002 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-1.984 m, impact when x=0 at t=0.3271 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 1.8658 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 3.5410 J (69.2% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 1.4100 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 30.03^{\\circ} \\rightarrow h_max \\approx 0.1776 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-1.98 m to x=0 in 0.327 s.", "At impact, 69.2% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 30.03^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.309 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0003 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.277854727670406, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 0.6256439206110995, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 6.066916198044913, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.3232553605102273, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.002156972960240755, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -1.9841942553255316, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.277854727670406, "M": 0.6256439206110995, "v_b": 6.066916198044913, "L": 1.3232553605102273, "g": 9.8, "b": 0.002156972960240755, "x_b0": -1.9841942553255316}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.277854727670406 kg, M=0.6256439206110995 kg, v_b=6.066916198044913 m/s, L=1.3232553605102273 m, g=9.8 m/s², b=0.002156972960240755 kg·m²/s, x_b0=-1.9841942553255316 m v_after = m·v_b/(m+M) = 1.8658 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.277854727670406, 0.6256439206110995 v_b = 6.066916198044913 L = 1.3232553605102273 g = 9.8 b = 0.002156972960240755 x_b0 = -1.9841942553255316 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:5f31c0e8f5de1e9f393b52d3fec0ad8a2f34dc4ea5abbceb354d08d94722b3aasize 19293123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.296 kg moves horizontally at v_b=7.805 m/s and embeds itself in a stationary block of mass M=1.400 kg hanging from a rigid massless rod of length L=1.127 m. After the perfectly inelastic impact at t \\approx 0.316 s, the loaded pendulum (combined mass m+M=1.696 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.005 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-2.464 m, impact when x=0 at t=0.3157 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 1.3609 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 7.4367 J (82.6% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 1.2073 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 23.63^{\\circ} \\rightarrow h_max \\approx 0.0945 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.46 m to x=0 in 0.316 s.", "At impact, 82.6% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 23.63^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.131 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0004 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.2956730046674745, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 1.4002250627312618, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 7.805472534926552, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.1271662214877365, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.004588180863164593, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -2.464067779299508, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.2956730046674745, "M": 1.4002250627312618, "v_b": 7.805472534926552, "L": 1.1271662214877365, "g": 9.8, "b": 0.004588180863164593, "x_b0": -2.464067779299508}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.2956730046674745 kg, M=1.4002250627312618 kg, v_b=7.805472534926552 m/s, L=1.1271662214877365 m, g=9.8 m/s², b=0.004588180863164593 kg·m²/s, x_b0=-2.464067779299508 m v_after = m·v_b/(m+M) = 1.3609 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.2956730046674745, 1.4002250627312618 v_b = 7.805472534926552 L = 1.1271662214877365 g = 9.8 b = 0.004588180863164593 x_b0 = -2.464067779299508 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:aa18f59010439c9a850bf1a83b28e1d2a169cdfb8cf960b75c3127c7c23c7528size 15178123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.333 kg moves horizontally at v_b=9.630 m/s and embeds itself in a stationary block of mass M=0.798 kg hanging from a rigid massless rod of length L=1.244 m. After the perfectly inelastic impact at t \\approx 0.194 s, the loaded pendulum (combined mass m+M=1.131 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.164 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-1.867 m, impact when x=0 at t=0.1939 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 2.8336 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 10.8881 J (70.6% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 2.2776 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 47.88^{\\circ} \\rightarrow h_max \\approx 0.4097 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-1.87 m to x=0 in 0.194 s.", "At impact, 70.6% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 47.88^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.239 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0167 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.33272108048438775, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 0.7980350539079105, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 9.629940574585856, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.2441308245379847, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.16372877169616085, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -1.8669171778069973, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.33272108048438775, "M": 0.7980350539079105, "v_b": 9.629940574585856, "L": 1.2441308245379847, "g": 9.8, "b": 0.16372877169616085, "x_b0": -1.8669171778069973}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.33272108048438775 kg, M=0.7980350539079105 kg, v_b=9.629940574585856 m/s, L=1.2441308245379847 m, g=9.8 m/s², b=0.16372877169616085 kg·m²/s, x_b0=-1.8669171778069973 m v_after = m·v_b/(m+M) = 2.8336 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.33272108048438775, 0.7980350539079105 v_b = 9.629940574585856 L = 1.2441308245379847 g = 9.8 b = 0.16372877169616085 x_b0 = -1.8669171778069973 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:8c49756846e9b9db23a5590a6fd3d3d77de559429731b7f2917b98dcca2e31dcsize 21273123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.231 kg moves horizontally at v_b=7.831 m/s and embeds itself in a stationary block of mass M=0.698 kg hanging from a rigid massless rod of length L=1.216 m. After the perfectly inelastic impact at t \\approx 0.344 s, the loaded pendulum (combined mass m+M=0.929 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.060 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-2.697 m, impact when x=0 at t=0.3445 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 1.9493 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 5.3283 J (75.1% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 1.6033 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 32.80^{\\circ} \\rightarrow h_max \\approx 0.1939 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.70 m to x=0 in 0.344 s.", "At impact, 75.1% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 32.80^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.213 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0076 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.23136581642631313, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 0.6981118089917856, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 7.830975332029041, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.2157684831760527, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.059512999463699506, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -2.6974548720002978, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.23136581642631313, "M": 0.6981118089917856, "v_b": 7.830975332029041, "L": 1.2157684831760527, "g": 9.8, "b": 0.059512999463699506, "x_b0": -2.6974548720002978}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.23136581642631313 kg, M=0.6981118089917856 kg, v_b=7.830975332029041 m/s, L=1.2157684831760527 m, g=9.8 m/s², b=0.059512999463699506 kg·m²/s, x_b0=-2.6974548720002978 m v_after = m·v_b/(m+M) = 1.9493 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.23136581642631313, 0.6981118089917856 v_b = 7.830975332029041 L = 1.2157684831760527 g = 9.8 b = 0.059512999463699506 x_b0 = -2.6974548720002978 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:bb83e8d23c8f6704f8eea3ce24e00c9c75e0b8fcdf7ddc9d48650e2629554cb1size 16584123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.361 kg moves horizontally at v_b=9.018 m/s and embeds itself in a stationary block of mass M=0.806 kg hanging from a rigid massless rod of length L=1.301 m. After the perfectly inelastic impact at t \\approx 0.208 s, the loaded pendulum (combined mass m+M=1.167 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.131 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-1.872 m, impact when x=0 at t=0.2076 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 2.7888 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 10.1356 J (69.1% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 2.1439 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 45.98^{\\circ} \\rightarrow h_max \\approx 0.3968 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-1.87 m to x=0 in 0.208 s.", "At impact, 69.1% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 45.98^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.289 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0121 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.36087622474370185, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 0.8060352909881511, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 9.017838224762661, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.3008299864937731, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.13115678214663504, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -1.8722626254798886, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.36087622474370185, "M": 0.8060352909881511, "v_b": 9.017838224762661, "L": 1.3008299864937731, "g": 9.8, "b": 0.13115678214663504, "x_b0": -1.8722626254798886}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.36087622474370185 kg, M=0.8060352909881511 kg, v_b=9.017838224762661 m/s, L=1.3008299864937731 m, g=9.8 m/s², b=0.13115678214663504 kg·m²/s, x_b0=-1.8722626254798886 m v_after = m·v_b/(m+M) = 2.7888 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.36087622474370185, 0.8060352909881511 v_b = 9.017838224762661 L = 1.3008299864937731 g = 9.8 b = 0.13115678214663504 x_b0 = -1.8722626254798886 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:4546103e548b98f332adf74feb4e33a3d82102cebe2a9d4ca77f7f912f53e15esize 21099123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.207 kg moves horizontally at v_b=7.329 m/s and embeds itself in a stationary block of mass M=1.361 kg hanging from a rigid massless rod of length L=0.961 m. After the perfectly inelastic impact at t \\approx 0.362 s, the loaded pendulum (combined mass m+M=1.568 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.166 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-2.654 m, impact when x=0 at t=0.3621 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 0.9673 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 4.8256 J (86.8% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 1.0070 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 18.14^{\\circ} \\rightarrow h_max \\approx 0.0477 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.65 m to x=0 in 0.362 s.", "At impact, 86.8% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 18.14^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 1.967 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0180 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.20701369973520545, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 1.3613513926580583, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 7.328711384042167, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 0.9606327137861861, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.16596822945010736, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -2.6537813600815108, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.20701369973520545, "M": 1.3613513926580583, "v_b": 7.328711384042167, "L": 0.9606327137861861, "g": 9.8, "b": 0.16596822945010736, "x_b0": -2.6537813600815108}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.20701369973520545 kg, M=1.3613513926580583 kg, v_b=7.328711384042167 m/s, L=0.9606327137861861 m, g=9.8 m/s², b=0.16596822945010736 kg·m²/s, x_b0=-2.6537813600815108 m v_after = m·v_b/(m+M) = 0.9673 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.20701369973520545, 1.3613513926580583 v_b = 7.328711384042167 L = 0.9606327137861861 g = 9.8 b = 0.16596822945010736 x_b0 = -2.6537813600815108 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:a31a3ffeb306a9dd325f08264b1caf6afaa45a104221ecf918b1fe86ba5404b0size 12404123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.230 kg moves horizontally at v_b=5.771 m/s and embeds itself in a stationary block of mass M=1.375 kg hanging from a rigid massless rod of length L=0.994 m. After the perfectly inelastic impact at t \\approx 0.456 s, the loaded pendulum (combined mass m+M=1.604 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.121 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-2.630 m, impact when x=0 at t=0.4558 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 0.8257 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 3.2754 J (85.7% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 0.8305 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 15.20^{\\circ} \\rightarrow h_max \\approx 0.0348 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.63 m to x=0 in 0.456 s.", "At impact, 85.7% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 15.20^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.001 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0121 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.22955961604757902, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 1.3748651298448733, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 5.7706881828296455, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 0.9942069151835331, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.12086343072208233, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -2.6303622718108217, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.22955961604757902, "M": 1.3748651298448733, "v_b": 5.7706881828296455, "L": 0.9942069151835331, "g": 9.8, "b": 0.12086343072208233, "x_b0": -2.6303622718108217}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.22955961604757902 kg, M=1.3748651298448733 kg, v_b=5.7706881828296455 m/s, L=0.9942069151835331 m, g=9.8 m/s², b=0.12086343072208233 kg·m²/s, x_b0=-2.6303622718108217 m v_after = m·v_b/(m+M) = 0.8257 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.22955961604757902, 1.3748651298448733 v_b = 5.7706881828296455 L = 0.9942069151835331 g = 9.8 b = 0.12086343072208233 x_b0 = -2.6303622718108217 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:bef95779603ca39032c7ac60b89e4f548376cb55c288cf314460c99446bfd9d0size 12283123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.341 kg moves horizontally at v_b=8.849 m/s and embeds itself in a stationary block of mass M=1.171 kg hanging from a rigid massless rod of length L=1.336 m. After the perfectly inelastic impact at t \\approx 0.317 s, the loaded pendulum (combined mass m+M=1.512 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.100 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-2.802 m, impact when x=0 at t=0.3167 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 1.9981 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 10.3488 J (77.4% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 1.4953 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 32.05^{\\circ} \\rightarrow h_max \\approx 0.2037 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.80 m to x=0 in 0.317 s.", "At impact, 77.4% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 32.05^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.320 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0068 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.34140775028832265, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 1.170627099286853, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 8.849013423019514, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.3361843924056986, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.1001355750309848, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -2.802402198347533, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.34140775028832265, "M": 1.170627099286853, "v_b": 8.849013423019514, "L": 1.3361843924056986, "g": 9.8, "b": 0.1001355750309848, "x_b0": -2.802402198347533}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.34140775028832265 kg, M=1.170627099286853 kg, v_b=8.849013423019514 m/s, L=1.3361843924056986 m, g=9.8 m/s², b=0.1001355750309848 kg·m²/s, x_b0=-2.802402198347533 m v_after = m·v_b/(m+M) = 1.9981 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.34140775028832265, 1.170627099286853 v_b = 8.849013423019514 L = 1.3361843924056986 g = 9.8 b = 0.1001355750309848 x_b0 = -2.802402198347533 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:fde0763c8bc221593b6377985c5e8acb54f97fea8ba701b81a869ea0ab6aafdcsize 16481123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.376 kg moves horizontally at v_b=7.118 m/s and embeds itself in a stationary block of mass M=0.828 kg hanging from a rigid massless rod of length L=1.315 m. After the perfectly inelastic impact at t \\approx 0.374 s, the loaded pendulum (combined mass m+M=1.204 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.149 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-2.663 m, impact when x=0 at t=0.3742 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 2.2222 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 6.5498 J (68.8% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 1.6901 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 36.06^{\\circ} \\rightarrow h_max \\approx 0.2519 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.66 m to x=0 in 0.374 s.", "At impact, 68.8% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 36.06^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.301 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0131 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.37586387793789355, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 0.8281380197518744, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 7.118267834510721, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.3148326528708325, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.14860774580133482, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -2.6634988868603466, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.37586387793789355, "M": 0.8281380197518744, "v_b": 7.118267834510721, "L": 1.3148326528708325, "g": 9.8, "b": 0.14860774580133482, "x_b0": -2.6634988868603466}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.37586387793789355 kg, M=0.8281380197518744 kg, v_b=7.118267834510721 m/s, L=1.3148326528708325 m, g=9.8 m/s², b=0.14860774580133482 kg·m²/s, x_b0=-2.6634988868603466 m v_after = m·v_b/(m+M) = 2.2222 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.37586387793789355, 0.8281380197518744 v_b = 7.118267834510721 L = 1.3148326528708325 g = 9.8 b = 0.14860774580133482 x_b0 = -2.6634988868603466 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:d4f21ad4fc4a74c8991bc9e389b706ce761ea5fe2a6de6c8b3ec3a32e11e0c69size 17073123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.137 kg moves horizontally at v_b=10.537 m/s and embeds itself in a stationary block of mass M=1.272 kg hanging from a rigid massless rod of length L=1.289 m. After the perfectly inelastic impact at t \\approx 0.175 s, the loaded pendulum (combined mass m+M=1.409 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.002 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-1.848 m, impact when x=0 at t=0.1754 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 1.0227 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 6.8544 J (90.3% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 0.7931 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 16.54^{\\circ} \\rightarrow h_max \\approx 0.0534 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-1.85 m to x=0 in 0.175 s.", "At impact, 90.3% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 16.54^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.279 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0002 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.1367495085430944, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 1.2721931750134614, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 10.536762883484913, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.2894580530885746, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.002460173781960262, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -1.8481107949142412, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.1367495085430944, "M": 1.2721931750134614, "v_b": 10.536762883484913, "L": 1.2894580530885746, "g": 9.8, "b": 0.002460173781960262, "x_b0": -1.8481107949142412}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.1367495085430944 kg, M=1.2721931750134614 kg, v_b=10.536762883484913 m/s, L=1.2894580530885746 m, g=9.8 m/s², b=0.002460173781960262 kg·m²/s, x_b0=-1.8481107949142412 m v_after = m·v_b/(m+M) = 1.0227 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.1367495085430944, 1.2721931750134614 v_b = 10.536762883484913 L = 1.2894580530885746 g = 9.8 b = 0.002460173781960262 x_b0 = -1.8481107949142412 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:74d784da1446ad538a3ffc93a6583029aaa0dce4eac8aa991a38ab9158b23ab4size 16316123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.143 kg moves horizontally at v_b=8.600 m/s and embeds itself in a stationary block of mass M=1.091 kg hanging from a rigid massless rod of length L=1.326 m. After the perfectly inelastic impact at t \\approx 0.247 s, the loaded pendulum (combined mass m+M=1.234 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.081 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-2.126 m, impact when x=0 at t=0.2473 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 0.9972 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 4.6797 J (88.4% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 0.7522 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 15.90^{\\circ} \\rightarrow h_max \\approx 0.0507 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.13 m to x=0 in 0.247 s.", "At impact, 88.4% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 15.90^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.311 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0068 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.14314511159886073, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 1.09135106633226, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 8.59995509786118, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.3257054289917123, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.08062926759352221, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -2.1264181561810274, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.14314511159886073, "M": 1.09135106633226, "v_b": 8.59995509786118, "L": 1.3257054289917123, "g": 9.8, "b": 0.08062926759352221, "x_b0": -2.1264181561810274}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.14314511159886073 kg, M=1.09135106633226 kg, v_b=8.59995509786118 m/s, L=1.3257054289917123 m, g=9.8 m/s², b=0.08062926759352221 kg·m²/s, x_b0=-2.1264181561810274 m v_after = m·v_b/(m+M) = 0.9972 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.14314511159886073, 1.09135106633226 v_b = 8.59995509786118 L = 1.3257054289917123 g = 9.8 b = 0.08062926759352221 x_b0 = -2.1264181561810274 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:2d2f3c19447e5fe432d1f09a0f9d3cb002211f15653ea2dfac7d53daa0d284f6size 15180123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.243 kg moves horizontally at v_b=7.454 m/s and embeds itself in a stationary block of mass M=0.509 kg hanging from a rigid massless rod of length L=1.378 m. After the perfectly inelastic impact at t \\approx 0.376 s, the loaded pendulum (combined mass m+M=0.752 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.139 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-2.803 m, impact when x=0 at t=0.3760 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 2.4091 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 4.5702 J (67.7% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 1.7485 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 38.27^{\\circ} \\rightarrow h_max \\approx 0.2961 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.80 m to x=0 in 0.376 s.", "At impact, 67.7% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 38.27^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.356 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0182 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.24308081369008974, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 0.5090227035207093, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 7.4538203382365475, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.377794309528464, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.13871425723151906, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -2.8026935662800985, "unit": "m", "description": "Bullet initial x-position" } }}123456789{ "m": 0.24308081369008974, "M": 0.5090227035207093, "v_b": 7.4538203382365475, "L": 1.377794309528464, "g": 9.8, "b": 0.13871425723151906, "x_b0": -2.8026935662800985}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Ballistic Pendulum — auto-generated simulation script.
Physics: 1. Inelastic collision (instantaneous): m·v_b = (m+M)·v_after 2. Loaded pendulum after impact: θ̈ = -(g/L)·sin(θ) - (b/((m+M)·L²))·θ̇ 3. From the swing's max angle θ_max one recovers v_b via v_b = ((m+M)/m)·sqrt(2·g·L·(1 - cos θ_max)) (b → 0 limit)
Parameters: m=0.24308081369008974 kg, M=0.5090227035207093 kg, v_b=7.4538203382365475 m/s, L=1.377794309528464 m, g=9.8 m/s², b=0.13871425723151906 kg·m²/s, x_b0=-2.8026935662800985 m v_after = m·v_b/(m+M) = 2.4091 m/s"""import numpy as npfrom scipy.integrate import solve_ivpimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport matplotlib.patches as patches
m, M = 0.24308081369008974, 0.5090227035207093 v_b = 7.4538203382365475 L = 1.377794309528464 g = 9.8 b = 0.13871425723151906 x_b0 = -2.8026935662800985 duration = 12fps = 30
t_impact = max(0.0, -x_b0 / v_b)v_after = m * v_b / (m + M)omega_after = v_after / L
def ode(t, y): theta, omega = y Iover = (m + M) * L * L dtheta = omega domega = -(g / L) * np.sin(theta) - (b / Iover) * omega return [dtheta, domega]
n_frames = int(duration * fps) + 1t_eval = np.linspace(0, duration, n_frames)pre_mask = t_eval < t_impactpost_mask = ~pre_mask
bullet_x = np.empty(n_frames)bullet_y = np.full(n_frames, -L)theta = np.zeros(n_frames)embedded = np.zeros(n_frames)
bullet_x[pre_mask] = x_b0 + v_b * t_eval[pre_mask]bullet_x[post_mask] = 0.0
if np.any(post_mask): post_t_local = t_eval[post_mask] - t_impact if post_t_local[-1] > 0: sol = solve_ivp(ode, (0.0, post_t_local[-1]), [0.0, omega_after], t_eval=post_t_local, method="RK45", rtol=1e-9, atol=1e-11) theta[post_mask] = sol.y[0] bullet_x[post_mask] = L * np.sin(theta[post_mask]) bullet_y[post_mask] = -L * np.cos(theta[post_mask]) embedded[post_mask] = 1.0
bw = max(0.16, 0.10 * L); bh = max(0.16, 0.10 * L)pad = 0.4xlim = (x_b0 - 0.3, L + pad)ylim = (-L - max(bh, 0.4), 0.6)
fig, ax = plt.subplots(figsize=(7, 5), facecolor="#1a1a2e")ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim)ax.set_aspect("equal"); ax.axis("off")ax.plot([0], [0], "o", color="white", ms=7, zorder=6)ax.axvline(0, color="#4a4e69", lw=0.8, ls="--", alpha=0.5, zorder=1)ax.axhline(-L, color="#4a4e69", lw=0.6, ls=":", alpha=0.4, zorder=1)ax.plot([x_b0, 0], [-L, -L], color="#4a4e69", lw=0.8, ls=":", alpha=0.5, zorder=1)
rod, = ax.plot([], [], "-", color="#a8dadc", lw=2.5, zorder=3)block_p = patches.FancyBboxPatch((-bw/2, -L-bh/2), bw, bh, boxstyle="round,pad=0.02", linewidth=1.5, edgecolor="white", facecolor="#457b9d")ax.add_patch(block_p)bullet_p, = ax.plot([], [], "o", color="#e63946", ms=10, zorder=5)trail, = ax.plot([], [], "-", color="#e63946", alpha=0.35, lw=1.0, zorder=2)tx, ty = [], []
def update(f): th = theta[f] bx = L * np.sin(th); by = -L * np.cos(th) rod.set_data([0, bx], [0, by]) block_p.set_x(bx - bw/2); block_p.set_y(by - bh/2) bullet_p.set_data([bullet_x[f]], [bullet_y[f]]) if embedded[f] > 0.5: tx.append(bx); ty.append(by) if len(tx) > 60: tx.pop(0); ty.pop(0) trail.set_data(tx, ty) return rod, block_p, bullet_p, trailani = animation.FuncAnimation(fig, update, frames=len(t_eval), interval=1000/fps, blit=False)ani.save("ballistic_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120)plt.close(); print("Saved ballistic_pendulum.mp4")123version https://git-lfs.github.com/spec/v1oid sha256:409ac173a2bc4b0df8a69beefd51202c292fc6edd6150d0b4829abab1b32c084size 16724123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{ "simulation": "ballistic_pendulum", "physical_observation": "A small projectile of mass m=0.315 kg moves horizontally at v_b=8.055 m/s and embeds itself in a stationary block of mass M=0.554 kg hanging from a rigid massless rod of length L=1.232 m. After the perfectly inelastic impact at t \\approx 0.248 s, the loaded pendulum (combined mass m+M=0.869 kg) swings up under gravity to a maximum angle, then oscillates with light damping (b=0.067 kg \\cdot m^2/s).", "physical_law": { "name": "Conservation of Linear Momentum + Conservation of Mechanical Energy", "statement": "(1) Across an instantaneous collision with no external impulse, total linear momentum is conserved: \\Sigma p_before = \\Sigma p_after. (2) After the perfectly inelastic impact, only conservative forces and (small) damping act on the loaded pendulum, so mechanical energy is conserved up to the work done by damping; in the b \\rightarrow 0 limit, the post-impact KE equals the gain in gravitational PE at the highest point.", "formula": "Collision: m \\cdot v_b = (m+M) \\cdot v_after \\rightarrow v_after = m \\cdot v_b/(m+M). Swing (b=0): \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max) \\rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." }, "ode_system": { "state_variables": [ "\\theta (rod angle from downward vertical, rad)", "\\omega = \\dot{\\theta} (angular velocity, rad/s)" ], "equations_latex": [ "Pre-impact (t < t_impact): bullet at constant velocity, \\theta = 0, \\omega = 0.", "Impact (t = t_impact): \\theta unchanged; \\omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", " \\dot{\\theta} = \\omega", " \\dot{\\omega} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\omega" ], "equations_python": [ "Pre-impact (t < t_impact): bullet at constant velocity, theta = 0, omega = 0.", "Impact (t = t_impact): theta unchanged; omega jumps to v_after/L by momentum conservation.", "Post-impact (t > t_impact):", "theta_dot = omega", "omega_dot = -(g/L) * np.sin ( theta ) - (b/((m+M) * L**2)) * omega" ] }, "derivation_steps": [ "Phase 1 --- Pre-impact ballistic flight:", " Bullet flies horizontally at constant velocity v_b (gravity neglected over the brief flight).", " x_bullet(t) = x_b0 + v_b \\cdot t (x_b0=-1.999 m, impact when x=0 at t=0.2482 s)", "Phase 2 --- Inelastic collision (instantaneous):", " External horizontal forces (rod tension, gravity) are negligible during contact \\Rightarrow linear momentum is conserved.", " Conservation of linear momentum: m \\cdot v_b = (m+M) \\cdot v_after", " \\Rightarrow v_after = m \\cdot v_b/(m+M) = 2.9223 m/s", " Energy lost to deformation/heat: \\DeltaKE = \\tfrac{1}{2} m v_b^2 - \\tfrac{1}{2} (m+M)v_after^2 = 6.5184 J (63.7% of pre-impact KE)", "Phase 3 --- Loaded pendulum:", " Treat (m+M) as a point mass at distance L from the pivot \\Rightarrow I = (m+M) \\cdot L^2.", " Torques about the pivot:", " \\tau_gravity = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) (restoring)", " \\tau_damping = -b \\cdot \\dot{\\theta} (b is angular damping, kg \\cdot m^2/s)", " Newton's 2nd law for rotation: I \\cdot \\ddot{\\theta} = \\Sigma\\tau", " (m+M) \\cdot L^2 \\cdot \\ddot{\\theta} = -(m+M) \\cdot g \\cdot L \\cdot \\sin(\\theta) - b \\cdot \\dot{\\theta}", " \\Rightarrow \\ddot{\\theta} = -(g/L) \\cdot \\sin(\\theta) - (b/((m+M) \\cdot L^2)) \\cdot \\dot{\\theta}", "Initial conditions at t = t_impact: \\theta = 0, \\dot{\\theta} = \\omega_after = v_after/L", " \\omega_after = v_after/L = 2.3728 rad/s", "Phase 4 --- Inferring v_b from observed \\theta_max (b \\rightarrow 0 limit):", " Energy conservation during the swing: \\tfrac{1}{2} (m+M)v_after^2 = (m+M) \\cdot g \\cdot h_max", " Geometry: h_max = L \\cdot (1 - \\cos(\\theta)_max)", " \\Rightarrow v_after = \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Substituting v_after = m \\cdot v_b/(m+M):", " \\Rightarrow v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))", " Predicted (undamped) \\theta_max \\approx 49.74^{\\circ} \\rightarrow h_max \\approx 0.4357 m" ], "numerical_method": { "solver": "Two-phase: analytic constant-velocity flight, then RK45 for the loaded pendulum", "tolerance": "rtol=1e-9, atol=1e-11", "justification": "The collision is treated analytically (instantaneous, perfectly inelastic) by applying linear-momentum conservation as a discontinuous jump in the angular velocity at t = t_impact. The post-impact ODE is integrated with scipy.solve_ivp's RK45 (Dormand-Prince) at tight tolerances." }, "code_validation": { "ode_source": "Newton's 2nd law for rotation about a fixed axis applied to the loaded (m+M) pendulum; momentum conservation enforces the impact jump.", "momentum_check": "m \\cdot v_b \\equiv (m+M) \\cdot v_after at the impact instant (analytic, exact).", "energy_check": "Mechanical energy E = \\tfrac{1}{2} (m+M)L^2\\omega^2 + (m+M)gL(1 - \\cos(\\theta)) decreases monotonically after impact when b > 0 and is conserved when b = 0.", "physical_plausibility": true }, "expected_behavior": [ "Pre-impact: bullet travels straight from x=-2.00 m to x=0 in 0.248 s.", "At impact, 63.7% of the bullet's kinetic energy is dissipated (perfectly inelastic).", "Predicted maximum swing angle (undamped): \\theta_max \\approx 49.74^{\\circ}.", "Natural small-angle period of the loaded pendulum: T_0 \\approx 2.227 s.", "Damping ratio \\zeta = b/(2(m+M)L^2 \\cdot \\omega_0) = 0.0090 < 1 \\rightarrow underdamped oscillations decay slowly.", "v_b can be reconstructed from the observed \\theta_max via v_b = ((m+M)/m) \\cdot \\sqrt (2 \\cdot g \\cdot L \\cdot (1 - \\cos(\\theta)_max))." ], "parameters": { "m": { "value": 0.31533280636498684, "unit": "kg", "description": "Bullet/projectile mass" }, "M": { "value": 0.5538448002990061, "unit": "kg", "description": "Hanging-block mass" }, "v_b": { "value": 8.05493930612291, "unit": "m/s", "description": "Bullet initial speed" }, "L": { "value": 1.2315939710262125, "unit": "m", "description": "Pendulum rod length" }, "g": { "value": 9.8, "unit": "m/s^2", "description": "Gravitational acceleration" }, "b": { "value": 0.06711845691466987, "unit": "kg \\cdot m^2/s", "description": "Angular damping coefficient" }, "x_b0": { "value": -1.9991113017150832, "unit": "m", "description": "Bullet initial x-position" } }}scipy/ballistic_pendulum/071/video.mp4Added+3
scipy/ballistic_pendulum/081/cot.jsonAdded+112
scipy/ballistic_pendulum/081/params.jsonAdded+9
scipy/ballistic_pendulum/081/simulation_code.pyAdded+107
scipy/ballistic_pendulum/081/video.mp4Added+3
scipy/ballistic_pendulum/103/cot.jsonAdded+112
scipy/ballistic_pendulum/103/params.jsonAdded+9
scipy/ballistic_pendulum/103/simulation_code.pyAdded+107
scipy/ballistic_pendulum/103/video.mp4Added+3
scipy/ballistic_pendulum/196/cot.jsonAdded+112
scipy/ballistic_pendulum/196/params.jsonAdded+9
scipy/ballistic_pendulum/196/simulation_code.pyAdded+107
scipy/ballistic_pendulum/196/video.mp4Added+3
scipy/ballistic_pendulum/233/cot.jsonAdded+112
scipy/ballistic_pendulum/233/params.jsonAdded+9
scipy/ballistic_pendulum/233/simulation_code.pyAdded+107
scipy/ballistic_pendulum/233/video.mp4Added+3
scipy/ballistic_pendulum/238/cot.jsonAdded+112
scipy/ballistic_pendulum/238/params.jsonAdded+9
scipy/ballistic_pendulum/238/simulation_code.pyAdded+107
scipy/ballistic_pendulum/238/video.mp4Added+3
scipy/ballistic_pendulum/284/cot.jsonAdded+112
scipy/ballistic_pendulum/284/params.jsonAdded+9
scipy/ballistic_pendulum/284/simulation_code.pyAdded+107
scipy/ballistic_pendulum/284/video.mp4Added+3
scipy/ballistic_pendulum/296/cot.jsonAdded+112
scipy/ballistic_pendulum/296/params.jsonAdded+9
scipy/ballistic_pendulum/296/simulation_code.pyAdded+107
scipy/ballistic_pendulum/296/video.mp4Added+3
scipy/ballistic_pendulum/300/cot.jsonAdded+112
scipy/ballistic_pendulum/300/params.jsonAdded+9
scipy/ballistic_pendulum/300/simulation_code.pyAdded+107
scipy/ballistic_pendulum/300/video.mp4Added+3
scipy/ballistic_pendulum/370/cot.jsonAdded+112
scipy/ballistic_pendulum/370/params.jsonAdded+9
scipy/ballistic_pendulum/370/simulation_code.pyAdded+107
scipy/ballistic_pendulum/370/video.mp4Added+3
scipy/ballistic_pendulum/389/cot.jsonAdded+112
scipy/ballistic_pendulum/389/params.jsonAdded+9
scipy/ballistic_pendulum/389/simulation_code.pyAdded+107
scipy/ballistic_pendulum/389/video.mp4Added+3
scipy/ballistic_pendulum/464/cot.jsonAdded+112
scipy/ballistic_pendulum/464/params.jsonAdded+9
scipy/ballistic_pendulum/464/simulation_code.pyAdded+107
scipy/ballistic_pendulum/464/video.mp4Added+3
scipy/ballistic_pendulum/565/cot.jsonAdded+112
scipy/ballistic_pendulum/565/params.jsonAdded+9
scipy/ballistic_pendulum/565/simulation_code.pyAdded+107
scipy/ballistic_pendulum/565/video.mp4Added+3
scipy/ballistic_pendulum/591/cot.jsonAdded+112