diff --git a/scipy/compound_atwood/277/video.mp4 b/scipy/compound_atwood/277/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a264fb82747bb4e16b80370254dfccb205c37835 --- /dev/null +++ b/scipy/compound_atwood/277/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4f39a6b15286240ba376082d91eb7f075c1a2e605684daf0f61cbbf3b47b030 +size 8540 diff --git a/scipy/compound_atwood/284/cot.json b/scipy/compound_atwood/284/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..42d010e313c281d1663f541c8a44cf11ea593f93 --- /dev/null +++ b/scipy/compound_atwood/284/cot.json @@ -0,0 +1,150 @@ +{ + "simulation": "compound_atwood", + "physical_observation": "Compound (double) Atwood machine: a fixed pulley A on the ceiling carries a string with mass m1=2.444 kg on one side and the axle of a movable pulley B on the other. A rope over B carries mass m2=1.909 kg and m3=1.649 kg. Gravity g=9.800 m/s^2 drives the system; all motions start from rest.", + "physical_law": { + "name": "Newton II + massless inextensible-cord constraints + massless pulleys", + "statement": "Each mass obeys m_i \\ddot{y}_i = m_i g - T_i; the cord constraints couple accelerations; a massless movable pulley enforces T_A = 2 T_B.", + "formula": "T_B = 4 g / (1/m2 + 1/m3 + 4/m1); T_A = 2 T_B; a_i = g - T_i/m_i; a_B = -a_1." + }, + "ode_system": { + "state_variables": [ + "y1, y2, y3 (cube depths, m, +y down)", + "yB (movable pulley depth)" + ], + "equations_latex": [ + "\\dot{y}_i = v_i; \\dot{v}_i = a_i (constants)", + "a1 = -1.793729; a2 = 2.379439; a3 = 1.208019; aB = 1.793729" + ], + "equations_python": [ + "y_dot_i = v_i; v_dot_i = a_i (constants)", + "a1 = -1.793729; a2 = 2.379439; a3 = 1.208019; aB = 1.793729" + ] + }, + "derivation_steps": [ + "Massless movable pulley B: tension balance gives T_A = 2 T_B (so T_A = 28.3344 N, T_B = 14.1672 N).", + "Constraint on string A: y1 + yB = const => \\ddot{y}1 + \\ddot{y}B = 0 => a_B = -a_1.", + "Constraint on rope B: (y2 - yB) + (y3 - yB) = const => a_2 + a_3 - 2 a_B = 0.", + "Newton II for each mass (down = +): m_i \\ddot{y}_i = m_i g - T_i (T_1 = T_A on m1; T_2 = T_3 = T_B on m2, m3).", + "Solving the linear system yields T_B = 4 g / (1/m2 + 1/m3 + 4/m1).", + "Therefore a_1 = -1.7937 m/s^2, a_2 = +2.3794, a_3 = +1.2080, a_B = +1.7937." + ], + "physical_constants_derived": { + "T_A_N": 28.334408699039933, + "T_B_N": 14.167204349519967, + "a_1_m_s2": -1.7937289008575554, + "a_2_m_s2": 2.379439052696598, + "a_3_m_s2": 1.2080187490185104, + "a_B_m_s2": 1.7937289008575554 + }, + "numerical_method": { + "solver": "Closed form (constant accelerations); positions are quadratic in t. No ODE integrator required.", + "tolerance": "Machine precision.", + "justification": "All four accelerations are time-independent, so y_i(t) = y_i_0 + v_i_0 t + 0.5 a_i t^2." + }, + "code_validation": { + "ode_source": "Newton II for three point masses with two cord constraints and a tension ratio T_A=2 T_B.", + "energy_check": "\\SigmaKE - \\SigmaPE evolves consistent with constant accelerations (no friction).", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass with the largest a_i descends fastest. a_1, a_2, a_3, a_B = -1.794, +2.379, +1.208, +1.794 m/s^2.", + "Motion stops in the render once the descender reaches the floor." + ], + "parameters": { + "m1": { + "value": 2.44394266429191, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.909182398760334, + "unit": "", + "description": "" + }, + "m3": { + "value": 1.6488867859088496, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "x_A": { + "value": 2.0, + "unit": "", + "description": "" + }, + "x_B": { + "value": 2.5, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.5, + "unit": "", + "description": "" + }, + "cube_side": { + "value": 0.45, + "unit": "", + "description": "" + }, + "x_m1": { + "value": 1.5, + "unit": "", + "description": "" + }, + "x_m2": { + "value": 2.0, + "unit": "", + "description": "" + }, + "x_m3": { + "value": 3.0, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 1.5, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 5.0, + "unit": "", + "description": "" + }, + "y3_0": { + "value": 3.5, + "unit": "", + "description": "" + }, + "yB_0": { + "value": 2.5, + "unit": "", + "description": "" + }, + "v1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v3_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vB_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/compound_atwood/284/params.json b/scipy/compound_atwood/284/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e899f425beb040162260ef19b1ad8d5a5fb07c25 --- /dev/null +++ b/scipy/compound_atwood/284/params.json @@ -0,0 +1,21 @@ +{ + "m1": 2.44394266429191, + "m2": 1.909182398760334, + "m3": 1.6488867859088496, + "g": 9.8, + "x_A": 2.0, + "x_B": 2.5, + "r_pulley": 0.5, + "cube_side": 0.45, + "x_m1": 1.5, + "x_m2": 2.0, + "x_m3": 3.0, + "y1_0": 1.5, + "y2_0": 5.0, + "y3_0": 3.5, + "yB_0": 2.5, + "v1_0": 0.0, + "v2_0": 0.0, + "v3_0": 0.0, + "vB_0": 0.0 +} \ No newline at end of file diff --git a/scipy/compound_atwood/284/simulation_code.py b/scipy/compound_atwood/284/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c0ac95c6fdd7406c73da62c5e092fb2a78022fb5 --- /dev/null +++ b/scipy/compound_atwood/284/simulation_code.py @@ -0,0 +1,112 @@ +""" +Compound Atwood machine — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, m3 = 2.44394266429191, 1.909182398760334, 1.6488867859088496 +g = 9.8 +r_pulley = 0.5 +cube_side = 0.45 +x_A, x_B = 2.0, 2.5 +x_m1, x_m2, x_m3 = 1.5, 2.0, 3.0 +y1_0 = 1.5; y2_0 = 5.0; y3_0 = 3.5; yB_0 = 2.5 +v1_0 = 0.0; v2_0 = 0.0; v3_0 = 0.0; vB_0 = 0.0 +duration = 12 +fps = 30 + +T_B = 4.0 * g / (1.0/m2 + 1.0/m3 + 4.0/m1) +T_A = 2.0 * T_B +a1 = g - T_A/m1 +a2 = g - T_B/m2 +a3 = g - T_B/m3 +aB = -a1 + +y_floor = max(y1_0, y2_0, y3_0) + 2.5 +y_A = r_pulley + 0.05 + +n_frames = int(duration * fps) + 1 +t_grid = np.linspace(0, duration, n_frames) +y1 = y1_0 + v1_0 * t_grid + 0.5 * a1 * t_grid ** 2 +y2 = y2_0 + v2_0 * t_grid + 0.5 * a2 * t_grid ** 2 +y3 = y3_0 + v3_0 * t_grid + 0.5 * a3 * t_grid ** 2 +yB = yB_0 + vB_0 * t_grid + 0.5 * aB * t_grid ** 2 + +ok = ((y1 >= y_A) & (y2 >= yB + r_pulley) & (y3 >= yB + r_pulley) + & (yB >= r_pulley) + & (y1 + cube_side <= y_floor) + & (y2 + cube_side <= y_floor) + & (y3 + cube_side <= y_floor) + & (yB + r_pulley <= y_floor)) +if not ok.all(): + first_bad = int(np.argmax(~ok)) + last_good = max(first_bad - 1, 0) + y1[first_bad:] = y1[last_good] + y2[first_bad:] = y2[last_good] + y3[first_bad:] = y3[last_good] + yB[first_bad:] = yB[last_good] + +y_A = r_pulley + 0.05 +y_floor_render = max(y1.max(), y2.max(), y3.max()) + cube_side + 0.5 + +fig_w, fig_h = 5.0, 8.0 +fig_aspect = fig_w / fig_h +x_lo_d = min(x_m1, x_m2, x_m3) - cube_side/2 - 0.4 +x_hi_d = max(x_m1, x_m2, x_m3) + cube_side/2 + 0.4 +y_lo_d = -0.4 +y_hi_d = y_floor_render + 0.4 +dx, dy = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx/dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx/fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_hi, y_lo) +ax.set_aspect("equal"); ax.axis("off") + +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0, 0], color="#adb5bd", lw=2.5, zorder=2) +ax.add_patch(patches.Rectangle((x_lo, y_floor_render), x_hi - x_lo, y_hi - y_floor_render, facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [y_floor_render, y_floor_render], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_A, y_A), r_pulley, facecolor="#4a4e69", edgecolor="white", lw=1.6, zorder=4)) +ax.plot([x_A, x_A], [0, y_A - r_pulley], color="#adb5bd", lw=2.5, zorder=3) +ax.add_patch(patches.Arc((x_A, y_A), 2*r_pulley, 2*r_pulley, angle=0, theta1=180, theta2=360, color="#a8dadc", lw=2.5, zorder=5)) +ax.add_patch(patches.Circle((x_A, y_A), r_pulley * 0.18, facecolor="#1a1a2e", edgecolor="#adb5bd", lw=1.0, zorder=6)) + +pulley_B_body = patches.Circle((x_B, yB_0), r_pulley, facecolor="#4a4e69", edgecolor="white", lw=1.6, zorder=4) +arc_B = patches.Arc((x_B, yB_0), 2*r_pulley, 2*r_pulley, angle=0, theta1=180, theta2=360, color="#a8dadc", lw=2.5, zorder=5) +hub_B = patches.Circle((x_B, yB_0), r_pulley * 0.18, facecolor="#1a1a2e", edgecolor="#adb5bd", lw=1.0, zorder=6) +ax.add_patch(pulley_B_body); ax.add_patch(arc_B); ax.add_patch(hub_B) + +cube1 = patches.Rectangle((x_m1 - cube_side/2, y1_0), cube_side, cube_side, facecolor="#e63946", edgecolor="white", lw=1.5, zorder=7) +cube2 = patches.Rectangle((x_m2 - cube_side/2, y2_0), cube_side, cube_side, facecolor="#f4d35e", edgecolor="white", lw=1.5, zorder=7) +cube3 = patches.Rectangle((x_m3 - cube_side/2, y3_0), cube_side, cube_side, facecolor="#a8dadc", edgecolor="white", lw=1.5, zorder=7) +ax.add_patch(cube1); ax.add_patch(cube2); ax.add_patch(cube3) + +str_A_left, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +str_A_right, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +rope_B_left, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +rope_B_right,= ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) + +def update(f): + y1f, y2f, y3f, yBf = y1[f], y2[f], y3[f], yB[f] + cube1.set_y(y1f); cube2.set_y(y2f); cube3.set_y(y3f) + pulley_B_body.center = (x_B, yBf) + hub_B.center = (x_B, yBf) + arc_B.set_center((x_B, yBf)) + str_A_left.set_data([x_A - r_pulley, x_A - r_pulley], [y_A, y1f]) + str_A_right.set_data([x_A + r_pulley, x_B], [y_A, yBf - r_pulley]) + rope_B_left.set_data([x_B - r_pulley, x_B - r_pulley], [yBf, y2f]) + rope_B_right.set_data([x_B + r_pulley, x_B + r_pulley], [yBf, y3f]) + return cube1, cube2, cube3, pulley_B_body, hub_B, arc_B, str_A_left, str_A_right, rope_B_left, rope_B_right + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("compound_atwood.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved compound_atwood.mp4") diff --git a/scipy/compound_atwood/284/video.mp4 b/scipy/compound_atwood/284/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..68f3f7cf7b0821c3105b47decbfdd0d2462ad1f8 --- /dev/null +++ b/scipy/compound_atwood/284/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8cce51920bf6542989aba203366a49fd35675b4c0f58f94e7cbe460ff2c907a1 +size 7823 diff --git a/scipy/compound_atwood/296/cot.json b/scipy/compound_atwood/296/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4d3ae674bf79fbd4defea652de3efafc83c7d6b4 --- /dev/null +++ b/scipy/compound_atwood/296/cot.json @@ -0,0 +1,150 @@ +{ + "simulation": "compound_atwood", + "physical_observation": "Compound (double) Atwood machine: a fixed pulley A on the ceiling carries a string with mass m1=2.256 kg on one side and the axle of a movable pulley B on the other. A rope over B carries mass m2=1.713 kg and m3=1.241 kg. Gravity g=9.800 m/s^2 drives the system; all motions start from rest.", + "physical_law": { + "name": "Newton II + massless inextensible-cord constraints + massless pulleys", + "statement": "Each mass obeys m_i \\ddot{y}_i = m_i g - T_i; the cord constraints couple accelerations; a massless movable pulley enforces T_A = 2 T_B.", + "formula": "T_B = 4 g / (1/m2 + 1/m3 + 4/m1); T_A = 2 T_B; a_i = g - T_i/m_i; a_B = -a_1." + }, + "ode_system": { + "state_variables": [ + "y1, y2, y3 (cube depths, m, +y down)", + "yB (movable pulley depth)" + ], + "equations_latex": [ + "\\dot{y}_i = v_i; \\dot{v}_i = a_i (constants)", + "a1 = -1.186310; a2 = 2.563555; a3 = -0.190935; aB = 1.186310" + ], + "equations_python": [ + "y_dot_i = v_i; v_dot_i = a_i (constants)", + "a1 = -1.186310; a2 = 2.563555; a3 = -0.190935; aB = 1.186310" + ] + }, + "derivation_steps": [ + "Massless movable pulley B: tension balance gives T_A = 2 T_B (so T_A = 24.7899 N, T_B = 12.3950 N).", + "Constraint on string A: y1 + yB = const => \\ddot{y}1 + \\ddot{y}B = 0 => a_B = -a_1.", + "Constraint on rope B: (y2 - yB) + (y3 - yB) = const => a_2 + a_3 - 2 a_B = 0.", + "Newton II for each mass (down = +): m_i \\ddot{y}_i = m_i g - T_i (T_1 = T_A on m1; T_2 = T_3 = T_B on m2, m3).", + "Solving the linear system yields T_B = 4 g / (1/m2 + 1/m3 + 4/m1).", + "Therefore a_1 = -1.1863 m/s^2, a_2 = +2.5636, a_3 = -0.1909, a_B = +1.1863." + ], + "physical_constants_derived": { + "T_A_N": 24.789919133158584, + "T_B_N": 12.394959566579292, + "a_1_m_s2": -1.1863099226324891, + "a_2_m_s2": 2.563555066819448, + "a_3_m_s2": -0.1909352215544704, + "a_B_m_s2": 1.1863099226324891 + }, + "numerical_method": { + "solver": "Closed form (constant accelerations); positions are quadratic in t. No ODE integrator required.", + "tolerance": "Machine precision.", + "justification": "All four accelerations are time-independent, so y_i(t) = y_i_0 + v_i_0 t + 0.5 a_i t^2." + }, + "code_validation": { + "ode_source": "Newton II for three point masses with two cord constraints and a tension ratio T_A=2 T_B.", + "energy_check": "\\SigmaKE - \\SigmaPE evolves consistent with constant accelerations (no friction).", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass with the largest a_i descends fastest. a_1, a_2, a_3, a_B = -1.186, +2.564, -0.191, +1.186 m/s^2.", + "Motion stops in the render once the descender reaches the floor." + ], + "parameters": { + "m1": { + "value": 2.256437266719537, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.7128520538788201, + "unit": "", + "description": "" + }, + "m3": { + "value": 1.2406205517015436, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "x_A": { + "value": 2.0, + "unit": "", + "description": "" + }, + "x_B": { + "value": 2.5, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.5, + "unit": "", + "description": "" + }, + "cube_side": { + "value": 0.45, + "unit": "", + "description": "" + }, + "x_m1": { + "value": 1.5, + "unit": "", + "description": "" + }, + "x_m2": { + "value": 2.0, + "unit": "", + "description": "" + }, + "x_m3": { + "value": 3.0, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 1.5, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 5.0, + "unit": "", + "description": "" + }, + "y3_0": { + "value": 3.5, + "unit": "", + "description": "" + }, + "yB_0": { + "value": 2.5, + "unit": "", + "description": "" + }, + "v1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v3_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vB_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/compound_atwood/296/params.json b/scipy/compound_atwood/296/params.json new file mode 100644 index 0000000000000000000000000000000000000000..9884da8625b2293b8587436037b4b857e1d02f2c --- /dev/null +++ b/scipy/compound_atwood/296/params.json @@ -0,0 +1,21 @@ +{ + "m1": 2.256437266719537, + "m2": 1.7128520538788201, + "m3": 1.2406205517015436, + "g": 9.8, + "x_A": 2.0, + "x_B": 2.5, + "r_pulley": 0.5, + "cube_side": 0.45, + "x_m1": 1.5, + "x_m2": 2.0, + "x_m3": 3.0, + "y1_0": 1.5, + "y2_0": 5.0, + "y3_0": 3.5, + "yB_0": 2.5, + "v1_0": 0.0, + "v2_0": 0.0, + "v3_0": 0.0, + "vB_0": 0.0 +} \ No newline at end of file diff --git a/scipy/compound_atwood/296/simulation_code.py b/scipy/compound_atwood/296/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..8bd64eca916b0164f7da8b4dceebf43e223aad4e --- /dev/null +++ b/scipy/compound_atwood/296/simulation_code.py @@ -0,0 +1,112 @@ +""" +Compound Atwood machine — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, m3 = 2.256437266719537, 1.7128520538788201, 1.2406205517015436 +g = 9.8 +r_pulley = 0.5 +cube_side = 0.45 +x_A, x_B = 2.0, 2.5 +x_m1, x_m2, x_m3 = 1.5, 2.0, 3.0 +y1_0 = 1.5; y2_0 = 5.0; y3_0 = 3.5; yB_0 = 2.5 +v1_0 = 0.0; v2_0 = 0.0; v3_0 = 0.0; vB_0 = 0.0 +duration = 12 +fps = 30 + +T_B = 4.0 * g / (1.0/m2 + 1.0/m3 + 4.0/m1) +T_A = 2.0 * T_B +a1 = g - T_A/m1 +a2 = g - T_B/m2 +a3 = g - T_B/m3 +aB = -a1 + +y_floor = max(y1_0, y2_0, y3_0) + 2.5 +y_A = r_pulley + 0.05 + +n_frames = int(duration * fps) + 1 +t_grid = np.linspace(0, duration, n_frames) +y1 = y1_0 + v1_0 * t_grid + 0.5 * a1 * t_grid ** 2 +y2 = y2_0 + v2_0 * t_grid + 0.5 * a2 * t_grid ** 2 +y3 = y3_0 + v3_0 * t_grid + 0.5 * a3 * t_grid ** 2 +yB = yB_0 + vB_0 * t_grid + 0.5 * aB * t_grid ** 2 + +ok = ((y1 >= y_A) & (y2 >= yB + r_pulley) & (y3 >= yB + r_pulley) + & (yB >= r_pulley) + & (y1 + cube_side <= y_floor) + & (y2 + cube_side <= y_floor) + & (y3 + cube_side <= y_floor) + & (yB + r_pulley <= y_floor)) +if not ok.all(): + first_bad = int(np.argmax(~ok)) + last_good = max(first_bad - 1, 0) + y1[first_bad:] = y1[last_good] + y2[first_bad:] = y2[last_good] + y3[first_bad:] = y3[last_good] + yB[first_bad:] = yB[last_good] + +y_A = r_pulley + 0.05 +y_floor_render = max(y1.max(), y2.max(), y3.max()) + cube_side + 0.5 + +fig_w, fig_h = 5.0, 8.0 +fig_aspect = fig_w / fig_h +x_lo_d = min(x_m1, x_m2, x_m3) - cube_side/2 - 0.4 +x_hi_d = max(x_m1, x_m2, x_m3) + cube_side/2 + 0.4 +y_lo_d = -0.4 +y_hi_d = y_floor_render + 0.4 +dx, dy = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx/dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx/fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_hi, y_lo) +ax.set_aspect("equal"); ax.axis("off") + +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0, 0], color="#adb5bd", lw=2.5, zorder=2) +ax.add_patch(patches.Rectangle((x_lo, y_floor_render), x_hi - x_lo, y_hi - y_floor_render, facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [y_floor_render, y_floor_render], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_A, y_A), r_pulley, facecolor="#4a4e69", edgecolor="white", lw=1.6, zorder=4)) +ax.plot([x_A, x_A], [0, y_A - r_pulley], color="#adb5bd", lw=2.5, zorder=3) +ax.add_patch(patches.Arc((x_A, y_A), 2*r_pulley, 2*r_pulley, angle=0, theta1=180, theta2=360, color="#a8dadc", lw=2.5, zorder=5)) +ax.add_patch(patches.Circle((x_A, y_A), r_pulley * 0.18, facecolor="#1a1a2e", edgecolor="#adb5bd", lw=1.0, zorder=6)) + +pulley_B_body = patches.Circle((x_B, yB_0), r_pulley, facecolor="#4a4e69", edgecolor="white", lw=1.6, zorder=4) +arc_B = patches.Arc((x_B, yB_0), 2*r_pulley, 2*r_pulley, angle=0, theta1=180, theta2=360, color="#a8dadc", lw=2.5, zorder=5) +hub_B = patches.Circle((x_B, yB_0), r_pulley * 0.18, facecolor="#1a1a2e", edgecolor="#adb5bd", lw=1.0, zorder=6) +ax.add_patch(pulley_B_body); ax.add_patch(arc_B); ax.add_patch(hub_B) + +cube1 = patches.Rectangle((x_m1 - cube_side/2, y1_0), cube_side, cube_side, facecolor="#e63946", edgecolor="white", lw=1.5, zorder=7) +cube2 = patches.Rectangle((x_m2 - cube_side/2, y2_0), cube_side, cube_side, facecolor="#f4d35e", edgecolor="white", lw=1.5, zorder=7) +cube3 = patches.Rectangle((x_m3 - cube_side/2, y3_0), cube_side, cube_side, facecolor="#a8dadc", edgecolor="white", lw=1.5, zorder=7) +ax.add_patch(cube1); ax.add_patch(cube2); ax.add_patch(cube3) + +str_A_left, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +str_A_right, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +rope_B_left, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +rope_B_right,= ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) + +def update(f): + y1f, y2f, y3f, yBf = y1[f], y2[f], y3[f], yB[f] + cube1.set_y(y1f); cube2.set_y(y2f); cube3.set_y(y3f) + pulley_B_body.center = (x_B, yBf) + hub_B.center = (x_B, yBf) + arc_B.set_center((x_B, yBf)) + str_A_left.set_data([x_A - r_pulley, x_A - r_pulley], [y_A, y1f]) + str_A_right.set_data([x_A + r_pulley, x_B], [y_A, yBf - r_pulley]) + rope_B_left.set_data([x_B - r_pulley, x_B - r_pulley], [yBf, y2f]) + rope_B_right.set_data([x_B + r_pulley, x_B + r_pulley], [yBf, y3f]) + return cube1, cube2, cube3, pulley_B_body, hub_B, arc_B, str_A_left, str_A_right, rope_B_left, rope_B_right + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("compound_atwood.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved compound_atwood.mp4") diff --git a/scipy/compound_atwood/296/video.mp4 b/scipy/compound_atwood/296/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3da8ef73b20db8837363626c9a7650d676293fbe --- /dev/null +++ b/scipy/compound_atwood/296/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1973d99a57eacb6e7e61d2e2d3bb0a77e57e3a0ea3124c2a2537bc1a0ea6a53e +size 7483 diff --git a/scipy/compound_atwood/299/cot.json b/scipy/compound_atwood/299/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0b8b3a51c22d8f710587ab15b0475454128660cf --- /dev/null +++ b/scipy/compound_atwood/299/cot.json @@ -0,0 +1,150 @@ +{ + "simulation": "compound_atwood", + "physical_observation": "Compound (double) Atwood machine: a fixed pulley A on the ceiling carries a string with mass m1=2.376 kg on one side and the axle of a movable pulley B on the other. A rope over B carries mass m2=0.848 kg and m3=1.121 kg. Gravity g=9.800 m/s^2 drives the system; all motions start from rest.", + "physical_law": { + "name": "Newton II + massless inextensible-cord constraints + massless pulleys", + "statement": "Each mass obeys m_i \\ddot{y}_i = m_i g - T_i; the cord constraints couple accelerations; a massless movable pulley enforces T_A = 2 T_B.", + "formula": "T_B = 4 g / (1/m2 + 1/m3 + 4/m1); T_A = 2 T_B; a_i = g - T_i/m_i; a_B = -a_1." + }, + "ode_system": { + "state_variables": [ + "y1, y2, y3 (cube depths, m, +y down)", + "yB (movable pulley depth)" + ], + "equations_latex": [ + "\\dot{y}_i = v_i; \\dot{v}_i = a_i (constants)", + "a1 = 1.013799; a2 = -2.512182; a3 = 0.484585; aB = -1.013799" + ], + "equations_python": [ + "y_dot_i = v_i; v_dot_i = a_i (constants)", + "a1 = 1.013799; a2 = -2.512182; a3 = 0.484585; aB = -1.013799" + ] + }, + "derivation_steps": [ + "Massless movable pulley B: tension balance gives T_A = 2 T_B (so T_A = 20.8799 N, T_B = 10.4400 N).", + "Constraint on string A: y1 + yB = const => \\ddot{y}1 + \\ddot{y}B = 0 => a_B = -a_1.", + "Constraint on rope B: (y2 - yB) + (y3 - yB) = const => a_2 + a_3 - 2 a_B = 0.", + "Newton II for each mass (down = +): m_i \\ddot{y}_i = m_i g - T_i (T_1 = T_A on m1; T_2 = T_3 = T_B on m2, m3).", + "Solving the linear system yields T_B = 4 g / (1/m2 + 1/m3 + 4/m1).", + "Therefore a_1 = +1.0138 m/s^2, a_2 = -2.5122, a_3 = +0.4846, a_B = -1.0138." + ], + "physical_constants_derived": { + "T_A_N": 20.87993613401704, + "T_B_N": 10.43996806700852, + "a_1_m_s2": 1.0137985734817132, + "a_2_m_s2": -2.5121818299273873, + "a_3_m_s2": 0.4845846829639662, + "a_B_m_s2": -1.0137985734817132 + }, + "numerical_method": { + "solver": "Closed form (constant accelerations); positions are quadratic in t. No ODE integrator required.", + "tolerance": "Machine precision.", + "justification": "All four accelerations are time-independent, so y_i(t) = y_i_0 + v_i_0 t + 0.5 a_i t^2." + }, + "code_validation": { + "ode_source": "Newton II for three point masses with two cord constraints and a tension ratio T_A=2 T_B.", + "energy_check": "\\SigmaKE - \\SigmaPE evolves consistent with constant accelerations (no friction).", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass with the largest a_i descends fastest. a_1, a_2, a_3, a_B = +1.014, -2.512, +0.485, -1.014 m/s^2.", + "Motion stops in the render once the descender reaches the floor." + ], + "parameters": { + "m1": { + "value": 2.37644632992339, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.8479380999419572, + "unit": "", + "description": "" + }, + "m3": { + "value": 1.120719550519224, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "x_A": { + "value": 2.0, + "unit": "", + "description": "" + }, + "x_B": { + "value": 2.5, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.5, + "unit": "", + "description": "" + }, + "cube_side": { + "value": 0.45, + "unit": "", + "description": "" + }, + "x_m1": { + "value": 1.5, + "unit": "", + "description": "" + }, + "x_m2": { + "value": 2.0, + "unit": "", + "description": "" + }, + "x_m3": { + "value": 3.0, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 1.5, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 5.0, + "unit": "", + "description": "" + }, + "y3_0": { + "value": 3.5, + "unit": "", + "description": "" + }, + "yB_0": { + "value": 2.5, + "unit": "", + "description": "" + }, + "v1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v3_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vB_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/compound_atwood/299/params.json b/scipy/compound_atwood/299/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e458e00302de6b588b917510d1a0dd2f2f2a45b0 --- /dev/null +++ b/scipy/compound_atwood/299/params.json @@ -0,0 +1,21 @@ +{ + "m1": 2.37644632992339, + "m2": 0.8479380999419572, + "m3": 1.120719550519224, + "g": 9.8, + "x_A": 2.0, + "x_B": 2.5, + "r_pulley": 0.5, + "cube_side": 0.45, + "x_m1": 1.5, + "x_m2": 2.0, + "x_m3": 3.0, + "y1_0": 1.5, + "y2_0": 5.0, + "y3_0": 3.5, + "yB_0": 2.5, + "v1_0": 0.0, + "v2_0": 0.0, + "v3_0": 0.0, + "vB_0": 0.0 +} \ No newline at end of file diff --git a/scipy/compound_atwood/299/simulation_code.py b/scipy/compound_atwood/299/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..53a7a71d14ff2a07c136cd6a5a6a2992ebb6cf4b --- /dev/null +++ b/scipy/compound_atwood/299/simulation_code.py @@ -0,0 +1,112 @@ +""" +Compound Atwood machine — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, m3 = 2.37644632992339, 0.8479380999419572, 1.120719550519224 +g = 9.8 +r_pulley = 0.5 +cube_side = 0.45 +x_A, x_B = 2.0, 2.5 +x_m1, x_m2, x_m3 = 1.5, 2.0, 3.0 +y1_0 = 1.5; y2_0 = 5.0; y3_0 = 3.5; yB_0 = 2.5 +v1_0 = 0.0; v2_0 = 0.0; v3_0 = 0.0; vB_0 = 0.0 +duration = 12 +fps = 30 + +T_B = 4.0 * g / (1.0/m2 + 1.0/m3 + 4.0/m1) +T_A = 2.0 * T_B +a1 = g - T_A/m1 +a2 = g - T_B/m2 +a3 = g - T_B/m3 +aB = -a1 + +y_floor = max(y1_0, y2_0, y3_0) + 2.5 +y_A = r_pulley + 0.05 + +n_frames = int(duration * fps) + 1 +t_grid = np.linspace(0, duration, n_frames) +y1 = y1_0 + v1_0 * t_grid + 0.5 * a1 * t_grid ** 2 +y2 = y2_0 + v2_0 * t_grid + 0.5 * a2 * t_grid ** 2 +y3 = y3_0 + v3_0 * t_grid + 0.5 * a3 * t_grid ** 2 +yB = yB_0 + vB_0 * t_grid + 0.5 * aB * t_grid ** 2 + +ok = ((y1 >= y_A) & (y2 >= yB + r_pulley) & (y3 >= yB + r_pulley) + & (yB >= r_pulley) + & (y1 + cube_side <= y_floor) + & (y2 + cube_side <= y_floor) + & (y3 + cube_side <= y_floor) + & (yB + r_pulley <= y_floor)) +if not ok.all(): + first_bad = int(np.argmax(~ok)) + last_good = max(first_bad - 1, 0) + y1[first_bad:] = y1[last_good] + y2[first_bad:] = y2[last_good] + y3[first_bad:] = y3[last_good] + yB[first_bad:] = yB[last_good] + +y_A = r_pulley + 0.05 +y_floor_render = max(y1.max(), y2.max(), y3.max()) + cube_side + 0.5 + +fig_w, fig_h = 5.0, 8.0 +fig_aspect = fig_w / fig_h +x_lo_d = min(x_m1, x_m2, x_m3) - cube_side/2 - 0.4 +x_hi_d = max(x_m1, x_m2, x_m3) + cube_side/2 + 0.4 +y_lo_d = -0.4 +y_hi_d = y_floor_render + 0.4 +dx, dy = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx/dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx/fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_hi, y_lo) +ax.set_aspect("equal"); ax.axis("off") + +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0, 0], color="#adb5bd", lw=2.5, zorder=2) +ax.add_patch(patches.Rectangle((x_lo, y_floor_render), x_hi - x_lo, y_hi - y_floor_render, facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [y_floor_render, y_floor_render], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_A, y_A), r_pulley, facecolor="#4a4e69", edgecolor="white", lw=1.6, zorder=4)) +ax.plot([x_A, x_A], [0, y_A - r_pulley], color="#adb5bd", lw=2.5, zorder=3) +ax.add_patch(patches.Arc((x_A, y_A), 2*r_pulley, 2*r_pulley, angle=0, theta1=180, theta2=360, color="#a8dadc", lw=2.5, zorder=5)) +ax.add_patch(patches.Circle((x_A, y_A), r_pulley * 0.18, facecolor="#1a1a2e", edgecolor="#adb5bd", lw=1.0, zorder=6)) + +pulley_B_body = patches.Circle((x_B, yB_0), r_pulley, facecolor="#4a4e69", edgecolor="white", lw=1.6, zorder=4) +arc_B = patches.Arc((x_B, yB_0), 2*r_pulley, 2*r_pulley, angle=0, theta1=180, theta2=360, color="#a8dadc", lw=2.5, zorder=5) +hub_B = patches.Circle((x_B, yB_0), r_pulley * 0.18, facecolor="#1a1a2e", edgecolor="#adb5bd", lw=1.0, zorder=6) +ax.add_patch(pulley_B_body); ax.add_patch(arc_B); ax.add_patch(hub_B) + +cube1 = patches.Rectangle((x_m1 - cube_side/2, y1_0), cube_side, cube_side, facecolor="#e63946", edgecolor="white", lw=1.5, zorder=7) +cube2 = patches.Rectangle((x_m2 - cube_side/2, y2_0), cube_side, cube_side, facecolor="#f4d35e", edgecolor="white", lw=1.5, zorder=7) +cube3 = patches.Rectangle((x_m3 - cube_side/2, y3_0), cube_side, cube_side, facecolor="#a8dadc", edgecolor="white", lw=1.5, zorder=7) +ax.add_patch(cube1); ax.add_patch(cube2); ax.add_patch(cube3) + +str_A_left, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +str_A_right, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +rope_B_left, = ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) +rope_B_right,= ax.plot([], [], color="#a8dadc", lw=2.5, zorder=5) + +def update(f): + y1f, y2f, y3f, yBf = y1[f], y2[f], y3[f], yB[f] + cube1.set_y(y1f); cube2.set_y(y2f); cube3.set_y(y3f) + pulley_B_body.center = (x_B, yBf) + hub_B.center = (x_B, yBf) + arc_B.set_center((x_B, yBf)) + str_A_left.set_data([x_A - r_pulley, x_A - r_pulley], [y_A, y1f]) + str_A_right.set_data([x_A + r_pulley, x_B], [y_A, yBf - r_pulley]) + rope_B_left.set_data([x_B - r_pulley, x_B - r_pulley], [yBf, y2f]) + rope_B_right.set_data([x_B + r_pulley, x_B + r_pulley], [yBf, y3f]) + return cube1, cube2, cube3, pulley_B_body, hub_B, arc_B, str_A_left, str_A_right, rope_B_left, rope_B_right + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("compound_atwood.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved compound_atwood.mp4") diff --git a/scipy/compound_atwood/299/video.mp4 b/scipy/compound_atwood/299/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..cae93415c0428535e7e3d7869e64c5c73eeb493c --- /dev/null +++ b/scipy/compound_atwood/299/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a7a477e8d0fc66e0a06b83c050515e40cd1778480a342b5ae4711a759023fbc +size 9970 diff --git a/scipy/conveyor_belt_drop/029/cot.json b/scipy/conveyor_belt_drop/029/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..bfea81f702a07208b40167522b0f202b688352e2 --- /dev/null +++ b/scipy/conveyor_belt_drop/029/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.450 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.261 m/s rightward. Coulomb friction mu_belt=0.25272488955055605, mu_floor=0.3741802575064322 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 2.4792; ends when vx = v_belt = 1.2609200575127593", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -3.6707; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 2.4792; ends * when * vx = v_belt = 1.2609200575127593", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -3.6707; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.270 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2345 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 2.4792 m/s^2; t2 = v_belt/a = 0.5086 s; dx2 = 0.3206 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 0.9102 m -> t3 = 0.7219 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.5693 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 3.6707; t5 = 0.3435 s; dx5 = v_belt^2/(2 a_fl) = 0.2166 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.23448536522336647, + "t2_slip_s": 0.5085931778186846, + "t3_ride_s": 0.7218831934446154, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.34350864887141697, + "dx2_slip_m": 0.32064766951286644, + "dx4_off_belt_m": 0.5693352153600982, + "dx5_floor_m": 0.21656847264553863, + "final_x_m": 2.585903688005637 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.509 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.344 s on the floor.", + "Final cube rest position x ~ 2.586 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.2609200575127593, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.25272488955055605, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.3741802575064322, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5691153326914549, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.4496935108018039, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/029/params.json b/scipy/conveyor_belt_drop/029/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f1a91c5faa9b9d2e8f92687e470d4f2eec814b0c --- /dev/null +++ b/scipy/conveyor_belt_drop/029/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.2609200575127593, + "mu_belt": 0.25272488955055605, + "mu_floor": 0.3741802575064322, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5691153326914549, + "y_drop_top": 1.4496935108018039 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/029/simulation_code.py b/scipy/conveyor_belt_drop/029/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..21b20abc56955b989084a3b7510e8259fd695a40 --- /dev/null +++ b/scipy/conveyor_belt_drop/029/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.2609200575127593 +mu_belt = 0.25272488955055605 +mu_floor = 0.3741802575064322 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5691153326914549 +y_drop_top = 1.4496935108018039 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/029/video.mp4 b/scipy/conveyor_belt_drop/029/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6392c9068ced0e71c07a00b4b661d59eeec8a1eb --- /dev/null +++ b/scipy/conveyor_belt_drop/029/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa153076e104cb89da33c3318a658047b22f656138788fcb6f7d8cd5034be046 +size 15614 diff --git a/scipy/conveyor_belt_drop/034/cot.json b/scipy/conveyor_belt_drop/034/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..679247c4fe2147c84262dbe374e653f165255c1a --- /dev/null +++ b/scipy/conveyor_belt_drop/034/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.633 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.087 m/s rightward. Coulomb friction mu_belt=0.3765730539484565, mu_floor=0.4102183112577019 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 3.6942; ends when vx = v_belt = 1.087473851973722", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -4.0242; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 3.6942; ends * when * vx = v_belt = 1.087473851973722", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -4.0242; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.453 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.3037 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 3.6942 m/s^2; t2 = v_belt/a = 0.2944 s; dx2 = 0.1601 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.1756 m -> t3 = 1.0811 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.4910 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 4.0242; t5 = 0.2702 s; dx5 = v_belt^2/(2 a_fl) = 0.1469 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.30374564271843263, + "t2_slip_s": 0.2943747634216525, + "t3_ride_s": 1.0810755895105577, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.27023075427124726, + "dx2_slip_m": 0.16006242895099876, + "dx4_off_belt_m": 0.4910201531199527, + "dx5_floor_m": 0.1469344396345588, + "final_x_m": 2.4379545927545117 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.294 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.270 s on the floor.", + "Final cube rest position x ~ 2.438 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.087473851973722, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.3765730539484565, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.4102183112577019, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.4642961354491928, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.6325422428824774, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/034/params.json b/scipy/conveyor_belt_drop/034/params.json new file mode 100644 index 0000000000000000000000000000000000000000..06b1ea3b73a32f8d610b1da77bc3e86838c0da27 --- /dev/null +++ b/scipy/conveyor_belt_drop/034/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.087473851973722, + "mu_belt": 0.3765730539484565, + "mu_floor": 0.4102183112577019, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.4642961354491928, + "y_drop_top": 1.6325422428824774 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/034/simulation_code.py b/scipy/conveyor_belt_drop/034/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6dc8bcdc3c8730db5b3707cd8c9cf584350db36f --- /dev/null +++ b/scipy/conveyor_belt_drop/034/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.087473851973722 +mu_belt = 0.3765730539484565 +mu_floor = 0.4102183112577019 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.4642961354491928 +y_drop_top = 1.6325422428824774 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/034/video.mp4 b/scipy/conveyor_belt_drop/034/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..0b9839853e98598d2996359e5f9b40d19ce037dd --- /dev/null +++ b/scipy/conveyor_belt_drop/034/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:345e0338afd359b7e5692d590c10e57b70dfda0d638160bcdcb12847242da690 +size 15181 diff --git a/scipy/conveyor_belt_drop/035/cot.json b/scipy/conveyor_belt_drop/035/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6803cfdf5dabda204ea6262b80270efb2b9be328 --- /dev/null +++ b/scipy/conveyor_belt_drop/035/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.545 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=0.955 m/s rightward. Coulomb friction mu_belt=0.27619220618152307, mu_floor=0.2804261022675867 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 2.7094; ends when vx = v_belt = 0.9552151069878713", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -2.7510; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 2.7094; ends * when * vx = v_belt = 0.9552151069878713", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -2.7510; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.365 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2726 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 2.7094 m/s^2; t2 = v_belt/a = 0.3526 s; dx2 = 0.1684 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 0.9929 m -> t3 = 1.0394 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.4313 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 2.7510; t5 = 0.3472 s; dx5 = v_belt^2/(2 a_fl) = 0.1658 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.2726143740529498, + "t2_slip_s": 0.3525500298695348, + "t3_ride_s": 1.039444136553637, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.3472272008620485, + "dx2_slip_m": 0.16838055725020246, + "dx4_off_belt_m": 0.4313022030317381, + "dx5_floor_m": 0.16583833391027034, + "final_x_m": 2.3971405369420085 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.353 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.347 s on the floor.", + "Final cube rest position x ~ 2.397 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 0.9552151069878713, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.27619220618152307, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.2804261022675867, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.6387267006437998, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.5445327179920814, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/035/params.json b/scipy/conveyor_belt_drop/035/params.json new file mode 100644 index 0000000000000000000000000000000000000000..6106a69841c42cbedef222f1a34604db3945d9e8 --- /dev/null +++ b/scipy/conveyor_belt_drop/035/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 0.9552151069878713, + "mu_belt": 0.27619220618152307, + "mu_floor": 0.2804261022675867, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.6387267006437998, + "y_drop_top": 1.5445327179920814 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/035/simulation_code.py b/scipy/conveyor_belt_drop/035/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..baf8589781f2768b0c918394dcc17481b162f51e --- /dev/null +++ b/scipy/conveyor_belt_drop/035/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 0.9552151069878713 +mu_belt = 0.27619220618152307 +mu_floor = 0.2804261022675867 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.6387267006437998 +y_drop_top = 1.5445327179920814 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/035/video.mp4 b/scipy/conveyor_belt_drop/035/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ce68a1e90acb00191d978361eac7c1356b4066c4 --- /dev/null +++ b/scipy/conveyor_belt_drop/035/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32a073ab3357517b2f78765b1093e245970e5be91d0ef78dede6a6a1acc8e952 +size 15313 diff --git a/scipy/conveyor_belt_drop/041/cot.json b/scipy/conveyor_belt_drop/041/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..50a455b944bacca4617fc5cacfa36a43bf419d8b --- /dev/null +++ b/scipy/conveyor_belt_drop/041/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.573 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.169 m/s rightward. Coulomb friction mu_belt=0.4135161181563597, mu_floor=0.3389781300055946 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 4.0566; ends when vx = v_belt = 1.169202623140597", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -3.3254; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 4.0566; ends * when * vx = v_belt = 1.169202623140597", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -3.3254; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.393 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2829 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 4.0566 m/s^2; t2 = v_belt/a = 0.2882 s; dx2 = 0.1685 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.1705 m -> t3 = 1.0011 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.5279 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 3.3254; t5 = 0.3516 s; dx5 = v_belt^2/(2 a_fl) = 0.2055 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.28293566800960934, + "t2_slip_s": 0.2882227989865531, + "t3_ride_s": 1.0010819221152623, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.3516001843514599, + "dx2_slip_m": 0.16849542631200143, + "dx4_off_belt_m": 0.5279226254505097, + "dx5_floor_m": 0.20554592892022222, + "final_x_m": 2.533468554370732 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.288 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.352 s on the floor.", + "Final cube rest position x ~ 2.533 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.169202623140597, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.4135161181563597, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.3389781300055946, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.46103696437220315, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.572657964898175, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/041/params.json b/scipy/conveyor_belt_drop/041/params.json new file mode 100644 index 0000000000000000000000000000000000000000..567386ebf8b4c6808a245c7e9ae8ea6805072aef --- /dev/null +++ b/scipy/conveyor_belt_drop/041/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.169202623140597, + "mu_belt": 0.4135161181563597, + "mu_floor": 0.3389781300055946, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.46103696437220315, + "y_drop_top": 1.572657964898175 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/041/simulation_code.py b/scipy/conveyor_belt_drop/041/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..12ad07cb7fd000936d59d0d875d0093a75e3c058 --- /dev/null +++ b/scipy/conveyor_belt_drop/041/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.169202623140597 +mu_belt = 0.4135161181563597 +mu_floor = 0.3389781300055946 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.46103696437220315 +y_drop_top = 1.572657964898175 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/041/video.mp4 b/scipy/conveyor_belt_drop/041/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6d533079013c19e4607974f0308c187bf1d5ff52 --- /dev/null +++ b/scipy/conveyor_belt_drop/041/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88579e4751d97ed23fff63510e3f27c7c4cdfea07aa2989c2b44c01c6f88fc74 +size 13058 diff --git a/scipy/conveyor_belt_drop/080/cot.json b/scipy/conveyor_belt_drop/080/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0e220bd1909e2dd266a6be929f6e1af5b406a80e --- /dev/null +++ b/scipy/conveyor_belt_drop/080/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.492 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.230 m/s rightward. Coulomb friction mu_belt=0.43438504772240105, mu_floor=0.42858530097377967 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 4.2613; ends when vx = v_belt = 1.229860093733831", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -4.2044; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 4.2613; ends * when * vx = v_belt = 1.229860093733831", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -4.2044; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.312 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2524 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 4.2613 m/s^2; t2 = v_belt/a = 0.2886 s; dx2 = 0.1775 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.1156 m -> t3 = 0.9071 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.5553 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 4.2044; t5 = 0.2925 s; dx5 = v_belt^2/(2 a_fl) = 0.1799 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.2523623240712337, + "t2_slip_s": 0.2886103056661856, + "t3_ride_s": 0.9071264376028906, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.2925158681717193, + "dx2_slip_m": 0.17747514878958237, + "dx4_off_belt_m": 0.5553109074257517, + "dx5_floor_m": 0.17987679652415184, + "final_x_m": 2.5351877039499033 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.289 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.293 s on the floor.", + "Final cube rest position x ~ 2.535 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.229860093733831, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.43438504772240105, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.42858530097377967, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5068862456316905, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.4923834725051617, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/080/params.json b/scipy/conveyor_belt_drop/080/params.json new file mode 100644 index 0000000000000000000000000000000000000000..3330ad5afa38dcff64626f8de4a7aee63a1308cb --- /dev/null +++ b/scipy/conveyor_belt_drop/080/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.229860093733831, + "mu_belt": 0.43438504772240105, + "mu_floor": 0.42858530097377967, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5068862456316905, + "y_drop_top": 1.4923834725051617 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/080/simulation_code.py b/scipy/conveyor_belt_drop/080/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c188832ca020e91789998e105f25297e7105bfdb --- /dev/null +++ b/scipy/conveyor_belt_drop/080/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.229860093733831 +mu_belt = 0.43438504772240105 +mu_floor = 0.42858530097377967 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5068862456316905 +y_drop_top = 1.4923834725051617 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/080/video.mp4 b/scipy/conveyor_belt_drop/080/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b918059ec48e54b8576cbd4d6ef28e453226ed63 --- /dev/null +++ b/scipy/conveyor_belt_drop/080/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8fd167057a61c1689235b124c81b94262139dede94b68ce040af58f5f33ceaf3 +size 13705 diff --git a/scipy/conveyor_belt_drop/095/cot.json b/scipy/conveyor_belt_drop/095/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..fa8492487daa3c8917b003e963022b095db0caee --- /dev/null +++ b/scipy/conveyor_belt_drop/095/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.608 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.366 m/s rightward. Coulomb friction mu_belt=0.34436149271107924, mu_floor=0.3618359595338859 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 3.3782; ends when vx = v_belt = 1.3664233263792682", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -3.5496; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 3.3782; ends * when * vx = v_belt = 1.3664233263792682", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -3.5496; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.428 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2955 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 3.3782 m/s^2; t2 = v_belt/a = 0.4045 s; dx2 = 0.2763 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 0.9409 m -> t3 = 0.6886 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.6170 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 3.5496; t5 = 0.3850 s; dx5 = v_belt^2/(2 a_fl) = 0.2630 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.29553012228736086, + "t2_slip_s": 0.4044843084096268, + "t3_ride_s": 0.6885508106507919, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.3849501868238257, + "dx2_slip_m": 0.27634839708265, + "dx4_off_belt_m": 0.6169724354546009, + "dx5_floor_m": 0.26300245738506633, + "final_x_m": 2.679974892839667 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.404 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.385 s on the floor.", + "Final cube rest position x ~ 2.680 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.3664233263792682, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.34436149271107924, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.3618359595338859, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5827997138467532, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.60839315084389, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/095/params.json b/scipy/conveyor_belt_drop/095/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c0c7ca65f1bc2502883041e41d93b9c3e3804ae9 --- /dev/null +++ b/scipy/conveyor_belt_drop/095/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.3664233263792682, + "mu_belt": 0.34436149271107924, + "mu_floor": 0.3618359595338859, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5827997138467532, + "y_drop_top": 1.60839315084389 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/095/simulation_code.py b/scipy/conveyor_belt_drop/095/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..2ebc0688a7b244683d4abbe63aa33944d1c90983 --- /dev/null +++ b/scipy/conveyor_belt_drop/095/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.3664233263792682 +mu_belt = 0.34436149271107924 +mu_floor = 0.3618359595338859 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5827997138467532 +y_drop_top = 1.60839315084389 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/095/video.mp4 b/scipy/conveyor_belt_drop/095/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..93d05f8708d171622a790d999268c022ba628fe8 --- /dev/null +++ b/scipy/conveyor_belt_drop/095/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f6dceb3a9510ed9f908836fff160f997064ad5fc982edd4b22b397c5d22f3e6 +size 15765 diff --git a/scipy/conveyor_belt_drop/244/cot.json b/scipy/conveyor_belt_drop/244/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..cc7675c0ea28eb4db980e73461d92853abfc15cb --- /dev/null +++ b/scipy/conveyor_belt_drop/244/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.604 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.483 m/s rightward. Coulomb friction mu_belt=0.33294151078801415, mu_floor=0.36278662540912265 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 3.2662; ends when vx = v_belt = 1.4827812683679797", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -3.5589; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 3.2662; ends * when * vx = v_belt = 1.4827812683679797", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -3.5589; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.424 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2939 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 3.2662 m/s^2; t2 = v_belt/a = 0.4540 s; dx2 = 0.3366 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 0.8854 m -> t3 = 0.5971 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.6695 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 3.5589; t5 = 0.4166 s; dx5 = v_belt^2/(2 a_fl) = 0.3089 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.2938610017142196, + "t2_slip_s": 0.4539835721608513, + "t3_ride_s": 0.5971454429526873, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.41663602184264104, + "dx2_slip_m": 0.33657916847344665, + "dx4_off_belt_m": 0.6695107970789503, + "dx5_floor_m": 0.30889004445781026, + "final_x_m": 2.7784008415367607 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.454 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.417 s on the floor.", + "Final cube rest position x ~ 2.778 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.4827812683679797, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.33294151078801415, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.36278662540912265, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5779847542250085, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.6035677842512168, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/244/params.json b/scipy/conveyor_belt_drop/244/params.json new file mode 100644 index 0000000000000000000000000000000000000000..76e1d53aefd631cdf661ef9c1fb90cdbdb708790 --- /dev/null +++ b/scipy/conveyor_belt_drop/244/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.4827812683679797, + "mu_belt": 0.33294151078801415, + "mu_floor": 0.36278662540912265, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5779847542250085, + "y_drop_top": 1.6035677842512168 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/244/simulation_code.py b/scipy/conveyor_belt_drop/244/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6dfe1891c35044392c8dfe90c92dc6395d2672f7 --- /dev/null +++ b/scipy/conveyor_belt_drop/244/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.4827812683679797 +mu_belt = 0.33294151078801415 +mu_floor = 0.36278662540912265 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5779847542250085 +y_drop_top = 1.6035677842512168 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/244/video.mp4 b/scipy/conveyor_belt_drop/244/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..36ba03f32da944193f0f2f99742c2430871399f4 --- /dev/null +++ b/scipy/conveyor_belt_drop/244/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebdf5286f478a9d29854c295bb20e960a41084b51ee205a153cb1bdfd3970056 +size 15562 diff --git a/scipy/conveyor_belt_drop/257/cot.json b/scipy/conveyor_belt_drop/257/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..417398a4a1236a0f4b2d40b1e2657b9d16034d5f --- /dev/null +++ b/scipy/conveyor_belt_drop/257/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.618 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=0.968 m/s rightward. Coulomb friction mu_belt=0.34298813719428556, mu_floor=0.22859095354435696 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 3.3647; ends when vx = v_belt = 0.9680709723656657", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -2.2425; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 3.3647; ends * when * vx = v_belt = 0.9680709723656657", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -2.2425; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.438 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2988 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 3.3647 m/s^2; t2 = v_belt/a = 0.2877 s; dx2 = 0.1393 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.1075 m -> t3 = 1.1440 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.4371 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 2.2425; t5 = 0.4317 s; dx5 = v_belt^2/(2 a_fl) = 0.2090 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.2988341073006338, + "t2_slip_s": 0.28771273873676134, + "t3_ride_s": 1.14402390638891, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.431697120014153, + "dx2_slip_m": 0.13926317537544264, + "dx4_off_belt_m": 0.4371069301751423, + "dx5_floor_m": 0.2089567253697793, + "final_x_m": 2.446063655544922 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.288 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.432 s on the floor.", + "Final cube rest position x ~ 2.446 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 0.9680709723656657, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.34298813719428556, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.22859095354435696, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5532404891570779, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.6180254451806477, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/257/params.json b/scipy/conveyor_belt_drop/257/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5aa4fa22435217916e1b8a4296cdebec0ebaf6f8 --- /dev/null +++ b/scipy/conveyor_belt_drop/257/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 0.9680709723656657, + "mu_belt": 0.34298813719428556, + "mu_floor": 0.22859095354435696, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5532404891570779, + "y_drop_top": 1.6180254451806477 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/257/simulation_code.py b/scipy/conveyor_belt_drop/257/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..153e3bd5cd1079e51b98aced0d298d629f8e58a9 --- /dev/null +++ b/scipy/conveyor_belt_drop/257/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 0.9680709723656657 +mu_belt = 0.34298813719428556 +mu_floor = 0.22859095354435696 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5532404891570779 +y_drop_top = 1.6180254451806477 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/257/video.mp4 b/scipy/conveyor_belt_drop/257/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f14f805a7719d4c2a19c7bbc97037a3a7154b604 --- /dev/null +++ b/scipy/conveyor_belt_drop/257/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d6d52e5ccf6e0e41e14325d4d97cfd915c7a0b66fbcdb5250d06553e51bae9e +size 15232 diff --git a/scipy/conveyor_belt_drop/260/cot.json b/scipy/conveyor_belt_drop/260/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..59a83b24358ebca8b5ca117cd76169bfa4bbb120 --- /dev/null +++ b/scipy/conveyor_belt_drop/260/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.434 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=0.981 m/s rightward. Coulomb friction mu_belt=0.3126096564704527, mu_floor=0.2517886259367248 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 3.0667; ends when vx = v_belt = 0.9808614451044682", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -2.4700; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 3.0667; ends * when * vx = v_belt = 0.9808614451044682", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -2.4700; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.254 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2274 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 3.0667 m/s^2; t2 = v_belt/a = 0.3198 s; dx2 = 0.1569 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.0520 m -> t3 = 1.0725 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.4429 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 2.4700; t5 = 0.3971 s; dx5 = v_belt^2/(2 a_fl) = 0.1948 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.22738489248792534, + "t2_slip_s": 0.31984257072010386, + "t3_ride_s": 1.072494931954687, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.3971024337793752, + "dx2_slip_m": 0.15686062306122459, + "dx4_off_belt_m": 0.4428821309960951, + "dx5_floor_m": 0.19475123352566967, + "final_x_m": 2.4376333645217647 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.320 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.397 s on the floor.", + "Final cube rest position x ~ 2.438 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 0.9808614451044682, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.3126096564704527, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.2517886259367248, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5911704481144829, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.433607577172211, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/260/params.json b/scipy/conveyor_belt_drop/260/params.json new file mode 100644 index 0000000000000000000000000000000000000000..97d3a03b69fab6db273752350959bedde5136105 --- /dev/null +++ b/scipy/conveyor_belt_drop/260/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 0.9808614451044682, + "mu_belt": 0.3126096564704527, + "mu_floor": 0.2517886259367248, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5911704481144829, + "y_drop_top": 1.433607577172211 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/260/simulation_code.py b/scipy/conveyor_belt_drop/260/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..66eb9237f0b57e39ae8df5286595c38e9ac6d874 --- /dev/null +++ b/scipy/conveyor_belt_drop/260/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 0.9808614451044682 +mu_belt = 0.3126096564704527 +mu_floor = 0.2517886259367248 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5911704481144829 +y_drop_top = 1.433607577172211 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/260/video.mp4 b/scipy/conveyor_belt_drop/260/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..240f092c291f772e202fd0fb08b8f3396b43773c --- /dev/null +++ b/scipy/conveyor_belt_drop/260/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a4ba3809052c4b1022ceac30bc766190d1669a002b01c1bece2e94957744dd7 +size 15859 diff --git a/scipy/conveyor_belt_drop/271/cot.json b/scipy/conveyor_belt_drop/271/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..930a6b0736bc4bc2ad7342311eecbf1adfdcc4b1 --- /dev/null +++ b/scipy/conveyor_belt_drop/271/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.575 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=0.989 m/s rightward. Coulomb friction mu_belt=0.2004926860740261, mu_floor=0.21798917796520362 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 1.9668; ends when vx = v_belt = 0.9887897620447693", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -2.1385; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 1.9668; ends * when * vx = v_belt = 0.9887897620447693", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -2.1385; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.395 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2838 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 1.9668 m/s^2; t2 = v_belt/a = 0.5027 s; dx2 = 0.2485 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 0.9401 m -> t3 = 0.9507 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.4465 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 2.1385; t5 = 0.4624 s; dx5 = v_belt^2/(2 a_fl) = 0.2286 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.28384204566176324, + "t2_slip_s": 0.5027318720845381, + "t3_ride_s": 0.9507235012244237, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.46238104272012037, + "dx2_slip_m": 0.2485480640853959, + "dx4_off_belt_m": 0.4464619535278687, + "dx5_floor_m": 0.22859882060262007, + "final_x_m": 2.4750607741304886 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.503 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.462 s on the floor.", + "Final cube rest position x ~ 2.475 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 0.9887897620447693, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.2004926860740261, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.21798917796520362, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.6113862713685363, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.5751777352731542, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/271/params.json b/scipy/conveyor_belt_drop/271/params.json new file mode 100644 index 0000000000000000000000000000000000000000..509592ff6704b4b9bce9121ad1f1c12a4ffb1010 --- /dev/null +++ b/scipy/conveyor_belt_drop/271/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 0.9887897620447693, + "mu_belt": 0.2004926860740261, + "mu_floor": 0.21798917796520362, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.6113862713685363, + "y_drop_top": 1.5751777352731542 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/271/simulation_code.py b/scipy/conveyor_belt_drop/271/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5df80c0f2d4b27edca4e2b166c210cecfe2db524 --- /dev/null +++ b/scipy/conveyor_belt_drop/271/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 0.9887897620447693 +mu_belt = 0.2004926860740261 +mu_floor = 0.21798917796520362 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.6113862713685363 +y_drop_top = 1.5751777352731542 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/271/video.mp4 b/scipy/conveyor_belt_drop/271/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f2f107e20a52205769dd6ba8cf7e9e3e510ac2bb --- /dev/null +++ b/scipy/conveyor_belt_drop/271/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a97133fb95e4d1a2f39d5f40d22afa1eea3b448b64f3459084807738d0e020b +size 15098 diff --git a/scipy/conveyor_belt_drop/304/cot.json b/scipy/conveyor_belt_drop/304/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1195d32a873380a4af0171161fc0e2548f7c1571 --- /dev/null +++ b/scipy/conveyor_belt_drop/304/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.523 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.138 m/s rightward. Coulomb friction mu_belt=0.2582411807663782, mu_floor=0.2264492188702012 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 2.5333; ends when vx = v_belt = 1.138116788752079", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -2.2215; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 2.5333; ends * when * vx = v_belt = 1.138116788752079", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -2.2215; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.343 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2643 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 2.5333 m/s^2; t2 = v_belt/a = 0.4493 s; dx2 = 0.2557 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.0464 m -> t3 = 0.9194 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.5139 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 2.2215; t5 = 0.5123 s; dx5 = v_belt^2/(2 a_fl) = 0.2915 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.26426955957425075, + "t2_slip_s": 0.4492543838253693, + "t3_ride_s": 0.9194373414256923, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.5123267067219801, + "dx2_slip_m": 0.2556519783260616, + "dx4_off_belt_m": 0.5138866363243266, + "dx5_floor_m": 0.29154381312317407, + "final_x_m": 2.6054304494475007 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.449 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.512 s on the floor.", + "Final cube rest position x ~ 2.605 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.138116788752079, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.2582411807663782, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.2264492188702012, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.4979209471917807, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.5225573525766734, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/304/params.json b/scipy/conveyor_belt_drop/304/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ba0cb6479a249df4026975f8e61c945edfd0759c --- /dev/null +++ b/scipy/conveyor_belt_drop/304/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.138116788752079, + "mu_belt": 0.2582411807663782, + "mu_floor": 0.2264492188702012, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.4979209471917807, + "y_drop_top": 1.5225573525766734 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/304/simulation_code.py b/scipy/conveyor_belt_drop/304/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5020399f4995c2c624e1e6969bb59f5c9f410cc0 --- /dev/null +++ b/scipy/conveyor_belt_drop/304/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.138116788752079 +mu_belt = 0.2582411807663782 +mu_floor = 0.2264492188702012 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.4979209471917807 +y_drop_top = 1.5225573525766734 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/304/video.mp4 b/scipy/conveyor_belt_drop/304/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..296f87ffaceadc0db9e6c302c3e6bc107861ac79 --- /dev/null +++ b/scipy/conveyor_belt_drop/304/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:787b375ed54b626885e0e58435c6e6c51051490b1772f158b12ebaff09a1107a +size 15577 diff --git a/scipy/conveyor_belt_drop/435/cot.json b/scipy/conveyor_belt_drop/435/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a6c5ce4ae59eb42a8ffd4dfe3c54815458addd0a --- /dev/null +++ b/scipy/conveyor_belt_drop/435/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.523 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=0.938 m/s rightward. Coulomb friction mu_belt=0.25684875826630316, mu_floor=0.2617111410174831 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 2.5197; ends when vx = v_belt = 0.9382287186125178", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -2.5674; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 2.5197; ends * when * vx = v_belt = 0.9382287186125178", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -2.5674; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.343 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2643 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 2.5197 m/s^2; t2 = v_belt/a = 0.3724 s; dx2 = 0.1747 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.0683 m -> t3 = 1.1386 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.4236 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 2.5674; t5 = 0.3654 s; dx5 = v_belt^2/(2 a_fl) = 0.1714 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.2642786097679999, + "t2_slip_s": 0.3723593336557219, + "t3_ride_s": 1.1385960385663592, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.3654411963759357, + "dx2_slip_m": 0.17467911023960944, + "dx4_off_belt_m": 0.4236324471053008, + "dx5_floor_m": 0.1714337127020098, + "final_x_m": 2.3950661598073104 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.372 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.365 s on the floor.", + "Final cube rest position x ~ 2.395 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 0.9382287186125178, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.25684875826630316, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.2617111410174831, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5570573874789866, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.5225808154643476, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/435/params.json b/scipy/conveyor_belt_drop/435/params.json new file mode 100644 index 0000000000000000000000000000000000000000..9c1c3a509d1abbdece1d5a97e00bff8bb992b130 --- /dev/null +++ b/scipy/conveyor_belt_drop/435/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 0.9382287186125178, + "mu_belt": 0.25684875826630316, + "mu_floor": 0.2617111410174831, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5570573874789866, + "y_drop_top": 1.5225808154643476 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/435/simulation_code.py b/scipy/conveyor_belt_drop/435/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..1f11e13b437fc8ae0b8e6cf5ee3d40a231541034 --- /dev/null +++ b/scipy/conveyor_belt_drop/435/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 0.9382287186125178 +mu_belt = 0.25684875826630316 +mu_floor = 0.2617111410174831 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5570573874789866 +y_drop_top = 1.5225808154643476 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/435/video.mp4 b/scipy/conveyor_belt_drop/435/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..695bd34a09a7e02416939933342b030695e77c64 --- /dev/null +++ b/scipy/conveyor_belt_drop/435/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76f0bf1d2934a1498f19e9af5f70a989acaaba4118832e89d050d561646e2cc3 +size 15623 diff --git a/scipy/conveyor_belt_drop/436/cot.json b/scipy/conveyor_belt_drop/436/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c95d4fcc76781f80dd173960dde874a476810c25 --- /dev/null +++ b/scipy/conveyor_belt_drop/436/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.459 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=0.826 m/s rightward. Coulomb friction mu_belt=0.28696062836576586, mu_floor=0.4307765337644742 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 2.8151; ends when vx = v_belt = 0.8262943076588644", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -4.2259; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 2.8151; ends * when * vx = v_belt = 0.8262943076588644", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -4.2259; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.279 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2386 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 2.8151 m/s^2; t2 = v_belt/a = 0.2935 s; dx2 = 0.1213 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.1895 m -> t3 = 1.4395 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.3731 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 4.2259; t5 = 0.1955 s; dx5 = v_belt^2/(2 a_fl) = 0.0808 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.23855095260721784, + "t2_slip_s": 0.29352387951897263, + "t3_ride_s": 1.4395170538177209, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.1955301422086611, + "dx2_slip_m": 0.12126855540423669, + "dx4_off_belt_m": 0.37309141431991416, + "dx5_floor_m": 0.08078272174137247, + "final_x_m": 2.253874136061287 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.294 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.196 s on the floor.", + "Final cube rest position x ~ 2.254 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 0.8262943076588644, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.28696062836576586, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.4307765337644742, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.4892666972483215, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.4591266620350234, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/436/params.json b/scipy/conveyor_belt_drop/436/params.json new file mode 100644 index 0000000000000000000000000000000000000000..bffc707861debf0ae914d4159038b9d2702f1092 --- /dev/null +++ b/scipy/conveyor_belt_drop/436/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 0.8262943076588644, + "mu_belt": 0.28696062836576586, + "mu_floor": 0.4307765337644742, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.4892666972483215, + "y_drop_top": 1.4591266620350234 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/436/simulation_code.py b/scipy/conveyor_belt_drop/436/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d6b320a266ad2f5a3aa7d5e21c5f7c23f7e0854c --- /dev/null +++ b/scipy/conveyor_belt_drop/436/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 0.8262943076588644 +mu_belt = 0.28696062836576586 +mu_floor = 0.4307765337644742 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.4892666972483215 +y_drop_top = 1.4591266620350234 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/436/video.mp4 b/scipy/conveyor_belt_drop/436/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..53cc92b229ee9379f99248303e6fe8940dae9ea6 --- /dev/null +++ b/scipy/conveyor_belt_drop/436/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27fe35826ff0b8a533d743d2fdec4ed5b2c3cdc8e4072d0b13ced686e33086c2 +size 15388 diff --git a/scipy/conveyor_belt_drop/470/cot.json b/scipy/conveyor_belt_drop/470/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1c3a326d5161e3b123c3b969f3c472f736ab2043 --- /dev/null +++ b/scipy/conveyor_belt_drop/470/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.601 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.276 m/s rightward. Coulomb friction mu_belt=0.28703371962745206, mu_floor=0.43736356638353935 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 2.8158; ends when vx = v_belt = 1.275645169437491", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -4.2905; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 2.8158; ends * when * vx = v_belt = 1.275645169437491", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -4.2905; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.421 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.2930 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 2.8158 m/s^2; t2 = v_belt/a = 0.4530 s; dx2 = 0.2890 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 0.9408 m -> t3 = 0.7375 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.5760 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 4.2905; t5 = 0.2973 s; dx5 = v_belt^2/(2 a_fl) = 0.1896 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.29299404435628984, + "t2_slip_s": 0.4530310433088138, + "t3_ride_s": 0.7375210614110437, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.2973159985475374, + "dx2_slip_m": 0.2889534310010576, + "dx4_off_belt_m": 0.5759839515102756, + "dx5_floor_m": 0.18963485867182506, + "final_x_m": 2.5656188101821007 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.453 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.297 s on the floor.", + "Final cube rest position x ~ 2.566 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.275645169437491, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.28703371962745206, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.43736356638353935, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5702313896515333, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.6010722266885933, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/470/params.json b/scipy/conveyor_belt_drop/470/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7ffd58cd55ccb82ebc54f237f2b00cfb0a149617 --- /dev/null +++ b/scipy/conveyor_belt_drop/470/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.275645169437491, + "mu_belt": 0.28703371962745206, + "mu_floor": 0.43736356638353935, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5702313896515333, + "y_drop_top": 1.6010722266885933 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/470/simulation_code.py b/scipy/conveyor_belt_drop/470/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c6af1629b4dfb5fff134c7c2eefec946664fff7a --- /dev/null +++ b/scipy/conveyor_belt_drop/470/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.275645169437491 +mu_belt = 0.28703371962745206 +mu_floor = 0.43736356638353935 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5702313896515333 +y_drop_top = 1.6010722266885933 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/470/video.mp4 b/scipy/conveyor_belt_drop/470/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..22aee0d252e4ec269105b7e1cfae44bb5ddccf60 --- /dev/null +++ b/scipy/conveyor_belt_drop/470/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6198950f8de2543dccdf48b774761d9606d86400a97bb102ee1702d8a3a2ea4 +size 13703 diff --git a/scipy/conveyor_belt_drop/491/cot.json b/scipy/conveyor_belt_drop/491/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..356a8c45df419c5b6cd6c96709801fe7d9910964 --- /dev/null +++ b/scipy/conveyor_belt_drop/491/cot.json @@ -0,0 +1,123 @@ +{ + "simulation": "conveyor_belt_drop", + "physical_observation": "A cube (m=0.500 kg, side=0.180 m) is dropped from height y_drop_top=1.643 m above a conveyor belt whose top is at y=1.000 m and runs at v_belt=1.121 m/s rightward. Coulomb friction mu_belt=0.3091860636045425, mu_floor=0.38251198592424085 couples cube to belt and to the floor. Cube exits the belt's right edge at x=1.800 m, falls to the floor, and slides to rest.", + "physical_law": { + "name": "Newton II + Coulomb kinetic friction + perfectly inelastic vertical contact", + "statement": "Vertical free fall under gravity; friction f = mu_k m g acts to oppose relative slip; cube does not bounce vertically off the belt or floor.", + "formula": "Free fall: y'' = -g. Slipping on belt: vx' = mu_belt g. No-slip ride: vx = v_belt. Off belt: vx const, y free fall. Floor slide: vx' = -mu_floor g until vx=0." + }, + "ode_system": { + "state_variables": [ + "x_cube (m)", + "y_cube (m)" + ], + "equations_latex": [ + "Phase 1 (drop): y(t) = y0 - 0.5 g t^2; x = x_drop", + "Phase 2 (slipping): vx' = mu_belt \\cdot g = 3.0331; ends when vx = v_belt = 1.1207425464327243", + "Phase 3 (riding): x' = v_belt; y on belt top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 (floor): vx' = -mu_floor \\cdot g = -3.7524; stops at v=0" + ], + "equations_python": [ + "Phase 1 * (drop): y(t) = y0 - 0.5 * g * t**2; x = x_drop", + "Phase 2 * (slipping): vx' = mu_belt * g = 3.0331; ends * when * vx = v_belt = 1.1207425464327243", + "Phase 3 * (riding): x' = v_belt; y * on * belt * top", + "Phase 4 (off belt): x' = v_belt; y free fall", + "Phase 5 * (floor): vx' = -mu_floor * g = -3.7524; stops * at * v=0" + ] + }, + "derivation_steps": [ + "Phase 1 free fall through 0.463 m: t1 = \\sqrt(2 (y_drop_top - cube_size - y_belt_top)/g) = 0.3074 s.", + "Phase 2 slipping: cube starts at vx=0, belt moves at v_belt. Friction f = mu_belt m g pulls cube forward. a = mu_belt g = 3.0331 m/s^2; t2 = v_belt/a = 0.3695 s; dx2 = 0.2071 m.", + "Phase 3 no-slip: cube co-moves with belt at v_belt; remaining distance to right edge = 1.0741 m -> t3 = 0.9584 s.", + "Phase 4 off-belt projectile: vy free fall from y_belt_top to floor (drop 1.000 m); t4 = 0.4515 s; horizontal travel dx4 = 0.5060 m.", + "Phase 5 floor friction: deceleration a_fl = mu_floor g = 3.7524; t5 = 0.2987 s; dx5 = v_belt^2/(2 a_fl) = 0.1674 m." + ], + "physical_constants_derived": { + "t1_drop_s": 0.3073942521029724, + "t2_slip_s": 0.3695021261998615, + "t3_ride_s": 0.9583856936327133, + "t4_fall_s": 0.4515236409857309, + "t5_floor_slide_s": 0.29867013870742093, + "dx2_slip_m": 0.2070583769147693, + "dx4_off_belt_m": 0.5060417551729233, + "dx5_floor_m": 0.16736616589918496, + "final_x_m": 2.4734079210721083 + }, + "numerical_method": { + "solver": "Closed-form per phase; no ODE solver needed.", + "tolerance": "Machine precision.", + "justification": "Each phase has constant acceleration with analytic transition times." + }, + "code_validation": { + "ode_source": "Newton II for each phase; standard friction-on-belt textbook problem.", + "energy_check": "KE evolves consistent with the work-energy theorem; friction dissipates KE while belt does positive work in phase 2.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Drop, then slip on belt for ~0.370 s, ride to right edge, projectile to floor in ~0.452 s, and stop after ~0.299 s on the floor.", + "Final cube rest position x ~ 2.473 m." + ], + "parameters": { + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "v_belt": { + "value": 1.1207425464327243, + "unit": "", + "description": "" + }, + "mu_belt": { + "value": 0.3091860636045425, + "unit": "", + "description": "" + }, + "mu_floor": { + "value": 0.38251198592424085, + "unit": "", + "description": "" + }, + "m_cube": { + "value": 0.5, + "unit": "", + "description": "" + }, + "x_belt_left": { + "value": 0.3, + "unit": "", + "description": "" + }, + "x_belt_right": { + "value": 1.8, + "unit": "", + "description": "" + }, + "y_belt_top": { + "value": 1.0, + "unit": "", + "description": "" + }, + "r_pulley": { + "value": 0.07, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.18, + "unit": "", + "description": "" + }, + "x_drop": { + "value": 0.5188380003386108, + "unit": "", + "description": "" + }, + "y_drop_top": { + "value": 1.6434794646382638, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/conveyor_belt_drop/491/params.json b/scipy/conveyor_belt_drop/491/params.json new file mode 100644 index 0000000000000000000000000000000000000000..42e5e0525f071fd9efffe54fb7a4bec27d96f039 --- /dev/null +++ b/scipy/conveyor_belt_drop/491/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.81, + "v_belt": 1.1207425464327243, + "mu_belt": 0.3091860636045425, + "mu_floor": 0.38251198592424085, + "m_cube": 0.5, + "x_belt_left": 0.3, + "x_belt_right": 1.8, + "y_belt_top": 1.0, + "r_pulley": 0.07, + "cube_size": 0.18, + "x_drop": 0.5188380003386108, + "y_drop_top": 1.6434794646382638 +} \ No newline at end of file diff --git a/scipy/conveyor_belt_drop/491/simulation_code.py b/scipy/conveyor_belt_drop/491/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..148631f7f228f3864ad3719936b6cd7f521b4953 --- /dev/null +++ b/scipy/conveyor_belt_drop/491/simulation_code.py @@ -0,0 +1,122 @@ +""" +Conveyor Belt Drop — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Rectangle, Circle, Polygon +from matplotlib.collections import LineCollection + +g = 9.81 +v_belt = 1.1207425464327243 +mu_belt = 0.3091860636045425 +mu_floor = 0.38251198592424085 +m_cube = 0.5 +x_belt_left = 0.3 +x_belt_right = 1.8 +y_belt_top = 1.0 +r_pulley = 0.07 +cube_size = 0.18 +x_drop = 0.5188380003386108 +y_drop_top = 1.6434794646382638 +duration = 12 +fps = 30 + +fall_dist_1 = (y_drop_top - cube_size) - y_belt_top +t1_dur = np.sqrt(max(2.0 * fall_dist_1 / g, 0.0)) +a_friction = mu_belt * g +t2_dur = v_belt / a_friction if a_friction > 0 else 0.0 +dx2 = 0.5 * a_friction * t2_dur ** 2 +x_at_phase3_start = x_drop + dx2 +t3_dur = max(0.0, (x_belt_right - x_at_phase3_start) / v_belt) if v_belt > 0 else 0.0 +fall_dist_4 = y_belt_top +t4_dur = np.sqrt(2.0 * fall_dist_4 / g) +dx4 = v_belt * t4_dur +a_floor = mu_floor * g +t5_dur = v_belt / a_floor if a_floor > 0 else 0.0 +dx5 = v_belt ** 2 / (2.0 * a_floor) if a_floor > 0 else 0.0 +t1_end = t1_dur +t2_end = t1_end + t2_dur +t3_end = t2_end + t3_dur +t4_end = t3_end + t4_dur +t5_end = t4_end + t5_dur + +def cube_com(t): + if t <= t1_end: + return (x_drop, (y_drop_top - cube_size/2) - 0.5*g*t**2) + if t <= t2_end: + dt = t - t1_end + return (x_drop + 0.5*a_friction*dt**2, y_belt_top + cube_size/2) + if t <= t3_end: + dt = t - t2_end + return (x_at_phase3_start + v_belt*dt, y_belt_top + cube_size/2) + if t <= t4_end: + dt = t - t3_end + return (x_belt_right + v_belt*dt, (y_belt_top + cube_size/2) - 0.5*g*dt**2) + if t <= t5_end: + dt = t - t4_end + return (x_belt_right + dx4 + v_belt*dt - 0.5*a_floor*dt**2, cube_size/2) + return (x_belt_right + dx4 + dx5, cube_size/2) + +fig_w, fig_h = 11.0, 6.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.20 +x_hi_d = x_belt_right + dx4 + dx5 + 0.30 +y_lo_d = -0.25 +y_hi_d = y_drop_top + 0.20 +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Polygon([(x_lo, y_lo), (x_hi, y_lo), (x_hi, 0.0), (x_lo, 0.0)], + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo, x_hi], [0.0, 0.0], color="#adb5bd", lw=2.0, zorder=1) +y_pulley_c = y_belt_top - r_pulley +ax.plot([x_belt_left, x_belt_right], [y_belt_top, y_belt_top], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.plot([x_belt_left, x_belt_right], [y_belt_top - 2*r_pulley, y_belt_top - 2*r_pulley], + color="#4a4e69", lw=10, solid_capstyle="butt", zorder=2) +ax.add_patch(Circle((x_belt_left, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) +ax.add_patch(Circle((x_belt_right, y_pulley_c), r_pulley, facecolor="#3a4357", edgecolor="#adb5bd", lw=1.2, zorder=3)) + +hash_spacing = 0.12; hash_w = 0.025 +hash_lc = LineCollection([], colors="#adb5bd", linewidths=2.0, zorder=4) +ax.add_collection(hash_lc) + +cube_patch = Rectangle((0, 0), cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.2, zorder=5) +ax.add_patch(cube_patch) + +def update(f): + t = f / fps + cx, cy = cube_com(t) + cube_patch.set_xy((cx - cube_size/2, cy - cube_size/2)) + s0 = (v_belt * t) % hash_spacing + span = x_belt_right - x_belt_left + n_marks = int(np.ceil(span / hash_spacing)) + 1 + segs = [] + for k in range(n_marks): + x_m = x_belt_left + s0 + k * hash_spacing + if x_belt_left <= x_m <= x_belt_right: + segs.append([(x_m, y_belt_top - hash_w), (x_m, y_belt_top + hash_w)]) + x_m_b = x_belt_right - s0 - k * hash_spacing + if x_belt_left <= x_m_b <= x_belt_right: + y_b = y_belt_top - 2 * r_pulley + segs.append([(x_m_b, y_b - hash_w), (x_m_b, y_b + hash_w)]) + hash_lc.set_segments(segs) + return cube_patch, hash_lc + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("conveyor_belt_drop.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved conveyor_belt_drop.mp4") diff --git a/scipy/conveyor_belt_drop/491/video.mp4 b/scipy/conveyor_belt_drop/491/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..0211d2acd0d99cdfb060201bdb590609046aa1c6 --- /dev/null +++ b/scipy/conveyor_belt_drop/491/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84a20b1e1aea0caa858b971725320daee00f25d27ca8d34016a0331ca560d4a6 +size 14308 diff --git a/scipy/cylinder_piston_ball/040/cot.json b/scipy/cylinder_piston_ball/040/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a7fef5c562716468e07d6325309fbc4a4d95da76 --- /dev/null +++ b/scipy/cylinder_piston_ball/040/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.163 kg, r_b=0.097 m) starts at y=0.821 m and a piston (m_p=0.856 kg, thickness t_p=0.200 m) starts with its bottom at y=2.100 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.6821342406861384, ball-piston restitution e_bp=0.5115029009488352.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 0.821 m, piston bottom at 2.100 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.384 s.", + "Initial gap piston-ball: 1.182 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.491 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.3844874093487868, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.4911010082734383, + "expected_final_y_b": 0.09698294414293906, + "expected_final_y_p_bot": 0.19396588828587813 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.16320449728667633, + "unit": "", + "description": "" + }, + "m_p": { + "value": 0.8563736084562179, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.09698294414293906, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 0.8213527270868726, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.1001186528330313, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.6821342406861384, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.5115029009488352, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/040/params.json b/scipy/cylinder_piston_ball/040/params.json new file mode 100644 index 0000000000000000000000000000000000000000..28ef59d38e7fabf115fbbf3ee1e978c2c709fcc9 --- /dev/null +++ b/scipy/cylinder_piston_ball/040/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.16320449728667633, + "m_p": 0.8563736084562179, + "r_b": 0.09698294414293906, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 0.8213527270868726, + "y_p_bot_0": 2.1001186528330313, + "e_floor": 0.6821342406861384, + "e_bp": 0.5115029009488352, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/040/simulation_code.py b/scipy/cylinder_piston_ball/040/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..1a76c2409d2c0c2763e619e1aba9fd22087d8566 --- /dev/null +++ b/scipy/cylinder_piston_ball/040/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.16320449728667633 +m_p = 0.8563736084562179 +r_b = 0.09698294414293906 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 0.8213527270868726 +y_p_bot_0= 2.1001186528330313 +e_floor = 0.6821342406861384 +e_bp = 0.5115029009488352 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/040/video.mp4 b/scipy/cylinder_piston_ball/040/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9400f5b8bc63a694f1e1b437bb97b3f80d32a161 --- /dev/null +++ b/scipy/cylinder_piston_ball/040/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b495e51dc9ad3c9710648a2d5151ba52010023608ceb453a9292c88682046ad +size 7246 diff --git a/scipy/cylinder_piston_ball/083/cot.json b/scipy/cylinder_piston_ball/083/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..9a8cf72be9f005ceaefa8e57252492947f4fb2a1 --- /dev/null +++ b/scipy/cylinder_piston_ball/083/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.170 kg, r_b=0.125 m) starts at y=0.885 m and a piston (m_p=0.735 kg, thickness t_p=0.200 m) starts with its bottom at y=2.092 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.8370565885564737, ball-piston restitution e_bp=0.6697143000279504.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 0.885 m, piston bottom at 2.092 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.394 s.", + "Initial gap piston-ball: 1.082 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.470 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.39382295170874787, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.4699967632208616, + "expected_final_y_b": 0.12471397638636382, + "expected_final_y_p_bot": 0.24942795277272764 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.16972800979061542, + "unit": "", + "description": "" + }, + "m_p": { + "value": 0.7345988449853253, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.12471397638636382, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 0.8846869111200587, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.091795978953047, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.8370565885564737, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.6697143000279504, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/083/params.json b/scipy/cylinder_piston_ball/083/params.json new file mode 100644 index 0000000000000000000000000000000000000000..0f085b3bf972568ca0e6e67d0cbceb8bea8fe2d0 --- /dev/null +++ b/scipy/cylinder_piston_ball/083/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.16972800979061542, + "m_p": 0.7345988449853253, + "r_b": 0.12471397638636382, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 0.8846869111200587, + "y_p_bot_0": 2.091795978953047, + "e_floor": 0.8370565885564737, + "e_bp": 0.6697143000279504, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/083/simulation_code.py b/scipy/cylinder_piston_ball/083/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9e7b779ae802538b5dab50b3ce2808f56874984f --- /dev/null +++ b/scipy/cylinder_piston_ball/083/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.16972800979061542 +m_p = 0.7345988449853253 +r_b = 0.12471397638636382 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 0.8846869111200587 +y_p_bot_0= 2.091795978953047 +e_floor = 0.8370565885564737 +e_bp = 0.6697143000279504 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/083/video.mp4 b/scipy/cylinder_piston_ball/083/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4978c08ca463414de2a9de4d75558699a127965e --- /dev/null +++ b/scipy/cylinder_piston_ball/083/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f1f3abe0fd93a36421b0b73f88d0d3bfda53fdbdc0c788053e0913de66ef0dd +size 7905 diff --git a/scipy/cylinder_piston_ball/122/cot.json b/scipy/cylinder_piston_ball/122/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4dfb010cc24aaa37be48d93c712cbe7e7cc5b0a9 --- /dev/null +++ b/scipy/cylinder_piston_ball/122/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.181 kg, r_b=0.091 m) starts at y=1.132 m and a piston (m_p=1.216 kg, thickness t_p=0.200 m) starts with its bottom at y=2.195 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.8431135467319677, ball-piston restitution e_bp=0.6249178402374299.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 1.132 m, piston bottom at 2.195 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.461 s.", + "Initial gap piston-ball: 0.972 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.445 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.4610537100919718, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.4454578765305558, + "expected_final_y_b": 0.09073293151814679, + "expected_final_y_p_bot": 0.18146586303629358 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.18126956693230672, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.2160476712206278, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.09073293151814679, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 1.1323284971070497, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.195381755464445, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.8431135467319677, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.6249178402374299, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/122/params.json b/scipy/cylinder_piston_ball/122/params.json new file mode 100644 index 0000000000000000000000000000000000000000..9f3f2b3042097c5bcacd5f0b152972fd6443cb8f --- /dev/null +++ b/scipy/cylinder_piston_ball/122/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.18126956693230672, + "m_p": 1.2160476712206278, + "r_b": 0.09073293151814679, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 1.1323284971070497, + "y_p_bot_0": 2.195381755464445, + "e_floor": 0.8431135467319677, + "e_bp": 0.6249178402374299, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/122/simulation_code.py b/scipy/cylinder_piston_ball/122/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..10b6006b21a158745e880c03e62cbf8fec00c469 --- /dev/null +++ b/scipy/cylinder_piston_ball/122/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.18126956693230672 +m_p = 1.2160476712206278 +r_b = 0.09073293151814679 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 1.1323284971070497 +y_p_bot_0= 2.195381755464445 +e_floor = 0.8431135467319677 +e_bp = 0.6249178402374299 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/122/video.mp4 b/scipy/cylinder_piston_ball/122/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c7a941407d713c47b8b982cc9c8b8e855ee27389 --- /dev/null +++ b/scipy/cylinder_piston_ball/122/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5465bea6878399a96420b22f85f037efd6b702dceb91286d7a7be8cc940c2d2f +size 7566 diff --git a/scipy/cylinder_piston_ball/240/cot.json b/scipy/cylinder_piston_ball/240/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4201f16bea7e8f4a3a394be1d29e23c8f4649b46 --- /dev/null +++ b/scipy/cylinder_piston_ball/240/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.111 kg, r_b=0.099 m) starts at y=1.024 m and a piston (m_p=0.944 kg, thickness t_p=0.200 m) starts with its bottom at y=2.008 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.7111806383320182, ball-piston restitution e_bp=0.4561678316887217.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 1.024 m, piston bottom at 2.008 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.435 s.", + "Initial gap piston-ball: 0.884 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.425 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.43451448194302206, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.4247744974427094, + "expected_final_y_b": 0.09936083432974036, + "expected_final_y_p_bot": 0.1987216686594807 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.11129126318955025, + "unit": "", + "description": "" + }, + "m_p": { + "value": 0.9438461966076874, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.09936083432974036, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 1.0244947259189832, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.0079790912694846, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.7111806383320182, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.4561678316887217, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/240/params.json b/scipy/cylinder_piston_ball/240/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a0adfd867118a134acdd228d1b5f5bb60a59d29c --- /dev/null +++ b/scipy/cylinder_piston_ball/240/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.11129126318955025, + "m_p": 0.9438461966076874, + "r_b": 0.09936083432974036, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 1.0244947259189832, + "y_p_bot_0": 2.0079790912694846, + "e_floor": 0.7111806383320182, + "e_bp": 0.4561678316887217, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/240/simulation_code.py b/scipy/cylinder_piston_ball/240/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..0911fb999ed932298e63080fe681c4e13c9bc4c6 --- /dev/null +++ b/scipy/cylinder_piston_ball/240/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.11129126318955025 +m_p = 0.9438461966076874 +r_b = 0.09936083432974036 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 1.0244947259189832 +y_p_bot_0= 2.0079790912694846 +e_floor = 0.7111806383320182 +e_bp = 0.4561678316887217 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/240/video.mp4 b/scipy/cylinder_piston_ball/240/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..75f00eb5c9308c8bb09cf1561c75591f59c654e6 --- /dev/null +++ b/scipy/cylinder_piston_ball/240/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04bb27a7d1a9dc6c667049f2203a7d038084f8b4d9ca704a65ca3a87c8ff3537 +size 6381 diff --git a/scipy/cylinder_piston_ball/252/cot.json b/scipy/cylinder_piston_ball/252/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..91bb0a4273da3528d2a351b0c60b5398ddf50916 --- /dev/null +++ b/scipy/cylinder_piston_ball/252/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.163 kg, r_b=0.128 m) starts at y=1.018 m and a piston (m_p=1.011 kg, thickness t_p=0.200 m) starts with its bottom at y=2.059 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.7747026694710091, ball-piston restitution e_bp=0.5379450263347197.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 1.018 m, piston bottom at 2.059 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.426 s.", + "Initial gap piston-ball: 0.914 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.432 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.42612118438410007, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.43185030013108056, + "expected_final_y_b": 0.12784556935593988, + "expected_final_y_p_bot": 0.25569113871187976 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.16332705640581152, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.0107783142586817, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.12784556935593988, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 1.01758396188239, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.0592534716825215, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.7747026694710091, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.5379450263347197, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/252/params.json b/scipy/cylinder_piston_ball/252/params.json new file mode 100644 index 0000000000000000000000000000000000000000..6a2a047641b3aa57f2130a22abdb2ec87e78638f --- /dev/null +++ b/scipy/cylinder_piston_ball/252/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.16332705640581152, + "m_p": 1.0107783142586817, + "r_b": 0.12784556935593988, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 1.01758396188239, + "y_p_bot_0": 2.0592534716825215, + "e_floor": 0.7747026694710091, + "e_bp": 0.5379450263347197, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/252/simulation_code.py b/scipy/cylinder_piston_ball/252/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b8ee4905da8d852089b8c6df3849d2211f862e43 --- /dev/null +++ b/scipy/cylinder_piston_ball/252/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.16332705640581152 +m_p = 1.0107783142586817 +r_b = 0.12784556935593988 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 1.01758396188239 +y_p_bot_0= 2.0592534716825215 +e_floor = 0.7747026694710091 +e_bp = 0.5379450263347197 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/252/video.mp4 b/scipy/cylinder_piston_ball/252/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..025527d927e1e4b7f7599398b9f61061494301b6 --- /dev/null +++ b/scipy/cylinder_piston_ball/252/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cffadfbda73e40cc2569b0942811678ada65476cd70134fefc0ee788d3f5e0c2 +size 6806 diff --git a/scipy/cylinder_piston_ball/413/cot.json b/scipy/cylinder_piston_ball/413/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6dadbb23aeb4572a5dca6a73fbbd94ae8a485e52 --- /dev/null +++ b/scipy/cylinder_piston_ball/413/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.196 kg, r_b=0.063 m) starts at y=0.977 m and a piston (m_p=0.837 kg, thickness t_p=0.200 m) starts with its bottom at y=2.027 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.7152099017041156, ball-piston restitution e_bp=0.6926549515140383.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 0.977 m, piston bottom at 2.027 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.432 s.", + "Initial gap piston-ball: 0.988 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.449 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.43192096132941704, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.44902615786488487, + "expected_final_y_b": 0.06251864225601433, + "expected_final_y_p_bot": 0.12503728451202867 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.19639898193615318, + "unit": "", + "description": "" + }, + "m_p": { + "value": 0.8372375841943787, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.06251864225601433, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 0.9766416547510804, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.0271203001969074, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.7152099017041156, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.6926549515140383, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/413/params.json b/scipy/cylinder_piston_ball/413/params.json new file mode 100644 index 0000000000000000000000000000000000000000..af1d918d55de05fa1089b45e48352621f5b726e0 --- /dev/null +++ b/scipy/cylinder_piston_ball/413/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.19639898193615318, + "m_p": 0.8372375841943787, + "r_b": 0.06251864225601433, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 0.9766416547510804, + "y_p_bot_0": 2.0271203001969074, + "e_floor": 0.7152099017041156, + "e_bp": 0.6926549515140383, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/413/simulation_code.py b/scipy/cylinder_piston_ball/413/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f87d4edaa4e89da3b1244f9b607397e322d7d7ed --- /dev/null +++ b/scipy/cylinder_piston_ball/413/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.19639898193615318 +m_p = 0.8372375841943787 +r_b = 0.06251864225601433 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 0.9766416547510804 +y_p_bot_0= 2.0271203001969074 +e_floor = 0.7152099017041156 +e_bp = 0.6926549515140383 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/413/video.mp4 b/scipy/cylinder_piston_ball/413/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..79ebf169386250f8aae7625b8cfd5f180797306d --- /dev/null +++ b/scipy/cylinder_piston_ball/413/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0df8a7c24cd2e89391e6c669a8e75365652d851194c1730377c300a12ad53905 +size 6531 diff --git a/scipy/cylinder_piston_ball/429/cot.json b/scipy/cylinder_piston_ball/429/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8da9753e7a1b87e34723e72337556ada0a340a01 --- /dev/null +++ b/scipy/cylinder_piston_ball/429/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.235 kg, r_b=0.144 m) starts at y=0.954 m and a piston (m_p=1.287 kg, thickness t_p=0.200 m) starts with its bottom at y=2.220 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.5997424175202793, ball-piston restitution e_bp=0.41025598710433026.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 0.954 m, piston bottom at 2.220 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.407 s.", + "Initial gap piston-ball: 1.121 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.478 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.4065297543640409, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.4783557111779015, + "expected_final_y_b": 0.14446552120613473, + "expected_final_y_p_bot": 0.28893104241226947 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.235008424798103, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.2870296782987616, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.14446552120613473, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 0.9542710830042431, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.219975117651306, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.5997424175202793, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.41025598710433026, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/429/params.json b/scipy/cylinder_piston_ball/429/params.json new file mode 100644 index 0000000000000000000000000000000000000000..97a4a7570285542d6e41cd6a5891387ee355b665 --- /dev/null +++ b/scipy/cylinder_piston_ball/429/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.235008424798103, + "m_p": 1.2870296782987616, + "r_b": 0.14446552120613473, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 0.9542710830042431, + "y_p_bot_0": 2.219975117651306, + "e_floor": 0.5997424175202793, + "e_bp": 0.41025598710433026, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/429/simulation_code.py b/scipy/cylinder_piston_ball/429/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..db095bbd16710c1953ee5eecfe0fda095b86fd03 --- /dev/null +++ b/scipy/cylinder_piston_ball/429/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.235008424798103 +m_p = 1.2870296782987616 +r_b = 0.14446552120613473 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 0.9542710830042431 +y_p_bot_0= 2.219975117651306 +e_floor = 0.5997424175202793 +e_bp = 0.41025598710433026 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/429/video.mp4 b/scipy/cylinder_piston_ball/429/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7674f49d31be3c7170dae74d042c5366d319bb1e --- /dev/null +++ b/scipy/cylinder_piston_ball/429/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b42ad004115985a5fe07d029e01a01ddf5cfed08ce274e37dad433579d826ff +size 7059 diff --git a/scipy/cylinder_piston_ball/578/cot.json b/scipy/cylinder_piston_ball/578/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..9b8794836390b1f0920df8071dbd34a0fa39ff3c --- /dev/null +++ b/scipy/cylinder_piston_ball/578/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.300 kg, r_b=0.126 m) starts at y=1.105 m and a piston (m_p=1.144 kg, thickness t_p=0.200 m) starts with its bottom at y=2.150 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.6729198425050363, ball-piston restitution e_bp=0.6677215944886657.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 1.105 m, piston bottom at 2.150 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.447 s.", + "Initial gap piston-ball: 0.918 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.433 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.447019726914059, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.4328649095741255, + "expected_final_y_b": 0.12612115615873176, + "expected_final_y_p_bot": 0.2522423123174635 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.2998810901239549, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.1439405097367734, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.12612115615873176, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 1.1052716737852992, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.1495157766530486, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.6729198425050363, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.6677215944886657, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/578/params.json b/scipy/cylinder_piston_ball/578/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c80363dd1e1426f8a4cdca4f1b994ca7b4f1f4be --- /dev/null +++ b/scipy/cylinder_piston_ball/578/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.2998810901239549, + "m_p": 1.1439405097367734, + "r_b": 0.12612115615873176, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 1.1052716737852992, + "y_p_bot_0": 2.1495157766530486, + "e_floor": 0.6729198425050363, + "e_bp": 0.6677215944886657, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/578/simulation_code.py b/scipy/cylinder_piston_ball/578/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..694370dd7662b0ef49a2b6673e46cfaa53801f1a --- /dev/null +++ b/scipy/cylinder_piston_ball/578/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.2998810901239549 +m_p = 1.1439405097367734 +r_b = 0.12612115615873176 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 1.1052716737852992 +y_p_bot_0= 2.1495157766530486 +e_floor = 0.6729198425050363 +e_bp = 0.6677215944886657 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/578/video.mp4 b/scipy/cylinder_piston_ball/578/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..0a2ff26e84d8369e7dba1061a12c49e7066f8ddb --- /dev/null +++ b/scipy/cylinder_piston_ball/578/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:340a0dd5ef1009b0498b80f0648457abf6ef09a7af76f09f8216cb5b1986a52b +size 7827 diff --git a/scipy/cylinder_piston_ball/583/cot.json b/scipy/cylinder_piston_ball/583/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..18b292f8f0184423838605b190270dfe3633ae9b --- /dev/null +++ b/scipy/cylinder_piston_ball/583/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.144 kg, r_b=0.107 m) starts at y=1.079 m and a piston (m_p=1.405 kg, thickness t_p=0.200 m) starts with its bottom at y=2.380 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.6245854455764612, ball-piston restitution e_bp=0.6161464678838091.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 1.079 m, piston bottom at 2.380 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.445 s.", + "Initial gap piston-ball: 1.194 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.494 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.44541093560081857, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.4936542455690622, + "expected_final_y_b": 0.10670160806062831, + "expected_final_y_p_bot": 0.21340321612125662 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.14439047219457182, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.404821569816956, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.10670160806062831, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 1.0788170256693315, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.3796217531549235, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.6245854455764612, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.6161464678838091, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/583/params.json b/scipy/cylinder_piston_ball/583/params.json new file mode 100644 index 0000000000000000000000000000000000000000..97a143b3cca94fdd7d8398bed8f452a6105005c2 --- /dev/null +++ b/scipy/cylinder_piston_ball/583/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.14439047219457182, + "m_p": 1.404821569816956, + "r_b": 0.10670160806062831, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 1.0788170256693315, + "y_p_bot_0": 2.3796217531549235, + "e_floor": 0.6245854455764612, + "e_bp": 0.6161464678838091, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/583/simulation_code.py b/scipy/cylinder_piston_ball/583/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ff17ed4061f326b6359cbd676f578c4fcf61fbea --- /dev/null +++ b/scipy/cylinder_piston_ball/583/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.14439047219457182 +m_p = 1.404821569816956 +r_b = 0.10670160806062831 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 1.0788170256693315 +y_p_bot_0= 2.3796217531549235 +e_floor = 0.6245854455764612 +e_bp = 0.6161464678838091 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/583/video.mp4 b/scipy/cylinder_piston_ball/583/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..da965c1d824eb5d7f763ef2cd4ca34f16fd40e53 --- /dev/null +++ b/scipy/cylinder_piston_ball/583/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ab4eecb38c413f471ebc679bd63328c61d9f4a0e9fefbdd756bee78a693b952 +size 6683 diff --git a/scipy/cylinder_piston_ball/592/cot.json b/scipy/cylinder_piston_ball/592/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6d4dd650ed16b2844e91d6cf7c70f976f2fcb8bf --- /dev/null +++ b/scipy/cylinder_piston_ball/592/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.158 kg, r_b=0.122 m) starts at y=0.883 m and a piston (m_p=1.227 kg, thickness t_p=0.200 m) starts with its bottom at y=2.012 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.7523411718487837, ball-piston restitution e_bp=0.4525640760400731.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 0.883 m, piston bottom at 2.012 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.394 s.", + "Initial gap piston-ball: 1.007 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.453 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.39403393586695823, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.45326820654963784, + "expected_final_y_b": 0.12204210355338188, + "expected_final_y_p_bot": 0.24408420710676376 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.1576094549539995, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.2270543584871016, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.12204210355338188, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 0.8828295423659319, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.011586774556067, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.7523411718487837, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.4525640760400731, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/592/params.json b/scipy/cylinder_piston_ball/592/params.json new file mode 100644 index 0000000000000000000000000000000000000000..63c451e8d1e49e8acda965f4214a958c11691db8 --- /dev/null +++ b/scipy/cylinder_piston_ball/592/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.1576094549539995, + "m_p": 1.2270543584871016, + "r_b": 0.12204210355338188, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 0.8828295423659319, + "y_p_bot_0": 2.011586774556067, + "e_floor": 0.7523411718487837, + "e_bp": 0.4525640760400731, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/592/simulation_code.py b/scipy/cylinder_piston_ball/592/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..60cb6f152bae49217f21b0503baf8a67052cf98f --- /dev/null +++ b/scipy/cylinder_piston_ball/592/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.1576094549539995 +m_p = 1.2270543584871016 +r_b = 0.12204210355338188 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 0.8828295423659319 +y_p_bot_0= 2.011586774556067 +e_floor = 0.7523411718487837 +e_bp = 0.4525640760400731 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/592/video.mp4 b/scipy/cylinder_piston_ball/592/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a883614132ed9e4a3c9201e4d2ae4839008831ed --- /dev/null +++ b/scipy/cylinder_piston_ball/592/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3912ba6925c957af741b6487c683c3aa3615959b7ae69d46ce7d8dbe3f99a582 +size 6467 diff --git a/scipy/cylinder_piston_ball/597/cot.json b/scipy/cylinder_piston_ball/597/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..3908f753e9b986daa1b67143e60a16c25b53ea5f --- /dev/null +++ b/scipy/cylinder_piston_ball/597/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.218 kg, r_b=0.077 m) starts at y=1.032 m and a piston (m_p=0.787 kg, thickness t_p=0.200 m) starts with its bottom at y=2.364 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.7828828398205925, ball-piston restitution e_bp=0.5123591778398938.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 1.032 m, piston bottom at 2.364 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.441 s.", + "Initial gap piston-ball: 1.256 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.506 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.4413909213663831, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.5062028898359335, + "expected_final_y_b": 0.07711672395487099, + "expected_final_y_p_bot": 0.15423344790974197 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.21839901559650188, + "unit": "", + "description": "" + }, + "m_p": { + "value": 0.7865261419723102, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.07711672395487099, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 1.0317638567317275, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.364463272510025, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.7828828398205925, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.5123591778398938, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/597/params.json b/scipy/cylinder_piston_ball/597/params.json new file mode 100644 index 0000000000000000000000000000000000000000..98fb6950c60088324f514677f74a18af32b77941 --- /dev/null +++ b/scipy/cylinder_piston_ball/597/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.21839901559650188, + "m_p": 0.7865261419723102, + "r_b": 0.07711672395487099, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 1.0317638567317275, + "y_p_bot_0": 2.364463272510025, + "e_floor": 0.7828828398205925, + "e_bp": 0.5123591778398938, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/597/simulation_code.py b/scipy/cylinder_piston_ball/597/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3ab28e5ef39633e1a1329eda71c3e0ba4d9dc80c --- /dev/null +++ b/scipy/cylinder_piston_ball/597/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.21839901559650188 +m_p = 0.7865261419723102 +r_b = 0.07711672395487099 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 1.0317638567317275 +y_p_bot_0= 2.364463272510025 +e_floor = 0.7828828398205925 +e_bp = 0.5123591778398938 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/597/video.mp4 b/scipy/cylinder_piston_ball/597/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6f38951eb7b82812a15a61d37bff818a2e2e3350 --- /dev/null +++ b/scipy/cylinder_piston_ball/597/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23fdfa17ddc6149384bd36a904f4b8926dde54db29546cde8471969e422d91eb +size 7384 diff --git a/scipy/cylinder_piston_ball/608/cot.json b/scipy/cylinder_piston_ball/608/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0f6a4f796916f63d82a1b8f9d531536c3e8cfaed --- /dev/null +++ b/scipy/cylinder_piston_ball/608/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.193 kg, r_b=0.065 m) starts at y=0.984 m and a piston (m_p=1.432 kg, thickness t_p=0.200 m) starts with its bottom at y=2.168 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.6630748984119348, ball-piston restitution e_bp=0.4482810777699861.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 0.984 m, piston bottom at 2.168 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.433 s.", + "Initial gap piston-ball: 1.119 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.478 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.4330210896114903, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.47791918725528504, + "expected_final_y_b": 0.06517779808571543, + "expected_final_y_p_bot": 0.13035559617143086 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.19282688765464734, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.4321795181202503, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.06517779808571543, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 0.9839633919224947, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.168334262787296, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.6630748984119348, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.4482810777699861, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/608/params.json b/scipy/cylinder_piston_ball/608/params.json new file mode 100644 index 0000000000000000000000000000000000000000..da1e1d08388db5ab0dd105e1f210a08f23786ff8 --- /dev/null +++ b/scipy/cylinder_piston_ball/608/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.19282688765464734, + "m_p": 1.4321795181202503, + "r_b": 0.06517779808571543, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 0.9839633919224947, + "y_p_bot_0": 2.168334262787296, + "e_floor": 0.6630748984119348, + "e_bp": 0.4482810777699861, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/608/simulation_code.py b/scipy/cylinder_piston_ball/608/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d77bff7e51ed8ceb93befe8a9b92751eb99d9d1a --- /dev/null +++ b/scipy/cylinder_piston_ball/608/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.19282688765464734 +m_p = 1.4321795181202503 +r_b = 0.06517779808571543 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 0.9839633919224947 +y_p_bot_0= 2.168334262787296 +e_floor = 0.6630748984119348 +e_bp = 0.4482810777699861 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/608/video.mp4 b/scipy/cylinder_piston_ball/608/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..907e2dc88cfd5988f3003b57443b369642d0c8c0 --- /dev/null +++ b/scipy/cylinder_piston_ball/608/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8fcd15d4454332adc91d9e847fc0ef7ce966367e2f8f093e062dd8a4c1f4b9c6 +size 6395 diff --git a/scipy/cylinder_piston_ball/634/cot.json b/scipy/cylinder_piston_ball/634/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..94192e8980c71626a52dd924fad8364a5e8465a9 --- /dev/null +++ b/scipy/cylinder_piston_ball/634/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.145 kg, r_b=0.133 m) starts at y=1.190 m and a piston (m_p=0.818 kg, thickness t_p=0.200 m) starts with its bottom at y=2.082 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.6410245774197838, ball-piston restitution e_bp=0.6578958272066198.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 1.190 m, piston bottom at 2.082 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.464 s.", + "Initial gap piston-ball: 0.759 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.394 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.46445483096014284, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.39361997711724545, + "expected_final_y_b": 0.13298341437779707, + "expected_final_y_p_bot": 0.26596682875559413 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.1448243535581312, + "unit": "", + "description": "" + }, + "m_p": { + "value": 0.8180970416226916, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.13298341437779707, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 1.19000303538865, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.082176213056773, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.6410245774197838, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.6578958272066198, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/634/params.json b/scipy/cylinder_piston_ball/634/params.json new file mode 100644 index 0000000000000000000000000000000000000000..895909c460b23502438c79323883a16c590a51c9 --- /dev/null +++ b/scipy/cylinder_piston_ball/634/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.1448243535581312, + "m_p": 0.8180970416226916, + "r_b": 0.13298341437779707, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 1.19000303538865, + "y_p_bot_0": 2.082176213056773, + "e_floor": 0.6410245774197838, + "e_bp": 0.6578958272066198, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/634/simulation_code.py b/scipy/cylinder_piston_ball/634/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..03bb0e671634c8bfea4afea30e564f331fd76511 --- /dev/null +++ b/scipy/cylinder_piston_ball/634/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.1448243535581312 +m_p = 0.8180970416226916 +r_b = 0.13298341437779707 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 1.19000303538865 +y_p_bot_0= 2.082176213056773 +e_floor = 0.6410245774197838 +e_bp = 0.6578958272066198 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/634/video.mp4 b/scipy/cylinder_piston_ball/634/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c5a238d4d98af339fafe56699a9a01092568812b --- /dev/null +++ b/scipy/cylinder_piston_ball/634/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f7c3f2524c9a6cb2700bd5aa705f98c208d5a30eb25cca63847e9d5c3d13396 +size 7392 diff --git a/scipy/cylinder_piston_ball/673/cot.json b/scipy/cylinder_piston_ball/673/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4bd47d36083b2aaa59e1e1b105a2bb73e74b5dc0 --- /dev/null +++ b/scipy/cylinder_piston_ball/673/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.150 kg, r_b=0.142 m) starts at y=0.839 m and a piston (m_p=1.441 kg, thickness t_p=0.200 m) starts with its bottom at y=2.338 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.7554553430899348, ball-piston restitution e_bp=0.5341240854552951.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 0.839 m, piston bottom at 2.338 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.377 s.", + "Initial gap piston-ball: 1.357 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.526 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.3771589369434968, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.526327684991635, + "expected_final_y_b": 0.14170031957690243, + "expected_final_y_p_bot": 0.28340063915380487 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.15032418057893876, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.4414072557923319, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.14170031957690243, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 0.8387197517870104, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.3378221481083163, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.7554553430899348, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.5341240854552951, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/673/params.json b/scipy/cylinder_piston_ball/673/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ab43c1ffef5187e48c836ab777170b602b235104 --- /dev/null +++ b/scipy/cylinder_piston_ball/673/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.15032418057893876, + "m_p": 1.4414072557923319, + "r_b": 0.14170031957690243, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 0.8387197517870104, + "y_p_bot_0": 2.3378221481083163, + "e_floor": 0.7554553430899348, + "e_bp": 0.5341240854552951, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/673/simulation_code.py b/scipy/cylinder_piston_ball/673/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..91edc63277fd8d8e0d979e9b921c316dd8241315 --- /dev/null +++ b/scipy/cylinder_piston_ball/673/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.15032418057893876 +m_p = 1.4414072557923319 +r_b = 0.14170031957690243 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 0.8387197517870104 +y_p_bot_0= 2.3378221481083163 +e_floor = 0.7554553430899348 +e_bp = 0.5341240854552951 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/673/video.mp4 b/scipy/cylinder_piston_ball/673/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..45c44e4ba7e893fa9be6f5f6438224b8515443b1 --- /dev/null +++ b/scipy/cylinder_piston_ball/673/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b51eaacec80724f0217b80f986089a3cf66fd719e4e896bff085ef7c85dd845d +size 6952 diff --git a/scipy/cylinder_piston_ball/691/cot.json b/scipy/cylinder_piston_ball/691/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f79f896be890242e3719d758a265919228d8100a --- /dev/null +++ b/scipy/cylinder_piston_ball/691/cot.json @@ -0,0 +1,122 @@ +{ + "simulation": "cylinder_piston_ball", + "physical_observation": "Inside a vertical cylinder (inner diameter D=0.600 m, height H=2.500 m, closed bottom) a small ball (m_b=0.192 kg, r_b=0.143 m) starts at y=0.932 m and a piston (m_p=1.244 kg, thickness t_p=0.200 m) starts with its bottom at y=2.231 m. Both released from rest under gravity g=9.800 m/s^2; ball-floor restitution e_floor=0.8300466339247832, ball-piston restitution e_bp=0.611437596200129.", + "physical_law": { + "name": "Newton II in 1D + impulsive Newton restitution at contacts", + "statement": "Between contacts, both bodies free-fall. Floor and ball-piston collisions are instantaneous impulses governed by Newton's restitution law.", + "formula": "Free fall: v_i' = -g. Floor: v_b -> -e_floor v_b. Ball-piston: v_b' = ((m_b-e_bp m_p)v_b + (1+e_bp)m_p v_p)/(m_b+m_p), v_p' = ((m_p-e_bp m_b)v_p + (1+e_bp)m_b v_b)/(m_b+m_p)." + }, + "ode_system": { + "state_variables": [ + "y_b (ball centre y)", + "y_p_bot (piston bottom y)", + "v_b", + "v_p" + ], + "equations_latex": [ + "\\dot{y}_b = v_b; dy_p_bot/dt = v_p; \\dot{v}_b = -g; \\dot{v}_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 \\to v_b \\cdot= -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p \\to apply Newton-restitution formulas above" + ], + "equations_python": [ + "y_dot_b = v_b; dy_p_bot/dt = v_p; v_dot_b = -g; v_dot_p = -g", + "Floor event: y_b - r_b = 0 with v_b<0 -> v_b * = -e_floor", + "Ball-piston event: y_p_bot - y_b - r_b = 0 with v_b>v_p -> apply Newton-restitution formulas above" + ] + }, + "derivation_steps": [ + "Initial heights: ball at 0.932 m, piston bottom at 2.231 m.", + "Free-fall time of ball to floor (no piston): t ~ \\sqrt(2 (y_b_0-r_b)/g) = 0.401 s.", + "Initial gap piston-ball: 1.156 m; piston catches up to ball after t ~ \\sqrt(2 gap/g) = 0.486 s (if ball were stationary).", + "Each ball-floor impact reduces ball |v| by factor (1-e_floor) of the kinetic energy; each ball-piston impact transfers momentum/energy by the 1D Newton-restitution formulas.", + "System eventually settles to ball at rest on floor and piston resting on ball." + ], + "physical_constants_derived": { + "free_fall_to_floor_s": 0.4012378013662612, + "free_fall_to_piston_meet_s_if_ball_stationary": 0.485785804519236, + "expected_final_y_b": 0.14275755287368552, + "expected_final_y_p_bot": 0.28551510574737105 + }, + "numerical_method": { + "solver": "Hybrid free-fall RK45 (scipy.solve_ivp) with three terminal events (ball-floor, ball-piston, piston-floor); analytic impulses at each event.", + "tolerance": "rtol=1e-9, atol=1e-11; max_step=0.02 s.", + "justification": "Velocities have impulsive jumps; analytic event handling avoids near-discontinuous RHS issues." + }, + "code_validation": { + "ode_source": "Newton II + standard 1D restitution formulas (textbook).", + "energy_check": "Each restitution event dissipates a non-negative amount of KE; total energy decreases monotonically.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Ball bounces on the floor several times while piston falls slower than ball-bounces.", + "Eventually piston catches ball, dissipating energy through ball-piston impacts.", + "System settles with ball resting on floor and piston resting on ball." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_b": { + "value": 0.19151420772532507, + "unit": "", + "description": "" + }, + "m_p": { + "value": 1.2439967170997592, + "unit": "", + "description": "" + }, + "r_b": { + "value": 0.14275755287368552, + "unit": "", + "description": "" + }, + "D_cyl": { + "value": 0.6, + "unit": "", + "description": "" + }, + "t_p": { + "value": 0.2, + "unit": "", + "description": "" + }, + "H_cyl": { + "value": 2.5, + "unit": "", + "description": "" + }, + "y_b_0": { + "value": 0.9316172417753187, + "unit": "", + "description": "" + }, + "y_p_bot_0": { + "value": 2.230715249223771, + "unit": "", + "description": "" + }, + "e_floor": { + "value": 0.8300466339247832, + "unit": "", + "description": "" + }, + "e_bp": { + "value": 0.611437596200129, + "unit": "", + "description": "" + }, + "v_b_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "v_p_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/cylinder_piston_ball/691/params.json b/scipy/cylinder_piston_ball/691/params.json new file mode 100644 index 0000000000000000000000000000000000000000..393913b2b36bfaf531d305d443c74102e62da9e7 --- /dev/null +++ b/scipy/cylinder_piston_ball/691/params.json @@ -0,0 +1,15 @@ +{ + "g": 9.8, + "m_b": 0.19151420772532507, + "m_p": 1.2439967170997592, + "r_b": 0.14275755287368552, + "D_cyl": 0.6, + "t_p": 0.2, + "H_cyl": 2.5, + "y_b_0": 0.9316172417753187, + "y_p_bot_0": 2.230715249223771, + "e_floor": 0.8300466339247832, + "e_bp": 0.611437596200129, + "v_b_0": 0.0, + "v_p_0": 0.0 +} \ No newline at end of file diff --git a/scipy/cylinder_piston_ball/691/simulation_code.py b/scipy/cylinder_piston_ball/691/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b86c1e82159d0e1346fba1a1e709b5aaf3efc6e1 --- /dev/null +++ b/scipy/cylinder_piston_ball/691/simulation_code.py @@ -0,0 +1,117 @@ +""" +Cylinder-Piston-Ball — auto-generated. +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +g = 9.8 +m_b = 0.19151420772532507 +m_p = 1.2439967170997592 +r_b = 0.14275755287368552 +D_cyl = 0.6 +t_p = 0.2 +H_cyl = 2.5 +y_b_0 = 0.9316172417753187 +y_p_bot_0= 2.230715249223771 +e_floor = 0.8300466339247832 +e_bp = 0.611437596200129 +v_b_0 = 0.0 +v_p_0 = 0.0 +duration = 12 +fps = 30 + +def free(t, y): return [y[2], y[3], -g, -g] +def ev_floor(t, y): return y[0] - r_b +ev_floor.terminal = True; ev_floor.direction = -1 +def ev_bp(t, y): return y[1] - y[0] - r_b +ev_bp.terminal = True; ev_bp.direction = -1 +def ev_pfloor(t, y): return y[1] +ev_pfloor.terminal = True; ev_pfloor.direction = -1 + +t_eval_g = np.linspace(0.0, duration, int(duration * fps) + 1) +S = np.zeros((4, len(t_eval_g))) +state = np.array([y_b_0, y_p_bot_0, v_b_0, v_p_0], dtype=float) +S[:, 0] = state +last_idx = 1 +t_cur = 0.0 +settle_v_eps = 0.05 +settle_gap_eps = 1e-3 + +for _seg in range(20000): + if t_cur >= duration - 1e-12: break + yb, ypb, vb, vp = state + if (abs(vb) < settle_v_eps and abs(vp) < settle_v_eps + and (ypb - yb - r_b) < settle_gap_eps + and (yb - r_b) < settle_gap_eps): + state = np.array([r_b, 2.0 * r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + sol = solve_ivp(free, (t_cur, duration), state, + events=[ev_floor, ev_bp, ev_pfloor], + dense_output=True, max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval_g) and t_eval_g[last_idx] <= seg_end + 1e-12: + S[:, last_idx] = sol.sol(t_eval_g[last_idx]); last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + t_floor = sol.t_events[0]; t_bp = sol.t_events[1]; t_pf = sol.t_events[2] + times = [] + if len(t_floor) > 0: times.append(("floor", t_floor[-1])) + if len(t_bp) > 0: times.append(("bp", t_bp[-1])) + if len(t_pf) > 0: times.append(("pf", t_pf[-1])) + if not times: break + kind = max(times, key=lambda x: x[1])[0] + if kind == "floor": + state[2] = -e_floor * state[2] + elif kind == "bp": + vb, vp = state[2], state[3] + new_vb = ((m_b - e_bp*m_p)*vb + (1+e_bp)*m_p*vp) / (m_b + m_p) + new_vp = ((m_p - e_bp*m_b)*vp + (1+e_bp)*m_b*vb) / (m_b + m_p) + state[2] = new_vb; state[3] = new_vp + elif kind == "pf": + state = np.array([r_b, 2.0*r_b, 0.0, 0.0]) + while last_idx < len(t_eval_g): + S[:, last_idx] = state; last_idx += 1 + break + +if last_idx < len(t_eval_g): + S[:, last_idx:] = state[:, None] + +yb_arr = S[0]; ypb_arr = S[1] + +fig_w, fig_h = 5, 7 +x_lo = -D_cyl/2.0 - 0.20; x_hi = D_cyl/2.0 + 0.20 +y_lo = -0.20; y_hi = H_cyl + 0.20 +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo, y_lo), x_hi - x_lo, -y_lo, facecolor="#4a4e69", edgecolor="none", alpha=0.8, zorder=0)) +ax.axhline(0.0, color="#adb5bd", lw=2.0, zorder=1) +wall_lw = 4.0 +ax.plot([-D_cyl/2.0, -D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([ D_cyl/2.0, D_cyl/2.0], [0.0, H_cyl], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") +ax.plot([-D_cyl/2.0, D_cyl/2.0], [0.0, 0.0], color="#adb5bd", lw=wall_lw, zorder=2, solid_capstyle="butt") + +piston = patches.Rectangle((-D_cyl/2.0, y_p_bot_0), D_cyl, t_p, facecolor="#8a4f33", edgecolor="white", lw=1.2, zorder=3) +ax.add_patch(piston) +handle_w = 0.12; handle_h = 0.10 +handle = patches.Rectangle((-handle_w/2.0, y_p_bot_0 + t_p), handle_w, handle_h, facecolor="#5a3520", edgecolor="white", lw=1.0, zorder=4) +ax.add_patch(handle) +ball = patches.Circle((0.0, y_b_0), r_b, facecolor="#e63946", edgecolor="white", lw=1.2, zorder=5) +ax.add_patch(ball) + +def update(f): + ypb_f = ypb_arr[f] + piston.set_xy((-D_cyl/2.0, ypb_f)) + handle.set_xy((-handle_w/2.0, ypb_f + t_p)) + ball.set_center((0.0, yb_arr[f])) + return piston, handle, ball + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), interval=1000/fps, blit=True) +ani.save("cylinder_piston_ball.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved cylinder_piston_ball.mp4") diff --git a/scipy/cylinder_piston_ball/691/video.mp4 b/scipy/cylinder_piston_ball/691/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..65bd2d297935ef48b57dc9eaf9958b48d47324fb --- /dev/null +++ b/scipy/cylinder_piston_ball/691/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b1f41c4c19efed4f3d4060867a03611004ffbe7d6546045588dcc5774f7f352 +size 7682 diff --git a/scipy/dangle_stick/134/cot.json b/scipy/dangle_stick/134/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f4cbe82ead6b380ea9085179369969ecee803776 --- /dev/null +++ b/scipy/dangle_stick/134/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=1.138 kg on an extensible spring: stiffness k=1.220 N/m, rest length b_rest=1.524 m) hangs from a pivot. A rigid stick (length L=0.805 m, mass m_2=1.340 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 1.0353 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 3.4902 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 1.0353, + "T_spring_s": 6.0689, + "omega_stick_rad_s": 3.4902, + "T_stick_s": 1.8002 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 1.035 rad/s (T = 6.069 s).", + "Stick oscillates at \\omega_stick = 3.490 rad/s (T = 1.800 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 1.138374415163536, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.3400868421339072, + "unit": "", + "description": "" + }, + "L": { + "value": 0.8045082035081391, + "unit": "m", + "description": "" + }, + "k": { + "value": 1.2202017882744665, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.523963638966737, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.6598504302279949, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.3274167201204226, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": 0.26265430954107805, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/134/params.json b/scipy/dangle_stick/134/params.json new file mode 100644 index 0000000000000000000000000000000000000000..469ba3c7e7be1641a8af2fa259158e9b5b5abd01 --- /dev/null +++ b/scipy/dangle_stick/134/params.json @@ -0,0 +1,14 @@ +{ + "m1": 1.138374415163536, + "m2": 1.3400868421339072, + "L": 0.8045082035081391, + "k": 1.2202017882744665, + "b_rest": 1.523963638966737, + "g": 9.8, + "theta0": -0.6598504302279949, + "theta_dot0": 0.0, + "r0": 1.3274167201204226, + "r_dot0": 0.0, + "phi0": 0.26265430954107805, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/134/simulation_code.py b/scipy/dangle_stick/134/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f46ea0e7df92e0b343b86fd1a221df26174b9ab6 --- /dev/null +++ b/scipy/dangle_stick/134/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=1.138374415163536 kg, m2=1.3400868421339072 kg, L=0.8045082035081391 m, k=1.2202017882744665 N/m + b_rest=1.523963638966737 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 1.138374415163536, 1.3400868421339072, 0.8045082035081391, 1.2202017882744665, 1.523963638966737 +g = 9.8 +theta0, theta_dot0 = -0.659850, 0.000000 +r0, r_dot0 = 1.327417, 0.000000 +phi0, phi_dot0 = 0.262654, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/134/video.mp4 b/scipy/dangle_stick/134/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b708185559d7abefd22ee07b386f8a66b21f2386 --- /dev/null +++ b/scipy/dangle_stick/134/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad87e882b76f1817237c125f852fee1625db53d4ebc2822d965106edfbbe8594 +size 8588 diff --git a/scipy/dangle_stick/209/cot.json b/scipy/dangle_stick/209/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..5f50f2d6d6de334c2a7580e2199a37b1f65a6050 --- /dev/null +++ b/scipy/dangle_stick/209/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.675 kg on an extensible spring: stiffness k=2.795 N/m, rest length b_rest=1.767 m) hangs from a pivot. A rigid stick (length L=1.099 m, mass m_2=0.972 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 2.0355 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 2.9862 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 2.0355, + "T_spring_s": 3.0868, + "omega_stick_rad_s": 2.9862, + "T_stick_s": 2.1041 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 2.036 rad/s (T = 3.087 s).", + "Stick oscillates at \\omega_stick = 2.986 rad/s (T = 2.104 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.6746518056780625, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.972342771311751, + "unit": "", + "description": "" + }, + "L": { + "value": 1.09896529630644, + "unit": "m", + "description": "" + }, + "k": { + "value": 2.795303522076488, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.7667355758941172, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.09342777024039184, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.0614285398724062, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.4675709223303106, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/209/params.json b/scipy/dangle_stick/209/params.json new file mode 100644 index 0000000000000000000000000000000000000000..df03e6a0b3549b7736c87aa7f19218e11c6454ec --- /dev/null +++ b/scipy/dangle_stick/209/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.6746518056780625, + "m2": 0.972342771311751, + "L": 1.09896529630644, + "k": 2.795303522076488, + "b_rest": 1.7667355758941172, + "g": 9.8, + "theta0": -0.09342777024039184, + "theta_dot0": 0.0, + "r0": 1.0614285398724062, + "r_dot0": 0.0, + "phi0": -0.4675709223303106, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/209/simulation_code.py b/scipy/dangle_stick/209/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..af5c870dc1ea826542281b6ec4623ca4115cfb76 --- /dev/null +++ b/scipy/dangle_stick/209/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.6746518056780625 kg, m2=0.972342771311751 kg, L=1.09896529630644 m, k=2.795303522076488 N/m + b_rest=1.7667355758941172 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.6746518056780625, 0.972342771311751, 1.09896529630644, 2.795303522076488, 1.7667355758941172 +g = 9.8 +theta0, theta_dot0 = -0.093428, 0.000000 +r0, r_dot0 = 1.061429, 0.000000 +phi0, phi_dot0 = -0.467571, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/209/video.mp4 b/scipy/dangle_stick/209/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..856a7c18d932d52fbe86647210d8b720498138a9 --- /dev/null +++ b/scipy/dangle_stick/209/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f91668d59d626c860780428131f4c2b434c2fae29427c5e789624457e9ac38e0 +size 12327 diff --git a/scipy/dangle_stick/244/cot.json b/scipy/dangle_stick/244/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f08129a00a682c5ade347e99280b975b58f9fcd7 --- /dev/null +++ b/scipy/dangle_stick/244/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=1.391 kg on an extensible spring: stiffness k=3.544 N/m, rest length b_rest=1.493 m) hangs from a pivot. A rigid stick (length L=0.993 m, mass m_2=0.633 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 1.5962 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 3.1417 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 1.5962, + "T_spring_s": 3.9364, + "omega_stick_rad_s": 3.1417, + "T_stick_s": 1.9999 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 1.596 rad/s (T = 3.936 s).", + "Stick oscillates at \\omega_stick = 3.142 rad/s (T = 2.000 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 1.3909122641668297, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.6331204600510727, + "unit": "", + "description": "" + }, + "L": { + "value": 0.9928576504336878, + "unit": "m", + "description": "" + }, + "k": { + "value": 3.543768070099262, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.4929395699739856, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.12136966970120056, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.4693865300481224, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.5953304708164894, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/244/params.json b/scipy/dangle_stick/244/params.json new file mode 100644 index 0000000000000000000000000000000000000000..820d3f41b817d8da607cc46ab1230f338d5c1078 --- /dev/null +++ b/scipy/dangle_stick/244/params.json @@ -0,0 +1,14 @@ +{ + "m1": 1.3909122641668297, + "m2": 0.6331204600510727, + "L": 0.9928576504336878, + "k": 3.543768070099262, + "b_rest": 1.4929395699739856, + "g": 9.8, + "theta0": -0.12136966970120056, + "theta_dot0": 0.0, + "r0": 1.4693865300481224, + "r_dot0": 0.0, + "phi0": -0.5953304708164894, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/244/simulation_code.py b/scipy/dangle_stick/244/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ef41e2a5c3127ac426eb4d9608e6963a932a4d54 --- /dev/null +++ b/scipy/dangle_stick/244/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=1.3909122641668297 kg, m2=0.6331204600510727 kg, L=0.9928576504336878 m, k=3.543768070099262 N/m + b_rest=1.4929395699739856 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 1.3909122641668297, 0.6331204600510727, 0.9928576504336878, 3.543768070099262, 1.4929395699739856 +g = 9.8 +theta0, theta_dot0 = -0.121370, 0.000000 +r0, r_dot0 = 1.469387, 0.000000 +phi0, phi_dot0 = -0.595330, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/244/video.mp4 b/scipy/dangle_stick/244/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..8e635dd167b88842b5032ed5d5fbe5d01e73353e --- /dev/null +++ b/scipy/dangle_stick/244/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68e6814b47db95fc45a6ddae83ceac62bea67abbb49901a3ecdc0c5eae87f232 +size 13123 diff --git a/scipy/dangle_stick/267/cot.json b/scipy/dangle_stick/267/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f61db6e051bdc4570e360be7ccec5d214de0cc24 --- /dev/null +++ b/scipy/dangle_stick/267/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.470 kg on an extensible spring: stiffness k=6.608 N/m, rest length b_rest=1.181 m) hangs from a pivot. A rigid stick (length L=1.187 m, mass m_2=0.930 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 3.7487 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 2.8728 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 3.7487, + "T_spring_s": 1.6761, + "omega_stick_rad_s": 2.8728, + "T_stick_s": 2.1871 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 3.749 rad/s (T = 1.676 s).", + "Stick oscillates at \\omega_stick = 2.873 rad/s (T = 2.187 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.47022896145461557, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.9302282546546388, + "unit": "", + "description": "" + }, + "L": { + "value": 1.1874582158652918, + "unit": "m", + "description": "" + }, + "k": { + "value": 6.60817674556164, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.1812589731610117, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.22322308848979644, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.0466047881044183, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.1416697550396792, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/267/params.json b/scipy/dangle_stick/267/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5352eed69ba2facc3e39489ce3a02c4a1831c810 --- /dev/null +++ b/scipy/dangle_stick/267/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.47022896145461557, + "m2": 0.9302282546546388, + "L": 1.1874582158652918, + "k": 6.60817674556164, + "b_rest": 1.1812589731610117, + "g": 9.8, + "theta0": -0.22322308848979644, + "theta_dot0": 0.0, + "r0": 1.0466047881044183, + "r_dot0": 0.0, + "phi0": -0.1416697550396792, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/267/simulation_code.py b/scipy/dangle_stick/267/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b8efc4bf7432500bb602fbe669b71e604b5f456e --- /dev/null +++ b/scipy/dangle_stick/267/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.47022896145461557 kg, m2=0.9302282546546388 kg, L=1.1874582158652918 m, k=6.60817674556164 N/m + b_rest=1.1812589731610117 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.47022896145461557, 0.9302282546546388, 1.1874582158652918, 6.60817674556164, 1.1812589731610117 +g = 9.8 +theta0, theta_dot0 = -0.223223, 0.000000 +r0, r_dot0 = 1.046605, 0.000000 +phi0, phi_dot0 = -0.141670, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/267/video.mp4 b/scipy/dangle_stick/267/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ce0e014f3b2ec564157737d6aca2db2659cb5dde --- /dev/null +++ b/scipy/dangle_stick/267/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5fdbb376416cdaa77c1919d701d0a811885bc987264662a096a6839cf2a83de5 +size 16178 diff --git a/scipy/dangle_stick/271/cot.json b/scipy/dangle_stick/271/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..24bca2c8e211c618d6b611864700749849097821 --- /dev/null +++ b/scipy/dangle_stick/271/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=1.476 kg on an extensible spring: stiffness k=6.456 N/m, rest length b_rest=0.933 m) hangs from a pivot. A rigid stick (length L=0.740 m, mass m_2=1.412 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 2.0911 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 3.6394 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 2.0911, + "T_spring_s": 3.0047, + "omega_stick_rad_s": 3.6394, + "T_stick_s": 1.7265 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 2.091 rad/s (T = 3.005 s).", + "Stick oscillates at \\omega_stick = 3.639 rad/s (T = 1.726 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 1.4764663523533834, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.4121809983571212, + "unit": "", + "description": "" + }, + "L": { + "value": 0.7399068447349282, + "unit": "m", + "description": "" + }, + "k": { + "value": 6.4563448242306665, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 0.9326511378432993, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.1290607104992938, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.5906725610444394, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.578985690112945, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/271/params.json b/scipy/dangle_stick/271/params.json new file mode 100644 index 0000000000000000000000000000000000000000..cd4b49e8474d2349b9ed62ab462f5ec9e7fcbb3c --- /dev/null +++ b/scipy/dangle_stick/271/params.json @@ -0,0 +1,14 @@ +{ + "m1": 1.4764663523533834, + "m2": 1.4121809983571212, + "L": 0.7399068447349282, + "k": 6.4563448242306665, + "b_rest": 0.9326511378432993, + "g": 9.8, + "theta0": -0.1290607104992938, + "theta_dot0": 0.0, + "r0": 1.5906725610444394, + "r_dot0": 0.0, + "phi0": -0.578985690112945, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/271/simulation_code.py b/scipy/dangle_stick/271/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ca0981f60d15d6fc7334af91d2d4b996f3fddbb0 --- /dev/null +++ b/scipy/dangle_stick/271/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=1.4764663523533834 kg, m2=1.4121809983571212 kg, L=0.7399068447349282 m, k=6.4563448242306665 N/m + b_rest=0.9326511378432993 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 1.4764663523533834, 1.4121809983571212, 0.7399068447349282, 6.4563448242306665, 0.9326511378432993 +g = 9.8 +theta0, theta_dot0 = -0.129061, 0.000000 +r0, r_dot0 = 1.590673, 0.000000 +phi0, phi_dot0 = -0.578986, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/271/video.mp4 b/scipy/dangle_stick/271/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9cddd971c4e275c256004b8c7fc463add052d3b2 --- /dev/null +++ b/scipy/dangle_stick/271/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b5fe45c7891cb9cc1b0b5261323520a8de7a069719e6f76ab00cca2a2fff5cc5 +size 15629 diff --git a/scipy/dangle_stick/307/cot.json b/scipy/dangle_stick/307/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4450e89d7f3c1695ca84e48bcc0a6125daa501e6 --- /dev/null +++ b/scipy/dangle_stick/307/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=1.250 kg on an extensible spring: stiffness k=4.845 N/m, rest length b_rest=1.711 m) hangs from a pivot. A rigid stick (length L=0.576 m, mass m_2=1.249 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 1.9685 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 4.1239 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 1.9685, + "T_spring_s": 3.1919, + "omega_stick_rad_s": 4.1239, + "T_stick_s": 1.5236 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 1.968 rad/s (T = 3.192 s).", + "Stick oscillates at \\omega_stick = 4.124 rad/s (T = 1.524 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 1.2503921797781405, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.2492344816099932, + "unit": "", + "description": "" + }, + "L": { + "value": 0.576242919902647, + "unit": "m", + "description": "" + }, + "k": { + "value": 4.845240304085287, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.7112722877666828, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": 0.36982159098764034, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.1648982901859202, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.1365651330877855, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/307/params.json b/scipy/dangle_stick/307/params.json new file mode 100644 index 0000000000000000000000000000000000000000..0dbb62461fac49d72cd02fe46707bec8bf142f09 --- /dev/null +++ b/scipy/dangle_stick/307/params.json @@ -0,0 +1,14 @@ +{ + "m1": 1.2503921797781405, + "m2": 1.2492344816099932, + "L": 0.576242919902647, + "k": 4.845240304085287, + "b_rest": 1.7112722877666828, + "g": 9.8, + "theta0": 0.36982159098764034, + "theta_dot0": 0.0, + "r0": 1.1648982901859202, + "r_dot0": 0.0, + "phi0": -0.1365651330877855, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/307/simulation_code.py b/scipy/dangle_stick/307/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3a11a73d83b0748e422e2644b4c5be391c7954a9 --- /dev/null +++ b/scipy/dangle_stick/307/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=1.2503921797781405 kg, m2=1.2492344816099932 kg, L=0.576242919902647 m, k=4.845240304085287 N/m + b_rest=1.7112722877666828 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 1.2503921797781405, 1.2492344816099932, 0.576242919902647, 4.845240304085287, 1.7112722877666828 +g = 9.8 +theta0, theta_dot0 = 0.369822, 0.000000 +r0, r_dot0 = 1.164898, 0.000000 +phi0, phi_dot0 = -0.136565, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/307/video.mp4 b/scipy/dangle_stick/307/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c4e8b5f9cec72feb5a9dc7e2f36fd9013cf87bfa --- /dev/null +++ b/scipy/dangle_stick/307/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c3a533a3f995d6eb7a58fdeccc1df8f6808189cdcb942815d51e1d1f6f553df +size 12256 diff --git a/scipy/dangle_stick/321/cot.json b/scipy/dangle_stick/321/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..50ead6ff58eeef56cf30dd4d319958eb0a4ed590 --- /dev/null +++ b/scipy/dangle_stick/321/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.408 kg on an extensible spring: stiffness k=1.434 N/m, rest length b_rest=1.820 m) hangs from a pivot. A rigid stick (length L=1.272 m, mass m_2=1.467 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 1.8758 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 2.7752 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 1.8758, + "T_spring_s": 3.3495, + "omega_stick_rad_s": 2.7752, + "T_stick_s": 2.264 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 1.876 rad/s (T = 3.350 s).", + "Stick oscillates at \\omega_stick = 2.775 rad/s (T = 2.264 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.4076508390124798, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.46737450427847, + "unit": "", + "description": "" + }, + "L": { + "value": 1.2724337959852687, + "unit": "m", + "description": "" + }, + "k": { + "value": 1.4344285998128927, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.8198860922992979, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.31625134583720294, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.7281193534186339, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.2094099812680567, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/321/params.json b/scipy/dangle_stick/321/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e8e137cc1ac4ea0673e95d07454cb3e7cda51107 --- /dev/null +++ b/scipy/dangle_stick/321/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.4076508390124798, + "m2": 1.46737450427847, + "L": 1.2724337959852687, + "k": 1.4344285998128927, + "b_rest": 1.8198860922992979, + "g": 9.8, + "theta0": -0.31625134583720294, + "theta_dot0": 0.0, + "r0": 1.7281193534186339, + "r_dot0": 0.0, + "phi0": -0.2094099812680567, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/321/simulation_code.py b/scipy/dangle_stick/321/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..1b48747ab83764825151567d4963ce488cdb80c0 --- /dev/null +++ b/scipy/dangle_stick/321/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.4076508390124798 kg, m2=1.46737450427847 kg, L=1.2724337959852687 m, k=1.4344285998128927 N/m + b_rest=1.8198860922992979 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.4076508390124798, 1.46737450427847, 1.2724337959852687, 1.4344285998128927, 1.8198860922992979 +g = 9.8 +theta0, theta_dot0 = -0.316251, 0.000000 +r0, r_dot0 = 1.728119, 0.000000 +phi0, phi_dot0 = -0.209410, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/321/video.mp4 b/scipy/dangle_stick/321/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..03382f90e7bd2d178ec9dedc8df59014642b5f49 --- /dev/null +++ b/scipy/dangle_stick/321/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5533b5afed05f2547cb98c0718a06a5a2031fe9a130b54e72cef6e6010a9f450 +size 9194 diff --git a/scipy/dangle_stick/323/cot.json b/scipy/dangle_stick/323/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..396f6e36d73e6f3e432de4a9acb31c29e9815fad --- /dev/null +++ b/scipy/dangle_stick/323/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.755 kg on an extensible spring: stiffness k=2.034 N/m, rest length b_rest=1.518 m) hangs from a pivot. A rigid stick (length L=0.593 m, mass m_2=1.475 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 1.6411 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 4.0648 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 1.6411, + "T_spring_s": 3.8287, + "omega_stick_rad_s": 4.0648, + "T_stick_s": 1.5457 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 1.641 rad/s (T = 3.829 s).", + "Stick oscillates at \\omega_stick = 4.065 rad/s (T = 1.546 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.7552382910663717, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.4750866872322477, + "unit": "", + "description": "" + }, + "L": { + "value": 0.5931191186946234, + "unit": "m", + "description": "" + }, + "k": { + "value": 2.0339288914156812, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.517749370204287, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.058923129209103586, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.222707655564577, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": 0.14346577614144218, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/323/params.json b/scipy/dangle_stick/323/params.json new file mode 100644 index 0000000000000000000000000000000000000000..2e63a7066cb560e38b87c333e582ab364e2ff7e3 --- /dev/null +++ b/scipy/dangle_stick/323/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.7552382910663717, + "m2": 1.4750866872322477, + "L": 0.5931191186946234, + "k": 2.0339288914156812, + "b_rest": 1.517749370204287, + "g": 9.8, + "theta0": -0.058923129209103586, + "theta_dot0": 0.0, + "r0": 1.222707655564577, + "r_dot0": 0.0, + "phi0": 0.14346577614144218, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/323/simulation_code.py b/scipy/dangle_stick/323/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..812100d9fc5942849840946374ed39698befda32 --- /dev/null +++ b/scipy/dangle_stick/323/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.7552382910663717 kg, m2=1.4750866872322477 kg, L=0.5931191186946234 m, k=2.0339288914156812 N/m + b_rest=1.517749370204287 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.7552382910663717, 1.4750866872322477, 0.5931191186946234, 2.0339288914156812, 1.517749370204287 +g = 9.8 +theta0, theta_dot0 = -0.058923, 0.000000 +r0, r_dot0 = 1.222708, 0.000000 +phi0, phi_dot0 = 0.143466, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/323/video.mp4 b/scipy/dangle_stick/323/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..fdae9b2c0f66f4a36038007135ead2e4dd3d4f19 --- /dev/null +++ b/scipy/dangle_stick/323/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5d6b0c17897a195be41b9219db586c3448c8f3f17927d3c9711c5d6acd87464 +size 9267 diff --git a/scipy/dangle_stick/405/cot.json b/scipy/dangle_stick/405/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..02a44dedc00125b8b25377a4697589ce8b23c07d --- /dev/null +++ b/scipy/dangle_stick/405/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.336 kg on an extensible spring: stiffness k=6.515 N/m, rest length b_rest=1.583 m) hangs from a pivot. A rigid stick (length L=1.324 m, mass m_2=1.110 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 4.4061 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 2.7211 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 4.4061, + "T_spring_s": 1.426, + "omega_stick_rad_s": 2.7211, + "T_stick_s": 2.309 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 4.406 rad/s (T = 1.426 s).", + "Stick oscillates at \\omega_stick = 2.721 rad/s (T = 2.309 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.33556348800155394, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.1096575123288666, + "unit": "", + "description": "" + }, + "L": { + "value": 1.3235020156672381, + "unit": "m", + "description": "" + }, + "k": { + "value": 6.5146597561063935, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.5833850682064008, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.494917544561482, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.1481841635373855, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": 0.22068048122865858, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/405/params.json b/scipy/dangle_stick/405/params.json new file mode 100644 index 0000000000000000000000000000000000000000..0e66fd141a8d767fdad9db0ba1d6a338c42d46de --- /dev/null +++ b/scipy/dangle_stick/405/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.33556348800155394, + "m2": 1.1096575123288666, + "L": 1.3235020156672381, + "k": 6.5146597561063935, + "b_rest": 1.5833850682064008, + "g": 9.8, + "theta0": -0.494917544561482, + "theta_dot0": 0.0, + "r0": 1.1481841635373855, + "r_dot0": 0.0, + "phi0": 0.22068048122865858, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/405/simulation_code.py b/scipy/dangle_stick/405/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..181727919bf43dc41fea6508fadfb67dc056c3dc --- /dev/null +++ b/scipy/dangle_stick/405/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.33556348800155394 kg, m2=1.1096575123288666 kg, L=1.3235020156672381 m, k=6.5146597561063935 N/m + b_rest=1.5833850682064008 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.33556348800155394, 1.1096575123288666, 1.3235020156672381, 6.5146597561063935, 1.5833850682064008 +g = 9.8 +theta0, theta_dot0 = -0.494918, 0.000000 +r0, r_dot0 = 1.148184, 0.000000 +phi0, phi_dot0 = 0.220680, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/405/video.mp4 b/scipy/dangle_stick/405/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9bd6f6369097f8161e6c9a49600ecb9f1c8a4634 --- /dev/null +++ b/scipy/dangle_stick/405/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d68944b8cc7db57357c2759214cf217d99d153df8e0e5e77bc9705af0277bbc3 +size 18208 diff --git a/scipy/dangle_stick/468/cot.json b/scipy/dangle_stick/468/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f46091544d9b18c4708da7acff2c3dd8185afb95 --- /dev/null +++ b/scipy/dangle_stick/468/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.968 kg on an extensible spring: stiffness k=2.793 N/m, rest length b_rest=1.479 m) hangs from a pivot. A rigid stick (length L=0.965 m, mass m_2=1.161 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 1.6986 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 3.1874 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 1.6986, + "T_spring_s": 3.6991, + "omega_stick_rad_s": 3.1874, + "T_stick_s": 1.9712 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 1.699 rad/s (T = 3.699 s).", + "Stick oscillates at \\omega_stick = 3.187 rad/s (T = 1.971 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.9679730760696847, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.1606802406059558, + "unit": "", + "description": "" + }, + "L": { + "value": 0.9645868148368052, + "unit": "m", + "description": "" + }, + "k": { + "value": 2.7927159097652945, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.47903592581793, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.7274810259619651, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.0297883249036088, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.3354132420146863, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/468/params.json b/scipy/dangle_stick/468/params.json new file mode 100644 index 0000000000000000000000000000000000000000..02841ada8b7ff1b2584254bd7e9d58e044704e4b --- /dev/null +++ b/scipy/dangle_stick/468/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.9679730760696847, + "m2": 1.1606802406059558, + "L": 0.9645868148368052, + "k": 2.7927159097652945, + "b_rest": 1.47903592581793, + "g": 9.8, + "theta0": -0.7274810259619651, + "theta_dot0": 0.0, + "r0": 1.0297883249036088, + "r_dot0": 0.0, + "phi0": -0.3354132420146863, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/468/simulation_code.py b/scipy/dangle_stick/468/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4d96c385a7a5d2eadd757e936f9f0da38e00066e --- /dev/null +++ b/scipy/dangle_stick/468/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.9679730760696847 kg, m2=1.1606802406059558 kg, L=0.9645868148368052 m, k=2.7927159097652945 N/m + b_rest=1.47903592581793 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.9679730760696847, 1.1606802406059558, 0.9645868148368052, 2.7927159097652945, 1.47903592581793 +g = 9.8 +theta0, theta_dot0 = -0.727481, 0.000000 +r0, r_dot0 = 1.029788, 0.000000 +phi0, phi_dot0 = -0.335413, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/468/video.mp4 b/scipy/dangle_stick/468/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..dd6a0c060c32cc364c4d2e3454f7282c91a05036 --- /dev/null +++ b/scipy/dangle_stick/468/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba8e1f2856059be4f0978762c970bd9fbe5cd546f100bc66fa5b942ab8a92a21 +size 12226 diff --git a/scipy/dangle_stick/535/cot.json b/scipy/dangle_stick/535/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f0f88d4e2b72dd313c9bc7d960cc4780b1718227 --- /dev/null +++ b/scipy/dangle_stick/535/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=1.006 kg on an extensible spring: stiffness k=6.694 N/m, rest length b_rest=1.487 m) hangs from a pivot. A rigid stick (length L=0.727 m, mass m_2=0.759 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 2.5791 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 3.6724 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 2.5791, + "T_spring_s": 2.4362, + "omega_stick_rad_s": 3.6724, + "T_stick_s": 1.7109 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 2.579 rad/s (T = 2.436 s).", + "Stick oscillates at \\omega_stick = 3.672 rad/s (T = 1.711 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 1.0063682663489242, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7591040255652892, + "unit": "", + "description": "" + }, + "L": { + "value": 0.7266332992941205, + "unit": "m", + "description": "" + }, + "k": { + "value": 6.6940520511662305, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.4865406419750546, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.44198764027162735, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.4199200706394581, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.13541993576142075, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/535/params.json b/scipy/dangle_stick/535/params.json new file mode 100644 index 0000000000000000000000000000000000000000..bd44e3103623a8d48b682899126d428d70aae7d9 --- /dev/null +++ b/scipy/dangle_stick/535/params.json @@ -0,0 +1,14 @@ +{ + "m1": 1.0063682663489242, + "m2": 0.7591040255652892, + "L": 0.7266332992941205, + "k": 6.6940520511662305, + "b_rest": 1.4865406419750546, + "g": 9.8, + "theta0": -0.44198764027162735, + "theta_dot0": 0.0, + "r0": 1.4199200706394581, + "r_dot0": 0.0, + "phi0": -0.13541993576142075, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/535/simulation_code.py b/scipy/dangle_stick/535/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f2694f18f924349ef2ecb94e0beffe09b1a38ceb --- /dev/null +++ b/scipy/dangle_stick/535/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=1.0063682663489242 kg, m2=0.7591040255652892 kg, L=0.7266332992941205 m, k=6.6940520511662305 N/m + b_rest=1.4865406419750546 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 1.0063682663489242, 0.7591040255652892, 0.7266332992941205, 6.6940520511662305, 1.4865406419750546 +g = 9.8 +theta0, theta_dot0 = -0.441988, 0.000000 +r0, r_dot0 = 1.419920, 0.000000 +phi0, phi_dot0 = -0.135420, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/535/video.mp4 b/scipy/dangle_stick/535/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..0c2463bd7c9f8e19872ecc529e913ce40dbbea09 --- /dev/null +++ b/scipy/dangle_stick/535/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4b14afd70992f779e00a722b98036bc3287e9e8f6cb61ac265e362e8fe6cb77 +size 15047 diff --git a/scipy/dangle_stick/660/cot.json b/scipy/dangle_stick/660/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f48e259e685d7c8cd00dd71fa877e767a4780c2e --- /dev/null +++ b/scipy/dangle_stick/660/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.326 kg on an extensible spring: stiffness k=3.597 N/m, rest length b_rest=1.136 m) hangs from a pivot. A rigid stick (length L=1.472 m, mass m_2=0.366 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 3.3228 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 2.5805 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 3.3228, + "T_spring_s": 1.8909, + "omega_stick_rad_s": 2.5805, + "T_stick_s": 2.4349 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 3.323 rad/s (T = 1.891 s).", + "Stick oscillates at \\omega_stick = 2.580 rad/s (T = 2.435 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.325762685165651, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.3657527757404244, + "unit": "", + "description": "" + }, + "L": { + "value": 1.4717402699839313, + "unit": "m", + "description": "" + }, + "k": { + "value": 3.5967873786203484, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.1363504428126194, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.313973768688412, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.4111078578855345, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": 0.22567103504236785, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/660/params.json b/scipy/dangle_stick/660/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5d380ded2b5a61b091935f327adeb2935076beab --- /dev/null +++ b/scipy/dangle_stick/660/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.325762685165651, + "m2": 0.3657527757404244, + "L": 1.4717402699839313, + "k": 3.5967873786203484, + "b_rest": 1.1363504428126194, + "g": 9.8, + "theta0": -0.313973768688412, + "theta_dot0": 0.0, + "r0": 1.4111078578855345, + "r_dot0": 0.0, + "phi0": 0.22567103504236785, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/660/simulation_code.py b/scipy/dangle_stick/660/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..51da444969c1755cf2686ecc09daba43227b6c33 --- /dev/null +++ b/scipy/dangle_stick/660/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.325762685165651 kg, m2=0.3657527757404244 kg, L=1.4717402699839313 m, k=3.5967873786203484 N/m + b_rest=1.1363504428126194 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.325762685165651, 0.3657527757404244, 1.4717402699839313, 3.5967873786203484, 1.1363504428126194 +g = 9.8 +theta0, theta_dot0 = -0.313974, 0.000000 +r0, r_dot0 = 1.411108, 0.000000 +phi0, phi_dot0 = 0.225671, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/660/video.mp4 b/scipy/dangle_stick/660/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2329873170949fcefa0173b6e9484b3f6dd1479c --- /dev/null +++ b/scipy/dangle_stick/660/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33a580a5dce0d649729173a61fbc53e21d1fd11d67ac7ff71712fe25ec0b6f84 +size 16832 diff --git a/scipy/dangle_stick/685/cot.json b/scipy/dangle_stick/685/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..326fd4299cfe8a3efd7c9b2760969881489a625b --- /dev/null +++ b/scipy/dangle_stick/685/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.852 kg on an extensible spring: stiffness k=6.069 N/m, rest length b_rest=1.894 m) hangs from a pivot. A rigid stick (length L=0.872 m, mass m_2=1.332 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 2.6692 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 3.3531 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 2.6692, + "T_spring_s": 2.3539, + "omega_stick_rad_s": 3.3531, + "T_stick_s": 1.8738 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 2.669 rad/s (T = 2.354 s).", + "Stick oscillates at \\omega_stick = 3.353 rad/s (T = 1.874 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.8518464236510386, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.332474196652053, + "unit": "", + "description": "" + }, + "L": { + "value": 0.8716199749365651, + "unit": "m", + "description": "" + }, + "k": { + "value": 6.069198255412589, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.8943776454387402, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": 0.42125911443944974, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.5589859318501156, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": 0.01336675438262891, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/685/params.json b/scipy/dangle_stick/685/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a004317854f81ab296aced90a37e000c187d6c37 --- /dev/null +++ b/scipy/dangle_stick/685/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.8518464236510386, + "m2": 1.332474196652053, + "L": 0.8716199749365651, + "k": 6.069198255412589, + "b_rest": 1.8943776454387402, + "g": 9.8, + "theta0": 0.42125911443944974, + "theta_dot0": 0.0, + "r0": 1.5589859318501156, + "r_dot0": 0.0, + "phi0": 0.01336675438262891, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/685/simulation_code.py b/scipy/dangle_stick/685/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3d2903125d7506dbf13cdf33e965a62a6f1e5c54 --- /dev/null +++ b/scipy/dangle_stick/685/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.8518464236510386 kg, m2=1.332474196652053 kg, L=0.8716199749365651 m, k=6.069198255412589 N/m + b_rest=1.8943776454387402 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.8518464236510386, 1.332474196652053, 0.8716199749365651, 6.069198255412589, 1.8943776454387402 +g = 9.8 +theta0, theta_dot0 = 0.421259, 0.000000 +r0, r_dot0 = 1.558986, 0.000000 +phi0, phi_dot0 = 0.013367, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/685/video.mp4 b/scipy/dangle_stick/685/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d69b1dda4b295cb2ccbc8abc92573a5c8dc18bf2 --- /dev/null +++ b/scipy/dangle_stick/685/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43e9ac11026c295959aef1b3eb335d1531129614c751936011e160cb0adc39ed +size 14053 diff --git a/scipy/dangle_stick/687/cot.json b/scipy/dangle_stick/687/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..01a7c5ba582573c8581569ec06477da38a0ebdfc --- /dev/null +++ b/scipy/dangle_stick/687/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.922 kg on an extensible spring: stiffness k=1.591 N/m, rest length b_rest=1.095 m) hangs from a pivot. A rigid stick (length L=1.101 m, mass m_2=0.584 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 1.3136 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 2.9841 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 1.3136, + "T_spring_s": 4.7831, + "omega_stick_rad_s": 2.9841, + "T_stick_s": 2.1056 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 1.314 rad/s (T = 4.783 s).", + "Stick oscillates at \\omega_stick = 2.984 rad/s (T = 2.106 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.9221731356365224, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.5844736142440096, + "unit": "", + "description": "" + }, + "L": { + "value": 1.100538682876955, + "unit": "m", + "description": "" + }, + "k": { + "value": 1.5912912247630722, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 1.095265429531631, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": -0.13725236988571154, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 1.0304159864767577, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": -0.5366331567192569, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/687/params.json b/scipy/dangle_stick/687/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f4256cd9c7fe36a7e5c3f57bd74b5f7d508796fc --- /dev/null +++ b/scipy/dangle_stick/687/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.9221731356365224, + "m2": 0.5844736142440096, + "L": 1.100538682876955, + "k": 1.5912912247630722, + "b_rest": 1.095265429531631, + "g": 9.8, + "theta0": -0.13725236988571154, + "theta_dot0": 0.0, + "r0": 1.0304159864767577, + "r_dot0": 0.0, + "phi0": -0.5366331567192569, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/687/simulation_code.py b/scipy/dangle_stick/687/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..8fb512adc5d09bfc5de455ba0cc4aeed94ca647a --- /dev/null +++ b/scipy/dangle_stick/687/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.9221731356365224 kg, m2=0.5844736142440096 kg, L=1.100538682876955 m, k=1.5912912247630722 N/m + b_rest=1.095265429531631 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.9221731356365224, 0.5844736142440096, 1.100538682876955, 1.5912912247630722, 1.095265429531631 +g = 9.8 +theta0, theta_dot0 = -0.137252, 0.000000 +r0, r_dot0 = 1.030416, 0.000000 +phi0, phi_dot0 = -0.536633, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/687/video.mp4 b/scipy/dangle_stick/687/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..280a5318d34f585d9006cbbe744064f93e8b0e7c --- /dev/null +++ b/scipy/dangle_stick/687/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f420cc32f6422a0551ba64666dbcb63b40b59969844e8577a031cd0eb7755e93 +size 11164 diff --git a/scipy/dangle_stick/733/cot.json b/scipy/dangle_stick/733/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..852b0f068f93a5c11d5bf44c25e967b8ab28fc5b --- /dev/null +++ b/scipy/dangle_stick/733/cot.json @@ -0,0 +1,131 @@ +{ + "simulation": "dangle_stick", + "physical_observation": "A spring-pendulum (mass m_1=0.878 kg on an extensible spring: stiffness k=5.033 N/m, rest length b_rest=0.978 m) hangs from a pivot. A rigid stick (length L=1.110 m, mass m_2=0.704 kg) is pin-jointed to mass m_1, free to rotate at a separate angle \\phi. This 6-DOF Lagrangian system shows coupled spring-pendulum and stick oscillations.", + "physical_law": { + "name": "Lagrangian Mechanics for Coupled Spring-Pendulum + Rigid Stick", + "statement": "Three generalized coordinates: spring angle \\theta, spring length r, stick angle \\phi. Euler-Lagrange applied to each.", + "formula": "V = \\tfrac{1}{2} k(r-b_rest)^2 - m_1gr \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi))\nT = \\tfrac{1}{2} m_1(\\dot{r}^2+r^2\\dot{\\theta}^2) + \\tfrac{1}{2} m_2|v_CM2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2" + }, + "ode_system": { + "state_variables": [ + "\\theta (spring angle, rad)", + "\\dot{\\theta}", + "r (spring length, m)", + "\\dot{r}", + "\\phi (stick angle, rad)", + "\\dot{\\phi}" + ], + "equations_latex": [ + "\\dot{\\theta} = \\dot{\\theta}", + "\\ddot{\\theta} = (-2m_1r\\dot{r}\\dot{\\theta} - 2m_2r\\dot{r}\\dot{\\theta} - (m_1+m_2)g \\cdot r \\cdot \\sin(\\theta) - m_2gL/2 \\cdot \\sin(\\phi) \\cdot \\partial \\phi/ \\partial \\theta) / ((m_1+m_2)r^2)", + "\\dot{r} = \\dot{r}", + "\\ddot{r} = r \\cdot \\dot{\\theta}^2 - g \\cdot \\cos(\\theta) - k(r-b_rest)/m_1 [simplified decoupled form]", + "\\dot{\\phi} = \\dot{\\phi}", + "\\ddot{\\phi} = -(3g/(2L)) \\cdot \\sin(\\phi) [stick about pivot, simplified]" + ], + "equations_python": [ + "theta_dot = theta_dot", + "theta_ddot = (-2 * m_1 * r * r_dot * theta_dot - 2 * m_2 * r * r_dot * theta_dot - (m_1+m_2) *g * r * np.sin ( theta ) - m_2 * gL/2 * np.sin ( phi ) * d * phi / d * theta ) / ((m_1+m_2) *r**2)", + "r_dot = r_dot", + "r_ddot = r * theta_dot **2 - g * np.cos ( theta ) - k(r-b_rest)/m_1 [simplified decoupled form]", + "phi_dot = phi_dot", + "phi_ddot = -(3 * g/(2 * L)) * np.sin ( phi ) [stick about pivot, simplified]" + ] + }, + "derivation_steps": [ + "Generalized coordinates: \\theta (spring-pendulum angle), r (spring length), \\phi (stick angle).", + "Mass 1 position: (r \\cdot \\sin(\\theta), -r \\cdot \\cos(\\theta)) from pivot.", + "Mass 2 center of mass: (r \\cdot \\sin(\\theta) + L/2 \\cdot \\sin(\\phi), -r \\cdot \\cos(\\theta) - L/2 \\cdot \\cos(\\phi)).", + "Kinetic energy of m_1: T_1 = \\tfrac{1}{2} m_1(\\dot{r}^2 + r^2\\dot{\\theta}^2).", + "Kinetic energy of m_2 (translation + rotation about CM): T_2 = \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} (m_2L^2/12)\\dot{\\phi}^2.", + "Spring potential: V_spring = \\tfrac{1}{2} k(r - b_rest)^2.", + "Gravitational potential: V_grav = -m_1g \\cdot r \\cdot \\cos(\\theta) - m_2g(r \\cdot \\cos(\\theta) + L/2 \\cdot \\cos(\\phi)).", + "Euler-Lagrange for \\theta, r, \\phi \\rightarrow 3 coupled 2nd-order ODEs.", + "Spring subsystem natural frequency: \\omega_spring = \\sqrt(k/m_1) = 2.3947 rad/s.", + "Stick natural frequency (about pivot): \\omega_stick = \\sqrt(g/L) = 2.9716 rad/s." + ], + "physical_constants_derived": { + "omega_spring_rad_s": 2.3947, + "T_spring_s": 2.6238, + "omega_stick_rad_s": 2.9716, + "T_stick_s": 2.1144 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "6-DOF nonlinear coupled system; RK45 with tight tolerances prevents energy drift." + }, + "code_validation": { + "ode_source": "Euler-Lagrange for coupled spring-pendulum + rigid stick; matches DangleStickSim.ts evaluate()", + "energy_check": "For the full implemented Lagrangian with no damping, E = T + V should be conserved; the compact equations shown above include simplified component forms, while the code uses the coupled equations of motion.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Spring oscillates at \\omega_spring = 2.395 rad/s (T = 2.624 s).", + "Stick oscillates at \\omega_stick = 2.972 rad/s (T = 2.114 s).", + "Chaotic energy exchange between spring-pendulum and stick modes expected at large amplitudes.", + "Spring length r oscillates about b_rest + m_1g/k (static extension from gravity)." + ], + "parameters": { + "m1": { + "value": 0.8776905196347746, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7039329137260011, + "unit": "", + "description": "" + }, + "L": { + "value": 1.1097893214646257, + "unit": "m", + "description": "" + }, + "k": { + "value": 5.033044532585377, + "unit": "N/m", + "description": "" + }, + "b_rest": { + "value": 0.977569633362777, + "unit": "m", + "description": "Spring rest length" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta0": { + "value": 0.3278336143406393, + "unit": "", + "description": "" + }, + "theta_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r0": { + "value": 0.8734938498389251, + "unit": "m", + "description": "Current spring length" + }, + "r_dot0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "phi0": { + "value": 0.06583931149286826, + "unit": "", + "description": "" + }, + "phi_dot0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/dangle_stick/733/params.json b/scipy/dangle_stick/733/params.json new file mode 100644 index 0000000000000000000000000000000000000000..631ce804fddf485c0cb699868036ad59b361ed2f --- /dev/null +++ b/scipy/dangle_stick/733/params.json @@ -0,0 +1,14 @@ +{ + "m1": 0.8776905196347746, + "m2": 0.7039329137260011, + "L": 1.1097893214646257, + "k": 5.033044532585377, + "b_rest": 0.977569633362777, + "g": 9.8, + "theta0": 0.3278336143406393, + "theta_dot0": 0.0, + "r0": 0.8734938498389251, + "r_dot0": 0.0, + "phi0": 0.06583931149286826, + "phi_dot0": 0.0 +} \ No newline at end of file diff --git a/scipy/dangle_stick/733/simulation_code.py b/scipy/dangle_stick/733/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b4ab88a6be0fe77ffe2246832b1d95d4aa8b663b --- /dev/null +++ b/scipy/dangle_stick/733/simulation_code.py @@ -0,0 +1,83 @@ +""" +Dangle Stick — auto-generated simulation script. +Physics (DangleStickSim.ts): + theta'' = (-4*m1*(m1+m2)*r'*theta' + 2*m1*m2*L*phi'^2*sin(phi-theta) + - 2*g*m1*(m1+m2)*sin(theta) + k*m2*(b-r)*sin(2*(theta-phi))) + / (2*m1*(m1+m2)*r) + r'' = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r - k*m2*(b-r)*cos(2*(theta-phi)) + + 2*L*m1*m2*cos(phi-theta)*phi'^2) / (2*m1*(m1+m2)) + r*theta'^2 + g*cos(theta) + phi'' = k*(b-r)*sin(phi-theta)/(L*m1) +Parameters: m1=0.8776905196347746 kg, m2=0.7039329137260011 kg, L=1.1097893214646257 m, k=5.033044532585377 N/m + b_rest=0.977569633362777 m, g=9.8 m/s^2 +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1, m2, L, k, b = 0.8776905196347746, 0.7039329137260011, 1.1097893214646257, 5.033044532585377, 0.977569633362777 +g = 9.8 +theta0, theta_dot0 = 0.327834, 0.000000 +r0, r_dot0 = 0.873494, 0.000000 +phi0, phi_dot0 = 0.065839, 0.000000 +duration = 12 + +def ode(t, y): + theta, theta_dot, r, r_dot, phi, phi_dot = y + tsum = (-4*m1*(m1+m2)*r_dot*theta_dot + + 2*m1*m2*L*phi_dot**2*np.sin(phi-theta) + - 2*g*m1*(m1+m2)*np.sin(theta) + + k*m2*(b-r)*np.sin(2*(theta-phi))) + dtheta_dot = tsum/(2*m1*(m1+m2)*r) if abs(r)>1e-10 else 0.0 + rsum = (2*b*k*m1 + b*k*m2 - 2*k*m1*r - k*m2*r + - k*m2*(b-r)*np.cos(2*(theta-phi)) + + 2*L*m1*m2*np.cos(phi-theta)*phi_dot**2) + dr_dot = rsum/(2*m1*(m1+m2)) + r*theta_dot**2 + g*np.cos(theta) + dphi_dot = k*(b-r)*np.sin(phi-theta)/(L*m1) + return [theta_dot, dtheta_dot, r_dot, dr_dot, phi_dot, dphi_dot] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), + [theta0, theta_dot0, r0, r_dot0, phi0, phi_dot0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +theta_a, r_a, phi_a = sol.y[0], sol.y[2], sol.y[4] +x1a = r_a*np.sin(theta_a); y1a = -r_a*np.cos(theta_a) +x2a = x1a + L*np.sin(phi_a); y2a = y1a - L*np.cos(phi_a) + +all_x = np.concatenate([[0], x1a, x2a]); all_y = np.concatenate([[0], y1a, y2a]) +mg = max(b*1.5, L*1.5, 1.5) +xlim=(all_x.min()-mg, all_x.max()+mg); ylim=(all_y.min()-mg, all_y.max()+mg) + +fig, axv = plt.subplots(figsize=(8,6), facecolor="#1a1a2e") +axv.set_facecolor("#16213e"); axv.set_xlim(xlim); axv.set_ylim(ylim) +axv.set_aspect("equal"); axv.axis("off") + +asq=0.22 +axv.add_patch(patches.Rectangle((-asq/2,-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp,=axv.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +st,=axv.plot([],[],"-",color="#e9c46a",lw=3.0,zorder=3) +b1c=plt.Circle((x1a[0],y1a[0]),0.15,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2a[0],y2a[0]),0.15,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +axv.add_patch(b1c); axv.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=8,r=0.12): + dx,dy=x2-x1,y2-y1; dist=np.hypot(dx,dy) + if dist<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/dist,dy/dist; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + sx,sy=spfn(0,0,b1x,b1y); sp.set_data(sx,sy) + st.set_data([b1x,b2x],[b1y,b2y]) + return (sp,st,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("dangle_stick.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved dangle_stick.mp4") diff --git a/scipy/dangle_stick/733/video.mp4 b/scipy/dangle_stick/733/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a0381e32386840cb7701ca8b611b4bd6e75a2b05 --- /dev/null +++ b/scipy/dangle_stick/733/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfe1ebb91dd9d8ff3266bb7ba4e821566bd5b28bd6fff94d90105bbce4defbc7 +size 14914 diff --git a/scipy/differential_pulley_chain_fall/009/cot.json b/scipy/differential_pulley_chain_fall/009/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..90bd16efd130c585013a88b6c4e51e8781a07ce8 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/009/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.102 m and small radius r=0.086 m (r/R=0.844, ideal mechanical advantage MA = 2R/(R-r) = 12.83). A load M_load=15.00 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=2.266 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 6.62, the effort exceeds the lifting threshold (overload_factor OF = 1.88 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.051 N \\cdot m + viscous c_drag=0.780 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 1.305 rad/s, giving load speed 1.04 cm/s and effort speed 13.36 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 12.834.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0187 + 0.00098 + 0.0238 = 0.0434 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 2.277 - 1.208 = +1.068 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 1.88 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.056 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 1.3047 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 1.041 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 13.362 cm/s", + " Over a 12.0-s clip the load rises \\approx 12.5 cm and the effort falls \\approx 160.3 cm (ratio 12.83)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 12.834 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.056 s) the upper compound reaches its terminal \\omega_ss = 1.305 rad/s.", + "Load (M_load = 15.00 kg) rises slowly at 1.04 cm/s while effort (m_eff = 2.266 kg) falls 12.83 \\times faster --- exactly the mechanical advantage MA = 12.83.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 160.3 cm \\approx M_load \\cdot g \\cdot 12.49 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.10241272027970039, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.8441690566998968, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 15.004783510509814, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.43053327773651784, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 1.8842407397096956, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.018696990436877517, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 1.3047164580605763, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.0508421689532878, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.08645364947258508, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 2.266082102292826, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 0.7799049949420793, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/009/params.json b/scipy/differential_pulley_chain_fall/009/params.json new file mode 100644 index 0000000000000000000000000000000000000000..0b99448776e227047f21c65d23684c6e4a9fcf14 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/009/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.10241272027970039, + "r_over_R": 0.8441690566998968, + "M_load": 15.004783510509814, + "m_lp": 0.43053327773651784, + "overload_factor": 1.8842407397096956, + "I_axle": 0.018696990436877517, + "omega_target": 1.3047164580605763, + "tau_friction": 0.0508421689532878, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.08645364947258508, + "m_eff": 2.266082102292826, + "c_drag": 0.7799049949420793 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/009/simulation_code.py b/scipy/differential_pulley_chain_fall/009/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..de9967bcb13933b7f19c69dd43c7061fafae04cf --- /dev/null +++ b/scipy/differential_pulley_chain_fall/009/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.10241272027970039 +r = 0.08645364947258508 +M_load = 15.004783510509814 +m_lp = 0.43053327773651784 +m_eff = 2.266082102292826 +I_axle = 0.018696990436877517 +tau_friction= 0.0508421689532878 +alpha_tanh = 30.0 +c_drag = 0.7799049949420793 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/009/video.mp4 b/scipy/differential_pulley_chain_fall/009/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..db21b5f12e217ca09c3b932f4df5bae79c3e7d8b --- /dev/null +++ b/scipy/differential_pulley_chain_fall/009/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1732d0092ad60d6e52cfeb447e3da9c1ab2fd7e248699be1a66afee50515a394 +size 13746 diff --git a/scipy/differential_pulley_chain_fall/074/cot.json b/scipy/differential_pulley_chain_fall/074/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e342dc4a00e9ab8051e220f6a8bddb4570049c7f --- /dev/null +++ b/scipy/differential_pulley_chain_fall/074/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.099 m and small radius r=0.084 m (r/R=0.843, ideal mechanical advantage MA = 2R/(R-r) = 12.75). A load M_load=13.77 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=1.982 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 6.95, the effort exceeds the lifting threshold (overload_factor OF = 1.76 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.026 N \\cdot m + viscous c_drag=0.923 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 0.879 rad/s, giving load speed 0.69 cm/s and effort speed 8.74 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 12.755.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0130 + 0.00087 + 0.0196 = 0.0335 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 1.933 - 1.096 = +0.837 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 1.76 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.036 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 0.8794 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.685 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 8.742 cm/s", + " Over a 12.0-s clip the load rises \\approx 8.2 cm and the effort falls \\approx 104.9 cm (ratio 12.75)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 12.755 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.036 s) the upper compound reaches its terminal \\omega_ss = 0.879 rad/s.", + "Load (M_load = 13.77 kg) rises slowly at 0.69 cm/s while effort (m_eff = 1.982 kg) falls 12.75 \\times faster --- exactly the mechanical advantage MA = 12.75.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 104.9 cm \\approx M_load \\cdot g \\cdot 8.22 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.09941097018747522, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.8431952456578369, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 13.768721144501209, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.5618937926154131, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 1.7642218474646076, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.013032006055740973, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 0.8793515848840343, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.0258384300636532, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.08382285742831207, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 1.9821990029896621, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 0.922873719765736, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/074/params.json b/scipy/differential_pulley_chain_fall/074/params.json new file mode 100644 index 0000000000000000000000000000000000000000..1d2f3f89a9529f5ff687779c047a6141e54bbaaf --- /dev/null +++ b/scipy/differential_pulley_chain_fall/074/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.09941097018747522, + "r_over_R": 0.8431952456578369, + "M_load": 13.768721144501209, + "m_lp": 0.5618937926154131, + "overload_factor": 1.7642218474646076, + "I_axle": 0.013032006055740973, + "omega_target": 0.8793515848840343, + "tau_friction": 0.0258384300636532, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.08382285742831207, + "m_eff": 1.9821990029896621, + "c_drag": 0.922873719765736 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/074/simulation_code.py b/scipy/differential_pulley_chain_fall/074/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..95031f82aee21b1e65c953ee33900431ced87335 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/074/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.09941097018747522 +r = 0.08382285742831207 +M_load = 13.768721144501209 +m_lp = 0.5618937926154131 +m_eff = 1.9821990029896621 +I_axle = 0.013032006055740973 +tau_friction= 0.0258384300636532 +alpha_tanh = 30.0 +c_drag = 0.922873719765736 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/074/video.mp4 b/scipy/differential_pulley_chain_fall/074/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a9906f42fc336b31cbfccd7b35f0e2ee3d384007 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/074/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c834830d57ca4e42e53f5a9a3433be3636ac0bba3385c14b4d4ea0a099c0a9ac +size 13009 diff --git a/scipy/differential_pulley_chain_fall/075/cot.json b/scipy/differential_pulley_chain_fall/075/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f8073da770013dd9bf9a481acc68dde40e408bc0 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/075/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.108 m and small radius r=0.096 m (r/R=0.887, ideal mechanical advantage MA = 2R/(R-r) = 17.67). A load M_load=20.21 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=2.344 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 8.62, the effort exceeds the lifting threshold (overload_factor OF = 1.98 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.057 N \\cdot m + viscous c_drag=1.274 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 0.920 rad/s, giving load speed 0.56 cm/s and effort speed 9.92 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 17.669.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0088 + 0.00078 + 0.0273 = 0.0369 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 2.480 - 1.250 = +1.229 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 1.98 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.029 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 0.9199 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.561 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 9.920 cm/s", + " Over a 12.0-s clip the load rises \\approx 6.7 cm and the effort falls \\approx 119.0 cm (ratio 17.67)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 17.669 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.029 s) the upper compound reaches its terminal \\omega_ss = 0.920 rad/s.", + "Load (M_load = 20.21 kg) rises slowly at 0.56 cm/s while effort (m_eff = 2.344 kg) falls 17.67 \\times faster --- exactly the mechanical advantage MA = 17.67.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 119.0 cm \\approx M_load \\cdot g \\cdot 6.74 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.10784695143316589, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.886809846460747, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 20.211380965170463, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.6681911531839951, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 1.9834255698962677, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.008829317734112926, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 0.919855211708168, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.0571439290414454, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.09563973844170548, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 2.343776284987248, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 1.274470161206576, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/075/params.json b/scipy/differential_pulley_chain_fall/075/params.json new file mode 100644 index 0000000000000000000000000000000000000000..cd90b68093687723af6c6bc7e0f9f84f32c0060a --- /dev/null +++ b/scipy/differential_pulley_chain_fall/075/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.10784695143316589, + "r_over_R": 0.886809846460747, + "M_load": 20.211380965170463, + "m_lp": 0.6681911531839951, + "overload_factor": 1.9834255698962677, + "I_axle": 0.008829317734112926, + "omega_target": 0.919855211708168, + "tau_friction": 0.0571439290414454, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.09563973844170548, + "m_eff": 2.343776284987248, + "c_drag": 1.274470161206576 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/075/simulation_code.py b/scipy/differential_pulley_chain_fall/075/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..8dee691310a3cd2b316943f19702f364657e63b8 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/075/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.10784695143316589 +r = 0.09563973844170548 +M_load = 20.211380965170463 +m_lp = 0.6681911531839951 +m_eff = 2.343776284987248 +I_axle = 0.008829317734112926 +tau_friction= 0.0571439290414454 +alpha_tanh = 30.0 +c_drag = 1.274470161206576 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/075/video.mp4 b/scipy/differential_pulley_chain_fall/075/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2b23d06fb8c9081d0f6d8f958b0ce14eee7e98e4 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/075/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ccf6552b3aa466a4d56d60047e4fd3e44f4e0c6c6bd977cbfdcfc5c3b7ce2d01 +size 13036 diff --git a/scipy/differential_pulley_chain_fall/102/cot.json b/scipy/differential_pulley_chain_fall/102/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f3d7038db0373a9e30dc375dd017dfff45f23964 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/102/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.102 m and small radius r=0.081 m (r/R=0.799, ideal mechanical advantage MA = 2R/(R-r) = 9.96). A load M_load=21.85 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=4.030 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 5.42, the effort exceeds the lifting threshold (overload_factor OF = 1.78 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.026 N \\cdot m + viscous c_drag=1.750 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 0.993 rad/s, giving load speed 1.01 cm/s and effort speed 10.08 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 9.961.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0158 + 0.00234 + 0.0415 = 0.0596 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 4.014 - 2.250 = +1.764 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 1.78 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.034 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 0.9928 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 1.012 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 10.080 cm/s", + " Over a 12.0-s clip the load rises \\approx 12.1 cm and the effort falls \\approx 121.0 cm (ratio 9.96)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 9.961 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.034 s) the upper compound reaches its terminal \\omega_ss = 0.993 rad/s.", + "Load (M_load = 21.85 kg) rises slowly at 1.01 cm/s while effort (m_eff = 4.030 kg) falls 9.96 \\times faster --- exactly the mechanical advantage MA = 9.96.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 121.0 cm \\approx M_load \\cdot g \\cdot 12.14 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.10153251360673883, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.7992107084919974, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 21.847381340870363, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.6568245027304604, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 1.7836685051855727, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.015750860391853132, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 0.9927632243344884, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.02613520295857699, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.0811458721346151, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 4.029845417357692, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 1.750051118503259, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/102/params.json b/scipy/differential_pulley_chain_fall/102/params.json new file mode 100644 index 0000000000000000000000000000000000000000..bb3da007dd41fb021f71ba1816413db6fac4c8cb --- /dev/null +++ b/scipy/differential_pulley_chain_fall/102/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.10153251360673883, + "r_over_R": 0.7992107084919974, + "M_load": 21.847381340870363, + "m_lp": 0.6568245027304604, + "overload_factor": 1.7836685051855727, + "I_axle": 0.015750860391853132, + "omega_target": 0.9927632243344884, + "tau_friction": 0.02613520295857699, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.0811458721346151, + "m_eff": 4.029845417357692, + "c_drag": 1.750051118503259 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/102/simulation_code.py b/scipy/differential_pulley_chain_fall/102/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..852be357bcf7ff5fd2c0ec0fd133a1d2594218fc --- /dev/null +++ b/scipy/differential_pulley_chain_fall/102/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.10153251360673883 +r = 0.0811458721346151 +M_load = 21.847381340870363 +m_lp = 0.6568245027304604 +m_eff = 4.029845417357692 +I_axle = 0.015750860391853132 +tau_friction= 0.02613520295857699 +alpha_tanh = 30.0 +c_drag = 1.750051118503259 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/102/video.mp4 b/scipy/differential_pulley_chain_fall/102/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3ed7a555e86600f9780b4aa99e721ab5444f686c --- /dev/null +++ b/scipy/differential_pulley_chain_fall/102/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c389d85298384ff512dcddef7a41c319d7bcf172229206782b8f9091ea38eba1 +size 12730 diff --git a/scipy/differential_pulley_chain_fall/135/cot.json b/scipy/differential_pulley_chain_fall/135/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..3e05958c371ff50f7f3714f5bcbb94bc9502c904 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/135/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.125 m and small radius r=0.109 m (r/R=0.870, ideal mechanical advantage MA = 2R/(R-r) = 15.35). A load M_load=16.31 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=2.583 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 6.31, the effort exceeds the lifting threshold (overload_factor OF = 2.35 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.031 N \\cdot m + viscous c_drag=1.916 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 0.935 rad/s, giving load speed 0.76 cm/s and effort speed 11.70 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 15.348.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0096 + 0.00112 + 0.0404 = 0.0511 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 3.169 - 1.346 = +1.824 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 2.35 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.027 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 0.9354 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.762 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 11.698 cm/s", + " Over a 12.0-s clip the load rises \\approx 9.1 cm and the effort falls \\approx 140.4 cm (ratio 15.35)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 15.348 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.027 s) the upper compound reaches its terminal \\omega_ss = 0.935 rad/s.", + "Load (M_load = 16.31 kg) rises slowly at 0.76 cm/s while effort (m_eff = 2.583 kg) falls 15.35 \\times faster --- exactly the mechanical advantage MA = 15.35.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 140.4 cm \\approx M_load \\cdot g \\cdot 9.15 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.12505894064628412, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.8696932046476118, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 16.311955154757918, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.526131963889265, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 2.3548734190338987, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.00957856612790962, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 0.9353799492711514, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.03095720700602069, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.10876291086050231, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 2.583434103641943, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 1.9164086279024852, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/135/params.json b/scipy/differential_pulley_chain_fall/135/params.json new file mode 100644 index 0000000000000000000000000000000000000000..33043a69a7017398d4c914dacecc3b921a9bd53c --- /dev/null +++ b/scipy/differential_pulley_chain_fall/135/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.12505894064628412, + "r_over_R": 0.8696932046476118, + "M_load": 16.311955154757918, + "m_lp": 0.526131963889265, + "overload_factor": 2.3548734190338987, + "I_axle": 0.00957856612790962, + "omega_target": 0.9353799492711514, + "tau_friction": 0.03095720700602069, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.10876291086050231, + "m_eff": 2.583434103641943, + "c_drag": 1.9164086279024852 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/135/simulation_code.py b/scipy/differential_pulley_chain_fall/135/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4db7ef749d78625b04d870e911d920daded2fed3 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/135/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.12505894064628412 +r = 0.10876291086050231 +M_load = 16.311955154757918 +m_lp = 0.526131963889265 +m_eff = 2.583434103641943 +I_axle = 0.00957856612790962 +tau_friction= 0.03095720700602069 +alpha_tanh = 30.0 +c_drag = 1.9164086279024852 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/135/video.mp4 b/scipy/differential_pulley_chain_fall/135/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..786e108a096827c248e435a2a0bbd6fe896cb47e --- /dev/null +++ b/scipy/differential_pulley_chain_fall/135/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9bd44f032d42b84754eac9d33f2e8fa1461ac8af59f990dec5966e05f851d2f7 +size 13183 diff --git a/scipy/differential_pulley_chain_fall/218/cot.json b/scipy/differential_pulley_chain_fall/218/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e6990406da4c5626f5960e590bfd28de26ee43f9 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/218/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.124 m and small radius r=0.112 m (r/R=0.905, ideal mechanical advantage MA = 2R/(R-r) = 21.04). A load M_load=21.74 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=2.552 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 8.52, the effort exceeds the lifting threshold (overload_factor OF = 2.39 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.050 N \\cdot m + viscous c_drag=2.169 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 0.809 rad/s, giving load speed 0.48 cm/s and effort speed 10.01 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 21.037.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0082 + 0.00078 + 0.0391 = 0.0481 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 3.100 - 1.297 = +1.804 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 2.39 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.022 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 0.8086 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.476 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 10.014 cm/s", + " Over a 12.0-s clip the load rises \\approx 5.7 cm and the effort falls \\approx 120.2 cm (ratio 21.04)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 21.037 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.022 s) the upper compound reaches its terminal \\omega_ss = 0.809 rad/s.", + "Load (M_load = 21.74 kg) rises slowly at 0.48 cm/s while effort (m_eff = 2.552 kg) falls 21.04 \\times faster --- exactly the mechanical advantage MA = 21.04.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 120.2 cm \\approx M_load \\cdot g \\cdot 5.71 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.12384082039983942, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.9049311680967089, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 21.738774230805987, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.7141566413747031, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 2.391121938235324, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.008197320801489761, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 0.8086380545093376, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.049928984932466156, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.11206741826248143, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 2.5520132534774933, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 2.1688726942393832, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/218/params.json b/scipy/differential_pulley_chain_fall/218/params.json new file mode 100644 index 0000000000000000000000000000000000000000..43ff3b310ec4ff51607152e72a9e0185e80ee095 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/218/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.12384082039983942, + "r_over_R": 0.9049311680967089, + "M_load": 21.738774230805987, + "m_lp": 0.7141566413747031, + "overload_factor": 2.391121938235324, + "I_axle": 0.008197320801489761, + "omega_target": 0.8086380545093376, + "tau_friction": 0.049928984932466156, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.11206741826248143, + "m_eff": 2.5520132534774933, + "c_drag": 2.1688726942393832 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/218/simulation_code.py b/scipy/differential_pulley_chain_fall/218/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..a239b2594abdcd96f95bc4d28b35777a0a96dc1a --- /dev/null +++ b/scipy/differential_pulley_chain_fall/218/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.12384082039983942 +r = 0.11206741826248143 +M_load = 21.738774230805987 +m_lp = 0.7141566413747031 +m_eff = 2.5520132534774933 +I_axle = 0.008197320801489761 +tau_friction= 0.049928984932466156 +alpha_tanh = 30.0 +c_drag = 2.1688726942393832 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/218/video.mp4 b/scipy/differential_pulley_chain_fall/218/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..46b53c8042e0e085fccf34bbcb4ca86a8e3a6e14 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/218/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b78bcda511a17916edc375959bcc3c43d3d298648a5945cae680a64dd1b6eada +size 12842 diff --git a/scipy/differential_pulley_chain_fall/271/cot.json b/scipy/differential_pulley_chain_fall/271/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f95be9626664dfb08f86bdb45c3a68307fc131a2 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/271/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.099 m and small radius r=0.084 m (r/R=0.852, ideal mechanical advantage MA = 2R/(R-r) = 13.56). A load M_load=22.26 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=3.815 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 5.84, the effort exceeds the lifting threshold (overload_factor OF = 2.25 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.054 N \\cdot m + viscous c_drag=1.950 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 1.026 rad/s, giving load speed 0.75 cm/s and effort speed 10.12 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 13.557.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0071 + 0.00122 + 0.0371 = 0.0454 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 3.692 - 1.638 = +2.054 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 2.25 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.023 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 1.0255 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.746 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 10.117 cm/s", + " Over a 12.0-s clip the load rises \\approx 9.0 cm and the effort falls \\approx 121.4 cm (ratio 13.56)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 13.557 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.023 s) the upper compound reaches its terminal \\omega_ss = 1.026 rad/s.", + "Load (M_load = 22.26 kg) rises slowly at 0.75 cm/s while effort (m_eff = 3.815 kg) falls 13.56 \\times faster --- exactly the mechanical advantage MA = 13.56.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 121.4 cm \\approx M_load \\cdot g \\cdot 8.96 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.09865453484251789, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.8524711174128069, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 22.259355891262913, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.6859643390832012, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 2.2537583803880707, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.007052200752752208, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 1.025547424041993, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.053922722467181786, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.08410014155504192, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 3.814595877903578, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 1.9499796472125495, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/271/params.json b/scipy/differential_pulley_chain_fall/271/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5cdbb45f4d9626d21c1c4e996399cfdcf1a0636b --- /dev/null +++ b/scipy/differential_pulley_chain_fall/271/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.09865453484251789, + "r_over_R": 0.8524711174128069, + "M_load": 22.259355891262913, + "m_lp": 0.6859643390832012, + "overload_factor": 2.2537583803880707, + "I_axle": 0.007052200752752208, + "omega_target": 1.025547424041993, + "tau_friction": 0.053922722467181786, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.08410014155504192, + "m_eff": 3.814595877903578, + "c_drag": 1.9499796472125495 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/271/simulation_code.py b/scipy/differential_pulley_chain_fall/271/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ce28b952571d3c77c79947bcb23cdef21d8d2873 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/271/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.09865453484251789 +r = 0.08410014155504192 +M_load = 22.259355891262913 +m_lp = 0.6859643390832012 +m_eff = 3.814595877903578 +I_axle = 0.007052200752752208 +tau_friction= 0.053922722467181786 +alpha_tanh = 30.0 +c_drag = 1.9499796472125495 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/271/video.mp4 b/scipy/differential_pulley_chain_fall/271/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4b3dbba8db39dd257263fab1ba0a2659ada5e15f --- /dev/null +++ b/scipy/differential_pulley_chain_fall/271/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d2b81f58a75404a6a5283684e209338eef8cdeccbdea9d6fdd25812be28cb8d +size 12671 diff --git a/scipy/differential_pulley_chain_fall/323/cot.json b/scipy/differential_pulley_chain_fall/323/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..804e6cbf5b96b36ae1798f43a1ec834a9562767f --- /dev/null +++ b/scipy/differential_pulley_chain_fall/323/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.091 m and small radius r=0.083 m (r/R=0.908, ideal mechanical advantage MA = 2R/(R-r) = 21.67). A load M_load=22.91 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=2.506 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 9.14, the effort exceeds the lifting threshold (overload_factor OF = 2.32 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.076 N \\cdot m + viscous c_drag=1.200 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 1.000 rad/s, giving load speed 0.42 cm/s and effort speed 9.14 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 21.667.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0053 + 0.00042 + 0.0209 = 0.0266 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 2.245 - 0.970 = +1.276 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 2.32 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.022 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 1.0001 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.422 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 9.136 cm/s", + " Over a 12.0-s clip the load rises \\approx 5.1 cm and the effort falls \\approx 109.6 cm (ratio 21.67)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 21.667 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.022 s) the upper compound reaches its terminal \\omega_ss = 1.000 rad/s.", + "Load (M_load = 22.91 kg) rises slowly at 0.42 cm/s while effort (m_eff = 2.506 kg) falls 21.67 \\times faster --- exactly the mechanical advantage MA = 21.67.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 109.6 cm \\approx M_load \\cdot g \\cdot 5.06 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.09134688879552838, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.9076919314158959, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 22.90675921405034, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.535189460417097, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 2.3158578604932796, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.005310867993638881, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 1.00011113941986, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.07587645032596345, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.08291483391964621, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 2.5056204184444635, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 1.1997682584224854, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/323/params.json b/scipy/differential_pulley_chain_fall/323/params.json new file mode 100644 index 0000000000000000000000000000000000000000..2ecdea5ba8441bc7c4cd96250122a1874eb84aa9 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/323/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.09134688879552838, + "r_over_R": 0.9076919314158959, + "M_load": 22.90675921405034, + "m_lp": 0.535189460417097, + "overload_factor": 2.3158578604932796, + "I_axle": 0.005310867993638881, + "omega_target": 1.00011113941986, + "tau_friction": 0.07587645032596345, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.08291483391964621, + "m_eff": 2.5056204184444635, + "c_drag": 1.1997682584224854 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/323/simulation_code.py b/scipy/differential_pulley_chain_fall/323/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..fd5d815668b7c12bbf6a55c365e64c5b3dec03d1 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/323/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.09134688879552838 +r = 0.08291483391964621 +M_load = 22.90675921405034 +m_lp = 0.535189460417097 +m_eff = 2.5056204184444635 +I_axle = 0.005310867993638881 +tau_friction= 0.07587645032596345 +alpha_tanh = 30.0 +c_drag = 1.1997682584224854 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/323/video.mp4 b/scipy/differential_pulley_chain_fall/323/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..bfd6241e12a3378a1d83c1a0bb747ef126a1e026 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/323/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:00b41ffe2c92f3a356c2c60d87bc3fe34edd95dab48dba947cd9056021dd8a68 +size 13694 diff --git a/scipy/differential_pulley_chain_fall/357/cot.json b/scipy/differential_pulley_chain_fall/357/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c4fd03669a6d7218c0915255b2362f5e08954cf6 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/357/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.090 m and small radius r=0.072 m (r/R=0.803, ideal mechanical advantage MA = 2R/(R-r) = 10.13). A load M_load=21.66 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=5.460 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 3.97, the effort exceeds the lifting threshold (overload_factor OF = 2.48 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.051 N \\cdot m + viscous c_drag=2.164 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 1.301 rad/s, giving load speed 1.15 cm/s and effort speed 11.67 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 10.133.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0123 + 0.00175 + 0.0439 = 0.0580 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 4.802 - 1.936 = +2.866 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 2.48 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.027 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 1.3012 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 1.151 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 11.667 cm/s", + " Over a 12.0-s clip the load rises \\approx 13.8 cm and the effort falls \\approx 140.0 cm (ratio 10.13)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 10.133 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.027 s) the upper compound reaches its terminal \\omega_ss = 1.301 rad/s.", + "Load (M_load = 21.66 kg) rises slowly at 1.15 cm/s while effort (m_eff = 5.460 kg) falls 10.13 \\times faster --- exactly the mechanical advantage MA = 10.13.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 140.0 cm \\approx M_load \\cdot g \\cdot 13.82 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.08966295397110488, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.8026188416300823, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 21.65769751849379, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.6467930163532603, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 2.480354166608369, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.012322037657791607, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 1.3011963331992622, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.050968192856183814, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.0719651762534196, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 5.459862468286664, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 2.163618522198101, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/357/params.json b/scipy/differential_pulley_chain_fall/357/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c5f9bb8653c0db7266382d5f8f7ded114eaacd95 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/357/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.08966295397110488, + "r_over_R": 0.8026188416300823, + "M_load": 21.65769751849379, + "m_lp": 0.6467930163532603, + "overload_factor": 2.480354166608369, + "I_axle": 0.012322037657791607, + "omega_target": 1.3011963331992622, + "tau_friction": 0.050968192856183814, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.0719651762534196, + "m_eff": 5.459862468286664, + "c_drag": 2.163618522198101 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/357/simulation_code.py b/scipy/differential_pulley_chain_fall/357/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b323a26b90b0dfafa05d46e5e536d5f850721dab --- /dev/null +++ b/scipy/differential_pulley_chain_fall/357/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.08966295397110488 +r = 0.0719651762534196 +M_load = 21.65769751849379 +m_lp = 0.6467930163532603 +m_eff = 5.459862468286664 +I_axle = 0.012322037657791607 +tau_friction= 0.050968192856183814 +alpha_tanh = 30.0 +c_drag = 2.163618522198101 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/357/video.mp4 b/scipy/differential_pulley_chain_fall/357/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c8d730e7e871d7d8b55a28fdbff8033550e3ba9f --- /dev/null +++ b/scipy/differential_pulley_chain_fall/357/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbc32b3434b2bdce8b4e0b859a838255c5f37210118312816158969d2b6ef54c +size 12731 diff --git a/scipy/differential_pulley_chain_fall/469/cot.json b/scipy/differential_pulley_chain_fall/469/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..b50c978dfbe38a034e294410fab33d091570b209 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/469/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.087 m and small radius r=0.068 m (r/R=0.783, ideal mechanical advantage MA = 2R/(R-r) = 9.22). A load M_load=20.56 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=5.693 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 3.61, the effort exceeds the lifting threshold (overload_factor OF = 2.48 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.038 N \\cdot m + viscous c_drag=3.335 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 0.853 rad/s, giving load speed 0.80 cm/s and effort speed 7.39 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 9.216.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0169 + 0.00187 + 0.0427 = 0.0614 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 4.836 - 1.954 = +2.882 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 2.48 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.018 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 0.8528 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.801 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 7.385 cm/s", + " Over a 12.0-s clip the load rises \\approx 9.6 cm and the effort falls \\approx 88.6 cm (ratio 9.22)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 9.216 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.018 s) the upper compound reaches its terminal \\omega_ss = 0.853 rad/s.", + "Load (M_load = 20.56 kg) rises slowly at 0.80 cm/s while effort (m_eff = 5.693 kg) falls 9.22 \\times faster --- exactly the mechanical advantage MA = 9.22.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 88.6 cm \\approx M_load \\cdot g \\cdot 9.62 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.0865951377982541, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.782984442394418, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 20.5567903518641, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.6406756563034088, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 2.475046595005783, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.016875792141113302, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 0.8528374655385829, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.03823963007748971, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.06780264568303378, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 5.692829805869607, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 3.3346179412585726, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/469/params.json b/scipy/differential_pulley_chain_fall/469/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a171cc809c42db4731df11fbda5358ef0c389fde --- /dev/null +++ b/scipy/differential_pulley_chain_fall/469/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.0865951377982541, + "r_over_R": 0.782984442394418, + "M_load": 20.5567903518641, + "m_lp": 0.6406756563034088, + "overload_factor": 2.475046595005783, + "I_axle": 0.016875792141113302, + "omega_target": 0.8528374655385829, + "tau_friction": 0.03823963007748971, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.06780264568303378, + "m_eff": 5.692829805869607, + "c_drag": 3.3346179412585726 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/469/simulation_code.py b/scipy/differential_pulley_chain_fall/469/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..baf1bee40a167ccabab16b9650750f50887474ab --- /dev/null +++ b/scipy/differential_pulley_chain_fall/469/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.0865951377982541 +r = 0.06780264568303378 +M_load = 20.5567903518641 +m_lp = 0.6406756563034088 +m_eff = 5.692829805869607 +I_axle = 0.016875792141113302 +tau_friction= 0.03823963007748971 +alpha_tanh = 30.0 +c_drag = 3.3346179412585726 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/469/video.mp4 b/scipy/differential_pulley_chain_fall/469/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b9bac6b4f9a6bd99bcf83ba9b930dcf29bf053b8 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/469/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b12b18dfcfbad9fa38a07fc8b56c1185487b73d1c04417ef65966c05477e6dd8 +size 11745 diff --git a/scipy/differential_pulley_chain_fall/518/cot.json b/scipy/differential_pulley_chain_fall/518/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..83797d36ca11d4e4541daa2b80efcc46b212a263 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/518/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.127 m and small radius r=0.116 m (r/R=0.916, ideal mechanical advantage MA = 2R/(R-r) = 23.71). A load M_load=24.16 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=1.662 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 14.54, the effort exceeds the lifting threshold (overload_factor OF = 1.61 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.023 N \\cdot m + viscous c_drag=0.571 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 1.328 rad/s, giving load speed 0.71 cm/s and effort speed 16.83 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 23.714.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0053 + 0.00070 + 0.0267 = 0.0327 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 2.066 - 1.286 = +0.781 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 1.61 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.057 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 1.3278 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.710 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 16.832 cm/s", + " Over a 12.0-s clip the load rises \\approx 8.5 cm and the effort falls \\approx 202.0 cm (ratio 23.71)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 23.714 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.057 s) the upper compound reaches its terminal \\omega_ss = 1.328 rad/s.", + "Load (M_load = 24.16 kg) rises slowly at 0.71 cm/s while effort (m_eff = 1.662 kg) falls 23.71 \\times faster --- exactly the mechanical advantage MA = 23.71.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 202.0 cm \\approx M_load \\cdot g \\cdot 8.52 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.12676498501599026, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.915662371795185, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 24.155352107913266, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.3586221435166887, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 1.6074740826712082, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.005304698463740158, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 1.3278336196640759, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.02250070401666815, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.11607392684032272, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 1.6616865047685174, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 0.5711631667349234, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/518/params.json b/scipy/differential_pulley_chain_fall/518/params.json new file mode 100644 index 0000000000000000000000000000000000000000..4a860ddfbdfe77d560906f5ed8c4043307b9a2f7 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/518/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.12676498501599026, + "r_over_R": 0.915662371795185, + "M_load": 24.155352107913266, + "m_lp": 0.3586221435166887, + "overload_factor": 1.6074740826712082, + "I_axle": 0.005304698463740158, + "omega_target": 1.3278336196640759, + "tau_friction": 0.02250070401666815, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.11607392684032272, + "m_eff": 1.6616865047685174, + "c_drag": 0.5711631667349234 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/518/simulation_code.py b/scipy/differential_pulley_chain_fall/518/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6c14d29ddc62c3acfc32202cd04a1dd8e6d7a0e1 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/518/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.12676498501599026 +r = 0.11607392684032272 +M_load = 24.155352107913266 +m_lp = 0.3586221435166887 +m_eff = 1.6616865047685174 +I_axle = 0.005304698463740158 +tau_friction= 0.02250070401666815 +alpha_tanh = 30.0 +c_drag = 0.5711631667349234 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/518/video.mp4 b/scipy/differential_pulley_chain_fall/518/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ca82db272ace8e81e275f01337c3a3b56f2a3dee --- /dev/null +++ b/scipy/differential_pulley_chain_fall/518/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:becbbf16473f499dc7e14d36f70fa7d7626ccbad883f1fbc5110ca7c609ed371 +size 12243 diff --git a/scipy/differential_pulley_chain_fall/550/cot.json b/scipy/differential_pulley_chain_fall/550/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..813a388490bd017fcf334709586ad1eccae1fc8c --- /dev/null +++ b/scipy/differential_pulley_chain_fall/550/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.116 m and small radius r=0.104 m (r/R=0.899, ideal mechanical advantage MA = 2R/(R-r) = 19.75). A load M_load=24.69 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=2.052 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 12.03, the effort exceeds the lifting threshold (overload_factor OF = 1.61 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.056 N \\cdot m + viscous c_drag=0.737 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 1.125 rad/s, giving load speed 0.66 cm/s and effort speed 13.01 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 19.748.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0158 + 0.00086 + 0.0274 = 0.0441 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 2.328 - 1.443 = +0.884 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 1.61 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.060 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 1.1247 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.659 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 13.006 cm/s", + " Over a 12.0-s clip the load rises \\approx 7.9 cm and the effort falls \\approx 156.1 cm (ratio 19.75)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 19.748 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.060 s) the upper compound reaches its terminal \\omega_ss = 1.125 rad/s.", + "Load (M_load = 24.69 kg) rises slowly at 0.66 cm/s while effort (m_eff = 2.052 kg) falls 19.75 \\times faster --- exactly the mechanical advantage MA = 19.75.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 156.1 cm \\approx M_load \\cdot g \\cdot 7.90 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.11563948987617237, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.8987254455609711, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 24.69188720404965, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.4344323933239418, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 1.6126491542823351, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.015813717537094957, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 1.1247173572557045, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.05572908194738076, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.10392815206340641, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 2.0518193359013313, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 0.7366683324368145, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/550/params.json b/scipy/differential_pulley_chain_fall/550/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c5f79ac95ad13dd3b396612e7a2a0b3ee2e19c96 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/550/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.11563948987617237, + "r_over_R": 0.8987254455609711, + "M_load": 24.69188720404965, + "m_lp": 0.4344323933239418, + "overload_factor": 1.6126491542823351, + "I_axle": 0.015813717537094957, + "omega_target": 1.1247173572557045, + "tau_friction": 0.05572908194738076, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.10392815206340641, + "m_eff": 2.0518193359013313, + "c_drag": 0.7366683324368145 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/550/simulation_code.py b/scipy/differential_pulley_chain_fall/550/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..7d0804e3150db49cde5f462ca4f2dec55b7acdff --- /dev/null +++ b/scipy/differential_pulley_chain_fall/550/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.11563948987617237 +r = 0.10392815206340641 +M_load = 24.69188720404965 +m_lp = 0.4344323933239418 +m_eff = 2.0518193359013313 +I_axle = 0.015813717537094957 +tau_friction= 0.05572908194738076 +alpha_tanh = 30.0 +c_drag = 0.7366683324368145 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/550/video.mp4 b/scipy/differential_pulley_chain_fall/550/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a9794b28061a1ce0c8b25669b53a72e148c1dd25 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/550/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84c50b50effd032e9837eb46b52eb65806b8b8553f0a6ec369095605d6b8fc66 +size 13841 diff --git a/scipy/differential_pulley_chain_fall/576/cot.json b/scipy/differential_pulley_chain_fall/576/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..2b407563a2ed2f078494016b32863fe0895a2e82 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/576/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.124 m and small radius r=0.097 m (r/R=0.783, ideal mechanical advantage MA = 2R/(R-r) = 9.24). A load M_load=14.17 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=3.772 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 3.76, the effort exceeds the lifting threshold (overload_factor OF = 2.33 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.073 N \\cdot m + viscous c_drag=2.027 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 1.259 rad/s, giving load speed 1.69 cm/s and effort speed 15.62 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 9.236.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0153 + 0.00269 + 0.0581 = 0.0760 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 4.592 - 1.968 = +2.624 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 2.33 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.038 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 1.2587 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 1.691 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 15.618 cm/s", + " Over a 12.0-s clip the load rises \\approx 20.3 cm and the effort falls \\approx 187.4 cm (ratio 9.24)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 9.236 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.038 s) the upper compound reaches its terminal \\omega_ss = 1.259 rad/s.", + "Load (M_load = 14.17 kg) rises slowly at 1.69 cm/s while effort (m_eff = 3.772 kg) falls 9.24 \\times faster --- exactly the mechanical advantage MA = 9.24.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 187.4 cm \\approx M_load \\cdot g \\cdot 20.29 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.12408181242213448, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.7834655465361582, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 14.172626115002863, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.75978959594883, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 2.3332688787480276, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.015251359195857066, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 1.2586971885962552, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.07266876954686304, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.09721382498450465, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 3.7721753508468354, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 2.0267609212346502, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/576/params.json b/scipy/differential_pulley_chain_fall/576/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f1807c0e35ddc0fe55979af03f5a1eaf0e35b32a --- /dev/null +++ b/scipy/differential_pulley_chain_fall/576/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.12408181242213448, + "r_over_R": 0.7834655465361582, + "M_load": 14.172626115002863, + "m_lp": 0.75978959594883, + "overload_factor": 2.3332688787480276, + "I_axle": 0.015251359195857066, + "omega_target": 1.2586971885962552, + "tau_friction": 0.07266876954686304, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.09721382498450465, + "m_eff": 3.7721753508468354, + "c_drag": 2.0267609212346502 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/576/simulation_code.py b/scipy/differential_pulley_chain_fall/576/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..7f46b5aad1fefa86c95d93aae8bb635cbf8060a9 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/576/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.12408181242213448 +r = 0.09721382498450465 +M_load = 14.172626115002863 +m_lp = 0.75978959594883 +m_eff = 3.7721753508468354 +I_axle = 0.015251359195857066 +tau_friction= 0.07266876954686304 +alpha_tanh = 30.0 +c_drag = 2.0267609212346502 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/576/video.mp4 b/scipy/differential_pulley_chain_fall/576/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f7623ef055be9f258958ee79fdf0a192603ccdcd --- /dev/null +++ b/scipy/differential_pulley_chain_fall/576/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6eb4597f9554719bd83743663316705c380c98132f238fd638fa2392738a8789 +size 12531 diff --git a/scipy/differential_pulley_chain_fall/636/cot.json b/scipy/differential_pulley_chain_fall/636/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c4407189d16b27d4f12752f5fbffe0f02d918bad --- /dev/null +++ b/scipy/differential_pulley_chain_fall/636/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.117 m and small radius r=0.095 m (r/R=0.816, ideal mechanical advantage MA = 2R/(R-r) = 10.88). A load M_load=20.98 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=2.914 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 7.20, the effort exceeds the lifting threshold (overload_factor OF = 1.47 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.064 N \\cdot m + viscous c_drag=1.233 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 0.816 rad/s, giving load speed 0.87 cm/s and effort speed 9.52 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 10.881.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0175 + 0.00248 + 0.0397 = 0.0596 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 3.335 - 2.265 = +1.070 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 1.47 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.048 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 0.8160 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.875 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 9.519 cm/s", + " Over a 12.0-s clip the load rises \\approx 10.5 cm and the effort falls \\approx 114.2 cm (ratio 10.88)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 10.881 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.048 s) the upper compound reaches its terminal \\omega_ss = 0.816 rad/s.", + "Load (M_load = 20.98 kg) rises slowly at 0.87 cm/s while effort (m_eff = 2.914 kg) falls 10.88 \\times faster --- exactly the mechanical advantage MA = 10.88.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 114.2 cm \\approx M_load \\cdot g \\cdot 10.50 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.1166590849429269, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.8161908604108513, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 20.9837531040083, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.553478908101372, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 1.4722576606712918, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.017473770527327893, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 0.8159999127400628, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.06405511568804845, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.0952160789143101, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 2.9141427085783445, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 1.232503410186839, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/636/params.json b/scipy/differential_pulley_chain_fall/636/params.json new file mode 100644 index 0000000000000000000000000000000000000000..109dae32906f4376192a1e97b8f476ca17ae6706 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/636/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.1166590849429269, + "r_over_R": 0.8161908604108513, + "M_load": 20.9837531040083, + "m_lp": 0.553478908101372, + "overload_factor": 1.4722576606712918, + "I_axle": 0.017473770527327893, + "omega_target": 0.8159999127400628, + "tau_friction": 0.06405511568804845, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.0952160789143101, + "m_eff": 2.9141427085783445, + "c_drag": 1.232503410186839 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/636/simulation_code.py b/scipy/differential_pulley_chain_fall/636/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ec073255c1014a1e5446ac0e785fad10fa3804a9 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/636/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.1166590849429269 +r = 0.0952160789143101 +M_load = 20.9837531040083 +m_lp = 0.553478908101372 +m_eff = 2.9141427085783445 +I_axle = 0.017473770527327893 +tau_friction= 0.06405511568804845 +alpha_tanh = 30.0 +c_drag = 1.232503410186839 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/636/video.mp4 b/scipy/differential_pulley_chain_fall/636/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..62c1a33580b87e30eb60a88477d3925ee182b981 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/636/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5952c1d49cc0aaf1676eed441ed1557d64c728ae4ed69063990d2fe7a3bb8b88 +size 13740 diff --git a/scipy/differential_pulley_chain_fall/769/cot.json b/scipy/differential_pulley_chain_fall/769/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8a706dafac639bebfa9e96ad61e6fd6d18b324a9 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/769/cot.json @@ -0,0 +1,156 @@ +{ + "simulation": "differential_pulley_chain_fall", + "physical_observation": "A Weston differential pulley with large radius R=0.093 m and small radius r=0.083 m (r/R=0.893, ideal mechanical advantage MA = 2R/(R-r) = 18.64). A load M_load=17.18 kg hangs from a single lower movable pulley; the only effort is a small weight m_eff=1.498 kg on the free end of the continuous chain. Despite M_load/m_eff \\approx 11.46, the effort exceeds the lifting threshold (overload_factor OF = 1.58 > 1) so the load rises. Friction at the upper axle (Coulomb \\tau_f=0.070 N \\cdot m + viscous c_drag=0.621 N \\cdot m \\cdot s/rad) clamps the upper-axle \\omega to a slow terminal value \\omega_ss = 0.691 rad/s, giving load speed 0.34 cm/s and effort speed 6.42 cm/s.", + "physical_law": { + "name": "Lagrangian mechanics of a differential pulley (single-DOF)", + "statement": "A continuous-chain Weston differential pulley reduces to one generalised coordinate \\phi. Kinematic constraints from the chain wrap give dh = (R-r)/2 \\cdot d\\phi for the load and dz_eff = R \\cdot d\\phi for the effort, so the velocity ratio (= ideal mechanical advantage) is 2R/(R-r). Newton's 2nd law for the system in \\phi-form is I_eff \\cdot \\ddot{\\phi} = Q_\\phi + \\tau_friction, where Q_\\phi is the net gravitational generalised force and \\tau_friction lumps Coulomb + viscous bearing torque at the upper axle.", + "formula": "MA = 2R / (R - r); I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2; Q_phi = m_eff g R - (M_load + m_lp) g (R-r)/2; I_eff phi_dotdot = Q_phi - tau_f \\tanh(alpha omega) - c_drag omega." + }, + "ode_system": { + "state_variables": [ + "phi (rad)", + "omega (rad/s)" + ], + "equations_latex": [ + "\\dot{phi} = omega", + "\\dot{omega} = (m_eff \\cdot g \\cdot R - (M_load+m_lp) \\cdot g \\cdot (R-r)/2 - tau_friction \\cdot \\tanh(alpha \\cdot omega) - c_drag \\cdot omega) / I_eff" + ], + "equations_python": [ + "phi_dot = omega", + "omega_dot = (m_eff * g * R - (M_load+m_lp) * g * (R-r)/2 - tau_friction * np.tanh (alpha * omega) - c_drag * omega) / I_eff" + ] + }, + "derivation_steps": [ + "Generalised coordinate: \\phi = upper-axle rotation angle.", + "", + "Kinematic constraints (single-DOF system). When the upper axle rotates by d\\phi, the LARGE pulley pays out R d\\phi of chain and the SMALL pulley takes up r d\\phi; the net chain delivered into the lower-pulley loop is (R - r) d\\phi. The lower pulley is supported by TWO chain segments, so the load rises by", + " dh = (R - r) d\\phi / 2, (load--rotation relation)", + "and the effort end falls by", + " dz_eff = R d\\phi, (effort--rotation relation).", + "Velocity ratio \\Rightarrow ideal mechanical advantage:", + " MA_ideal = dz_eff / dh = R / [(R - r)/2] = 2R / (R - r) = 18.638.", + "", + "Effective inertia about \\phi. Sum the kinetic energies of all moving parts:", + " T = (1/2) I_axle \\dot{\\phi}^2 (compound axle)", + " + (1/2) (M_load + m_lp) ((R-r)/2)^2 \\dot{\\phi}^2 (load + lower pulley translation)", + " + (1/2) m_eff R^2 \\dot{\\phi}^2 (effort weight)", + " \\Rightarrow I_eff = I_axle + (M_load + m_lp)((R-r)/2)^2 + m_eff R^2", + " = 0.0086 + 0.00044 + 0.0129 = 0.0219 kg \\cdot m^2.", + "", + "Generalised force from gravity on the moving masses:", + " Q_\\phi = m_eff g R - (M_load + m_lp) g (R - r)/2", + " = 1.364 - 0.865 = +0.499 N \\cdot m.", + "Q_\\phi > 0 \\Rightarrow load rises (here OF = m_eff R / [(M_load+m_lp)(R-r)/2] = 1.58 > 1).", + "", + "Static (quasi-equilibrium) force balance for the actual load lifted:", + " W (R - r)/2 = F_eff R \\Rightarrow W / F_eff = 2R / (R - r) = MA_ideal.", + " Tiny effort F_eff lifts a heavy load W with this leverage, but at the cost of MA-fold larger displacement and MA-fold larger speed of the effort end (work in = work out).", + "", + "Friction at the upper axle (regularised Coulomb + viscous):", + " \\tau_fric = - \\tau_f \\cdot \\tanh(\\alpha \\omega) - c_drag \\cdot \\omega, \\alpha = 30.0.", + "", + "Equation of motion:", + " I_eff \\cdot \\dot{\\omega} = Q_\\phi + \\tau_fric \\Rightarrow \\dot{\\omega} = (Q_\\phi + \\tau_fric) / I_eff.", + "Time constant \\tau_response = I_eff / c_drag \\approx 0.035 s (the system rapidly approaches its terminal \\omega after release).", + "", + "Terminal angular velocity (set \\tau_fric = -(\\tau_f + c_drag \\omega) and \\dot{\\omega} = 0):", + " \\omega_ss \\approx (Q_\\phi - \\tau_f) / c_drag = 0.6912 rad/s.", + " \\Rightarrow load speed v_load = (R - r)/2 \\cdot \\omega_ss = 0.344 cm/s", + " effort speed v_eff = R \\cdot \\omega_ss = 6.415 cm/s", + " Over a 12.0-s clip the load rises \\approx 4.1 cm and the effort falls \\approx 77.0 cm (ratio 18.64)." + ], + "numerical_method": { + "solver": "RK45 (Dormand-Prince 4(5))", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Smooth ODE with linear viscous damping plus \\tanh-regularised Coulomb friction; standard non-stiff RK45 with tight tolerances captures the transient and the long, slow terminal-velocity drift." + }, + "code_validation": { + "ode_source": "Single-DOF Lagrangian: I_eff \\ddot{\\phi} = Q_\\phi - \\tau_f \\tanh(\\alpha\\omega) - c_drag \\omega, with Q_\\phi and I_eff derived from the chain kinematic constraints.", + "energy_check": "P_input = m_eff \\cdot g \\cdot v_eff; P_lifted = M_load \\cdot g \\cdot v_load; P_friction = \\tau_f|\\omega| + c_drag \\cdot \\omega^2. Steady state: P_input = P_lifted + P_friction.", + "physical_plausibility": true, + "MA_ideal": 18.638 + }, + "expected_behavior": [ + "After a brief transient ( \\approx \\tau_response = 0.035 s) the upper compound reaches its terminal \\omega_ss = 0.691 rad/s.", + "Load (M_load = 17.18 kg) rises slowly at 0.34 cm/s while effort (m_eff = 1.498 kg) falls 18.64 \\times faster --- exactly the mechanical advantage MA = 18.64.", + "Total mechanical work in/out balance: F_eff \\cdot z_eff = m_eff \\cdot g \\cdot 77.0 cm \\approx M_load \\cdot g \\cdot 4.13 cm + friction loss.", + "Total system KE settles to a constant value once \\omega = \\omega_ss; the remaining energy input goes to lifting load PE plus friction dissipation." + ], + "parameters": { + "R": { + "value": 0.09280903392873077, + "unit": "m", + "description": "Large upper-pulley radius" + }, + "r_over_R": { + "value": 0.8926908441244221, + "unit": "", + "description": "r / R" + }, + "M_load": { + "value": 17.175157231199428, + "unit": "kg", + "description": "Hanging load mass" + }, + "m_lp": { + "value": 0.5373289573613222, + "unit": "kg", + "description": "Lower pulley + block mass" + }, + "overload_factor": { + "value": 1.5767527505334984, + "unit": "", + "description": "OF = effort_torque / weight_torque" + }, + "I_axle": { + "value": 0.008570053432275047, + "unit": "kg \\cdot m^2", + "description": "Upper-axle moment of inertia" + }, + "omega_target": { + "value": 0.691228116401085, + "unit": "rad/s", + "description": "Target terminal upper-axle \\omega used to derive c_drag" + }, + "tau_friction": { + "value": 0.07009688631040291, + "unit": "N \\cdot m", + "description": "Coulomb-friction torque magnitude at axle" + }, + "alpha_\\tanh": { + "value": 30.0, + "unit": "s/rad", + "description": "\\tanh smoothing for sgn(\\omega)" + }, + "g": { + "value": 9.81, + "unit": "m/s^2", + "description": "Gravity" + }, + "phi0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "r": { + "value": 0.0828497748402108, + "unit": "m", + "description": "Small upper-pulley radius" + }, + "m_eff": { + "value": 1.498476390749541, + "unit": "kg", + "description": "Effort weight mass = OF \\cdot (M_load+m_lp) \\cdot (R-r)/(2R)" + }, + "c_drag": { + "value": 0.6205519857800988, + "unit": "N \\cdot m \\cdot s/rad", + "description": "Viscous bearing damping (derived from omega_target)" + } + } +} diff --git a/scipy/differential_pulley_chain_fall/769/params.json b/scipy/differential_pulley_chain_fall/769/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f0d6617d5b4b9e2d736637de3e3b1e469d864fd0 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/769/params.json @@ -0,0 +1,17 @@ +{ + "R": 0.09280903392873077, + "r_over_R": 0.8926908441244221, + "M_load": 17.175157231199428, + "m_lp": 0.5373289573613222, + "overload_factor": 1.5767527505334984, + "I_axle": 0.008570053432275047, + "omega_target": 0.691228116401085, + "tau_friction": 0.07009688631040291, + "alpha_tanh": 30.0, + "g": 9.81, + "phi0": 0.0, + "omega0": 0.0, + "r": 0.0828497748402108, + "m_eff": 1.498476390749541, + "c_drag": 0.6205519857800988 +} \ No newline at end of file diff --git a/scipy/differential_pulley_chain_fall/769/simulation_code.py b/scipy/differential_pulley_chain_fall/769/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..69deb7f07752bad48e8e9f00c28eb0b7dc7a2eb1 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/769/simulation_code.py @@ -0,0 +1,130 @@ +""" +Differential Pulley (Weston Block) — auto-generated standalone simulation. + +Single-DOF Lagrangian: + I_eff omega_dot = Q_phi - tau_friction · tanh(alpha · omega) - c_drag · omega + Q_phi = m_eff·g·R − (M_load+m_lp)·g·(R−r)/2 + I_eff = I_axle + (M_load+m_lp)·((R−r)/2)² + m_eff·R² + Constraint: load rises by dh = (R−r)/2 · dphi; effort falls by R · dphi. + Mechanical advantage: MA = 2R / (R − r). +""" +import math +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + + +R = 0.09280903392873077 +r = 0.0828497748402108 +M_load = 17.175157231199428 +m_lp = 0.5373289573613222 +m_eff = 1.498476390749541 +I_axle = 0.008570053432275047 +tau_friction= 0.07009688631040291 +alpha_tanh = 30.0 +c_drag = 0.6205519857800988 +g = 9.81 +phi0 = 0.0 +omega0 = 0.0 +duration = 12 +fps = 30 +I_eff = I_axle + (M_load + m_lp) * ((R - r) / 2.0) ** 2 + m_eff * R * R + +def ode(t, y): + phi, omega = y + Q_phi = m_eff * g * R - (M_load + m_lp) * g * (R - r) / 2.0 + tau_f = -tau_friction * np.tanh(alpha_tanh * omega) - c_drag * omega + return [omega, (Q_phi + tau_f) / I_eff] + +t_eval = np.linspace(0.0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0.0, duration), [phi0, omega0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +t = sol.t; phi = sol.y[0]; omega = sol.y[1] + + +y_top = 2.5; ceiling_y = y_top + 0.30 +x_large = -R - 0.06; x_small = +r + 0.06 +y_lower_init = 1.20; r_lp = 0.06 +load_w = 0.32; load_h = 0.30 +eff_w = 0.16; eff_h = 0.16 +y_eff_init = y_top - 0.50 +h_load = (R - r) / 2.0 * phi +z_eff = -R * phi +y_lower_t = y_lower_init + h_load +y_eff_top_t = y_eff_init + z_eff +load_top_t = y_lower_t - r_lp - 0.05 +load_bot_t = load_top_t - load_h +eff_bot_t = y_eff_top_t - eff_h +pad_x = R + 0.30 +x_min = x_large - R - pad_x +x_max = x_small + r + pad_x +y_min = float(min(np.min(load_bot_t), np.min(eff_bot_t))) - 0.20 +y_max = ceiling_y + 0.50 + +fig, ax = plt.subplots(figsize=(7, 9), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(x_min, x_max); ax.set_ylim(y_min, y_max) +ax.set_aspect("equal"); ax.axis("off") + +ax.axhline(ceiling_y, color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_large], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_small, x_small], [y_top, ceiling_y], color="#4a4e69", lw=2.5, zorder=1) +ax.plot([x_large, x_small], [y_top, y_top], color="#adb5bd", lw=2.5, zorder=2) + +ax.add_patch(patches.Circle((x_large, y_top), R, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) +ax.add_patch(patches.Circle((x_small, y_top), r, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3)) + +eff_top_x = x_large - R +chain_L_top = (x_large + R, y_top) +chain_R_top = (x_small - r, y_top) + +spoke_large, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_small, = ax.plot([], [], "-", color="#e63946", lw=2.0, zorder=4) +spoke_lower, = ax.plot([], [], "-", color="#e63946", lw=1.5, zorder=4) +lower_pulley = patches.Circle((0, y_lower_init), r_lp, facecolor="none", + edgecolor="#a8dadc", lw=2.0, zorder=3) +ax.add_patch(lower_pulley) +chain_left, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_right, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +chain_under, = ax.plot([], [], "-", color="#ffd166", lw=2.2, zorder=2) +eff_rope, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +eff_block = patches.FancyBboxPatch((eff_top_x - eff_w/2, 0), eff_w, eff_h, + boxstyle="round,pad=0.005", facecolor="#f4a261", edgecolor="white", lw=1.2, zorder=4) +ax.add_patch(eff_block) +load_chain_top, = ax.plot([], [], "-", color="#ffd166", lw=2.0, zorder=2) +load_block = patches.FancyBboxPatch((-load_w/2, 0), load_w, load_h, + boxstyle="round,pad=0.005", facecolor="#e63946", edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(load_block) + +def update(frame): + ph = float(phi[frame]) + spoke_large.set_data([x_large, x_large + R * math.cos(ph)], + [y_top, y_top + R * math.sin(ph)]) + spoke_small.set_data([x_small, x_small + r * math.cos(ph)], + [y_top, y_top + r * math.sin(ph)]) + y_lp = y_lower_init + (R - r) / 2.0 * ph + lower_pulley.center = (0, y_lp) + ph_lp = -ph * (R + r) / (2.0 * r_lp) + spoke_lower.set_data([0, r_lp * math.cos(ph_lp)], + [y_lp, y_lp + r_lp * math.sin(ph_lp)]) + chain_left.set_data([chain_L_top[0], -r_lp], [chain_L_top[1], y_lp]) + chain_right.set_data([chain_R_top[0], +r_lp], [chain_R_top[1], y_lp]) + theta = np.linspace(math.pi, 2.0 * math.pi, 30) + chain_under.set_data(r_lp * np.cos(theta), y_lp + r_lp * np.sin(theta)) + y_eff_top = y_eff_init + z_eff[frame] + eff_rope.set_data([eff_top_x, eff_top_x], [y_top, y_eff_top]) + eff_block.set_y(y_eff_top - eff_h) + load_chain_top.set_data([0, 0], [y_lp - r_lp, y_lp - r_lp - 0.05]) + load_block.set_y(y_lp - r_lp - 0.05 - load_h) + return [spoke_large, spoke_small, spoke_lower, lower_pulley, + chain_left, chain_right, chain_under, eff_rope, eff_block, + load_chain_top, load_block] + +ani = animation.FuncAnimation(fig, update, frames=len(t), + interval=1000 / fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved video.mp4") diff --git a/scipy/differential_pulley_chain_fall/769/video.mp4 b/scipy/differential_pulley_chain_fall/769/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9dbd4ea1a81f7c5b6e033acb0a86d0bf27df9e77 --- /dev/null +++ b/scipy/differential_pulley_chain_fall/769/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec036cff7abd087754130606dc87667971b2f7abf529d65141985a07564ebf90 +size 11590 diff --git a/scipy/discs_friction_coupling/008/cot.json b/scipy/discs_friction_coupling/008/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..61d30fde867112ba9572d8f84c575ffe3ebf6ff9 --- /dev/null +++ b/scipy/discs_friction_coupling/008/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.465 kg, R1=0.350 m; m2=0.298 kg, R2=0.217 m) spin CCW at omega1_0=7.809 rad/s and omega2_0=13.489 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.421 N presses the rims with friction mu_k=0.079, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -2.3431, alpha_2 = -5.9081", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 5.6931", + "after no-slip: omega_1 = 1.4987, omega_2 = -2.4223" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -2.3431, alpha_2 = -5.9081", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 5.6931", + "after no-slip: omega_1 = 1.4987, omega_2 = -2.4223" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.02857 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.00701 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -5.6609 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -2.3431, alpha_2 = -5.9081 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 2.6931 s.", + "Final angular velocities: omega_1 -> 1.4987, omega_2 -> -2.4223 rad/s; check omega_1 R_1 + omega_2 R_2 = 2.220e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.02856870923024208, + "I_2_kg_m2": 0.007009874844359908, + "s_0_m_s": -5.660911948691858, + "delta_t_slip_s": 2.6930930984973913, + "t_no_slip_s": 5.693093098497391, + "omega_1_final_rad_s": 1.4986805688337022, + "omega_2_final_rad_s": -2.4222904145278576 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 2.693 s.", + "After no-slip, both discs spin at constant 1.499 and -2.422 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.4652953075359218, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.298251465373071, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.350425717226458, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.2168097640469221, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 7.808796947167135, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 13.488823672960205, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.0788868603207045, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.421452635471068, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/008/params.json b/scipy/discs_friction_coupling/008/params.json new file mode 100644 index 0000000000000000000000000000000000000000..52359f4eb4fe16e14bb410623a3f3c737b27b8fd --- /dev/null +++ b/scipy/discs_friction_coupling/008/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.4652953075359218, + "m_2": 0.298251465373071, + "R_1": 0.350425717226458, + "R_2": 0.2168097640469221, + "omega_1_0": 7.808796947167135, + "omega_2_0": 13.488823672960205, + "mu_k": 0.0788868603207045, + "F_n": 2.421452635471068, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/008/simulation_code.py b/scipy/discs_friction_coupling/008/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..fea68e8554b0cfa99f3b83e0cefc799f431d0244 --- /dev/null +++ b/scipy/discs_friction_coupling/008/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.4652953075359218 +m_2 = 0.298251465373071 +R_1 = 0.350425717226458 +R_2 = 0.2168097640469221 +omega_1_0 = 7.808796947167135 +omega_2_0 = 13.488823672960205 +mu_k = 0.0788868603207045 +F_n = 2.421452635471068 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/008/video.mp4 b/scipy/discs_friction_coupling/008/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4e5e0c66fc801f168d8765c550cda737f6b387bc --- /dev/null +++ b/scipy/discs_friction_coupling/008/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6024bcfe5d683cecc4a8e40166d5d7938e89e4e2c9e0979413cfb5ec963e9a6 +size 88762 diff --git a/scipy/discs_friction_coupling/070/cot.json b/scipy/discs_friction_coupling/070/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..d48e418d6e75b0bc8d63d82bb0f7c7b456220710 --- /dev/null +++ b/scipy/discs_friction_coupling/070/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.403 kg, R1=0.371 m; m2=0.458 kg, R2=0.225 m) spin CCW at omega1_0=9.383 rad/s and omega2_0=10.805 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=3.681 N presses the rims with friction mu_k=0.034, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.6693, alpha_2 = -2.4223", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 8.0775", + "after no-slip: omega_1 = 0.9073, omega_2 = -1.4943" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.6693, alpha_2 = -2.4223", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 8.0775", + "after no-slip: omega_1 = 0.9073, omega_2 = -1.4943" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.02780 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.01163 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -5.9193 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.6693, alpha_2 = -2.4223 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 5.0775 s.", + "Final angular velocities: omega_1 -> 0.9073, omega_2 -> -1.4943 rad/s; check omega_1 R_1 + omega_2 R_2 = 8.327e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.027800619290727257, + "I_2_kg_m2": 0.011632474901806994, + "s_0_m_s": -5.919347563828347, + "delta_t_slip_s": 5.077516780131528, + "t_no_slip_s": 8.077516780131528, + "omega_1_final_rad_s": 0.9072573881574257, + "omega_2_final_rad_s": -1.4942596047316243 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 5.078 s.", + "After no-slip, both discs spin at constant 0.907 and -1.494 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.4033893516988649, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.4578604900092665, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.37126158811765775, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.22541586327584587, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 9.383391830295679, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 10.805160628832759, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.03396243472915017, + "unit": "", + "description": "" + }, + "F_n": { + "value": 3.680629518201978, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/070/params.json b/scipy/discs_friction_coupling/070/params.json new file mode 100644 index 0000000000000000000000000000000000000000..4d5ff3493dcea40ac649e24d1bcddb9582f2b873 --- /dev/null +++ b/scipy/discs_friction_coupling/070/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.4033893516988649, + "m_2": 0.4578604900092665, + "R_1": 0.37126158811765775, + "R_2": 0.22541586327584587, + "omega_1_0": 9.383391830295679, + "omega_2_0": 10.805160628832759, + "mu_k": 0.03396243472915017, + "F_n": 3.680629518201978, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/070/simulation_code.py b/scipy/discs_friction_coupling/070/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..918c6cd1e6915bf63f91be27462288c10c12a448 --- /dev/null +++ b/scipy/discs_friction_coupling/070/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.4033893516988649 +m_2 = 0.4578604900092665 +R_1 = 0.37126158811765775 +R_2 = 0.22541586327584587 +omega_1_0 = 9.383391830295679 +omega_2_0 = 10.805160628832759 +mu_k = 0.03396243472915017 +F_n = 3.680629518201978 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/070/video.mp4 b/scipy/discs_friction_coupling/070/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ceafb783cc497cd6ab00f30b2a648027eb7fc9b6 --- /dev/null +++ b/scipy/discs_friction_coupling/070/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5ca1a184f81b3172b645bbbde3ff0fa69c654cfa331700260feada69f5f26b3 +size 88670 diff --git a/scipy/discs_friction_coupling/161/cot.json b/scipy/discs_friction_coupling/161/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4925bab4327971bc3b8ee74b05e3c7b57a59d331 --- /dev/null +++ b/scipy/discs_friction_coupling/161/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.444 kg, R1=0.349 m; m2=0.285 kg, R2=0.252 m) spin CCW at omega1_0=9.904 rad/s and omega2_0=9.656 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.504 N presses the rims with friction mu_k=0.042, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.3543, alpha_2 = -2.9297", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 7.8660", + "after no-slip: omega_1 = 3.3133, omega_2 = -4.6000" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.3543, alpha_2 = -2.9297", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 7.8660", + "after no-slip: omega_1 = 3.3133, omega_2 = -4.6000" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.02710 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.00902 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -5.8916 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.3543, alpha_2 = -2.9297 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 4.8660 s.", + "Final angular velocities: omega_1 -> 3.3133, omega_2 -> -4.6000 rad/s; check omega_1 R_1 + omega_2 R_2 = 8.882e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.027101329904281973, + "I_2_kg_m2": 0.00902416181732823, + "s_0_m_s": -5.891569303723469, + "delta_t_slip_s": 4.866020912738596, + "t_no_slip_s": 7.866020912738595, + "omega_1_final_rad_s": 3.3133452265592602, + "omega_2_final_rad_s": -4.599956643890103 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 4.866 s.", + "After no-slip, both discs spin at constant 3.313 and -4.600 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.4438307401193424, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.28484444181541374, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.34946332924076645, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.2517181668082398, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 9.903614382147502, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 9.656113744357297, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.04194525090894393, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.5040060702103095, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/161/params.json b/scipy/discs_friction_coupling/161/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a6fb3cdb1e453b98091ad171e984e521f2f683e7 --- /dev/null +++ b/scipy/discs_friction_coupling/161/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.4438307401193424, + "m_2": 0.28484444181541374, + "R_1": 0.34946332924076645, + "R_2": 0.2517181668082398, + "omega_1_0": 9.903614382147502, + "omega_2_0": 9.656113744357297, + "mu_k": 0.04194525090894393, + "F_n": 2.5040060702103095, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/161/simulation_code.py b/scipy/discs_friction_coupling/161/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..150a292ffeca044213d4de7d0b347aa5b2735902 --- /dev/null +++ b/scipy/discs_friction_coupling/161/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.4438307401193424 +m_2 = 0.28484444181541374 +R_1 = 0.34946332924076645 +R_2 = 0.2517181668082398 +omega_1_0 = 9.903614382147502 +omega_2_0 = 9.656113744357297 +mu_k = 0.04194525090894393 +F_n = 2.5040060702103095 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/161/video.mp4 b/scipy/discs_friction_coupling/161/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f6353809fb7d94af6e0267ac4473af99bebddb95 --- /dev/null +++ b/scipy/discs_friction_coupling/161/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a14f63dbb95b615de6a78ee2a09ad328e82df2cf44e770b97bacdd35253760d4 +size 93145 diff --git a/scipy/discs_friction_coupling/250/cot.json b/scipy/discs_friction_coupling/250/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..2817b32efa7d53a82b88d08a487374caeeda5082 --- /dev/null +++ b/scipy/discs_friction_coupling/250/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.387 kg, R1=0.432 m; m2=0.330 kg, R2=0.210 m) spin CCW at omega1_0=8.890 rad/s and omega2_0=10.721 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.911 N presses the rims with friction mu_k=0.048, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.6727, alpha_2 = -4.0441", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 6.8769", + "after no-slip: omega_1 = 2.4046, omega_2 = -4.9575" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.6727, alpha_2 = -4.0441", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 6.8769", + "after no-slip: omega_1 = 2.4046, omega_2 = -4.9575" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.03611 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.00724 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -6.0887 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.6727, alpha_2 = -4.0441 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 3.8769 s.", + "Final angular velocities: omega_1 -> 2.4046, omega_2 -> -4.9575 rad/s; check omega_1 R_1 + omega_2 R_2 = 1.776e-15 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.03610713587933544, + "I_2_kg_m2": 0.007244076129603937, + "s_0_m_s": -6.088729079219483, + "delta_t_slip_s": 3.8769028309068667, + "t_no_slip_s": 6.876902830906866, + "omega_1_final_rad_s": 2.404621994143284, + "omega_2_final_rad_s": -4.957459942111768 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 3.877 s.", + "After no-slip, both discs spin at constant 2.405 and -4.957 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.3867184984832108, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.32976891044281176, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.43212962881447203, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.20960500375230745, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 8.88967831741783, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 10.721288363369602, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.04801786696120247, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.910750413841498, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/250/params.json b/scipy/discs_friction_coupling/250/params.json new file mode 100644 index 0000000000000000000000000000000000000000..4949601a5810d86efcb16561c9ff6153aaea5a93 --- /dev/null +++ b/scipy/discs_friction_coupling/250/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.3867184984832108, + "m_2": 0.32976891044281176, + "R_1": 0.43212962881447203, + "R_2": 0.20960500375230745, + "omega_1_0": 8.88967831741783, + "omega_2_0": 10.721288363369602, + "mu_k": 0.04801786696120247, + "F_n": 2.910750413841498, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/250/simulation_code.py b/scipy/discs_friction_coupling/250/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5578e9c79489e77cab6ff4623b350de3921998e4 --- /dev/null +++ b/scipy/discs_friction_coupling/250/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.3867184984832108 +m_2 = 0.32976891044281176 +R_1 = 0.43212962881447203 +R_2 = 0.20960500375230745 +omega_1_0 = 8.88967831741783 +omega_2_0 = 10.721288363369602 +mu_k = 0.04801786696120247 +F_n = 2.910750413841498 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/250/video.mp4 b/scipy/discs_friction_coupling/250/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..efd948ee36f92431faae41bfff9d0f13ad6fbc23 --- /dev/null +++ b/scipy/discs_friction_coupling/250/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:882f52023434706c45788ff95a540503d33deb45451dbe5c2db2c7fc45c82ed3 +size 88572 diff --git a/scipy/discs_friction_coupling/291/cot.json b/scipy/discs_friction_coupling/291/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..02c2a8bca72dd8e905e313ba9732acb68ba5c67e --- /dev/null +++ b/scipy/discs_friction_coupling/291/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.613 kg, R1=0.390 m; m2=0.419 kg, R2=0.202 m) spin CCW at omega1_0=5.648 rad/s and omega2_0=9.248 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=3.664 N presses the rims with friction mu_k=0.049, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.5004, alpha_2 = -4.2487", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 5.8210", + "after no-slip: omega_1 = 1.4158, omega_2 = -2.7378" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.5004, alpha_2 = -4.2487", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 5.8210", + "after no-slip: omega_1 = 1.4158, omega_2 = -2.7378" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.04668 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.00852 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -4.0709 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.5004, alpha_2 = -4.2487 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 2.8210 s.", + "Final angular velocities: omega_1 -> 1.4158, omega_2 -> -2.7378 rad/s; check omega_1 R_1 + omega_2 R_2 = 1.110e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.04667772299763482, + "I_2_kg_m2": 0.008524665800448921, + "s_0_m_s": -4.070878206219448, + "delta_t_slip_s": 2.820952853211925, + "t_no_slip_s": 5.820952853211924, + "omega_1_final_rad_s": 1.4158263240999345, + "omega_2_final_rad_s": -2.7377976370058192 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 2.821 s.", + "After no-slip, both discs spin at constant 1.416 and -2.738 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.6129072777262103, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.4185479323750315, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.3902765344526689, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.20182784282073257, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 5.648458180037527, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 9.24757207245861, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.04897766537527738, + "unit": "", + "description": "" + }, + "F_n": { + "value": 3.663986047505489, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/291/params.json b/scipy/discs_friction_coupling/291/params.json new file mode 100644 index 0000000000000000000000000000000000000000..52d2de3dff79eba28004b6b9ed9924b072dcda3f --- /dev/null +++ b/scipy/discs_friction_coupling/291/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.6129072777262103, + "m_2": 0.4185479323750315, + "R_1": 0.3902765344526689, + "R_2": 0.20182784282073257, + "omega_1_0": 5.648458180037527, + "omega_2_0": 9.24757207245861, + "mu_k": 0.04897766537527738, + "F_n": 3.663986047505489, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/291/simulation_code.py b/scipy/discs_friction_coupling/291/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..0e4e3daab5c2063119673f6879dca0630a2c6e65 --- /dev/null +++ b/scipy/discs_friction_coupling/291/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.6129072777262103 +m_2 = 0.4185479323750315 +R_1 = 0.3902765344526689 +R_2 = 0.20182784282073257 +omega_1_0 = 5.648458180037527 +omega_2_0 = 9.24757207245861 +mu_k = 0.04897766537527738 +F_n = 3.663986047505489 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/291/video.mp4 b/scipy/discs_friction_coupling/291/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..97e09bb3c70178d5bfb23adf88007f1f463c70cb --- /dev/null +++ b/scipy/discs_friction_coupling/291/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2269bc6adbe6f8707d9f084240012282c415ba4a6c35557887f738c885c2f6be +size 90905 diff --git a/scipy/discs_friction_coupling/309/cot.json b/scipy/discs_friction_coupling/309/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..16a2945f68edb0c6a78287942a0a5a26bb6ed976 --- /dev/null +++ b/scipy/discs_friction_coupling/309/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.570 kg, R1=0.312 m; m2=0.380 kg, R2=0.224 m) spin CCW at omega1_0=6.839 rad/s and omega2_0=12.883 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.802 N presses the rims with friction mu_k=0.050, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.5853, alpha_2 = -3.3026", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 7.0661", + "after no-slip: omega_1 = 0.3930, omega_2 = -0.5459" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.5853, alpha_2 = -3.3026", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 7.0661", + "after no-slip: omega_1 = 0.3930, omega_2 = -0.5459" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.02770 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.00957 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -5.0241 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.5853, alpha_2 = -3.3026 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 4.0661 s.", + "Final angular velocities: omega_1 -> 0.3930, omega_2 -> -0.5459 rad/s; check omega_1 R_1 + omega_2 R_2 = -4.441e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.02770437984899227, + "I_2_kg_m2": 0.00957252798564487, + "s_0_m_s": -5.024128017171037, + "delta_t_slip_s": 4.066070700479386, + "t_no_slip_s": 7.066070700479386, + "omega_1_final_rad_s": 0.39296734641774567, + "omega_2_final_rad_s": -0.5459178515035301 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 4.066 s.", + "After no-slip, both discs spin at constant 0.393 and -0.546 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.5698507352039417, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.37999771751416367, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.31182336791455634, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.22445941473235684, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 6.838795268114301, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 12.882648952985363, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.05026023958959986, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.8023282324243577, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/309/params.json b/scipy/discs_friction_coupling/309/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a4eea80023125d134fd85a2fbfc16746e42135fc --- /dev/null +++ b/scipy/discs_friction_coupling/309/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.5698507352039417, + "m_2": 0.37999771751416367, + "R_1": 0.31182336791455634, + "R_2": 0.22445941473235684, + "omega_1_0": 6.838795268114301, + "omega_2_0": 12.882648952985363, + "mu_k": 0.05026023958959986, + "F_n": 2.8023282324243577, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/309/simulation_code.py b/scipy/discs_friction_coupling/309/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..70cc92afa69ba4c55ca826f797a4489a9278a364 --- /dev/null +++ b/scipy/discs_friction_coupling/309/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.5698507352039417 +m_2 = 0.37999771751416367 +R_1 = 0.31182336791455634 +R_2 = 0.22445941473235684 +omega_1_0 = 6.838795268114301 +omega_2_0 = 12.882648952985363 +mu_k = 0.05026023958959986 +F_n = 2.8023282324243577 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/309/video.mp4 b/scipy/discs_friction_coupling/309/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d82200aeffdd5236a5b68cf703901a4c0e0f6126 --- /dev/null +++ b/scipy/discs_friction_coupling/309/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbbedcb393b02c0325f45ae43e2b41036d9bc88d38dc17f4acbf70bfec03d4f9 +size 84822 diff --git a/scipy/discs_friction_coupling/378/cot.json b/scipy/discs_friction_coupling/378/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e05a3d9d5e7ea53d9324c32b0e26d6bb04d9c7a6 --- /dev/null +++ b/scipy/discs_friction_coupling/378/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.678 kg, R1=0.363 m; m2=0.480 kg, R2=0.262 m) spin CCW at omega1_0=5.396 rad/s and omega2_0=8.240 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.591 N presses the rims with friction mu_k=0.080, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.6782, alpha_2 = -3.2836", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 5.8021", + "after no-slip: omega_1 = 0.6933, omega_2 = -0.9616" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.6782, alpha_2 = -3.2836", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 5.8021", + "after no-slip: omega_1 = 0.6933, omega_2 = -0.9616" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.04474 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.01649 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -4.1200 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.6782, alpha_2 = -3.2836 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 2.8021 s.", + "Final angular velocities: omega_1 -> 0.6933, omega_2 -> -0.9616 rad/s; check omega_1 R_1 + omega_2 R_2 = 5.551e-17 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.04474416488333092, + "I_2_kg_m2": 0.016486954157157636, + "s_0_m_s": -4.119978070603048, + "delta_t_slip_s": 2.802118469653324, + "t_no_slip_s": 5.8021184696533235, + "omega_1_final_rad_s": 0.6932624672401113, + "omega_2_final_rad_s": -0.9615572186954111 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 2.802 s.", + "After no-slip, both discs spin at constant 0.693 and -0.962 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.6775042926014379, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.48025396951696575, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.3634353569919522, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.26202922444113286, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 5.395675832524448, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 8.239533978705932, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.07973455519665446, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.5911763172873785, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/378/params.json b/scipy/discs_friction_coupling/378/params.json new file mode 100644 index 0000000000000000000000000000000000000000..075ea022b5d5263d1089a7e6d74c507c245f8aa4 --- /dev/null +++ b/scipy/discs_friction_coupling/378/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.6775042926014379, + "m_2": 0.48025396951696575, + "R_1": 0.3634353569919522, + "R_2": 0.26202922444113286, + "omega_1_0": 5.395675832524448, + "omega_2_0": 8.239533978705932, + "mu_k": 0.07973455519665446, + "F_n": 2.5911763172873785, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/378/simulation_code.py b/scipy/discs_friction_coupling/378/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..47a7d0577e12bebb0a21a236131621f96c789d06 --- /dev/null +++ b/scipy/discs_friction_coupling/378/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.6775042926014379 +m_2 = 0.48025396951696575 +R_1 = 0.3634353569919522 +R_2 = 0.26202922444113286 +omega_1_0 = 5.395675832524448 +omega_2_0 = 8.239533978705932 +mu_k = 0.07973455519665446 +F_n = 2.5911763172873785 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/378/video.mp4 b/scipy/discs_friction_coupling/378/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7d8d17f5d3e4795072239eeb1425882a6d43b0f5 --- /dev/null +++ b/scipy/discs_friction_coupling/378/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d95c40835484472d281e441692a13545f8691a692bb4c2e2fb9999ce169f0c6 +size 93665 diff --git a/scipy/discs_friction_coupling/448/cot.json b/scipy/discs_friction_coupling/448/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..29719e765667872d884db37965eee68e570e2c15 --- /dev/null +++ b/scipy/discs_friction_coupling/448/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.399 kg, R1=0.371 m; m2=0.289 kg, R2=0.253 m) spin CCW at omega1_0=5.709 rad/s and omega2_0=13.848 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.501 N presses the rims with friction mu_k=0.057, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.9147, alpha_2 = -3.8798", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 6.3226", + "after no-slip: omega_1 = -0.6528, omega_2 = 0.9570" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.9147, alpha_2 = -3.8798", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 6.3226", + "after no-slip: omega_1 = -0.6528, omega_2 = 0.9570" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.02752 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.00926 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -5.6291 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.9147, alpha_2 = -3.8798 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 3.3226 s.", + "Final angular velocities: omega_1 -> -0.6528, omega_2 -> 0.9570 rad/s; check omega_1 R_1 + omega_2 R_2 = 6.384e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.027515951315024264, + "I_2_kg_m2": 0.009263294046375912, + "s_0_m_s": -5.629130074780075, + "delta_t_slip_s": 3.3226496243836823, + "t_no_slip_s": 6.322649624383682, + "omega_1_final_rad_s": -0.6528496607809142, + "omega_2_final_rad_s": 0.9570075067402541 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 3.323 s.", + "After no-slip, both discs spin at constant -0.653 and 0.957 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.39893458004015303, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.2885937516842049, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.3714124200777074, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.2533694571356816, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 5.708967545282484, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 13.84834881957636, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.05670961162912347, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.5013132065242822, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/448/params.json b/scipy/discs_friction_coupling/448/params.json new file mode 100644 index 0000000000000000000000000000000000000000..88d51cb016c78755c4714c7c10c0803e303b668e --- /dev/null +++ b/scipy/discs_friction_coupling/448/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.39893458004015303, + "m_2": 0.2885937516842049, + "R_1": 0.3714124200777074, + "R_2": 0.2533694571356816, + "omega_1_0": 5.708967545282484, + "omega_2_0": 13.84834881957636, + "mu_k": 0.05670961162912347, + "F_n": 2.5013132065242822, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/448/simulation_code.py b/scipy/discs_friction_coupling/448/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..896edd89375bcacbc4c69a9300b0a4cdb90fa17b --- /dev/null +++ b/scipy/discs_friction_coupling/448/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.39893458004015303 +m_2 = 0.2885937516842049 +R_1 = 0.3714124200777074 +R_2 = 0.2533694571356816 +omega_1_0 = 5.708967545282484 +omega_2_0 = 13.84834881957636 +mu_k = 0.05670961162912347 +F_n = 2.5013132065242822 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/448/video.mp4 b/scipy/discs_friction_coupling/448/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e3bc96c6cc931f35ae79ec5d33578c05f5b41d60 --- /dev/null +++ b/scipy/discs_friction_coupling/448/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c2f0826b9d83944fce02065121fa8a61b7c5d4110e9fa4bdccba1abc909ea6d +size 89618 diff --git a/scipy/discs_friction_coupling/541/cot.json b/scipy/discs_friction_coupling/541/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8787cc594f868b9edde53c9ff0632f21083bdaa8 --- /dev/null +++ b/scipy/discs_friction_coupling/541/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.484 kg, R1=0.426 m; m2=0.380 kg, R2=0.216 m) spin CCW at omega1_0=8.953 rad/s and omega2_0=11.592 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=3.552 N presses the rims with friction mu_k=0.035, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.2000, alpha_2 = -3.0223", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 8.4284", + "after no-slip: omega_1 = 2.4385, omega_2 = -4.8136" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.2000, alpha_2 = -3.0223", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 8.4284", + "after no-slip: omega_1 = 2.4385, omega_2 = -4.8136" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.04396 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.00884 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -6.3160 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.2000, alpha_2 = -3.0223 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 5.4284 s.", + "Final angular velocities: omega_1 -> 2.4385, omega_2 -> -4.8136 rad/s; check omega_1 R_1 + omega_2 R_2 = 0.000e+00 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.04396384381600992, + "I_2_kg_m2": 0.00884343715445638, + "s_0_m_s": -6.316027082012848, + "delta_t_slip_s": 5.428404920942379, + "t_no_slip_s": 8.428404920942379, + "omega_1_final_rad_s": 2.438531989953953, + "omega_2_final_rad_s": -4.813586436263719 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 5.428 s.", + "After no-slip, both discs spin at constant 2.439 and -4.814 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.4844614915120154, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.37972162815091115, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.4260231459232521, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.21582059106038146, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 8.952870823031617, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 11.592484649624804, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.03486047083589551, + "unit": "", + "description": "" + }, + "F_n": { + "value": 3.552444659987209, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/541/params.json b/scipy/discs_friction_coupling/541/params.json new file mode 100644 index 0000000000000000000000000000000000000000..816b0fb4bb27af36da692f3edba0a7648cb1169e --- /dev/null +++ b/scipy/discs_friction_coupling/541/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.4844614915120154, + "m_2": 0.37972162815091115, + "R_1": 0.4260231459232521, + "R_2": 0.21582059106038146, + "omega_1_0": 8.952870823031617, + "omega_2_0": 11.592484649624804, + "mu_k": 0.03486047083589551, + "F_n": 3.552444659987209, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/541/simulation_code.py b/scipy/discs_friction_coupling/541/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..18e355e02d03401df61894a4d452dea8eb193aff --- /dev/null +++ b/scipy/discs_friction_coupling/541/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.4844614915120154 +m_2 = 0.37972162815091115 +R_1 = 0.4260231459232521 +R_2 = 0.21582059106038146 +omega_1_0 = 8.952870823031617 +omega_2_0 = 11.592484649624804 +mu_k = 0.03486047083589551 +F_n = 3.552444659987209 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/541/video.mp4 b/scipy/discs_friction_coupling/541/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c4c1ea99f29bb6a392f873b04562bee4ff467488 --- /dev/null +++ b/scipy/discs_friction_coupling/541/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:773a79b306b7e7bc2b8dd3fbd9f8ec0825c9ee60b7426563d65571dea8f46888 +size 93398 diff --git a/scipy/discs_friction_coupling/556/cot.json b/scipy/discs_friction_coupling/556/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6294b1aa9c00715d670634b5d9ed6b7a9593eeab --- /dev/null +++ b/scipy/discs_friction_coupling/556/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.569 kg, R1=0.317 m; m2=0.319 kg, R2=0.273 m) spin CCW at omega1_0=7.017 rad/s and omega2_0=13.823 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=3.211 N presses the rims with friction mu_k=0.079, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -2.8097, alpha_2 = -5.8212", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 5.4188", + "after no-slip: omega_1 = 0.2213, omega_2 = -0.2571" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -2.8097, alpha_2 = -5.8212", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 5.4188", + "after no-slip: omega_1 = 0.2213, omega_2 = -0.2571" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.02861 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.01188 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -6.0004 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -2.8097, alpha_2 = -5.8212 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 2.4188 s.", + "Final angular velocities: omega_1 -> 0.2213, omega_2 -> -0.2571 rad/s; check omega_1 R_1 + omega_2 R_2 = 8.604e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.028611721503818157, + "I_2_kg_m2": 0.011884169456103924, + "s_0_m_s": -6.000439907786305, + "delta_t_slip_s": 2.4188149034600004, + "t_no_slip_s": 5.4188149034599995, + "omega_1_final_rad_s": 0.2212507857280439, + "omega_2_final_rad_s": -0.25710001618859657 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 2.419 s.", + "After no-slip, both discs spin at constant 0.221 and -0.257 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.5685071302213917, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.31885653860546015, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.31726271352681285, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.27302458276986763, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 7.017319168485389, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 13.823320041075226, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.07891666654177693, + "unit": "", + "description": "" + }, + "F_n": { + "value": 3.210785749388025, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/556/params.json b/scipy/discs_friction_coupling/556/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7c0f17a4de68422ef24f2c033908210336c7c4e5 --- /dev/null +++ b/scipy/discs_friction_coupling/556/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.5685071302213917, + "m_2": 0.31885653860546015, + "R_1": 0.31726271352681285, + "R_2": 0.27302458276986763, + "omega_1_0": 7.017319168485389, + "omega_2_0": 13.823320041075226, + "mu_k": 0.07891666654177693, + "F_n": 3.210785749388025, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/556/simulation_code.py b/scipy/discs_friction_coupling/556/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..e878ed8cd2c6a89125d2f1897db59a1213774ee3 --- /dev/null +++ b/scipy/discs_friction_coupling/556/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.5685071302213917 +m_2 = 0.31885653860546015 +R_1 = 0.31726271352681285 +R_2 = 0.27302458276986763 +omega_1_0 = 7.017319168485389 +omega_2_0 = 13.823320041075226 +mu_k = 0.07891666654177693 +F_n = 3.210785749388025 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/556/video.mp4 b/scipy/discs_friction_coupling/556/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..1e79acb7a5f94a16273c489f5e38f003bbb658c0 --- /dev/null +++ b/scipy/discs_friction_coupling/556/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7b62249a0be857b7ba497964da7b7c810b6d894c88b9d70c92af2c44e8302e2 +size 79197 diff --git a/scipy/discs_friction_coupling/567/cot.json b/scipy/discs_friction_coupling/567/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..b58170b3afc9299b16cb16ce296c7ee3b17ad83d --- /dev/null +++ b/scipy/discs_friction_coupling/567/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.353 kg, R1=0.444 m; m2=0.481 kg, R2=0.291 m) spin CCW at omega1_0=6.135 rad/s and omega2_0=10.284 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.719 N presses the rims with friction mu_k=0.050, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.7310, alpha_2 = -1.9335", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 7.2943", + "after no-slip: omega_1 = -1.2988, omega_2 = 1.9807" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.7310, alpha_2 = -1.9335", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 7.2943", + "after no-slip: omega_1 = -1.2988, omega_2 = 1.9807" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.03469 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.02037 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -5.7121 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.7310, alpha_2 = -1.9335 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 4.2943 s.", + "Final angular velocities: omega_1 -> -1.2988, omega_2 -> 1.9807 rad/s; check omega_1 R_1 + omega_2 R_2 = 1.776e-15 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.03469219889642408, + "I_2_kg_m2": 0.02036580248023324, + "s_0_m_s": -5.712140067958685, + "delta_t_slip_s": 4.294312488891231, + "t_no_slip_s": 7.294312488891231, + "omega_1_final_rad_s": -1.298790615201228, + "omega_2_final_rad_s": 1.9807156884376322 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 4.294 s.", + "After no-slip, both discs spin at constant -1.299 and 1.981 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.35265717607095404, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.4814912781101204, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.44356222045162785, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.2908516616207607, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 6.1346414149806705, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 10.283746991809672, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.04978705923389114, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.719296318891576, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/567/params.json b/scipy/discs_friction_coupling/567/params.json new file mode 100644 index 0000000000000000000000000000000000000000..0012664eae048f7e84188bf8e457629915bcda80 --- /dev/null +++ b/scipy/discs_friction_coupling/567/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.35265717607095404, + "m_2": 0.4814912781101204, + "R_1": 0.44356222045162785, + "R_2": 0.2908516616207607, + "omega_1_0": 6.1346414149806705, + "omega_2_0": 10.283746991809672, + "mu_k": 0.04978705923389114, + "F_n": 2.719296318891576, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/567/simulation_code.py b/scipy/discs_friction_coupling/567/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..1763d5f11f7e07ea8265e91295d876d75e7eaea7 --- /dev/null +++ b/scipy/discs_friction_coupling/567/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.35265717607095404 +m_2 = 0.4814912781101204 +R_1 = 0.44356222045162785 +R_2 = 0.2908516616207607 +omega_1_0 = 6.1346414149806705 +omega_2_0 = 10.283746991809672 +mu_k = 0.04978705923389114 +F_n = 2.719296318891576 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/567/video.mp4 b/scipy/discs_friction_coupling/567/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..caedcfa60bf22937870ee9bea65d6c1f44da148a --- /dev/null +++ b/scipy/discs_friction_coupling/567/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b12b637bf80e6f0f017122faf72fffb477aba243924fe70f28e776324ea41d6 +size 97067 diff --git a/scipy/discs_friction_coupling/626/cot.json b/scipy/discs_friction_coupling/626/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8c2120567f8d6d61ab48e893e8ba610b4539255f --- /dev/null +++ b/scipy/discs_friction_coupling/626/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.472 kg, R1=0.399 m; m2=0.398 kg, R2=0.254 m) spin CCW at omega1_0=6.257 rad/s and omega2_0=12.938 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.839 N presses the rims with friction mu_k=0.053, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.6073, alpha_2 = -2.9957", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 7.1239", + "after no-slip: omega_1 = -0.3717, omega_2 = 0.5837" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.6073, alpha_2 = -2.9957", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 7.1239", + "after no-slip: omega_1 = -0.3717, omega_2 = 0.5837" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.03753 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.01282 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -5.7788 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.6073, alpha_2 = -2.9957 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 4.1239 s.", + "Final angular velocities: omega_1 -> -0.3717, omega_2 -> 0.5837 rad/s; check omega_1 R_1 + omega_2 R_2 = 5.551e-17 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.03752954021341712, + "I_2_kg_m2": 0.012823999963039304, + "s_0_m_s": -5.778821738383901, + "delta_t_slip_s": 4.123898339883158, + "t_no_slip_s": 7.123898339883157, + "omega_1_final_rad_s": -0.37174379595021634, + "omega_2_final_rad_s": 0.5837011005247827 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 4.124 s.", + "After no-slip, both discs spin at constant -0.372 and 0.584 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.47232275119969014, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.3979080226691485, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.3986412050220289, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.2538840420959007, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 6.25660523703015, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 12.937721726150592, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.05329041510204682, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.8394836488687814, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/626/params.json b/scipy/discs_friction_coupling/626/params.json new file mode 100644 index 0000000000000000000000000000000000000000..71908b9d53cde018bb3f5b1002dcdfa0f7e1c7b9 --- /dev/null +++ b/scipy/discs_friction_coupling/626/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.47232275119969014, + "m_2": 0.3979080226691485, + "R_1": 0.3986412050220289, + "R_2": 0.2538840420959007, + "omega_1_0": 6.25660523703015, + "omega_2_0": 12.937721726150592, + "mu_k": 0.05329041510204682, + "F_n": 2.8394836488687814, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/626/simulation_code.py b/scipy/discs_friction_coupling/626/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..697340aff455481f6aefae98c03f4db3f6f02795 --- /dev/null +++ b/scipy/discs_friction_coupling/626/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.47232275119969014 +m_2 = 0.3979080226691485 +R_1 = 0.3986412050220289 +R_2 = 0.2538840420959007 +omega_1_0 = 6.25660523703015 +omega_2_0 = 12.937721726150592 +mu_k = 0.05329041510204682 +F_n = 2.8394836488687814 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/626/video.mp4 b/scipy/discs_friction_coupling/626/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7074e3264635ddee81f6136ec79fe2231f1b9d96 --- /dev/null +++ b/scipy/discs_friction_coupling/626/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b735499503c878c63be1784c4655569cab219e6c5924e481e357cad064fd6e74 +size 93944 diff --git a/scipy/discs_friction_coupling/669/cot.json b/scipy/discs_friction_coupling/669/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a5f49510982e6231b5b7ea4f8d62b9bae11f4cf6 --- /dev/null +++ b/scipy/discs_friction_coupling/669/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.354 kg, R1=0.410 m; m2=0.402 kg, R2=0.233 m) spin CCW at omega1_0=5.621 rad/s and omega2_0=9.875 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=3.203 N presses the rims with friction mu_k=0.074, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -3.2770, alpha_2 = -5.0703", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 4.8239", + "after no-slip: omega_1 = -0.3561, omega_2 = 0.6270" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -3.2770, alpha_2 = -5.0703", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 4.8239", + "after no-slip: omega_1 = -0.3561, omega_2 = 0.6270" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.02970 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.01090 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -4.6023 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -3.2770, alpha_2 = -5.0703 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 1.8239 s.", + "Final angular velocities: omega_1 -> -0.3561, omega_2 -> 0.6270 rad/s; check omega_1 R_1 + omega_2 R_2 = 1.388e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.029698870271755613, + "I_2_kg_m2": 0.010901435859317528, + "s_0_m_s": -4.602315678000266, + "delta_t_slip_s": 1.823924219385284, + "t_no_slip_s": 4.823924219385283, + "omega_1_final_rad_s": -0.35608788688643855, + "omega_2_final_rad_s": 0.6269842414366646 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 1.824 s.", + "After no-slip, both discs spin at constant -0.356 and 0.627 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.3536065172479259, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.40240455252895485, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.4098498987053095, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.23276914270793075, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 5.6209540467518035, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 9.874883777855338, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.0741458722926282, + "unit": "", + "description": "" + }, + "F_n": { + "value": 3.2026363671158777, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/669/params.json b/scipy/discs_friction_coupling/669/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7c6945f41f4f0cc1503e9ffee76feb117d27f2f7 --- /dev/null +++ b/scipy/discs_friction_coupling/669/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.3536065172479259, + "m_2": 0.40240455252895485, + "R_1": 0.4098498987053095, + "R_2": 0.23276914270793075, + "omega_1_0": 5.6209540467518035, + "omega_2_0": 9.874883777855338, + "mu_k": 0.0741458722926282, + "F_n": 3.2026363671158777, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/669/simulation_code.py b/scipy/discs_friction_coupling/669/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ef7021ac69023aed31df1ab2c98918937128c7d1 --- /dev/null +++ b/scipy/discs_friction_coupling/669/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.3536065172479259 +m_2 = 0.40240455252895485 +R_1 = 0.4098498987053095 +R_2 = 0.23276914270793075 +omega_1_0 = 5.6209540467518035 +omega_2_0 = 9.874883777855338 +mu_k = 0.0741458722926282 +F_n = 3.2026363671158777 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/669/video.mp4 b/scipy/discs_friction_coupling/669/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..dd53cb7a6452b39a034724d38d17fd7f1f78782d --- /dev/null +++ b/scipy/discs_friction_coupling/669/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24f9227bdd3a787d1c61ef126b65e56b6640671c6239cafbc4a326a27a91fade +size 79274 diff --git a/scipy/discs_friction_coupling/683/cot.json b/scipy/discs_friction_coupling/683/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4562dc547430e768190d2e979a9cf52a3665f0f2 --- /dev/null +++ b/scipy/discs_friction_coupling/683/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.522 kg, R1=0.334 m; m2=0.407 kg, R2=0.222 m) spin CCW at omega1_0=5.203 rad/s and omega2_0=12.167 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.529 N presses the rims with friction mu_k=0.053, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.5274, alpha_2 = -2.9502", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 6.8097", + "after no-slip: omega_1 = -0.6159, omega_2 = 0.9275" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.5274, alpha_2 = -2.9502", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 6.8097", + "after no-slip: omega_1 = -0.6159, omega_2 = 0.9275" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.02919 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.01004 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -4.4413 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.5274, alpha_2 = -2.9502 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 3.8097 s.", + "Final angular velocities: omega_1 -> -0.6159, omega_2 -> 0.9275 rad/s; check omega_1 R_1 + omega_2 R_2 = -2.498e-16 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.02919262240133199, + "I_2_kg_m2": 0.010036586729944749, + "s_0_m_s": -4.441304789993374, + "delta_t_slip_s": 3.8097465144669007, + "t_no_slip_s": 6.8097465144669, + "omega_1_final_rad_s": -0.6159308881980134, + "omega_2_final_rad_s": 0.9275063511874304 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 3.810 s.", + "After no-slip, both discs spin at constant -0.616 and 0.928 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.522216895011886, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.40713052628017077, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.3343690672064417, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.22204509574165346, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 5.202957846332986, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 12.166882673886427, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.05272027443052775, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.529375609986303, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/683/params.json b/scipy/discs_friction_coupling/683/params.json new file mode 100644 index 0000000000000000000000000000000000000000..39feff1bfeed2cf51c2da68098627df3f703875f --- /dev/null +++ b/scipy/discs_friction_coupling/683/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.522216895011886, + "m_2": 0.40713052628017077, + "R_1": 0.3343690672064417, + "R_2": 0.22204509574165346, + "omega_1_0": 5.202957846332986, + "omega_2_0": 12.166882673886427, + "mu_k": 0.05272027443052775, + "F_n": 2.529375609986303, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/683/simulation_code.py b/scipy/discs_friction_coupling/683/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f595f153df1fd2fcb40bd0049dcf9d6fe1b69ae7 --- /dev/null +++ b/scipy/discs_friction_coupling/683/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.522216895011886 +m_2 = 0.40713052628017077 +R_1 = 0.3343690672064417 +R_2 = 0.22204509574165346 +omega_1_0 = 5.202957846332986 +omega_2_0 = 12.166882673886427 +mu_k = 0.05272027443052775 +F_n = 2.529375609986303 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/683/video.mp4 b/scipy/discs_friction_coupling/683/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..28bc117eb49a651912c8bd915a23c8bca1b01784 --- /dev/null +++ b/scipy/discs_friction_coupling/683/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9029605627895aaf46fb89cd74a80dcc6833c5561def39e58359bcb5685947e +size 82711 diff --git a/scipy/discs_friction_coupling/720/cot.json b/scipy/discs_friction_coupling/720/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..423d54321f942b4ef99b76bbacfe279b39e9b2dd --- /dev/null +++ b/scipy/discs_friction_coupling/720/cot.json @@ -0,0 +1,112 @@ +{ + "simulation": "discs_friction_coupling", + "physical_observation": "Top-down view: two solid discs (m1=0.684 kg, R1=0.342 m; m2=0.224 kg, R2=0.221 m) spin CCW at omega1_0=7.805 rad/s and omega2_0=13.213 rad/s on parallel axles. Disc 2 axle is translated toward disc 1 at v_approach=0.100 m/s across an initial gap of 0.300 m, then F_n=2.918 N presses the rims with friction mu_k=0.067, coupling the spins until omega_1 R_1 + omega_2 R_2 = 0.", + "physical_law": { + "name": "Newton II for rotation + Coulomb kinetic friction", + "statement": "Each disc obeys I theta'' = R \\cdot mu_k \\cdot F_n \\cdot sign(slip), with the friction torque opposing rim slip. The no-slip condition is omega_1 R_1 + omega_2 R_2 = 0 (gear-like).", + "formula": "I_i = (1/2) m_i R_i^2; s = -(omega_1 R_1 + omega_2 R_2); \\dot{s} = -mu_k F_n (R_1^2/I_1 + R_2^2/I_2) sign(s)." + }, + "ode_system": { + "state_variables": [ + "theta_1, theta_2 (rad)", + "omega_1, omega_2 (rad/s)", + "X_2 (axle x, m)" + ], + "equations_latex": [ + "X_2(t) = X_2_initial - approach_speed \\cdot t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i \\cdot (t - t_approach), alpha_1 = -1.6650, alpha_2 = -7.8632", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1^2/I1 + R2^2/I2)] = 5.4228", + "after no-slip: omega_1 = 3.7705, omega_2 = -5.8387" + ], + "equations_python": [ + "X_2 * (t) = X_2_initial - approach_speed * t, for t < t_approach = 3.0000", + "omega_i(t) = omega_i_0 + alpha_i * (t - t_approach), alpha_1 = -1.6650, alpha_2 = -7.8632", + "slip ends at t_no_slip = t_approach + |s_0|/[mu_k F_n (R1**2/I1 + R2**2/I2)] = 5.4228", + "after no-slip: omega_1 = 3.7705, omega_2 = -5.8387" + ] + }, + "derivation_steps": [ + "I_1 = (1/2) m_1 R_1^2 = 0.04009 kg m^2; I_2 = (1/2) m_2 R_2^2 = 0.00548 kg m^2.", + "At first contact, the slip velocity at the rim contact point is s_0 = -(omega_1 R_1 + omega_2 R_2) = -5.5943 m/s.", + "Friction force at contact has magnitude mu_k F_n; its torque on disc i has magnitude R_i mu_k F_n with sign so as to oppose s.", + "Therefore alpha_i = R_i mu_k F_n sign(s) / I_i: alpha_1 = -1.6650, alpha_2 = -7.8632 rad/s^2.", + "\\dot{s} = -(R_1^2/I_1 + R_2^2/I_2) mu_k F_n sign(s) is constant in magnitude; slip duration delta_t_slip = |s_0|/denom = 2.4228 s.", + "Final angular velocities: omega_1 -> 3.7705, omega_2 -> -5.8387 rad/s; check omega_1 R_1 + omega_2 R_2 = 2.220e-15 ~ 0." + ], + "physical_constants_derived": { + "I_1_kg_m2": 0.04008768151569895, + "I_2_kg_m2": 0.005481840352734027, + "s_0_m_s": -5.594270377078839, + "delta_t_slip_s": 2.4228362198716273, + "t_no_slip_s": 5.422836219871627, + "omega_1_final_rad_s": 3.7705366079904703, + "omega_2_final_rad_s": -5.838675129504532 + }, + "numerical_method": { + "solver": "Closed-form per phase: phase 1 axle translation, phase 2 constant angular acceleration during slip, phase 3 constant angular velocity post-slip.", + "tolerance": "Machine precision.", + "justification": "Kinematics are constant-acceleration in each phase; closed-form is exact and avoids stiff ODE issues at the slip-stick transition." + }, + "code_validation": { + "ode_source": "Newton II for rotation; Coulomb kinetic friction at the contact point.", + "energy_check": "Total rotational KE strictly decreases during slip by mu_k F_n * |s| dt; constant after no-slip.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Approach phase lasts t_approach = 3.000 s.", + "Slip phase reduces |omega1 R1 + omega2 R2| to zero in delta_t_slip = 2.423 s.", + "After no-slip, both discs spin at constant 3.771 and -5.839 rad/s respectively." + ], + "parameters": { + "m_1": { + "value": 0.6837685646603029, + "unit": "", + "description": "" + }, + "m_2": { + "value": 0.22420581592277222, + "unit": "", + "description": "" + }, + "R_1": { + "value": 0.3424253451083201, + "unit": "", + "description": "" + }, + "R_2": { + "value": 0.22113360832669826, + "unit": "", + "description": "" + }, + "omega_1_0": { + "value": 7.804675344101961, + "unit": "", + "description": "" + }, + "omega_2_0": { + "value": 13.21260821014503, + "unit": "", + "description": "" + }, + "mu_k": { + "value": 0.06679820253737717, + "unit": "", + "description": "" + }, + "F_n": { + "value": 2.918146111997637, + "unit": "", + "description": "" + }, + "gap_0": { + "value": 0.3, + "unit": "", + "description": "" + }, + "approach_speed": { + "value": 0.1, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/discs_friction_coupling/720/params.json b/scipy/discs_friction_coupling/720/params.json new file mode 100644 index 0000000000000000000000000000000000000000..b3bd24d144587ca387e51e16463f6387ed38d386 --- /dev/null +++ b/scipy/discs_friction_coupling/720/params.json @@ -0,0 +1,12 @@ +{ + "m_1": 0.6837685646603029, + "m_2": 0.22420581592277222, + "R_1": 0.3424253451083201, + "R_2": 0.22113360832669826, + "omega_1_0": 7.804675344101961, + "omega_2_0": 13.21260821014503, + "mu_k": 0.06679820253737717, + "F_n": 2.918146111997637, + "gap_0": 0.3, + "approach_speed": 0.1 +} \ No newline at end of file diff --git a/scipy/discs_friction_coupling/720/simulation_code.py b/scipy/discs_friction_coupling/720/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..a137635ce42489c474800c1de8407436e86be3b5 --- /dev/null +++ b/scipy/discs_friction_coupling/720/simulation_code.py @@ -0,0 +1,120 @@ +""" +Discs Friction Coupling — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle +from matplotlib.collections import LineCollection + +m_1 = 0.6837685646603029 +m_2 = 0.22420581592277222 +R_1 = 0.3424253451083201 +R_2 = 0.22113360832669826 +omega_1_0 = 7.804675344101961 +omega_2_0 = 13.21260821014503 +mu_k = 0.06679820253737717 +F_n = 2.918146111997637 +gap_0 = 0.3 +approach_speed = 0.1 +duration = 12 +fps = 30 + +I_1 = 0.5 * m_1 * R_1 ** 2 +I_2 = 0.5 * m_2 * R_2 ** 2 +X_1_fixed = 0.0 +X_2_initial = X_1_fixed + R_1 + R_2 + gap_0 +t_approach = gap_0 / approach_speed +s_0 = -(omega_1_0 * R_1 + omega_2_0 * R_2) +denom = mu_k * F_n * (R_1 ** 2 / I_1 + R_2 ** 2 / I_2) +delta_t_slip = abs(s_0) / denom if denom > 0 else 0.0 +t_no_slip = t_approach + delta_t_slip +sign_s0 = np.sign(s_0) +alpha_1 = R_1 * mu_k * F_n * sign_s0 / I_1 +alpha_2 = R_2 * mu_k * F_n * sign_s0 / I_2 +omega_1_final = omega_1_0 + alpha_1 * delta_t_slip +omega_2_final = omega_2_0 + alpha_2 * delta_t_slip + +def disc2_centre_x(t): + if t < t_approach: return X_2_initial - approach_speed * t + return X_1_fixed + R_1 + R_2 + +def phi_1(t): + if t <= t_approach: return omega_1_0 * t + base = omega_1_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_1_0 * dt + 0.5 * alpha_1 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_1_0 * dt_slip + 0.5 * alpha_1 * dt_slip ** 2 + return base_slip + omega_1_final * (t - t_no_slip) + +def phi_2(t): + if t <= t_approach: return omega_2_0 * t + base = omega_2_0 * t_approach + if t <= t_no_slip: + dt = t - t_approach + return base + omega_2_0 * dt + 0.5 * alpha_2 * dt ** 2 + dt_slip = t_no_slip - t_approach + base_slip = base + omega_2_0 * dt_slip + 0.5 * alpha_2 * dt_slip ** 2 + return base_slip + omega_2_final * (t - t_no_slip) + +pad = 0.35 +x_lo_d = X_1_fixed - R_1 - pad +x_hi_d = X_2_initial + R_2 + pad +y_lo_d = -max(R_1, R_2) - pad +y_hi_d = +max(R_1, R_2) + pad +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w / fig_h +dx = x_hi_d - x_lo_d; dy = y_hi_d - y_lo_d +if dx / dy < fig_aspect: + extra = (fig_aspect * dy - dx) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d - extra, x_hi_d + extra, y_lo_d, y_hi_d +else: + extra = (dx / fig_aspect - dy) / 2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") + +disc1_patch = Circle((X_1_fixed, 0.0), R_1, facecolor="#80c0ff", edgecolor="#ffffff", lw=1.6, zorder=3) +disc2_patch = Circle((X_2_initial, 0.0), R_2, facecolor="#ffd166", edgecolor="#ffffff", lw=1.6, zorder=3) +ax.add_patch(disc1_patch); ax.add_patch(disc2_patch) +axle1_dot = Circle((X_1_fixed, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +axle2_dot = Circle((X_2_initial, 0.0), 0.022, facecolor="#1a1a2e", edgecolor="#ffffff", lw=0.8, zorder=6) +ax.add_patch(axle1_dot); ax.add_patch(axle2_dot) + +N_TICKS = 6 +ticks1_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ticks2_lc = LineCollection([], colors="#1a1a2e", linewidths=2.8, zorder=5) +ax.add_collection(ticks1_lc); ax.add_collection(ticks2_lc) +hi_tick1, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) +hi_tick2, = ax.plot([], [], color="#e63946", lw=3.4, zorder=5.5) + +def radial_tick_segments(cx, cy, R, phi, n=N_TICKS, inner_frac=0.12): + angles = phi + 2.0 * np.pi * np.arange(n) / n + r0 = inner_frac * R; r1 = R * 0.97 + segs = np.empty((n, 2, 2)) + segs[:, 0, 0] = cx + r0 * np.cos(angles); segs[:, 0, 1] = cy + r0 * np.sin(angles) + segs[:, 1, 0] = cx + r1 * np.cos(angles); segs[:, 1, 1] = cy + r1 * np.sin(angles) + return segs + +def update(f): + t = f / fps + cx2 = disc2_centre_x(t) + disc2_patch.center = (cx2, 0.0); axle2_dot.center = (cx2, 0.0) + th1 = phi_1(t); th2 = phi_2(t) + ticks1_lc.set_segments(radial_tick_segments(X_1_fixed, 0.0, R_1, th1)) + ticks2_lc.set_segments(radial_tick_segments(cx2, 0.0, R_2, th2)) + hi_tick1.set_data([X_1_fixed + 0.12*R_1*np.cos(th1), X_1_fixed + 0.97*R_1*np.cos(th1)], + [0.0 + 0.12*R_1*np.sin(th1), 0.0 + 0.97*R_1*np.sin(th1)]) + hi_tick2.set_data([cx2 + 0.12*R_2*np.cos(th2), cx2 + 0.97*R_2*np.cos(th2)], + [0.0 + 0.12*R_2*np.sin(th2), 0.0 + 0.97*R_2*np.sin(th2)]) + return disc1_patch, disc2_patch, axle1_dot, axle2_dot, ticks1_lc, ticks2_lc, hi_tick1, hi_tick2 + +n_frames = int(duration * fps) + 1 +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("discs_friction_coupling.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved discs_friction_coupling.mp4") diff --git a/scipy/discs_friction_coupling/720/video.mp4 b/scipy/discs_friction_coupling/720/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..eae8f3ca8a788d6ba06ec116627e5cc00d93de74 --- /dev/null +++ b/scipy/discs_friction_coupling/720/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7aa3610ec9325c94974c363de5df064f828105a4a62f4a9bc920de2c04d9105c +size 91973 diff --git a/scipy/disk_spinoff/1101/cot.json b/scipy/disk_spinoff/1101/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4f5cdeece5d1ac374d7ca0725b274915d10ad000 --- /dev/null +++ b/scipy/disk_spinoff/1101/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.148 rad/s in t_ramp=1.195 s. 9 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.34256324565784024, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.5720597033333799 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.0889 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.08891007326870659 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.089 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 9.479126893265693, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.147936908086274, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.1946571113207793, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.34256324565784024, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.368088684886788, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.5720597033333799, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 5.197837223526865, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1101/params.json b/scipy/disk_spinoff/1101/params.json new file mode 100644 index 0000000000000000000000000000000000000000..20e27bd9fc90525dea3e6a386ec000079698e032 --- /dev/null +++ b/scipy/disk_spinoff/1101/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 9.479126893265693, + "cube_size": 0.08, + "omega_max": 6.147936908086274, + "t_ramp": 1.1946571113207793, + "mu_s_disk": 0.34256324565784024, + "mu_k_disk": 0.368088684886788, + "mu_k_floor": 0.5720597033333799, + "g": 9.81, + "seed": 5.197837223526865 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1101/simulation_code.py b/scipy/disk_spinoff/1101/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..eb5b5858caf3f24ef2dbdfaa5812632062a80728 --- /dev/null +++ b/scipy/disk_spinoff/1101/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 9 +cube_size = 0.08 +omega_max = 6.147936908086274 +t_ramp = 1.1946571113207793 +mu_s_disk = 0.34256324565784024 +mu_k_disk = 0.368088684886788 +mu_k_floor = 0.5720597033333799 +g = 9.81 +duration = 12 +fps = 30 +seed = 5 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1101/video.mp4 b/scipy/disk_spinoff/1101/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..bca7e71f42eef19c2da182450d5d2c49ec78ddbd --- /dev/null +++ b/scipy/disk_spinoff/1101/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48735ae1f893ff2260cf6b69dc2a56a644d0e891b7b43867dabcc315f83fbda2 +size 29981 diff --git a/scipy/disk_spinoff/1108/cot.json b/scipy/disk_spinoff/1108/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..30dae61bfbf42f738a7a57e4281606cd32722792 --- /dev/null +++ b/scipy/disk_spinoff/1108/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=5.615 rad/s in t_ramp=0.866 s. 12 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.3094307561541065, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.5801188462426962 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.0963 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.09626972499984879 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.096 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 12.527780371683184, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 5.615279490657308, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 0.8664343373577396, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.3094307561541065, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.3081300462889125, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.5801188462426962, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 59.0880225148308, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1108/params.json b/scipy/disk_spinoff/1108/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7b87d25b54eff6e539757a8993bc3d75974d5cd4 --- /dev/null +++ b/scipy/disk_spinoff/1108/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 12.527780371683184, + "cube_size": 0.08, + "omega_max": 5.615279490657308, + "t_ramp": 0.8664343373577396, + "mu_s_disk": 0.3094307561541065, + "mu_k_disk": 0.3081300462889125, + "mu_k_floor": 0.5801188462426962, + "g": 9.81, + "seed": 59.0880225148308 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1108/simulation_code.py b/scipy/disk_spinoff/1108/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..eccc5902c8ff018d6d43709ef40f7488a5152802 --- /dev/null +++ b/scipy/disk_spinoff/1108/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 12 +cube_size = 0.08 +omega_max = 5.615279490657308 +t_ramp = 0.8664343373577396 +mu_s_disk = 0.3094307561541065 +mu_k_disk = 0.3081300462889125 +mu_k_floor = 0.5801188462426962 +g = 9.81 +duration = 12 +fps = 30 +seed = 59 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1108/video.mp4 b/scipy/disk_spinoff/1108/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e229203c9261d47f42b8f90e687dfb96e29594a1 --- /dev/null +++ b/scipy/disk_spinoff/1108/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf753b2486f3ac57d4d401461e2bb36cc25b8c1db2a26a70815eb67a0552fe6f +size 31039 diff --git a/scipy/disk_spinoff/1123/cot.json b/scipy/disk_spinoff/1123/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..616f7092e713568443eb92cb5e11ac3253db6b09 --- /dev/null +++ b/scipy/disk_spinoff/1123/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.143 rad/s in t_ramp=1.489 s. 7 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.39654450750878323, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.5376496125574782 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.1031 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.10308474669558637 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.103 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 7.067601236785892, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.143038951583175, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.4894268897941378, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.39654450750878323, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.36376569031032313, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.5376496125574782, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 67.52606861754872, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1123/params.json b/scipy/disk_spinoff/1123/params.json new file mode 100644 index 0000000000000000000000000000000000000000..43c8fcbdae4e207c2d0e37da847b66255e41dfef --- /dev/null +++ b/scipy/disk_spinoff/1123/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 7.067601236785892, + "cube_size": 0.08, + "omega_max": 6.143038951583175, + "t_ramp": 1.4894268897941378, + "mu_s_disk": 0.39654450750878323, + "mu_k_disk": 0.36376569031032313, + "mu_k_floor": 0.5376496125574782, + "g": 9.81, + "seed": 67.52606861754872 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1123/simulation_code.py b/scipy/disk_spinoff/1123/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d3b091991e35ceb29fcfdb353420ad371561e209 --- /dev/null +++ b/scipy/disk_spinoff/1123/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 7 +cube_size = 0.08 +omega_max = 6.143038951583175 +t_ramp = 1.4894268897941378 +mu_s_disk = 0.39654450750878323 +mu_k_disk = 0.36376569031032313 +mu_k_floor = 0.5376496125574782 +g = 9.81 +duration = 12 +fps = 30 +seed = 67 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1123/video.mp4 b/scipy/disk_spinoff/1123/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9d8b9cce34d0bf5ff31a10f663b8e7df8f8ffe26 --- /dev/null +++ b/scipy/disk_spinoff/1123/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce00269fa92ec1580a70f5f0a3a5b4ba5f60d79bb3abc7acd254a463516bd04e +size 28874 diff --git a/scipy/disk_spinoff/1159/cot.json b/scipy/disk_spinoff/1159/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..bf0221cc2b23189c6a0507889e216cb635832338 --- /dev/null +++ b/scipy/disk_spinoff/1159/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.274 rad/s in t_ramp=1.400 s. 8 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.5280620617079361, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.4092946156813684 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.1316 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.13160511254522353 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.132 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 8.472162549335739, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.273943548960888, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.3995151346017063, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.5280620617079361, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.2774440064058251, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.4092946156813684, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 19.131868357475735, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1159/params.json b/scipy/disk_spinoff/1159/params.json new file mode 100644 index 0000000000000000000000000000000000000000..903ba4e59f4c97358d57caf91938db89bf02b096 --- /dev/null +++ b/scipy/disk_spinoff/1159/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 8.472162549335739, + "cube_size": 0.08, + "omega_max": 6.273943548960888, + "t_ramp": 1.3995151346017063, + "mu_s_disk": 0.5280620617079361, + "mu_k_disk": 0.2774440064058251, + "mu_k_floor": 0.4092946156813684, + "g": 9.81, + "seed": 19.131868357475735 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1159/simulation_code.py b/scipy/disk_spinoff/1159/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..8cf7326b27aa602fea83b8dded84d039c0fff2dd --- /dev/null +++ b/scipy/disk_spinoff/1159/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 8 +cube_size = 0.08 +omega_max = 6.273943548960888 +t_ramp = 1.3995151346017063 +mu_s_disk = 0.5280620617079361 +mu_k_disk = 0.2774440064058251 +mu_k_floor = 0.4092946156813684 +g = 9.81 +duration = 12 +fps = 30 +seed = 19 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1159/video.mp4 b/scipy/disk_spinoff/1159/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..5a55f9bed051730c9089f68bc414d1a4509919eb --- /dev/null +++ b/scipy/disk_spinoff/1159/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:915070cce326ddc9b0fc7389cf76df6a577616fac4d64cfe605d6d50c07527a6 +size 29621 diff --git a/scipy/disk_spinoff/1198/cot.json b/scipy/disk_spinoff/1198/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..7e29414aa0ef387f7f79989861349788bf022ae9 --- /dev/null +++ b/scipy/disk_spinoff/1198/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=5.762 rad/s in t_ramp=1.446 s. 8 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.3939931152352936, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.41703497704912207 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.1164 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.11639782972456776 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.116 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 8.091215129313195, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 5.76243949956884, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.4457135590729995, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.3939931152352936, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.20853541706371917, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.41703497704912207, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 60.591084036986935, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1198/params.json b/scipy/disk_spinoff/1198/params.json new file mode 100644 index 0000000000000000000000000000000000000000..536d8928a14b9b21b657a66c9715f099e385d879 --- /dev/null +++ b/scipy/disk_spinoff/1198/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 8.091215129313195, + "cube_size": 0.08, + "omega_max": 5.76243949956884, + "t_ramp": 1.4457135590729995, + "mu_s_disk": 0.3939931152352936, + "mu_k_disk": 0.20853541706371917, + "mu_k_floor": 0.41703497704912207, + "g": 9.81, + "seed": 60.591084036986935 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1198/simulation_code.py b/scipy/disk_spinoff/1198/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..65fbf1634abe8469959a1f20f35b49a917e59ddf --- /dev/null +++ b/scipy/disk_spinoff/1198/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 8 +cube_size = 0.08 +omega_max = 5.76243949956884 +t_ramp = 1.4457135590729995 +mu_s_disk = 0.3939931152352936 +mu_k_disk = 0.20853541706371917 +mu_k_floor = 0.41703497704912207 +g = 9.81 +duration = 12 +fps = 30 +seed = 60 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1198/video.mp4 b/scipy/disk_spinoff/1198/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..625f62b86c06322fd3e3694e63ed6fb4c136377c --- /dev/null +++ b/scipy/disk_spinoff/1198/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91347f28b01e3c0a1a84e5247c37f2901c336b7ef5dfc32952c0d688dec99a35 +size 28992 diff --git a/scipy/disk_spinoff/1300/cot.json b/scipy/disk_spinoff/1300/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6294fe8d4be9360637b705b75126df8a79d523cd --- /dev/null +++ b/scipy/disk_spinoff/1300/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.828 rad/s in t_ramp=1.254 s. 4 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.43089711282008664, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.5301777507803502 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.0907 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.09067340775896252 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.091 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 4.7588804298983485, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.827808418627063, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.2539370497506512, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.43089711282008664, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.4256714153005067, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.5301777507803502, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 79.23446648313718, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1300/params.json b/scipy/disk_spinoff/1300/params.json new file mode 100644 index 0000000000000000000000000000000000000000..56d6569feb0823fb6158b4068c2f6d7bc32418fb --- /dev/null +++ b/scipy/disk_spinoff/1300/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 4.7588804298983485, + "cube_size": 0.08, + "omega_max": 6.827808418627063, + "t_ramp": 1.2539370497506512, + "mu_s_disk": 0.43089711282008664, + "mu_k_disk": 0.4256714153005067, + "mu_k_floor": 0.5301777507803502, + "g": 9.81, + "seed": 79.23446648313718 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1300/simulation_code.py b/scipy/disk_spinoff/1300/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..e5d5ca985e74781c390dcee30866273406b2e793 --- /dev/null +++ b/scipy/disk_spinoff/1300/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 4 +cube_size = 0.08 +omega_max = 6.827808418627063 +t_ramp = 1.2539370497506512 +mu_s_disk = 0.43089711282008664 +mu_k_disk = 0.4256714153005067 +mu_k_floor = 0.5301777507803502 +g = 9.81 +duration = 12 +fps = 30 +seed = 79 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1300/video.mp4 b/scipy/disk_spinoff/1300/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4ab0d13b7f08908870235e601354e09563b4a5b0 --- /dev/null +++ b/scipy/disk_spinoff/1300/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:932a714047f35a4a2732934ecd39ab093171f40c26c82343f6b3b933b91c513b +size 26509 diff --git a/scipy/disk_spinoff/1400/cot.json b/scipy/disk_spinoff/1400/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..7e00a4c6f409d7268f601d8d55c965ec26540ae9 --- /dev/null +++ b/scipy/disk_spinoff/1400/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.438 rad/s in t_ramp=0.975 s. 11 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.3443577652898846, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.444739419482581 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.0815 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.08151412914813153 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.082 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 11.356134504617724, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.437585313229594, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 0.9749696451695743, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.3443577652898846, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.3062937457433773, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.444739419482581, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 24.814103654829363, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1400/params.json b/scipy/disk_spinoff/1400/params.json new file mode 100644 index 0000000000000000000000000000000000000000..9b3fcfcab16d4327f681c5f8ff3ce0318cdaf515 --- /dev/null +++ b/scipy/disk_spinoff/1400/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 11.356134504617724, + "cube_size": 0.08, + "omega_max": 6.437585313229594, + "t_ramp": 0.9749696451695743, + "mu_s_disk": 0.3443577652898846, + "mu_k_disk": 0.3062937457433773, + "mu_k_floor": 0.444739419482581, + "g": 9.81, + "seed": 24.814103654829363 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1400/simulation_code.py b/scipy/disk_spinoff/1400/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..58946ead939bf88e09ef798ea67bc1df8db43faa --- /dev/null +++ b/scipy/disk_spinoff/1400/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 11 +cube_size = 0.08 +omega_max = 6.437585313229594 +t_ramp = 0.9749696451695743 +mu_s_disk = 0.3443577652898846 +mu_k_disk = 0.3062937457433773 +mu_k_floor = 0.444739419482581 +g = 9.81 +duration = 12 +fps = 30 +seed = 24 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1400/video.mp4 b/scipy/disk_spinoff/1400/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7ce3ce36705db8cd7a9b4c66f138f14124e15947 --- /dev/null +++ b/scipy/disk_spinoff/1400/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:536e0ea39d5b8e459572b214735e51c70aff0c38a53c830c7074451d8ae93f17 +size 30621 diff --git a/scipy/disk_spinoff/1415/cot.json b/scipy/disk_spinoff/1415/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e50ddaaa457a45edc57fad531ac03423c2218573 --- /dev/null +++ b/scipy/disk_spinoff/1415/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.213 rad/s in t_ramp=1.181 s. 7 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.3123392835400222, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.48395278222153193 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.0794 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.07938823092557563 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.079 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 7.054234009323708, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.212547845114657, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.1805612543459314, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.3123392835400222, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.35945884832851993, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.48395278222153193, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 46.83700354686114, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1415/params.json b/scipy/disk_spinoff/1415/params.json new file mode 100644 index 0000000000000000000000000000000000000000..89b4f54787172e4386451eb4fc67d35135b97645 --- /dev/null +++ b/scipy/disk_spinoff/1415/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 7.054234009323708, + "cube_size": 0.08, + "omega_max": 6.212547845114657, + "t_ramp": 1.1805612543459314, + "mu_s_disk": 0.3123392835400222, + "mu_k_disk": 0.35945884832851993, + "mu_k_floor": 0.48395278222153193, + "g": 9.81, + "seed": 46.83700354686114 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1415/simulation_code.py b/scipy/disk_spinoff/1415/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f091c6db5126271cd95c56304df865d7c67ee363 --- /dev/null +++ b/scipy/disk_spinoff/1415/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 7 +cube_size = 0.08 +omega_max = 6.212547845114657 +t_ramp = 1.1805612543459314 +mu_s_disk = 0.3123392835400222 +mu_k_disk = 0.35945884832851993 +mu_k_floor = 0.48395278222153193 +g = 9.81 +duration = 12 +fps = 30 +seed = 46 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1415/video.mp4 b/scipy/disk_spinoff/1415/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4d90c5ef29106f9ab8a573d3e1170f771f0acad9 --- /dev/null +++ b/scipy/disk_spinoff/1415/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8a30408de09aa3fa0253107c1f9f8a100da4b266cac9ef3e3c4f55402b1b8c3 +size 28680 diff --git a/scipy/disk_spinoff/1433/cot.json b/scipy/disk_spinoff/1433/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..3cffa66ab53f752184d7eb06bf59afba2a571a44 --- /dev/null +++ b/scipy/disk_spinoff/1433/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.380 rad/s in t_ramp=1.022 s. 7 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.4206231663499167, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.5637682272542313 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.1014 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.1013735062287992 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.101 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 7.865633301185326, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.379973340218507, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.0215627243922145, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.4206231663499167, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.3826950947613013, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.5637682272542313, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 54.81514715126308, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1433/params.json b/scipy/disk_spinoff/1433/params.json new file mode 100644 index 0000000000000000000000000000000000000000..d81685faba0e5598b3a59862d9497b75660c8221 --- /dev/null +++ b/scipy/disk_spinoff/1433/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 7.865633301185326, + "cube_size": 0.08, + "omega_max": 6.379973340218507, + "t_ramp": 1.0215627243922145, + "mu_s_disk": 0.4206231663499167, + "mu_k_disk": 0.3826950947613013, + "mu_k_floor": 0.5637682272542313, + "g": 9.81, + "seed": 54.81514715126308 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1433/simulation_code.py b/scipy/disk_spinoff/1433/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4c89d6afc136d91fd6b2b92dc8362471e2464982 --- /dev/null +++ b/scipy/disk_spinoff/1433/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 7 +cube_size = 0.08 +omega_max = 6.379973340218507 +t_ramp = 1.0215627243922145 +mu_s_disk = 0.4206231663499167 +mu_k_disk = 0.3826950947613013 +mu_k_floor = 0.5637682272542313 +g = 9.81 +duration = 12 +fps = 30 +seed = 54 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1433/video.mp4 b/scipy/disk_spinoff/1433/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6fd921867f812088e882b80b0c77436e06e93ab2 --- /dev/null +++ b/scipy/disk_spinoff/1433/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af27508fde6bb967465754de300f487b38fdbb43235e154a7b80cf7b27183572 +size 28690 diff --git a/scipy/disk_spinoff/1466/cot.json b/scipy/disk_spinoff/1466/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..9f79c489564dc7910dfb646214541d7c8c987f29 --- /dev/null +++ b/scipy/disk_spinoff/1466/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.225 rad/s in t_ramp=1.270 s. 7 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.3362591021058952, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.5812375429727771 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.0851 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.08512515425568129 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.085 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 7.943772608596253, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.225046103483816, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.2701647835773562, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.3362591021058952, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.29746363617801375, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.5812375429727771, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 71.9577823332354, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/1466/params.json b/scipy/disk_spinoff/1466/params.json new file mode 100644 index 0000000000000000000000000000000000000000..fa84a5ecc5a32e9aeae0ad6cefa73d1632e28062 --- /dev/null +++ b/scipy/disk_spinoff/1466/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 7.943772608596253, + "cube_size": 0.08, + "omega_max": 6.225046103483816, + "t_ramp": 1.2701647835773562, + "mu_s_disk": 0.3362591021058952, + "mu_k_disk": 0.29746363617801375, + "mu_k_floor": 0.5812375429727771, + "g": 9.81, + "seed": 71.9577823332354 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/1466/simulation_code.py b/scipy/disk_spinoff/1466/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..487de26e240a6f47c057536a1339d0caba4439fd --- /dev/null +++ b/scipy/disk_spinoff/1466/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 7 +cube_size = 0.08 +omega_max = 6.225046103483816 +t_ramp = 1.2701647835773562 +mu_s_disk = 0.3362591021058952 +mu_k_disk = 0.29746363617801375 +mu_k_floor = 0.5812375429727771 +g = 9.81 +duration = 12 +fps = 30 +seed = 71 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/1466/video.mp4 b/scipy/disk_spinoff/1466/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a1720e70ddfc9b22e8b69ce8cd981b4c3fe350b4 --- /dev/null +++ b/scipy/disk_spinoff/1466/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e4f536d06222aeac65173be0aa7c015318f2ac90845b2153faf48dc19c31873 +size 28429 diff --git a/scipy/disk_spinoff/202/cot.json b/scipy/disk_spinoff/202/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..eee51dbebd1bfeb9168777bb72680756ab220fc9 --- /dev/null +++ b/scipy/disk_spinoff/202/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=5.660 rad/s in t_ramp=1.114 s. 11 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.3134007055364316, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.6439593752876134 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.0960 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.09597940983474304 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.096 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 11.013603691944482, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 5.659726579713473, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.1140988575345254, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.3134007055364316, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.3388661153719237, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.6439593752876134, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 11.856911438934212, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/202/params.json b/scipy/disk_spinoff/202/params.json new file mode 100644 index 0000000000000000000000000000000000000000..bfe927737af49c3da70376a25e74b525647c240c --- /dev/null +++ b/scipy/disk_spinoff/202/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 11.013603691944482, + "cube_size": 0.08, + "omega_max": 5.659726579713473, + "t_ramp": 1.1140988575345254, + "mu_s_disk": 0.3134007055364316, + "mu_k_disk": 0.3388661153719237, + "mu_k_floor": 0.6439593752876134, + "g": 9.81, + "seed": 11.856911438934212 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/202/simulation_code.py b/scipy/disk_spinoff/202/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..8d276c9addbb47924c1ccd3ec43356634ffb3016 --- /dev/null +++ b/scipy/disk_spinoff/202/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 11 +cube_size = 0.08 +omega_max = 5.659726579713473 +t_ramp = 1.1140988575345254 +mu_s_disk = 0.3134007055364316 +mu_k_disk = 0.3388661153719237 +mu_k_floor = 0.6439593752876134 +g = 9.81 +duration = 12 +fps = 30 +seed = 11 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/202/video.mp4 b/scipy/disk_spinoff/202/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..215b8a60df3c68cb66a4a07374cebbf2164b001a --- /dev/null +++ b/scipy/disk_spinoff/202/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1e6864a5d4dde0e43b715d437df3e10310ffd81080a48c9e98909f9901c8af2 +size 31152 diff --git a/scipy/disk_spinoff/633/cot.json b/scipy/disk_spinoff/633/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..be099ce8f92e554c52b019a27059e4dead78cdbd --- /dev/null +++ b/scipy/disk_spinoff/633/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=5.341 rad/s in t_ramp=1.368 s. 7 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.44322946728080115, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.49525022856316736 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.1524 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.1524420168861069 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.152 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 7.153756563824016, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 5.340678975558667, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.36785928435969, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.44322946728080115, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.2747578791469948, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.49525022856316736, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 14.161329596021416, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/633/params.json b/scipy/disk_spinoff/633/params.json new file mode 100644 index 0000000000000000000000000000000000000000..78562b44ff96d48bd2b75f2cb307b4390a4efd30 --- /dev/null +++ b/scipy/disk_spinoff/633/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 7.153756563824016, + "cube_size": 0.08, + "omega_max": 5.340678975558667, + "t_ramp": 1.36785928435969, + "mu_s_disk": 0.44322946728080115, + "mu_k_disk": 0.2747578791469948, + "mu_k_floor": 0.49525022856316736, + "g": 9.81, + "seed": 14.161329596021416 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/633/simulation_code.py b/scipy/disk_spinoff/633/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9a13b1befc221914f38611ededf0bd208d6b5c6c --- /dev/null +++ b/scipy/disk_spinoff/633/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 7 +cube_size = 0.08 +omega_max = 5.340678975558667 +t_ramp = 1.36785928435969 +mu_s_disk = 0.44322946728080115 +mu_k_disk = 0.2747578791469948 +mu_k_floor = 0.49525022856316736 +g = 9.81 +duration = 12 +fps = 30 +seed = 14 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/633/video.mp4 b/scipy/disk_spinoff/633/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4047a59b27d2f8ad3d3f495de8b1874ae8d94c2c --- /dev/null +++ b/scipy/disk_spinoff/633/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba7f496c98da82bd7959782cb02c4b3a698f7c11e26335075477397d66f2b56c +size 27839 diff --git a/scipy/disk_spinoff/738/cot.json b/scipy/disk_spinoff/738/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e68b40fbfc189fd2727240ce2f22501983d0ec0d --- /dev/null +++ b/scipy/disk_spinoff/738/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=4.799 rad/s in t_ramp=0.913 s. 8 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.4446445015550038, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.4887851972214604 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.1894 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.1894287990125304 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.189 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 8.041273244235589, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 4.798637724444496, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 0.9132658100556202, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.4446445015550038, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.4490907972977639, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.4887851972214604, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 59.527142131131384, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/738/params.json b/scipy/disk_spinoff/738/params.json new file mode 100644 index 0000000000000000000000000000000000000000..60399864bc6d91678c7baf89ff3c0a47dcbf28e6 --- /dev/null +++ b/scipy/disk_spinoff/738/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 8.041273244235589, + "cube_size": 0.08, + "omega_max": 4.798637724444496, + "t_ramp": 0.9132658100556202, + "mu_s_disk": 0.4446445015550038, + "mu_k_disk": 0.4490907972977639, + "mu_k_floor": 0.4887851972214604, + "g": 9.81, + "seed": 59.527142131131384 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/738/simulation_code.py b/scipy/disk_spinoff/738/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3f1984626c7ff4b05da73fa4ee6cbee543898548 --- /dev/null +++ b/scipy/disk_spinoff/738/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 8 +cube_size = 0.08 +omega_max = 4.798637724444496 +t_ramp = 0.9132658100556202 +mu_s_disk = 0.4446445015550038 +mu_k_disk = 0.4490907972977639 +mu_k_floor = 0.4887851972214604 +g = 9.81 +duration = 12 +fps = 30 +seed = 59 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/738/video.mp4 b/scipy/disk_spinoff/738/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..21d03929d1fd0c4699e9dbd74331e69545a6b00e --- /dev/null +++ b/scipy/disk_spinoff/738/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd7a27425125ce54528155b34179a06910f674e28c0e8d546e9168db344dbf67 +size 30135 diff --git a/scipy/disk_spinoff/858/cot.json b/scipy/disk_spinoff/858/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c88ee4ca43d46069309863fe209b788de487ff34 --- /dev/null +++ b/scipy/disk_spinoff/858/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=6.853 rad/s in t_ramp=1.026 s. 9 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.34872755804632466, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.6075949310382283 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.0728 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.07284015370715319 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.073 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 9.37004927807537, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 6.853181143244916, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.0259447124909276, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.34872755804632466, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.37155079480255715, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.6075949310382283, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 44.542529665228614, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/858/params.json b/scipy/disk_spinoff/858/params.json new file mode 100644 index 0000000000000000000000000000000000000000..91280649cd7e3c3c9083d6debeaf463de0fc2153 --- /dev/null +++ b/scipy/disk_spinoff/858/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 9.37004927807537, + "cube_size": 0.08, + "omega_max": 6.853181143244916, + "t_ramp": 1.0259447124909276, + "mu_s_disk": 0.34872755804632466, + "mu_k_disk": 0.37155079480255715, + "mu_k_floor": 0.6075949310382283, + "g": 9.81, + "seed": 44.542529665228614 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/858/simulation_code.py b/scipy/disk_spinoff/858/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c1ab97fa56fba0500d4bb4050b6bebc56d2f1539 --- /dev/null +++ b/scipy/disk_spinoff/858/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 9 +cube_size = 0.08 +omega_max = 6.853181143244916 +t_ramp = 1.0259447124909276 +mu_s_disk = 0.34872755804632466 +mu_k_disk = 0.37155079480255715 +mu_k_floor = 0.6075949310382283 +g = 9.81 +duration = 12 +fps = 30 +seed = 44 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/858/video.mp4 b/scipy/disk_spinoff/858/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a7d57de23ff280ff15cf5938f3abf03606069644 --- /dev/null +++ b/scipy/disk_spinoff/858/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad4b9b5d9d510d7081600f6c1a09758ebf506538ec0ccb577f26768d1ee14468 +size 29144 diff --git a/scipy/disk_spinoff/969/cot.json b/scipy/disk_spinoff/969/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..b3cdb6708910f05cf7c1b3f4226033aa26b2608b --- /dev/null +++ b/scipy/disk_spinoff/969/cot.json @@ -0,0 +1,104 @@ +{ + "simulation": "disk_spinoff", + "physical_observation": "Top-down view: a disk of radius R=1.000 m spins from rest, ramping linearly to omega_max=4.688 rad/s in t_ramp=1.222 s. 11 small cubes (side 0.080 m) co-rotate with the disk; once required centripetal force exceeds the static-friction limit (mu_s=0.3216674173778353, g=9.81), each cube slips outward, crosses the rim, and decelerates on the floor under mu_k_floor=0.44302298449035554 until it rests.", + "physical_law": { + "name": "Newton II in 2D + Coulomb static/kinetic friction; static-friction limit at the cube-disk contact", + "statement": "While stuck, friction supplies the centripetal+tangential force; once required acceleration exceeds mu_s g, kinetic friction f = mu_k m g acts opposite to relative slip velocity.", + "formula": "Stuck-to-slip threshold: omega^2 r >= mu_s g (when alpha=0). Slipping cube: a = -mu_k g v_rel/|v_rel|. Floor cube: a = -mu_k_floor g v/|v|." + }, + "ode_system": { + "state_variables": [ + "x_i, y_i (cube position, m)", + "vx_i, vy_i (cube velocity, m/s)", + "theta_i (cube orientation, rad)", + "status_i in {STUCK, SLIPPING, FLOOR}" + ], + "equations_latex": [ + "while STUCK and a_req \\leq mu_s \\cdot g: rotate position rigidly with disk; v = (-om y, om x).", + "while SLIPPING: a = -mu_k_disk \\cdot g \\cdot v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor \\cdot g \\cdot v/|v|." + ], + "equations_python": [ + "while STUCK and a_req <= mu_s * g: rotate position rigidly with disk; v = (-om y, om x).", + "while * SLIPPING: a = -mu_k_disk * g * v_rel/|v_rel|.", + "after crossing R_disk: status=FLOOR; a = -mu_k_floor * g * v/|v|." + ] + }, + "derivation_steps": [ + "Disk angular velocity: omega(t) = omega_max \\cdot t/t_ramp for t mu_s g, i.e., r > mu_s g / omega_max^2 = 0.1436 m.", + "During spin-up (t= R_disk^2; on the floor it decelerates by mu_k_floor g." + ], + "physical_constants_derived": { + "r_breakaway_at_max_omega_m": 0.1435910678133954 + }, + "numerical_method": { + "solver": "Fixed-step explicit Euler (dt=1e-3 s) on a 2D state per cube; analytic stuck/slip/floor branches.", + "tolerance": "dt = 1 ms; eps = 1e-6 for velocity-zero snap.", + "justification": "Simple to reason about and stable for the friction-limited dynamics over 12 s." + }, + "code_validation": { + "ode_source": "Newton II in 2D; standard Coulomb friction (static cone for stick, kinetic vector for slip).", + "energy_check": "The prescribed spinning disk can do work on cubes; kinetic friction dissipates relative slip on the disk, and floor friction reduces lab-frame KE after cubes leave the disk.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Cubes initially co-rotate with the disk; as omega ramps up, those at r > 0.144 m slip first.", + "Each slipping cube spirals outward, exits the disk, and slides on the floor until friction stops it.", + "After several seconds all cubes that started outside r_breakaway have left the disk and come to rest." + ], + "parameters": { + "R_disk": { + "value": 1.0, + "unit": "", + "description": "" + }, + "N_cubes": { + "value": 11.346169482314544, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.08, + "unit": "", + "description": "" + }, + "omega_max": { + "value": 4.687856696336084, + "unit": "", + "description": "" + }, + "t_ramp": { + "value": 1.2217173595374908, + "unit": "", + "description": "" + }, + "mu_s_disk": { + "value": 0.3216674173778353, + "unit": "", + "description": "" + }, + "mu_k_disk": { + "value": 0.3861245369461097, + "unit": "", + "description": "" + }, + "mu_k_floor": { + "value": 0.44302298449035554, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + }, + "seed": { + "value": 90.31617097191621, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/disk_spinoff/969/params.json b/scipy/disk_spinoff/969/params.json new file mode 100644 index 0000000000000000000000000000000000000000..dcda0a8e6525e138ed0f0d1df7c1dac801adf5e3 --- /dev/null +++ b/scipy/disk_spinoff/969/params.json @@ -0,0 +1,12 @@ +{ + "R_disk": 1.0, + "N_cubes": 11.346169482314544, + "cube_size": 0.08, + "omega_max": 4.687856696336084, + "t_ramp": 1.2217173595374908, + "mu_s_disk": 0.3216674173778353, + "mu_k_disk": 0.3861245369461097, + "mu_k_floor": 0.44302298449035554, + "g": 9.81, + "seed": 90.31617097191621 +} \ No newline at end of file diff --git a/scipy/disk_spinoff/969/simulation_code.py b/scipy/disk_spinoff/969/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..052a8da22cc396ae95baff96697644e36b787ec6 --- /dev/null +++ b/scipy/disk_spinoff/969/simulation_code.py @@ -0,0 +1,144 @@ +""" +Disk Spin-off — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.transforms as mtransforms +from matplotlib.patches import Rectangle, Circle + +R_disk = 1.0 +N_cubes = 11 +cube_size = 0.08 +omega_max = 4.687856696336084 +t_ramp = 1.2217173595374908 +mu_s_disk = 0.3216674173778353 +mu_k_disk = 0.3861245369461097 +mu_k_floor = 0.44302298449035554 +g = 9.81 +duration = 12 +fps = 30 +seed = 90 + +rng = np.random.default_rng(seed) +r_init = R_disk * np.sqrt(rng.uniform(0.05, 0.85, N_cubes)) +phi_init = rng.uniform(0.0, 2 * np.pi, N_cubes) +x = r_init * np.cos(phi_init); y = r_init * np.sin(phi_init) +vx = np.zeros(N_cubes); vy = np.zeros(N_cubes) +theta_cube = phi_init.copy() +ON_STUCK, ON_SLIP, ON_FLOOR = 0, 1, 2 +status = np.full(N_cubes, ON_STUCK, dtype=int) + +def omega_disk(t): + if t < t_ramp: return omega_max * (t / t_ramp) + return omega_max + +dt = 1e-3 +n_steps = int(round(duration / dt)) + 1 +frame_stride = int(round(1.0 / (fps * dt))) +n_frames = int(duration * fps) + 1 +X_hist = np.zeros((n_frames, N_cubes)) +Y_hist = np.zeros((n_frames, N_cubes)) +TH_hist = np.zeros((n_frames, N_cubes)) +DISK_HIST = np.zeros(n_frames) +disk_angle = 0.0; eps = 1e-6; frame_idx = 0 + +for step in range(n_steps): + t = step * dt + om = omega_disk(t) + disk_angle += om * dt + for i in range(N_cubes): + r2 = x[i]**2 + y[i]**2 + on_disk = r2 < R_disk**2 + if status[i] != ON_FLOOR and not on_disk: + status[i] = ON_FLOOR + if status[i] == ON_STUCK: + r_cur = np.sqrt(r2) + a_c = (om**2) * r_cur + alpha = omega_max/t_ramp if t < t_ramp else 0.0 + a_t = alpha * r_cur + a_req = np.sqrt(a_c**2 + a_t**2) + if a_req <= mu_s_disk * g: + c, s = np.cos(om*dt), np.sin(om*dt) + xn = c*x[i] - s*y[i]; yn = s*x[i] + c*y[i] + x[i] = xn; y[i] = yn + vx[i] = -om * y[i]; vy[i] = om * x[i] + theta_cube[i] += om * dt + else: + status[i] = ON_SLIP + if status[i] == ON_SLIP: + vdx = -om * y[i]; vdy = om * x[i] + vrx = vx[i] - vdx; vry = vy[i] - vdy + vr_mag = np.sqrt(vrx**2 + vry**2) + if vr_mag < eps: ax_ = 0.0; ay_ = 0.0 + else: + ax_ = -mu_k_disk * g * vrx / vr_mag + ay_ = -mu_k_disk * g * vry / vr_mag + vx[i] += ax_*dt; vy[i] += ay_*dt + x[i] += vx[i]*dt; y[i] += vy[i]*dt + theta_cube[i] += om * dt * 0.5 + if x[i]**2 + y[i]**2 >= R_disk**2: + status[i] = ON_FLOOR + elif status[i] == ON_FLOOR: + v_mag = np.sqrt(vx[i]**2 + vy[i]**2) + if v_mag < eps: vx[i] = 0.0; vy[i] = 0.0 + else: + ax_ = -mu_k_floor * g * vx[i] / v_mag + ay_ = -mu_k_floor * g * vy[i] / v_mag + vx_new = vx[i] + ax_*dt; vy_new = vy[i] + ay_*dt + if vx_new * vx[i] + vy_new * vy[i] < 0: + vx[i] = 0.0; vy[i] = 0.0 + else: + vx[i] = vx_new; vy[i] = vy_new + x[i] += vx[i]*dt; y[i] += vy[i]*dt + if step % frame_stride == 0 and frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +while frame_idx < n_frames: + X_hist[frame_idx] = x; Y_hist[frame_idx] = y + TH_hist[frame_idx] = theta_cube; DISK_HIST[frame_idx] = disk_angle + frame_idx += 1 + +W, H = 6.0, 6.0 +fig = plt.figure(figsize=(W, H), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.axis("off"); ax.set_aspect("equal") +extent = 1.6; aspect = W / H +dx = 2*extent; dy = 2*extent +if dx/dy < aspect: + extra = (aspect*dy - dx)/2 + ax.set_xlim(-extent - extra, extent + extra); ax.set_ylim(-extent, extent) +else: + extra = (dx/aspect - dy)/2 + ax.set_xlim(-extent, extent); ax.set_ylim(-extent - extra, extent + extra) + +xlim = ax.get_xlim(); ylim = ax.get_ylim() +ax.add_patch(Rectangle((xlim[0], ylim[0]), xlim[1]-xlim[0], ylim[1]-ylim[0], facecolor="#4a4e69", zorder=0)) +disk_patch = Circle((0,0), R_disk, facecolor="#3a4357", edgecolor="#a8dadc", lw=1.2, zorder=1) +ax.add_patch(disk_patch) +spoke_line, = ax.plot([], [], "-", color="#a8dadc", lw=2.0, zorder=2) +spoke_dot, = ax.plot([], [], "o", color="#a8dadc", ms=5, zorder=2) + +cube_patches = [] +for i in range(N_cubes): + rect = Rectangle((-cube_size/2, -cube_size/2), cube_size, cube_size, + facecolor="#e63946", edgecolor="#1a1a2e", lw=0.8, zorder=3) + ax.add_patch(rect); cube_patches.append(rect) + +def update(frame): + th_d = DISK_HIST[frame] + sx, sy = R_disk * np.cos(th_d), R_disk * np.sin(th_d) + spoke_line.set_data([0, sx], [0, sy]) + rd = 0.6 * R_disk + spoke_dot.set_data([rd * np.cos(th_d + 1.7)], [rd * np.sin(th_d + 1.7)]) + for i, rect in enumerate(cube_patches): + cx = X_hist[frame, i]; cy = Y_hist[frame, i]; th = TH_hist[frame, i] + tr = (mtransforms.Affine2D().rotate(th).translate(cx, cy)) + ax.transData + rect.set_transform(tr) + return [spoke_line, spoke_dot] + cube_patches + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000/fps, blit=True) +ani.save("disk_spinoff.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=2400), dpi=120) +plt.close(); print("Saved disk_spinoff.mp4") diff --git a/scipy/disk_spinoff/969/video.mp4 b/scipy/disk_spinoff/969/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..978bf89a314a8185371ab4cd98cf4fa1b0a29708 --- /dev/null +++ b/scipy/disk_spinoff/969/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:647adff49341ba05ac0ff0046fed77e53df2e017c726bf2a5925c04d10986ee8 +size 33575 diff --git a/scipy/double_2d_spring/045/cot.json b/scipy/double_2d_spring/045/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0cf90c52364722ae11ceb095d5d05fb3000371ee --- /dev/null +++ b/scipy/double_2d_spring/045/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.940 kg, m_2=0.725 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=3.914 N/m, R=1.888 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.372 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 2.0408 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 2.3233 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 2.0408, + "T1_nat_s": 3.0787, + "omega2_nat_rad_s": 2.3233, + "T2_nat_s": 2.7044 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 2.041 rad/s (T_1 = 3.079 s).", + "Mass 2 natural \\omega_2 = 2.323 rad/s (T_2 = 2.704 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 3.9142768314337064, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.9398110216666078, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7251646002167105, + "unit": "", + "description": "" + }, + "b": { + "value": 0.37235584587171194, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.8876739528306072, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.5185836485555677, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 1.9984988202320009, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.2631204722844869, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 2.1754449702514904, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/045/params.json b/scipy/double_2d_spring/045/params.json new file mode 100644 index 0000000000000000000000000000000000000000..35fc27b7c4e4bcb11f16d4809d5320522b9c125e --- /dev/null +++ b/scipy/double_2d_spring/045/params.json @@ -0,0 +1,18 @@ +{ + "k": 3.9142768314337064, + "m1": 0.9398110216666078, + "m2": 0.7251646002167105, + "b": 0.37235584587171194, + "g": 9.8, + "R": 1.8876739528306072, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.5185836485555677, + "y1_0": 1.9984988202320009, + "x2_0": 1.2631204722844869, + "y2_0": 2.1754449702514904, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/045/simulation_code.py b/scipy/double_2d_spring/045/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ad3497fe9a2d7171973c0074add04865dbd6fa5c --- /dev/null +++ b/scipy/double_2d_spring/045/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=3.9142768314337064 N/m, m1=0.9398110216666078 kg, m2=0.7251646002167105 kg, b=0.37235584587171194 kg/s + g=9.8 m/s^2, R=1.8876739528306072 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 3.9142768314337064, 0.9398110216666078, 0.7251646002167105, 0.37235584587171194, 9.8 +R = 1.8876739528306072 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.518584,1.998499,1.263120,2.175445 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/045/video.mp4 b/scipy/double_2d_spring/045/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..799e67f4defa36a0568f274951f7efd027778f62 --- /dev/null +++ b/scipy/double_2d_spring/045/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8655d293a6d64ef5af6e99b834c284feb0a63ecc76c77822f59f206898d0879c +size 18055 diff --git a/scipy/double_2d_spring/052/cot.json b/scipy/double_2d_spring/052/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a534639e194b49726ab272930ad18183a9b4d77d --- /dev/null +++ b/scipy/double_2d_spring/052/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.382 kg, m_2=1.071 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=3.892 N/m, R=1.337 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.068 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 3.1936 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.9066 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 3.1936, + "T1_nat_s": 1.9674, + "omega2_nat_rad_s": 1.9066, + "T2_nat_s": 3.2956 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 3.194 rad/s (T_1 = 1.967 s).", + "Mass 2 natural \\omega_2 = 1.907 rad/s (T_2 = 3.296 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 3.89217476494599, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.38161889886238887, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.0707591425395222, + "unit": "", + "description": "" + }, + "b": { + "value": 0.06805054263324087, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.3366333218835706, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.25972412857665494, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.373161356882028, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.0422792892874915, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 1.8660421544849675, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/052/params.json b/scipy/double_2d_spring/052/params.json new file mode 100644 index 0000000000000000000000000000000000000000..cd358330f8f7807579e8bc243535dc751ae6c70b --- /dev/null +++ b/scipy/double_2d_spring/052/params.json @@ -0,0 +1,18 @@ +{ + "k": 3.89217476494599, + "m1": 0.38161889886238887, + "m2": 1.0707591425395222, + "b": 0.06805054263324087, + "g": 9.8, + "R": 1.3366333218835706, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.25972412857665494, + "y1_0": 2.373161356882028, + "x2_0": 1.0422792892874915, + "y2_0": 1.8660421544849675, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/052/simulation_code.py b/scipy/double_2d_spring/052/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6e0462d26216f454387930ece794dc64de9ffc19 --- /dev/null +++ b/scipy/double_2d_spring/052/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=3.89217476494599 N/m, m1=0.38161889886238887 kg, m2=1.0707591425395222 kg, b=0.06805054263324087 kg/s + g=9.8 m/s^2, R=1.3366333218835706 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 3.89217476494599, 0.38161889886238887, 1.0707591425395222, 0.06805054263324087, 9.8 +R = 1.3366333218835706 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.259724,2.373161,1.042279,1.866042 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/052/video.mp4 b/scipy/double_2d_spring/052/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..86ba6bf7c9822f4e0cc12445c46a53549e31c9be --- /dev/null +++ b/scipy/double_2d_spring/052/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17b5715cc0612eb93fc9140bd4c9c311ab0d4b4c14e10e02b8849218215e4fb7 +size 15903 diff --git a/scipy/double_2d_spring/094/cot.json b/scipy/double_2d_spring/094/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..50ab68b20c0d89e7d67c641ef3090ca4c9b508b4 --- /dev/null +++ b/scipy/double_2d_spring/094/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.903 kg, m_2=0.790 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=1.949 N/m, R=1.117 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.520 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 1.4687 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.5709 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 1.4687, + "T1_nat_s": 4.278, + "omega2_nat_rad_s": 1.5709, + "T2_nat_s": 3.9998 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 1.469 rad/s (T_1 = 4.278 s).", + "Mass 2 natural \\omega_2 = 1.571 rad/s (T_2 = 4.000 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 1.9489134894208395, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.9034916543392186, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7897983322974342, + "unit": "", + "description": "" + }, + "b": { + "value": 0.5200424099000178, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.1170750199376596, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.593122086910179, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.1922493825974967, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.672511725044795, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 2.1130714668097417, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/094/params.json b/scipy/double_2d_spring/094/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e7c95470b58d8cb2ae68e73770e0bb69ff2cbd1e --- /dev/null +++ b/scipy/double_2d_spring/094/params.json @@ -0,0 +1,18 @@ +{ + "k": 1.9489134894208395, + "m1": 0.9034916543392186, + "m2": 0.7897983322974342, + "b": 0.5200424099000178, + "g": 9.8, + "R": 1.1170750199376596, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.593122086910179, + "y1_0": 2.1922493825974967, + "x2_0": 1.672511725044795, + "y2_0": 2.1130714668097417, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/094/simulation_code.py b/scipy/double_2d_spring/094/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c394cc3acdb0556f4b044fb55a199cf8ffd2890f --- /dev/null +++ b/scipy/double_2d_spring/094/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=1.9489134894208395 N/m, m1=0.9034916543392186 kg, m2=0.7897983322974342 kg, b=0.5200424099000178 kg/s + g=9.8 m/s^2, R=1.1170750199376596 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 1.9489134894208395, 0.9034916543392186, 0.7897983322974342, 0.5200424099000178, 9.8 +R = 1.1170750199376596 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.593122,2.192249,1.672512,2.113071 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/094/video.mp4 b/scipy/double_2d_spring/094/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..53fdd2a50c69877387eacd8fe9322ebf0298f978 --- /dev/null +++ b/scipy/double_2d_spring/094/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f1af6af1cfea16458557ae83cea9fc61fc86c78f1f53d05b0451c3567f26c9b +size 12528 diff --git a/scipy/double_2d_spring/208/cot.json b/scipy/double_2d_spring/208/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..5ccbea4ab8be8f3811783856070ba7d936cbcf74 --- /dev/null +++ b/scipy/double_2d_spring/208/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.245 kg, m_2=0.974 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=1.715 N/m, R=1.475 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.602 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 2.6469 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.3269 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 2.6469, + "T1_nat_s": 2.3738, + "omega2_nat_rad_s": 1.3269, + "T2_nat_s": 4.7352 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 2.647 rad/s (T_1 = 2.374 s).", + "Mass 2 natural \\omega_2 = 1.327 rad/s (T_2 = 4.735 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 1.7151930059632017, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.2448233628509166, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.9741753965020588, + "unit": "", + "description": "" + }, + "b": { + "value": 0.6016308658390098, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.4748695591960792, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": -0.8058129038777893, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.9355693161097185, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.3922188646002032, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 2.857451976376523, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/208/params.json b/scipy/double_2d_spring/208/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f1a73387eca31f75be47d31f97992116c4a1e018 --- /dev/null +++ b/scipy/double_2d_spring/208/params.json @@ -0,0 +1,18 @@ +{ + "k": 1.7151930059632017, + "m1": 0.2448233628509166, + "m2": 0.9741753965020588, + "b": 0.6016308658390098, + "g": 9.8, + "R": 1.4748695591960792, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": -0.8058129038777893, + "y1_0": 2.9355693161097185, + "x2_0": 1.3922188646002032, + "y2_0": 2.857451976376523, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/208/simulation_code.py b/scipy/double_2d_spring/208/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9f7728b02be89f27d412220aeea3b6756cc59670 --- /dev/null +++ b/scipy/double_2d_spring/208/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=1.7151930059632017 N/m, m1=0.2448233628509166 kg, m2=0.9741753965020588 kg, b=0.6016308658390098 kg/s + g=9.8 m/s^2, R=1.4748695591960792 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 1.7151930059632017, 0.2448233628509166, 0.9741753965020588, 0.6016308658390098, 9.8 +R = 1.4748695591960792 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = -0.805813,2.935569,1.392219,2.857452 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/208/video.mp4 b/scipy/double_2d_spring/208/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..61a7961d68ee44d2a72a41953b2bbfd666cf920b --- /dev/null +++ b/scipy/double_2d_spring/208/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d860390262a8d89016d6288ea02da746efcb0a4904bbb84fe29674d3846cb32 +size 11242 diff --git a/scipy/double_2d_spring/257/cot.json b/scipy/double_2d_spring/257/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..cfcbed98d3b9fb8f1f084d5672700f5d38c3abbb --- /dev/null +++ b/scipy/double_2d_spring/257/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.303 kg, m_2=0.261 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=3.478 N/m, R=1.874 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.454 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 3.3880 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 3.6470 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 3.388, + "T1_nat_s": 1.8546, + "omega2_nat_rad_s": 3.647, + "T2_nat_s": 1.7228 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 3.388 rad/s (T_1 = 1.855 s).", + "Mass 2 natural \\omega_2 = 3.647 rad/s (T_2 = 1.723 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 3.478020838152331, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.3030092109595656, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.26149424694710366, + "unit": "", + "description": "" + }, + "b": { + "value": 0.4536380797594209, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.8736952949199868, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.8847436403888724, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.817463237919868, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 2.5715932400870933, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 1.4997776550290323, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/257/params.json b/scipy/double_2d_spring/257/params.json new file mode 100644 index 0000000000000000000000000000000000000000..cec540a37191940ed4393850e459fa238ab055e0 --- /dev/null +++ b/scipy/double_2d_spring/257/params.json @@ -0,0 +1,18 @@ +{ + "k": 3.478020838152331, + "m1": 0.3030092109595656, + "m2": 0.26149424694710366, + "b": 0.4536380797594209, + "g": 9.8, + "R": 1.8736952949199868, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.8847436403888724, + "y1_0": 2.817463237919868, + "x2_0": 2.5715932400870933, + "y2_0": 1.4997776550290323, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/257/simulation_code.py b/scipy/double_2d_spring/257/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8b26e996f00d8344bdcf9ef4771018d4ee99e5 --- /dev/null +++ b/scipy/double_2d_spring/257/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=3.478020838152331 N/m, m1=0.3030092109595656 kg, m2=0.26149424694710366 kg, b=0.4536380797594209 kg/s + g=9.8 m/s^2, R=1.8736952949199868 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 3.478020838152331, 0.3030092109595656, 0.26149424694710366, 0.4536380797594209, 9.8 +R = 1.8736952949199868 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.884744,2.817463,2.571593,1.499778 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/257/video.mp4 b/scipy/double_2d_spring/257/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4c70a4612b2e60c783603a1fb148cf7548de72c7 --- /dev/null +++ b/scipy/double_2d_spring/257/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:264a2d5fa7c3770061dab0bc9811e35afc93b95dd099ef2ca1b176edced23dfc +size 14656 diff --git a/scipy/double_2d_spring/270/cot.json b/scipy/double_2d_spring/270/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..42f203412c490799ac789e6946240546cd5e7ec1 --- /dev/null +++ b/scipy/double_2d_spring/270/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=1.382 kg, m_2=0.790 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=2.598 N/m, R=1.198 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.157 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 1.3711 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.8140 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 1.3711, + "T1_nat_s": 4.5827, + "omega2_nat_rad_s": 1.814, + "T2_nat_s": 3.4638 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 1.371 rad/s (T_1 = 4.583 s).", + "Mass 2 natural \\omega_2 = 1.814 rad/s (T_2 = 3.464 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 2.5982538697199615, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.3821636002944826, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7896203177358374, + "unit": "", + "description": "" + }, + "b": { + "value": 0.15727732074187584, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.1976915060826852, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": -0.600572688302683, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.985609052593519, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.811381715855141, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 2.611998651322185, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/270/params.json b/scipy/double_2d_spring/270/params.json new file mode 100644 index 0000000000000000000000000000000000000000..26ceb824e367bf5edcb0a14eb633abec5e0fa22a --- /dev/null +++ b/scipy/double_2d_spring/270/params.json @@ -0,0 +1,18 @@ +{ + "k": 2.5982538697199615, + "m1": 1.3821636002944826, + "m2": 0.7896203177358374, + "b": 0.15727732074187584, + "g": 9.8, + "R": 1.1976915060826852, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": -0.600572688302683, + "y1_0": 2.985609052593519, + "x2_0": 1.811381715855141, + "y2_0": 2.611998651322185, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/270/simulation_code.py b/scipy/double_2d_spring/270/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ff80e713cd9ee9831fcfa39e3a5947b72b1c7712 --- /dev/null +++ b/scipy/double_2d_spring/270/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=2.5982538697199615 N/m, m1=1.3821636002944826 kg, m2=0.7896203177358374 kg, b=0.15727732074187584 kg/s + g=9.8 m/s^2, R=1.1976915060826852 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 2.5982538697199615, 1.3821636002944826, 0.7896203177358374, 0.15727732074187584, 9.8 +R = 1.1976915060826852 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = -0.600573,2.985609,1.811382,2.611999 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/270/video.mp4 b/scipy/double_2d_spring/270/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b0881d1b17b1042bff65508c009a5d8525019851 --- /dev/null +++ b/scipy/double_2d_spring/270/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21fdb4797936443b518aa2b64939e8a8e6a45365663b3c67e451832a5b0129d0 +size 12725 diff --git a/scipy/double_2d_spring/283/cot.json b/scipy/double_2d_spring/283/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6c24dcd8f3d2daf50edb1e622f598a3eeeccaa58 --- /dev/null +++ b/scipy/double_2d_spring/283/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=1.332 kg, m_2=0.583 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=1.994 N/m, R=1.284 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.733 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 1.2237 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.8503 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 1.2237, + "T1_nat_s": 5.1345, + "omega2_nat_rad_s": 1.8503, + "T2_nat_s": 3.3958 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 1.224 rad/s (T_1 = 5.134 s).", + "Mass 2 natural \\omega_2 = 1.850 rad/s (T_2 = 3.396 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 1.9942596674505904, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.3317291154694493, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.5825183599388062, + "unit": "", + "description": "" + }, + "b": { + "value": 0.7334535676743847, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.284262502352075, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.5226459448412544, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.056924749066795, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 2.3641639403914563, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 2.4971589567789714, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/283/params.json b/scipy/double_2d_spring/283/params.json new file mode 100644 index 0000000000000000000000000000000000000000..49ff47b164ed16fb4a9b006db084e17be0df39f6 --- /dev/null +++ b/scipy/double_2d_spring/283/params.json @@ -0,0 +1,18 @@ +{ + "k": 1.9942596674505904, + "m1": 1.3317291154694493, + "m2": 0.5825183599388062, + "b": 0.7334535676743847, + "g": 9.8, + "R": 1.284262502352075, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.5226459448412544, + "y1_0": 2.056924749066795, + "x2_0": 2.3641639403914563, + "y2_0": 2.4971589567789714, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/283/simulation_code.py b/scipy/double_2d_spring/283/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6c089830f08a960911049ac0d751dc5bfce8b440 --- /dev/null +++ b/scipy/double_2d_spring/283/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=1.9942596674505904 N/m, m1=1.3317291154694493 kg, m2=0.5825183599388062 kg, b=0.7334535676743847 kg/s + g=9.8 m/s^2, R=1.284262502352075 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 1.9942596674505904, 1.3317291154694493, 0.5825183599388062, 0.7334535676743847, 9.8 +R = 1.284262502352075 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.522646,2.056925,2.364164,2.497159 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/283/video.mp4 b/scipy/double_2d_spring/283/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9abd213abbab28bb1c2bd559fc31c27c4ffbffcb --- /dev/null +++ b/scipy/double_2d_spring/283/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad6de016302724914cd25773cd18b13e0fad218b270de2397ab0d9ef8b157dd0 +size 12428 diff --git a/scipy/double_2d_spring/433/cot.json b/scipy/double_2d_spring/433/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8f8815cbb3cb7818b1f28cc44d8f8868334a4031 --- /dev/null +++ b/scipy/double_2d_spring/433/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.906 kg, m_2=0.333 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=2.650 N/m, R=1.876 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.553 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 1.7100 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 2.8199 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 1.71, + "T1_nat_s": 3.6745, + "omega2_nat_rad_s": 2.8199, + "T2_nat_s": 2.2281 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 1.710 rad/s (T_1 = 3.674 s).", + "Mass 2 natural \\omega_2 = 2.820 rad/s (T_2 = 2.228 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 2.6501323375285364, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.9063541143290634, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.3332644767912461, + "unit": "", + "description": "" + }, + "b": { + "value": 0.5526226268056609, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.8759689381867737, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.6765119478903983, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 1.632042376058093, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.5672442808655516, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 2.0505433673883555, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/433/params.json b/scipy/double_2d_spring/433/params.json new file mode 100644 index 0000000000000000000000000000000000000000..77ebbef0c46fb0427823f370494bc59cf5753ebd --- /dev/null +++ b/scipy/double_2d_spring/433/params.json @@ -0,0 +1,18 @@ +{ + "k": 2.6501323375285364, + "m1": 0.9063541143290634, + "m2": 0.3332644767912461, + "b": 0.5526226268056609, + "g": 9.8, + "R": 1.8759689381867737, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.6765119478903983, + "y1_0": 1.632042376058093, + "x2_0": 1.5672442808655516, + "y2_0": 2.0505433673883555, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/433/simulation_code.py b/scipy/double_2d_spring/433/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..80eac50124ebca33a868051707c0134ed9e138c2 --- /dev/null +++ b/scipy/double_2d_spring/433/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=2.6501323375285364 N/m, m1=0.9063541143290634 kg, m2=0.3332644767912461 kg, b=0.5526226268056609 kg/s + g=9.8 m/s^2, R=1.8759689381867737 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 2.6501323375285364, 0.9063541143290634, 0.3332644767912461, 0.5526226268056609, 9.8 +R = 1.8759689381867737 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.676512,1.632042,1.567244,2.050543 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/433/video.mp4 b/scipy/double_2d_spring/433/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..071e82ea08ce38ed6600eb7a2c3195a6315a2d66 --- /dev/null +++ b/scipy/double_2d_spring/433/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f73ae7f6299f312eb7bbaa34ea6047dabda9b8afc0ba7bbe38e0f3d05c4f97d +size 14728 diff --git a/scipy/double_2d_spring/500/cot.json b/scipy/double_2d_spring/500/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..7f9d827a087fe8a7f7c2cc59ca7ab21d7cffca70 --- /dev/null +++ b/scipy/double_2d_spring/500/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=1.159 kg, m_2=1.262 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=5.277 N/m, R=1.938 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.635 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 2.1336 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 2.0445 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 2.1336, + "T1_nat_s": 2.9449, + "omega2_nat_rad_s": 2.0445, + "T2_nat_s": 3.0732 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 2.134 rad/s (T_1 = 2.945 s).", + "Mass 2 natural \\omega_2 = 2.044 rad/s (T_2 = 3.073 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 5.276964852365501, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.1591870310345553, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.2624408195461376, + "unit": "", + "description": "" + }, + "b": { + "value": 0.6352000033518214, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.9383723102164885, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": -0.7350182881357585, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.1029960328892288, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 2.580479437595275, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 1.7835907816253338, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/500/params.json b/scipy/double_2d_spring/500/params.json new file mode 100644 index 0000000000000000000000000000000000000000..94dd3761ecc0927d9aabdb901dc55db9238c24b1 --- /dev/null +++ b/scipy/double_2d_spring/500/params.json @@ -0,0 +1,18 @@ +{ + "k": 5.276964852365501, + "m1": 1.1591870310345553, + "m2": 1.2624408195461376, + "b": 0.6352000033518214, + "g": 9.8, + "R": 1.9383723102164885, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": -0.7350182881357585, + "y1_0": 2.1029960328892288, + "x2_0": 2.580479437595275, + "y2_0": 1.7835907816253338, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/500/simulation_code.py b/scipy/double_2d_spring/500/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..e18bc9db3284b6dc34820d11813b717ecca3c55d --- /dev/null +++ b/scipy/double_2d_spring/500/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=5.276964852365501 N/m, m1=1.1591870310345553 kg, m2=1.2624408195461376 kg, b=0.6352000033518214 kg/s + g=9.8 m/s^2, R=1.9383723102164885 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 5.276964852365501, 1.1591870310345553, 1.2624408195461376, 0.6352000033518214, 9.8 +R = 1.9383723102164885 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = -0.735018,2.102996,2.580479,1.783591 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/500/video.mp4 b/scipy/double_2d_spring/500/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b088ed99683fcc3aee5bf4b43c464ab33137cf95 --- /dev/null +++ b/scipy/double_2d_spring/500/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0d4cbd51e1ad0c6f20fb842ba1b4e6244865b94a4259b70fcdde24430ebdf20 +size 14988 diff --git a/scipy/double_2d_spring/517/cot.json b/scipy/double_2d_spring/517/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c10b4cc1c534c31bb73c73fdcdbf25f787e2b1c2 --- /dev/null +++ b/scipy/double_2d_spring/517/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.811 kg, m_2=0.392 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=1.532 N/m, R=1.491 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.793 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 1.3748 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.9777 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 1.3748, + "T1_nat_s": 4.5702, + "omega2_nat_rad_s": 1.9777, + "T2_nat_s": 3.177 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 1.375 rad/s (T_1 = 4.570 s).", + "Mass 2 natural \\omega_2 = 1.978 rad/s (T_2 = 3.177 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 1.532397061838747, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.8107407252341718, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.3917854709547445, + "unit": "", + "description": "" + }, + "b": { + "value": 0.7932021868867944, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.4911070553891506, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": -0.6981340177460267, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.623847860997972, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.2602778912330448, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 1.2026921140454108, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/517/params.json b/scipy/double_2d_spring/517/params.json new file mode 100644 index 0000000000000000000000000000000000000000..4487974728385cf1f8b6b32e4a25eff616e478e7 --- /dev/null +++ b/scipy/double_2d_spring/517/params.json @@ -0,0 +1,18 @@ +{ + "k": 1.532397061838747, + "m1": 0.8107407252341718, + "m2": 0.3917854709547445, + "b": 0.7932021868867944, + "g": 9.8, + "R": 1.4911070553891506, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": -0.6981340177460267, + "y1_0": 2.623847860997972, + "x2_0": 1.2602778912330448, + "y2_0": 1.2026921140454108, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/517/simulation_code.py b/scipy/double_2d_spring/517/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c75fd829991435a5040b7bda8b9d76ba741f0f43 --- /dev/null +++ b/scipy/double_2d_spring/517/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=1.532397061838747 N/m, m1=0.8107407252341718 kg, m2=0.3917854709547445 kg, b=0.7932021868867944 kg/s + g=9.8 m/s^2, R=1.4911070553891506 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 1.532397061838747, 0.8107407252341718, 0.3917854709547445, 0.7932021868867944, 9.8 +R = 1.4911070553891506 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = -0.698134,2.623848,1.260278,1.202692 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/517/video.mp4 b/scipy/double_2d_spring/517/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..20497dc7a1618784b1bff5527b8b80e7f6e18ac7 --- /dev/null +++ b/scipy/double_2d_spring/517/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82ea789dc1277eead95a10c292966af6c6bbd8822e9c4ef51eca4c1c0e93299b +size 12286 diff --git a/scipy/double_2d_spring/649/cot.json b/scipy/double_2d_spring/649/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..10e81ee31ed5965da23d08af91f8b569896a7c9a --- /dev/null +++ b/scipy/double_2d_spring/649/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.920 kg, m_2=1.179 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=4.547 N/m, R=1.883 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.503 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 2.2237 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.9635 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 2.2237, + "T1_nat_s": 2.8255, + "omega2_nat_rad_s": 1.9635, + "T2_nat_s": 3.2 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 2.224 rad/s (T_1 = 2.826 s).", + "Mass 2 natural \\omega_2 = 1.964 rad/s (T_2 = 3.200 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 4.5470318680222945, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.9195205667298298, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.179401302465896, + "unit": "", + "description": "" + }, + "b": { + "value": 0.5026845082754993, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.8825521796900229, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.46285651108570414, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.176078478603479, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 2.850321904701371, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 1.1551908913767897, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/649/params.json b/scipy/double_2d_spring/649/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a72aa6b48e07c6819d9018cfbc0565d4dced9d2a --- /dev/null +++ b/scipy/double_2d_spring/649/params.json @@ -0,0 +1,18 @@ +{ + "k": 4.5470318680222945, + "m1": 0.9195205667298298, + "m2": 1.179401302465896, + "b": 0.5026845082754993, + "g": 9.8, + "R": 1.8825521796900229, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.46285651108570414, + "y1_0": 2.176078478603479, + "x2_0": 2.850321904701371, + "y2_0": 1.1551908913767897, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/649/simulation_code.py b/scipy/double_2d_spring/649/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9fb7fa04f8dfbd85ea4f1972485b1f786d24946a --- /dev/null +++ b/scipy/double_2d_spring/649/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=4.5470318680222945 N/m, m1=0.9195205667298298 kg, m2=1.179401302465896 kg, b=0.5026845082754993 kg/s + g=9.8 m/s^2, R=1.8825521796900229 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 4.5470318680222945, 0.9195205667298298, 1.179401302465896, 0.5026845082754993, 9.8 +R = 1.8825521796900229 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.462857,2.176078,2.850322,1.155191 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/649/video.mp4 b/scipy/double_2d_spring/649/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..00e0342a754e541849d1b8fa365a2c2ae34a239b --- /dev/null +++ b/scipy/double_2d_spring/649/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba4f652c7306d029adf1de6dad33406574707bac0345b8ef8a45259f3fa6d52b +size 15494 diff --git a/scipy/double_2d_spring/703/cot.json b/scipy/double_2d_spring/703/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..70467d7e32113420a3ec8f54d67cd9d6d4330180 --- /dev/null +++ b/scipy/double_2d_spring/703/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=1.179 kg, m_2=1.365 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=2.125 N/m, R=1.944 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.179 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 1.3422 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.2478 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 1.3422, + "T1_nat_s": 4.6811, + "omega2_nat_rad_s": 1.2478, + "T2_nat_s": 5.0355 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 1.342 rad/s (T_1 = 4.681 s).", + "Mass 2 natural \\omega_2 = 1.248 rad/s (T_2 = 5.036 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 2.1248589672047773, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.1794212150817316, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.364763807251301, + "unit": "", + "description": "" + }, + "b": { + "value": 0.1793924962278892, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.9443542896230057, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.8136048288841102, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.649231924587207, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.6237273492407682, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 2.7617873762605893, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/703/params.json b/scipy/double_2d_spring/703/params.json new file mode 100644 index 0000000000000000000000000000000000000000..6438a8a1525551b42836afae5a550ced72fc92f8 --- /dev/null +++ b/scipy/double_2d_spring/703/params.json @@ -0,0 +1,18 @@ +{ + "k": 2.1248589672047773, + "m1": 1.1794212150817316, + "m2": 1.364763807251301, + "b": 0.1793924962278892, + "g": 9.8, + "R": 1.9443542896230057, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.8136048288841102, + "y1_0": 2.649231924587207, + "x2_0": 1.6237273492407682, + "y2_0": 2.7617873762605893, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/703/simulation_code.py b/scipy/double_2d_spring/703/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b6e251aeac12f8884120788ef1a445553f19f761 --- /dev/null +++ b/scipy/double_2d_spring/703/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=2.1248589672047773 N/m, m1=1.1794212150817316 kg, m2=1.364763807251301 kg, b=0.1793924962278892 kg/s + g=9.8 m/s^2, R=1.9443542896230057 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 2.1248589672047773, 1.1794212150817316, 1.364763807251301, 0.1793924962278892, 9.8 +R = 1.9443542896230057 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.813605,2.649232,1.623727,2.761787 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/703/video.mp4 b/scipy/double_2d_spring/703/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d5d9df55794405aac80d569e1e52793428684c45 --- /dev/null +++ b/scipy/double_2d_spring/703/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:30d651c700449e5721f6fe15932713b2d39a0930b6a420e00dc7aa18fd548888 +size 12195 diff --git a/scipy/double_2d_spring/849/cot.json b/scipy/double_2d_spring/849/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4d5eb19dab59849a047e6761312487f196ce8a50 --- /dev/null +++ b/scipy/double_2d_spring/849/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.702 kg, m_2=0.922 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=5.770 N/m, R=1.449 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.595 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 2.8669 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 2.5022 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 2.8669, + "T1_nat_s": 2.1916, + "omega2_nat_rad_s": 2.5022, + "T2_nat_s": 2.511 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 2.867 rad/s (T_1 = 2.192 s).", + "Mass 2 natural \\omega_2 = 2.502 rad/s (T_2 = 2.511 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 5.770349698519162, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.7020597830219768, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.9215993241876317, + "unit": "", + "description": "" + }, + "b": { + "value": 0.5949708599466426, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.449371057563288, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": -0.654864258124153, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 1.715392648372536, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 2.112846804127261, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 1.1410565392153749, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/849/params.json b/scipy/double_2d_spring/849/params.json new file mode 100644 index 0000000000000000000000000000000000000000..adcce1d3d453f78c1575d16426818b9a7dda421a --- /dev/null +++ b/scipy/double_2d_spring/849/params.json @@ -0,0 +1,18 @@ +{ + "k": 5.770349698519162, + "m1": 0.7020597830219768, + "m2": 0.9215993241876317, + "b": 0.5949708599466426, + "g": 9.8, + "R": 1.449371057563288, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": -0.654864258124153, + "y1_0": 1.715392648372536, + "x2_0": 2.112846804127261, + "y2_0": 1.1410565392153749, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/849/simulation_code.py b/scipy/double_2d_spring/849/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5aec4a74b0567bd8ea8db9e8ec51acdfd901908f --- /dev/null +++ b/scipy/double_2d_spring/849/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=5.770349698519162 N/m, m1=0.7020597830219768 kg, m2=0.9215993241876317 kg, b=0.5949708599466426 kg/s + g=9.8 m/s^2, R=1.449371057563288 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 5.770349698519162, 0.7020597830219768, 0.9215993241876317, 0.5949708599466426, 9.8 +R = 1.449371057563288 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = -0.654864,1.715393,2.112847,1.141057 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/849/video.mp4 b/scipy/double_2d_spring/849/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ca82aeec4cb4a043672b0e61583ed270791f6b80 --- /dev/null +++ b/scipy/double_2d_spring/849/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35e97ce501a57185e8270326d136de63bd0eefbcfdffa4a0b8cc4d5c4d1754ee +size 17240 diff --git a/scipy/double_2d_spring/866/cot.json b/scipy/double_2d_spring/866/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..ec77f1151629c7f2ad74e71a5400bb269ceda764 --- /dev/null +++ b/scipy/double_2d_spring/866/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=1.267 kg, m_2=1.417 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=3.756 N/m, R=1.045 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.027 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 1.7215 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.6285 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 1.7215, + "T1_nat_s": 3.6497, + "omega2_nat_rad_s": 1.6285, + "T2_nat_s": 3.8583 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 1.722 rad/s (T_1 = 3.650 s).", + "Mass 2 natural \\omega_2 = 1.628 rad/s (T_2 = 3.858 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 3.7564919088854474, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.2674889470292843, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.416523331338845, + "unit": "", + "description": "" + }, + "b": { + "value": 0.027420399969799194, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 1.0446225630527504, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.19730151094587423, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.5875798460130226, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 1.5308281329911102, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 2.0568939886482207, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/866/params.json b/scipy/double_2d_spring/866/params.json new file mode 100644 index 0000000000000000000000000000000000000000..767744db1bd5b929426b5e037547a4072adadf91 --- /dev/null +++ b/scipy/double_2d_spring/866/params.json @@ -0,0 +1,18 @@ +{ + "k": 3.7564919088854474, + "m1": 1.2674889470292843, + "m2": 1.416523331338845, + "b": 0.027420399969799194, + "g": 9.8, + "R": 1.0446225630527504, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.19730151094587423, + "y1_0": 2.5875798460130226, + "x2_0": 1.5308281329911102, + "y2_0": 2.0568939886482207, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/866/simulation_code.py b/scipy/double_2d_spring/866/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d6366aaae498d21410f5ece37e96aec2c96620fc --- /dev/null +++ b/scipy/double_2d_spring/866/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=3.7564919088854474 N/m, m1=1.2674889470292843 kg, m2=1.416523331338845 kg, b=0.027420399969799194 kg/s + g=9.8 m/s^2, R=1.0446225630527504 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 3.7564919088854474, 1.2674889470292843, 1.416523331338845, 0.027420399969799194, 9.8 +R = 1.0446225630527504 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.197302,2.587580,1.530828,2.056894 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/866/video.mp4 b/scipy/double_2d_spring/866/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..8d482d0bcf746036a82326c9d1b95786512c8c86 --- /dev/null +++ b/scipy/double_2d_spring/866/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:597d1597e2ecdb4ea40675a5ce4dc766dc5995be24420a64102c21581a93094e +size 12336 diff --git a/scipy/double_2d_spring/873/cot.json b/scipy/double_2d_spring/873/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..326752e85cf82dbace36d92ef89561fd32889bf0 --- /dev/null +++ b/scipy/double_2d_spring/873/cot.json @@ -0,0 +1,153 @@ +{ + "simulation": "double_2d_spring", + "physical_observation": "Two masses (m_1=0.508 kg, m_2=0.782 kg) are connected by springs in 2D. Mass 1 is attached to anchor (0.00, 4.00) via a spring (k=1.804 N/m, R=0.964 m). Mass 2 is connected to mass 1 via a second identical spring. Gravity g=9.800 m/s^2 acts downward; damping b=0.379 kg/s.", + "physical_law": { + "name": "Hooke's Law for Two Coupled 2D Springs + Newton's 2nd Law", + "statement": "Each mass obeys F=ma with spring forces from attached springs, gravity, and viscous damping.", + "formula": "F_spring = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|)\nm_1\\ddot{r}_1 = F_s1(anchor \\rightarrow m1) + F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_1\nm_2\\ddot{r}_2 = -F_s2(m1 \\rightarrow m2) + F_grav - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1", + "y_1", + "vx_1", + "vy_1", + "x_2", + "y_2", + "vx_2", + "vy_2" + ], + "equations_latex": [ + "\\dot{x}_1 = vx_1, \\dot{y}_1 = vy_1", + "\\dot{vx}_1 = [F_s1x + F_s2x]/m_1 - (b/m_1) \\cdot vx_1", + "\\dot{vy}_1 = [F_s1y + F_s2y]/m_1 - (b/m_1) \\cdot vy_1 - g", + "\\dot{x}_2 = vx_2, \\dot{y}_2 = vy_2", + "\\dot{vx}_2 = -F_s2x/m_2 - (b/m_2) \\cdot vx_2", + "\\dot{vy}_2 = -F_s2y/m_2 - (b/m_2) \\cdot vy_2 - g", + "F_sN = -k \\cdot (dist_N - R) \\cdot (\\DeltarN/dist_N)" + ], + "equations_python": [ + "x_dot_1 = vx_1, y_dot_1 = vy_1", + "vx_dot_1 = [F_s1 * x + F_s2 * x]/m_1 - (b/m_1) * vx_1", + "vy_dot_1 = [F_s1 * y + F_s2 * y]/m_1 - (b/m_1) * vy_1 - g", + "x_dot_2 = vx_2, y_dot_2 = vy_2", + "vx_dot_2 = -F_s2 * x/m_2 - (b/m_2) * vx_2", + "vy_dot_2 = -F_s2 * y/m_2 - (b/m_2) * vy_2 - g", + "F_sN = -k * (dist_N - R) * (DeltarN/dist_N)" + ] + }, + "derivation_steps": [ + "Spring 1 connects anchor (ax1,ay1) to mass 1: \\Deltar_1 = r_1 - (ax1,ay1).", + "Spring 2 connects mass 1 to mass 2: \\Deltar_2 = r_2 - r_1.", + "Spring force formula: F_s = -k \\cdot (|\\Deltar|-R) \\cdot (\\Deltar/|\\Deltar|).", + "Mass 1 forces: spring 1 (pulls toward anchor) + spring 2 (pulls toward m2) + gravity + damping.", + "Mass 2 forces: spring 2 (Newton's 3rd: opposite to force on m1) + gravity + damping.", + "Natural frequency of spring-mass 1: \\omega_1 = \\sqrt(k/m_1) = 1.8847 rad/s.", + "Natural frequency of spring-mass 2: \\omega_2 = \\sqrt(k/m_2) = 1.5186 rad/s.", + "Coupled 8-DOF system: 4 positions + 4 velocities." + ], + "physical_constants_derived": { + "omega1_nat_rad_s": 1.8847, + "T1_nat_s": 3.3338, + "omega2_nat_rad_s": 1.5186, + "T2_nat_s": 4.1374 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "8-DOF nonlinear system; adaptive step control essential." + }, + "code_validation": { + "ode_source": "Hooke's Law vector form for two springs; matches Double2DSpring.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1|v_1|^2 + \\tfrac{1}{2} m_2|v_2|^2 + \\tfrac{1}{2} k(s_1^2+s_2^2) + m_1gy_1 + m_2gy_2 decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Mass 1 natural \\omega_1 = 1.885 rad/s (T_1 = 3.334 s).", + "Mass 2 natural \\omega_2 = 1.519 rad/s (T_2 = 4.137 s).", + "Coupled 2D motion: complex Lissajous-like trajectories with beats between modes.", + "Energy cascades between spring 1 and spring 2 subsystems." + ], + "parameters": { + "k": { + "value": 1.8043773133745487, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.5079856260454021, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7823787468603085, + "unit": "", + "description": "" + }, + "b": { + "value": 0.37923750382813104, + "unit": "kg/s", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "R": { + "value": 0.9637769168649595, + "unit": "m", + "description": "" + }, + "ax1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "ay1": { + "value": 4.0, + "unit": "", + "description": "" + }, + "x1_0": { + "value": 0.8406184006597339, + "unit": "", + "description": "" + }, + "y1_0": { + "value": 2.5546176952985036, + "unit": "", + "description": "" + }, + "x2_0": { + "value": 2.8942900097074697, + "unit": "", + "description": "" + }, + "y2_0": { + "value": 1.1832280380859816, + "unit": "", + "description": "" + }, + "vx1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vx2_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "vy2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_2d_spring/873/params.json b/scipy/double_2d_spring/873/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f61b72157de34472da231ecc34b601531302c0f6 --- /dev/null +++ b/scipy/double_2d_spring/873/params.json @@ -0,0 +1,18 @@ +{ + "k": 1.8043773133745487, + "m1": 0.5079856260454021, + "m2": 0.7823787468603085, + "b": 0.37923750382813104, + "g": 9.8, + "R": 0.9637769168649595, + "ax1": 0.0, + "ay1": 4.0, + "x1_0": 0.8406184006597339, + "y1_0": 2.5546176952985036, + "x2_0": 2.8942900097074697, + "y2_0": 1.1832280380859816, + "vx1_0": 0.0, + "vy1_0": 0.0, + "vx2_0": 0.0, + "vy2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_2d_spring/873/simulation_code.py b/scipy/double_2d_spring/873/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..e4366242e3a3545a11be5acd1e18b29bfccc04c4 --- /dev/null +++ b/scipy/double_2d_spring/873/simulation_code.py @@ -0,0 +1,80 @@ +""" +Double 2D Spring — auto-generated simulation script. +Physics (Double2DSpringSim.ts): + Spring 1: anchor(0.0,4.0) -> bob1, Spring 2: bob1 -> bob2 + V1x' = (f12x + f21x - b*V1x) / m1 + V1y' = -g + (f12y + f21y - b*V1y) / m1 + V2x' = (f22x - b*V2x) / m2 + V2y' = -g + (f22y - b*V2y) / m2 +Parameters: k=1.8043773133745487 N/m, m1=0.5079856260454021 kg, m2=0.7823787468603085 kg, b=0.37923750382813104 kg/s + g=9.8 m/s^2, R=0.9637769168649595 m (rest length) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b, g = 1.8043773133745487, 0.5079856260454021, 0.7823787468603085, 0.37923750382813104, 9.8 +R = 0.9637769168649595 +ax1, ay1 = 0.0, 4.0 +x1_0,y1_0,x2_0,y2_0 = 0.840618,2.554618,2.894290,1.183228 +vx1_0,vy1_0,vx2_0,vy2_0 = 0.000000,0.000000,0.000000,0.000000 +duration = 12 + +def spring_force(xs, ys, xe, ye, k, R): + dx, dy = xe-xs, ye-ys + dist = np.hypot(dx, dy) + if dist < 1e-10: return 0,0,0,0 + st = dist - R; ux, uy = dx/dist, dy/dist + return k*st*ux, k*st*uy, -k*st*ux, -k*st*uy + +def ode(t, s): + x1,y1,x2,y2,vx1,vy1,vx2,vy2 = s + _,_,f12x,f12y = spring_force(ax1,ay1,x1,y1,k,R) + f21x,f21y,f22x,f22y = spring_force(x1,y1,x2,y2,k,R) + return [vx1,vy1,vx2,vy2, + (f12x+f21x-b*vx1)/m1, -g+(f12y+f21y-b*vy1)/m1, + (f22x-b*vx2)/m2, -g+(f22y-b*vy2)/m2] + +fps = 30 +t_eval = np.linspace(0,duration,int(duration*fps)+1) +sol = solve_ivp(ode,(0,duration),[x1_0,y1_0,x2_0,y2_0,vx1_0,vy1_0,vx2_0,vy2_0], + t_eval=t_eval,method="RK45",rtol=1e-8,atol=1e-10) +x1a,y1a,x2a,y2a = sol.y[0],sol.y[1],sol.y[2],sol.y[3] + +all_x=np.concatenate([[ax1],x1a,x2a]); all_y=np.concatenate([[ay1],y1a,y2a]) +mg=1.5 +xlim=(all_x.min()-mg,all_x.max()+mg); ylim=(all_y.min()-mg,all_y.max()+mg) + +fig,ax=plt.subplots(figsize=(8,6),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(xlim); ax.set_ylim(ylim) +ax.set_aspect("equal"); ax.axis("off") + +asq=0.22 +ax.add_patch(patches.Rectangle((ax1-asq/2,ay1-asq/2),asq,asq, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1.5,zorder=4)) +sp1,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +sp2,=ax.plot([],[],"-",color="#90e0ef",lw=2.5,zorder=3) +b1c=plt.Circle((x1_0,y1_0),0.18,facecolor="#e63946",edgecolor="white",lw=1.5,zorder=5) +b2c=plt.Circle((x2_0,y2_0),0.18,facecolor="#f4a261",edgecolor="white",lw=1.5,zorder=5) +ax.add_patch(b1c); ax.add_patch(b2c) + +def spfn(x1,y1,x2,y2,n=7,r=0.12): + dx,dy=x2-x1,y2-y1; L=np.hypot(dx,dy) + if L<1e-10: return np.array([x1,x2]),np.array([y1,y2]) + ux,uy=dx/L,dy/L; nx,ny=-uy,ux + n_pts=n*20+2; t=np.linspace(0,1,n_pts); mg2=0.08 + env=np.where((t1-mg2),0,np.sin(n*2*np.pi*(t-mg2)/(1-2*mg2))) + return x1+t*dx+r*env*nx, y1+t*dy+r*env*ny + +def update(f): + b1x,b1y=x1a[f],y1a[f]; b2x,b2y=x2a[f],y2a[f] + b1c.set_center((b1x,b1y)); b2c.set_center((b2x,b2y)) + s1x,s1y=spfn(ax1,ay1,b1x,b1y); sp1.set_data(s1x,s1y) + s2x,s2y=spfn(b1x,b1y,b2x,b2y); sp2.set_data(s2x,s2y) + return (sp1,sp2,b1c,b2c) + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_2d_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=100) +plt.close(); print("Saved double_2d_spring.mp4") diff --git a/scipy/double_2d_spring/873/video.mp4 b/scipy/double_2d_spring/873/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..378a5fbe07e0d2223cc920a1e02859274fb7880c --- /dev/null +++ b/scipy/double_2d_spring/873/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5cb18153e419413f4e2d0baf5aca6856db1705e950772efd4e3b23787b5b5c8 +size 13141 diff --git a/scipy/double_pendulum/003/cot.json b/scipy/double_pendulum/003/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..b21f9f46d7d2295bf7e8366c56453433ce9f0465 --- /dev/null +++ b/scipy/double_pendulum/003/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=0.594 m, L_2=1.399 m) with point masses (m_1=1.451 kg, m_2=2.789 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=-0.72 rad, \\theta_2=-0.25 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 0.593626634607902, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.3993164338604238, + "unit": "", + "description": "" + }, + "m1": { + "value": 1.45108714512032, + "unit": "", + "description": "" + }, + "m2": { + "value": 2.7886307205325975, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": -0.7167465030905683, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": -0.24600417431650978, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/003/params.json b/scipy/double_pendulum/003/params.json new file mode 100644 index 0000000000000000000000000000000000000000..6bdd96a117051400e7ac7a0a8160f83ccddb93be --- /dev/null +++ b/scipy/double_pendulum/003/params.json @@ -0,0 +1,11 @@ +{ + "L1": 0.593626634607902, + "L2": 1.3993164338604238, + "m1": 1.45108714512032, + "m2": 2.7886307205325975, + "g": 9.8, + "theta1_0": -0.7167465030905683, + "omega1_0": 0.0, + "theta2_0": -0.24600417431650978, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/003/simulation_code.py b/scipy/double_pendulum/003/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..418e1097298e952ae86e4c20aa1a220af979a1a6 --- /dev/null +++ b/scipy/double_pendulum/003/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 0.593626634607902, 1.3993164338604238 +m1, m2 = 1.45108714512032, 2.7886307205325975 +g = 9.8 +theta1_0 = -0.716747 +omega1_0 = 0.000000 +theta2_0 = -0.246004 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/003/video.mp4 b/scipy/double_pendulum/003/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c97207ca3e5326deaead952b145dd05b3f5efbec --- /dev/null +++ b/scipy/double_pendulum/003/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7320b473b709d8d99eb4c38b08c3527650f66b183573588f29464e300a90d1fe +size 18318 diff --git a/scipy/double_pendulum/009/cot.json b/scipy/double_pendulum/009/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..dd0c95f91e814fd84cbd581942a3104f1b1798a5 --- /dev/null +++ b/scipy/double_pendulum/009/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=1.369 m, L_2=1.331 m) with point masses (m_1=2.500 kg, m_2=2.833 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=1.46 rad, \\theta_2=1.19 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 1.3694695823315515, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.3311138648775818, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.500087208469949, + "unit": "", + "description": "" + }, + "m2": { + "value": 2.833031448707542, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": 1.4589534381593263, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": 1.1908372681247008, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/009/params.json b/scipy/double_pendulum/009/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f23b5ed1b0977db67a9d5af9389a35a4b1145c34 --- /dev/null +++ b/scipy/double_pendulum/009/params.json @@ -0,0 +1,11 @@ +{ + "L1": 1.3694695823315515, + "L2": 1.3311138648775818, + "m1": 2.500087208469949, + "m2": 2.833031448707542, + "g": 9.8, + "theta1_0": 1.4589534381593263, + "omega1_0": 0.0, + "theta2_0": 1.1908372681247008, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/009/simulation_code.py b/scipy/double_pendulum/009/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c8041c4c78647836150761a7899fe89125754951 --- /dev/null +++ b/scipy/double_pendulum/009/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 1.3694695823315515, 1.3311138648775818 +m1, m2 = 2.500087208469949, 2.833031448707542 +g = 9.8 +theta1_0 = 1.458953 +omega1_0 = 0.000000 +theta2_0 = 1.190837 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/009/video.mp4 b/scipy/double_pendulum/009/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e6ed989ee71d9d61fd2d629444b608bc9150f949 --- /dev/null +++ b/scipy/double_pendulum/009/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a609ac614c60482b3382a6c6c79ce2092ff9e44b22d6f1c839bebd5ea73c1f19 +size 22442 diff --git a/scipy/double_pendulum/036/cot.json b/scipy/double_pendulum/036/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..d12f4862295d2c239c0e1231803629a2a03d2a93 --- /dev/null +++ b/scipy/double_pendulum/036/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=0.502 m, L_2=0.819 m) with point masses (m_1=2.839 kg, m_2=1.552 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=0.24 rad, \\theta_2=0.82 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 0.5020629011168841, + "unit": "", + "description": "" + }, + "L2": { + "value": 0.818650717130989, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.8392259701258995, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.55190490508619, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": 0.24119036819422512, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": 0.8173219424744689, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/036/params.json b/scipy/double_pendulum/036/params.json new file mode 100644 index 0000000000000000000000000000000000000000..1c56e6faf7b77aeb5dff249ca2466802133e0490 --- /dev/null +++ b/scipy/double_pendulum/036/params.json @@ -0,0 +1,11 @@ +{ + "L1": 0.5020629011168841, + "L2": 0.818650717130989, + "m1": 2.8392259701258995, + "m2": 1.55190490508619, + "g": 9.8, + "theta1_0": 0.24119036819422512, + "omega1_0": 0.0, + "theta2_0": 0.8173219424744689, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/036/simulation_code.py b/scipy/double_pendulum/036/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..460dd3f3f3995374ca569e8b224c8b0310affe6b --- /dev/null +++ b/scipy/double_pendulum/036/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 0.5020629011168841, 0.818650717130989 +m1, m2 = 2.8392259701258995, 1.55190490508619 +g = 9.8 +theta1_0 = 0.241190 +omega1_0 = 0.000000 +theta2_0 = 0.817322 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/036/video.mp4 b/scipy/double_pendulum/036/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..950ce8f3b0a7f3466c8dd0fff647222180f17ca1 --- /dev/null +++ b/scipy/double_pendulum/036/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a32391642668e378b8cf959319c4053ac9d99aebd5689ba76cd9c0b8ac679956 +size 19915 diff --git a/scipy/double_pendulum/077/cot.json b/scipy/double_pendulum/077/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..ca09210bcb476548325746b9db775989cceabd89 --- /dev/null +++ b/scipy/double_pendulum/077/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=0.832 m, L_2=0.693 m) with point masses (m_1=2.655 kg, m_2=2.839 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=-0.63 rad, \\theta_2=-1.33 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 0.8324751314221878, + "unit": "", + "description": "" + }, + "L2": { + "value": 0.6927373618632513, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.6546686134791138, + "unit": "", + "description": "" + }, + "m2": { + "value": 2.8394190619681248, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": -0.62928451182811, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": -1.3269612329575833, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/077/params.json b/scipy/double_pendulum/077/params.json new file mode 100644 index 0000000000000000000000000000000000000000..027fc4ca67a709e0608a98d0d7e7d43524f5c6f5 --- /dev/null +++ b/scipy/double_pendulum/077/params.json @@ -0,0 +1,11 @@ +{ + "L1": 0.8324751314221878, + "L2": 0.6927373618632513, + "m1": 2.6546686134791138, + "m2": 2.8394190619681248, + "g": 9.8, + "theta1_0": -0.62928451182811, + "omega1_0": 0.0, + "theta2_0": -1.3269612329575833, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/077/simulation_code.py b/scipy/double_pendulum/077/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d1594945bc38bf40ab590e5353a91fe99fa5f8ee --- /dev/null +++ b/scipy/double_pendulum/077/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 0.8324751314221878, 0.6927373618632513 +m1, m2 = 2.6546686134791138, 2.8394190619681248 +g = 9.8 +theta1_0 = -0.629285 +omega1_0 = 0.000000 +theta2_0 = -1.326961 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/077/video.mp4 b/scipy/double_pendulum/077/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..1251cf0fd421435359348639be6071c5bda1a903 --- /dev/null +++ b/scipy/double_pendulum/077/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1f8bb221c9f6922369ff0592a9f3da99e85841d27a9de75a51ebd66a2e6f1369 +size 23990 diff --git a/scipy/double_pendulum/114/cot.json b/scipy/double_pendulum/114/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..5227f8973894132ecbba19ece29aa61a16ed6c9f --- /dev/null +++ b/scipy/double_pendulum/114/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=0.639 m, L_2=1.175 m) with point masses (m_1=2.480 kg, m_2=1.011 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=0.64 rad, \\theta_2=-1.05 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 0.6394019597358919, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.1746539302508934, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.4797265490092624, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.010696306705326, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": 0.6404787415568771, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": -1.0528623752594248, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/114/params.json b/scipy/double_pendulum/114/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5fb15a875337478dbd757b582a76e064e354e11d --- /dev/null +++ b/scipy/double_pendulum/114/params.json @@ -0,0 +1,11 @@ +{ + "L1": 0.6394019597358919, + "L2": 1.1746539302508934, + "m1": 2.4797265490092624, + "m2": 1.010696306705326, + "g": 9.8, + "theta1_0": 0.6404787415568771, + "omega1_0": 0.0, + "theta2_0": -1.0528623752594248, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/114/simulation_code.py b/scipy/double_pendulum/114/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..a23735a80832479309737b2c88be9c3fd22f0b0d --- /dev/null +++ b/scipy/double_pendulum/114/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 0.6394019597358919, 1.1746539302508934 +m1, m2 = 2.4797265490092624, 1.010696306705326 +g = 9.8 +theta1_0 = 0.640479 +omega1_0 = 0.000000 +theta2_0 = -1.052862 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/114/video.mp4 b/scipy/double_pendulum/114/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4ea407969f8d2b90f38d64490ebf35dcb865bd5e --- /dev/null +++ b/scipy/double_pendulum/114/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e9c69fab074b2be85e2aaf061ab846728cb4f550426a147b46c6ec506e9d92c +size 22670 diff --git a/scipy/double_pendulum/133/cot.json b/scipy/double_pendulum/133/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6c9e8c32d4666c83080c3cc826aac04e6335a45a --- /dev/null +++ b/scipy/double_pendulum/133/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=0.579 m, L_2=1.034 m) with point masses (m_1=1.571 kg, m_2=2.412 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=0.06 rad, \\theta_2=1.25 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 0.5794010615687899, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.0335200450700648, + "unit": "", + "description": "" + }, + "m1": { + "value": 1.570938834252646, + "unit": "", + "description": "" + }, + "m2": { + "value": 2.4118977470072562, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": 0.060619553479560384, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": 1.2513147949964383, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/133/params.json b/scipy/double_pendulum/133/params.json new file mode 100644 index 0000000000000000000000000000000000000000..81566d7431342b03b2c282e28ea33ec2c3f510b9 --- /dev/null +++ b/scipy/double_pendulum/133/params.json @@ -0,0 +1,11 @@ +{ + "L1": 0.5794010615687899, + "L2": 1.0335200450700648, + "m1": 1.570938834252646, + "m2": 2.4118977470072562, + "g": 9.8, + "theta1_0": 0.060619553479560384, + "omega1_0": 0.0, + "theta2_0": 1.2513147949964383, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/133/simulation_code.py b/scipy/double_pendulum/133/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c789168a0b9c92e28eb1dff6143267d86deb091c --- /dev/null +++ b/scipy/double_pendulum/133/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 0.5794010615687899, 1.0335200450700648 +m1, m2 = 1.570938834252646, 2.4118977470072562 +g = 9.8 +theta1_0 = 0.060620 +omega1_0 = 0.000000 +theta2_0 = 1.251315 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/133/video.mp4 b/scipy/double_pendulum/133/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a42838446819e84fd62860eeed876fb7ab3056ab --- /dev/null +++ b/scipy/double_pendulum/133/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2fc3725e9aa2b433d2a18c0b2b73c0cafa7d1b7334c366d697bdbce81126f2d5 +size 24279 diff --git a/scipy/double_pendulum/152/cot.json b/scipy/double_pendulum/152/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6466867dc9edcbe02a1d1a498435c5b02c2acefa --- /dev/null +++ b/scipy/double_pendulum/152/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=1.244 m, L_2=1.310 m) with point masses (m_1=2.830 kg, m_2=2.078 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=-1.11 rad, \\theta_2=-1.16 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 1.2441863725617717, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.3104882226223902, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.829966352276678, + "unit": "", + "description": "" + }, + "m2": { + "value": 2.0775433333495994, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": -1.1065161815014868, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": -1.1554857510168062, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/152/params.json b/scipy/double_pendulum/152/params.json new file mode 100644 index 0000000000000000000000000000000000000000..184c19627c1498932bd3bff779985510cda6f1db --- /dev/null +++ b/scipy/double_pendulum/152/params.json @@ -0,0 +1,11 @@ +{ + "L1": 1.2441863725617717, + "L2": 1.3104882226223902, + "m1": 2.829966352276678, + "m2": 2.0775433333495994, + "g": 9.8, + "theta1_0": -1.1065161815014868, + "omega1_0": 0.0, + "theta2_0": -1.1554857510168062, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/152/simulation_code.py b/scipy/double_pendulum/152/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d05086a56523a508fa4911a88122f15bca95d7b6 --- /dev/null +++ b/scipy/double_pendulum/152/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 1.2441863725617717, 1.3104882226223902 +m1, m2 = 2.829966352276678, 2.0775433333495994 +g = 9.8 +theta1_0 = -1.106516 +omega1_0 = 0.000000 +theta2_0 = -1.155486 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/152/video.mp4 b/scipy/double_pendulum/152/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7abda1ff644c66341ec00cde0e853126d4b9c15b --- /dev/null +++ b/scipy/double_pendulum/152/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4724601df1b51d846b3bd0026df7498fa32a054488c15679540341ee3ab03e6 +size 23234 diff --git a/scipy/double_pendulum/165/cot.json b/scipy/double_pendulum/165/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a95f4310aca45fbdbf5826a32170459f78a5bba9 --- /dev/null +++ b/scipy/double_pendulum/165/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=1.458 m, L_2=0.700 m) with point masses (m_1=1.971 kg, m_2=1.328 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=0.94 rad, \\theta_2=0.83 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 1.4575563814974815, + "unit": "", + "description": "" + }, + "L2": { + "value": 0.6999729067288812, + "unit": "", + "description": "" + }, + "m1": { + "value": 1.9705393721238593, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.3283640301455688, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": 0.9375600301084859, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": 0.829719063030538, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/165/params.json b/scipy/double_pendulum/165/params.json new file mode 100644 index 0000000000000000000000000000000000000000..4eba2287b144374c9cc8fd7abf7cf0ad86d325c9 --- /dev/null +++ b/scipy/double_pendulum/165/params.json @@ -0,0 +1,11 @@ +{ + "L1": 1.4575563814974815, + "L2": 0.6999729067288812, + "m1": 1.9705393721238593, + "m2": 1.3283640301455688, + "g": 9.8, + "theta1_0": 0.9375600301084859, + "omega1_0": 0.0, + "theta2_0": 0.829719063030538, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/165/simulation_code.py b/scipy/double_pendulum/165/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5d51bf8b199835f80563983e4904963f3d759529 --- /dev/null +++ b/scipy/double_pendulum/165/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 1.4575563814974815, 0.6999729067288812 +m1, m2 = 1.9705393721238593, 1.3283640301455688 +g = 9.8 +theta1_0 = 0.937560 +omega1_0 = 0.000000 +theta2_0 = 0.829719 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/165/video.mp4 b/scipy/double_pendulum/165/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..769c24380529f3de456930343533a6f92c647c52 --- /dev/null +++ b/scipy/double_pendulum/165/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc817b3a054dc7f3a7db0f7909420a6905e42bbcf829212733e02a0bd5ec0370 +size 22000 diff --git a/scipy/double_pendulum/268/cot.json b/scipy/double_pendulum/268/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8002386b8df88429eaa83252bdb07e68ee215f8e --- /dev/null +++ b/scipy/double_pendulum/268/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=1.044 m, L_2=1.438 m) with point masses (m_1=2.187 kg, m_2=1.418 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=-0.43 rad, \\theta_2=1.04 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 1.0443282341014766, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.438246001129288, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.1867025986542523, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.418449045245705, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": -0.43211805395292435, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": 1.0407113086309834, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/268/params.json b/scipy/double_pendulum/268/params.json new file mode 100644 index 0000000000000000000000000000000000000000..10ab3f486c99a9843d03fd9329f49edf9751cae6 --- /dev/null +++ b/scipy/double_pendulum/268/params.json @@ -0,0 +1,11 @@ +{ + "L1": 1.0443282341014766, + "L2": 1.438246001129288, + "m1": 2.1867025986542523, + "m2": 1.418449045245705, + "g": 9.8, + "theta1_0": -0.43211805395292435, + "omega1_0": 0.0, + "theta2_0": 1.0407113086309834, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/268/simulation_code.py b/scipy/double_pendulum/268/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ddadc6d9dbfe6e3298605c6bd190e734f17dd575 --- /dev/null +++ b/scipy/double_pendulum/268/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 1.0443282341014766, 1.438246001129288 +m1, m2 = 2.1867025986542523, 1.418449045245705 +g = 9.8 +theta1_0 = -0.432118 +omega1_0 = 0.000000 +theta2_0 = 1.040711 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/268/video.mp4 b/scipy/double_pendulum/268/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..cd2d02ec12732912e2b4544f275b4e68b4f98897 --- /dev/null +++ b/scipy/double_pendulum/268/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59722cf9b80b4565f101fe9c7d1b1a025e5173006ec95cea4592e66054b16389 +size 21275 diff --git a/scipy/double_pendulum/341/cot.json b/scipy/double_pendulum/341/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..10276e7a1a90c5789726d5350a1ef47e51f75b75 --- /dev/null +++ b/scipy/double_pendulum/341/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=0.910 m, L_2=1.486 m) with point masses (m_1=1.454 kg, m_2=1.788 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=0.43 rad, \\theta_2=-1.16 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 0.9100060022988777, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.485649163802862, + "unit": "", + "description": "" + }, + "m1": { + "value": 1.4535500653878293, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.7878698085726483, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": 0.43498312016166363, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": -1.1646052734075774, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/341/params.json b/scipy/double_pendulum/341/params.json new file mode 100644 index 0000000000000000000000000000000000000000..dcc53be5b7c0369b65e76f494c5c2529220eabb6 --- /dev/null +++ b/scipy/double_pendulum/341/params.json @@ -0,0 +1,11 @@ +{ + "L1": 0.9100060022988777, + "L2": 1.485649163802862, + "m1": 1.4535500653878293, + "m2": 1.7878698085726483, + "g": 9.8, + "theta1_0": 0.43498312016166363, + "omega1_0": 0.0, + "theta2_0": -1.1646052734075774, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/341/simulation_code.py b/scipy/double_pendulum/341/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..47a14e7f6eb2c8a3ec83eef55213487dfa712451 --- /dev/null +++ b/scipy/double_pendulum/341/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 0.9100060022988777, 1.485649163802862 +m1, m2 = 1.4535500653878293, 1.7878698085726483 +g = 9.8 +theta1_0 = 0.434983 +omega1_0 = 0.000000 +theta2_0 = -1.164605 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/341/video.mp4 b/scipy/double_pendulum/341/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..190debc01aecb4b0381ce3deb33e328f6ed0e58c --- /dev/null +++ b/scipy/double_pendulum/341/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c9bd17d9c5e051571fd0892c0506bebfff4b5fc9771ad63ad71912316c6ce3a3 +size 23307 diff --git a/scipy/double_pendulum/437/cot.json b/scipy/double_pendulum/437/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..fdf0eb5b601e107bfbbf42e3f6f9391056ae900f --- /dev/null +++ b/scipy/double_pendulum/437/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=0.773 m, L_2=1.467 m) with point masses (m_1=2.604 kg, m_2=2.624 kg) swing from a fixed pivot. Small initial angles produce near-periodic motion.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": false + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Near-linear, nearly periodic motion for small initial angles." + ], + "parameters": { + "L1": { + "value": 0.7729167152316081, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.4665237888925078, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.6044138714155434, + "unit": "", + "description": "" + }, + "m2": { + "value": 2.6240703787598054, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": 0.10683911474612406, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": -0.4372853671796486, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/437/params.json b/scipy/double_pendulum/437/params.json new file mode 100644 index 0000000000000000000000000000000000000000..4d162dbd5e15a406ba6f62405967951caac28cb0 --- /dev/null +++ b/scipy/double_pendulum/437/params.json @@ -0,0 +1,11 @@ +{ + "L1": 0.7729167152316081, + "L2": 1.4665237888925078, + "m1": 2.6044138714155434, + "m2": 2.6240703787598054, + "g": 9.8, + "theta1_0": 0.10683911474612406, + "omega1_0": 0.0, + "theta2_0": -0.4372853671796486, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/437/simulation_code.py b/scipy/double_pendulum/437/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ad8587c27759e3d6079f3f5ab07381022e75f809 --- /dev/null +++ b/scipy/double_pendulum/437/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 0.7729167152316081, 1.4665237888925078 +m1, m2 = 2.6044138714155434, 2.6240703787598054 +g = 9.8 +theta1_0 = 0.106839 +omega1_0 = 0.000000 +theta2_0 = -0.437285 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/437/video.mp4 b/scipy/double_pendulum/437/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3a5fbfc0ce5eb421c306c09b18ea5c6251392917 --- /dev/null +++ b/scipy/double_pendulum/437/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:020b7971826344c135ed8ab52dd0a75aa981e50f7c3be2d8813e29a101180743 +size 15460 diff --git a/scipy/double_pendulum/452/cot.json b/scipy/double_pendulum/452/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8fff1366c08a3bbb80f8517a787023002ede430f --- /dev/null +++ b/scipy/double_pendulum/452/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=1.191 m, L_2=1.249 m) with point masses (m_1=2.655 kg, m_2=2.127 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=-0.87 rad, \\theta_2=0.52 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 1.1912576213794548, + "unit": "", + "description": "" + }, + "L2": { + "value": 1.2486591364965465, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.6551435722705437, + "unit": "", + "description": "" + }, + "m2": { + "value": 2.1271135156219914, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": -0.8662784378136241, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": 0.5199166947614811, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/452/params.json b/scipy/double_pendulum/452/params.json new file mode 100644 index 0000000000000000000000000000000000000000..8f2553155c59081becfe049b8fca039742e687d1 --- /dev/null +++ b/scipy/double_pendulum/452/params.json @@ -0,0 +1,11 @@ +{ + "L1": 1.1912576213794548, + "L2": 1.2486591364965465, + "m1": 2.6551435722705437, + "m2": 2.1271135156219914, + "g": 9.8, + "theta1_0": -0.8662784378136241, + "omega1_0": 0.0, + "theta2_0": 0.5199166947614811, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/452/simulation_code.py b/scipy/double_pendulum/452/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..76f790c6506d7b5adae07d13502fbe74e2476846 --- /dev/null +++ b/scipy/double_pendulum/452/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 1.1912576213794548, 1.2486591364965465 +m1, m2 = 2.6551435722705437, 2.1271135156219914 +g = 9.8 +theta1_0 = -0.866278 +omega1_0 = 0.000000 +theta2_0 = 0.519917 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/452/video.mp4 b/scipy/double_pendulum/452/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..66620012cb80268242d8781d45b7fa0e38caca3a --- /dev/null +++ b/scipy/double_pendulum/452/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a938b3158153d01e4792f7efc85bcf9fc7a8c4d32a2109b8216c68bf7d37e00b +size 22248 diff --git a/scipy/double_pendulum/558/cot.json b/scipy/double_pendulum/558/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..2f52383562149e851c7cee1cbee6d88b1b6687df --- /dev/null +++ b/scipy/double_pendulum/558/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=1.291 m, L_2=0.804 m) with point masses (m_1=2.574 kg, m_2=1.930 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=-0.69 rad, \\theta_2=-0.52 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 1.2908273342777645, + "unit": "", + "description": "" + }, + "L2": { + "value": 0.8041444791252301, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.574247832805651, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.929693220087589, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": -0.6938048463442205, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": -0.5193847075713587, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/558/params.json b/scipy/double_pendulum/558/params.json new file mode 100644 index 0000000000000000000000000000000000000000..bb1088e45673149125986e9d6b7dd96f22c37132 --- /dev/null +++ b/scipy/double_pendulum/558/params.json @@ -0,0 +1,11 @@ +{ + "L1": 1.2908273342777645, + "L2": 0.8041444791252301, + "m1": 2.574247832805651, + "m2": 1.929693220087589, + "g": 9.8, + "theta1_0": -0.6938048463442205, + "omega1_0": 0.0, + "theta2_0": -0.5193847075713587, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/558/simulation_code.py b/scipy/double_pendulum/558/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d2f8711f9b658517e372037b9b68ae0717004a3f --- /dev/null +++ b/scipy/double_pendulum/558/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 1.2908273342777645, 0.8041444791252301 +m1, m2 = 2.574247832805651, 1.929693220087589 +g = 9.8 +theta1_0 = -0.693805 +omega1_0 = 0.000000 +theta2_0 = -0.519385 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/558/video.mp4 b/scipy/double_pendulum/558/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..346f6291e0b16b4ce02c82d9a7f4718eed8f2c6e --- /dev/null +++ b/scipy/double_pendulum/558/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:561ce87f486be69b9d1b8ba937e033a9d0ab173718c43ffa95625271fd53d769 +size 20419 diff --git a/scipy/double_pendulum/564/cot.json b/scipy/double_pendulum/564/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..64784331ca57db568a10d982fb4487a6d246b674 --- /dev/null +++ b/scipy/double_pendulum/564/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=1.249 m, L_2=0.774 m) with point masses (m_1=2.861 kg, m_2=1.714 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=-1.22 rad, \\theta_2=0.50 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 1.2486724732361, + "unit": "", + "description": "" + }, + "L2": { + "value": 0.7735600025604722, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.8608179994634946, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.7142967908235074, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": -1.2178531987965595, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": 0.5041486611373243, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/564/params.json b/scipy/double_pendulum/564/params.json new file mode 100644 index 0000000000000000000000000000000000000000..570b236366550f832f48d1dc922c34da9c98ddd0 --- /dev/null +++ b/scipy/double_pendulum/564/params.json @@ -0,0 +1,11 @@ +{ + "L1": 1.2486724732361, + "L2": 0.7735600025604722, + "m1": 2.8608179994634946, + "m2": 1.7142967908235074, + "g": 9.8, + "theta1_0": -1.2178531987965595, + "omega1_0": 0.0, + "theta2_0": 0.5041486611373243, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/564/simulation_code.py b/scipy/double_pendulum/564/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6c750aa91afe3337b33a8093173bfe0712051754 --- /dev/null +++ b/scipy/double_pendulum/564/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 1.2486724732361, 0.7735600025604722 +m1, m2 = 2.8608179994634946, 1.7142967908235074 +g = 9.8 +theta1_0 = -1.217853 +omega1_0 = 0.000000 +theta2_0 = 0.504149 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/564/video.mp4 b/scipy/double_pendulum/564/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4884a491f640f7a450403f86093761abb4998e59 --- /dev/null +++ b/scipy/double_pendulum/564/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8392566929505bab27a811c2a2b425479c6280f47e500cf936f96b1e485aa58a +size 25577 diff --git a/scipy/double_pendulum/574/cot.json b/scipy/double_pendulum/574/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..697b41a2b9388e22bfd109d42842a0f5cd8da3de --- /dev/null +++ b/scipy/double_pendulum/574/cot.json @@ -0,0 +1,102 @@ +{ + "simulation": "double_pendulum", + "physical_observation": "Two rigid rods connected in series (L_1=0.956 m, L_2=0.827 m) with point masses (m_1=2.794 kg, m_2=2.086 kg) swing from a fixed pivot. The large initial displacement (\\theta_1=1.05 rad, \\theta_2=0.10 rad) causes chaotic, non-repeating motion --- the hallmark of a double pendulum.", + "physical_law": { + "name": "Lagrangian Mechanics (Euler-Lagrange equations)", + "statement": "For generalized coordinates q_i: d/dt( \\partial L/ \\partial \\dot{q}_i) - \\partial L/ \\partial q_i = 0, where L = T - V.", + "formula": "Coupled 2nd-order ODEs derived from L = T(\\theta_1,\\theta_2,\\dot{\\theta}_1,\\dot{\\theta}_2) - V(\\theta_1,\\theta_2)" + }, + "ode_system": { + "state_variables": [ + "\\theta_1", + "\\omega_1=\\dot{\\theta}_1", + "\\theta_2", + "\\omega_2=\\dot{\\theta}_2" + ], + "equations_latex": [ + "\\dot{\\theta}_1 = \\omega_1", + "\\dot{\\omega}_1 = [-g(2m_1+m_2)\\sin(\\theta_1) - gm_2\\sin(\\theta_1-2\\theta_2) - 2m_2\\omega_2^2L_2\\sin(\\theta_1-\\theta_2) - m_2\\omega_1^2L_1\\sin(2(\\theta_1-\\theta_2))] / [L_1(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]", + "\\dot{\\theta}_2 = \\omega_2", + "\\dot{\\omega}_2 = [2\\sin(\\theta_1-\\theta_2)((m_1+m_2)\\omega_1^2L_1 + g(m_1+m_2)\\cos(\\theta_1) + m_2\\omega_2^2L_2\\cos(\\theta_1-\\theta_2))] / [L_2(2m_1+m_2-m_2\\cos(2(\\theta_1-\\theta_2)))]" + ], + "equations_python": [ + "theta_dot_1 = omega_1", + "omega_dot_1 = [-g(2 * m_1+m_2) * np.sin ( theta_1) - gm_2 * np.sin ( theta_1-2 * theta_2) - 2 * m_2 * omega_2**2 * L_2 * np.sin ( theta_1- theta_2) - m_2 * omega_1**2 * L_1 * np.sin (2 * ( theta_1- theta_2))] / [L_1 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]", + "theta_dot_2 = omega_2", + "omega_dot_2 = [2 * np.sin ( theta_1- theta_2)((m_1+m_2) * omega_1**2 * L_1 + g(m_1+m_2) * np.cos ( theta_1) + m_2 * omega_2**2 * L_2 * np.cos ( theta_1- theta_2))] / [L_2 * (2 * m_1+m_2-m_2 * np.cos (2 * ( theta_1- theta_2)))]" + ] + }, + "derivation_steps": [ + "Define Cartesian positions of bob 1 and bob 2:", + " x_1 = L_1 \\sin(\\theta_1), y_1 = -L_1 \\cos(\\theta_1)", + " x_2 = L_1 \\sin(\\theta_1) + L_2 \\sin(\\theta_2), y_2 = -L_1 \\cos(\\theta_1) - L_2 \\cos(\\theta_2)", + "Write kinetic energy T = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 in terms of \\theta_1, \\theta_2, \\dot{\\theta}_1, \\dot{\\theta}_2.", + "Write potential energy V = m_1 g y_1 + m_2 g y_2.", + "Form Lagrangian L = T - V.", + "Apply Euler-Lagrange: d/dt( \\partial L/ \\partial \\omega_1) - \\partial L/ \\partial \\theta_1 = 0 and d/dt( \\partial L/ \\partial \\omega_2) - \\partial L/ \\partial \\theta_2 = 0.", + "Solve the resulting 2 \\times 2 linear system for \\ddot{\\theta}_1, \\ddot{\\theta}_2 (see equations above).", + "These are exactly the equations implemented in DoublePendulumSim.ts evaluate()." + ], + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11", + "note": "High-accuracy tolerances needed because double pendulum is sensitive to initial conditions." + }, + "code_validation": { + "ode_source": "Euler-Lagrange equations; exact translation of DoublePendulumSim.ts evaluate()", + "energy_check": "Total E = T + V conserved (no damping); energy drift < 0.01% for 15 s run", + "physical_plausibility": true, + "chaos_indicator": true + }, + "expected_behavior": [ + "No damping --- total mechanical energy is conserved.", + "Sensitive dependence on initial conditions for large angles (chaos)." + ], + "parameters": { + "L1": { + "value": 0.9564689436338989, + "unit": "", + "description": "" + }, + "L2": { + "value": 0.826824530706679, + "unit": "", + "description": "" + }, + "m1": { + "value": 2.794103078138433, + "unit": "", + "description": "" + }, + "m2": { + "value": 2.0855771339453857, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "theta1_0": { + "value": 1.0532683044867603, + "unit": "", + "description": "" + }, + "omega1_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "theta2_0": { + "value": 0.10086344398759195, + "unit": "", + "description": "" + }, + "omega2_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_pendulum/574/params.json b/scipy/double_pendulum/574/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5108afbcc0479f47b3001b76b7dc66b53d147d14 --- /dev/null +++ b/scipy/double_pendulum/574/params.json @@ -0,0 +1,11 @@ +{ + "L1": 0.9564689436338989, + "L2": 0.826824530706679, + "m1": 2.794103078138433, + "m2": 2.0855771339453857, + "g": 9.8, + "theta1_0": 1.0532683044867603, + "omega1_0": 0.0, + "theta2_0": 0.10086344398759195, + "omega2_0": 0.0 +} \ No newline at end of file diff --git a/scipy/double_pendulum/574/simulation_code.py b/scipy/double_pendulum/574/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..46366324530000aade2ed38801aabbb7d1242f25 --- /dev/null +++ b/scipy/double_pendulum/574/simulation_code.py @@ -0,0 +1,65 @@ +""" +Double Pendulum — auto-generated simulation script. +Physics (Lagrangian mechanics): + θ̈₁ = [-g(2m₁+m₂)sin(θ₁) - gm₂sin(θ₁-2θ₂) - 2m₂θ̇₂²L₂sin(θ₁-θ₂) - m₂θ̇₁²L₁sin(2(θ₁-θ₂))] + / [L₁(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] + θ̈₂ = [2sin(θ₁-θ₂)((m₁+m₂)θ̇₁²L₁ + g(m₁+m₂)cos(θ₁) + m₂θ̇₂²L₂cos(θ₁-θ₂))] + / [L₂(2m₁+m₂ - m₂cos(2(θ₁-θ₂)))] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +L1, L2 = 0.9564689436338989, 0.826824530706679 +m1, m2 = 2.794103078138433, 2.0855771339453857 +g = 9.8 +theta1_0 = 1.053268 +omega1_0 = 0.000000 +theta2_0 = 0.100863 +omega2_0 = 0.000000 +duration = 12 + +def ode(t, y): + th1, dth1, th2, dth2 = y + diff = th1 - th2 + denom = 2*m1 + m2 - m2*np.cos(2*diff) + num1 = -g*(2*m1+m2)*np.sin(th1) - g*m2*np.sin(th1-2*th2) + num1 -= 2*m2*dth2**2*L2*np.sin(diff) + m2*dth1**2*L1*np.sin(2*diff) + ddth1 = num1 / (L1 * denom) + num2 = 2*np.sin(diff)*((m1+m2)*dth1**2*L1 + g*(m1+m2)*np.cos(th1) + m2*dth2**2*L2*np.cos(diff)) + ddth2 = num2 / (L2 * denom) + return [dth1, ddth1, dth2, ddth2] + +fps = 30 +t_eval = np.linspace(0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0, duration), [theta1_0, omega1_0, theta2_0, omega2_0], + t_eval=t_eval, method="RK45", rtol=1e-9, atol=1e-11) +th1, th2 = sol.y[0], sol.y[2] +x1 = L1*np.sin(th1); y1 = -L1*np.cos(th1) +x2 = x1+L2*np.sin(th2); y2 = y1-L2*np.cos(th2) + +lim = (L1+L2)*1.25 +fig, ax = plt.subplots(figsize=(6,6), facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(-lim,lim); ax.set_ylim(-lim,lim*0.2) +ax.set_aspect("equal"); ax.axis("off") +ax.plot([0],[0],"o",color="white",ms=7,zorder=5) +trail, = ax.plot([],[],"-",color="#e63946",alpha=0.4,lw=1.0,zorder=2) +rod1, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +rod2, = ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +bob1, = ax.plot([],[], "o",color="#f4d35e",ms=12,zorder=4) +bob2, = ax.plot([],[], "o",color="#e63946",ms=12,zorder=4) +tx,ty = [],[] + +def update(f): + rod1.set_data([0,x1[f]],[0,y1[f]]) + rod2.set_data([x1[f],x2[f]],[y1[f],y2[f]]) + bob1.set_data([x1[f]],[y1[f]]); bob2.set_data([x2[f]],[y2[f]]) + tx.append(x2[f]); ty.append(y2[f]) + if len(tx)>150: tx.pop(0); ty.pop(0) + trail.set_data(tx,ty) + return trail,rod1,rod2,bob1,bob2 + +ani = animation.FuncAnimation(fig, update, frames=len(sol.t), interval=1000/fps, blit=True) +ani.save("double_pendulum.mp4", writer=animation.FFMpegWriter(fps=fps,bitrate=1800), dpi=120) +plt.close(); print("Saved double_pendulum.mp4") diff --git a/scipy/double_pendulum/574/video.mp4 b/scipy/double_pendulum/574/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9e108e3f2bd4763bfcc4a80a091d0a54de5bc1b8 --- /dev/null +++ b/scipy/double_pendulum/574/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3c642e2647ebc8ae4b48333660de34c47a47ceca588b9102e54c57379b597ad +size 23925 diff --git a/scipy/double_spring/040/cot.json b/scipy/double_spring/040/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0c1c8c569134a6c8a3490998e866d6cb976da8da --- /dev/null +++ b/scipy/double_spring/040/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=1.941 kg, m_2=1.981 kg) are coupled by three identical springs (k=5.797 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=0.53 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "For m_1 \\approx m_2: in-phase \\omega_1 \\approx 1.719 rad/s, out-of-phase \\omega_2 \\approx 2.978 rad/s" + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "For m_1 \\approx m_2: in-phase \\omega_1 \\approx 1.719 rad/s, out-of-phase \\omega_2 \\approx 2.978 rad/s" + ], + "parameters": { + "k": { + "value": 5.796611149827626, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.940654706195517, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.98140257169819, + "unit": "", + "description": "" + }, + "b": { + "value": 0.11975937987947705, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": 0.5682973411452252, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.1739830304481531, + "unit": "", + "description": "" + }, + "dv2": { + "value": 0.5270061844504115, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/040/params.json b/scipy/double_spring/040/params.json new file mode 100644 index 0000000000000000000000000000000000000000..fe23db13ad83a30de39a936492b937a915709e8b --- /dev/null +++ b/scipy/double_spring/040/params.json @@ -0,0 +1,11 @@ +{ + "k": 5.796611149827626, + "m1": 1.940654706195517, + "m2": 1.98140257169819, + "b": 0.11975937987947705, + "R": 2.0, + "du1": 0.5682973411452252, + "dv1": 0.0, + "du2": 0.1739830304481531, + "dv2": 0.5270061844504115 +} \ No newline at end of file diff --git a/scipy/double_spring/040/simulation_code.py b/scipy/double_spring/040/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..27ed144acb32b5554ff0a8b4e7ed51cedd61479a --- /dev/null +++ b/scipy/double_spring/040/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 5.796611149827626, 1.940654706195517, 1.98140257169819, 0.11975937987947705 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + 0.5682973411452252 +x2_0 = 4.0000 + 0.1739830304481531 +v1_0, v2_0 = 0.0000, 0.5270 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/040/video.mp4 b/scipy/double_spring/040/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f97b43055e03d173fc945f187ecfa795a28a5605 --- /dev/null +++ b/scipy/double_spring/040/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:899338428f9314395cccb55e18638690700a3afecceb5d657bfecc5d29949a73 +size 56142 diff --git a/scipy/double_spring/042/cot.json b/scipy/double_spring/042/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..25bc99c678242e67538bedfac321e8471bd15dca --- /dev/null +++ b/scipy/double_spring/042/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=0.917 kg, m_2=1.184 kg) are coupled by three identical springs (k=3.694 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-2.15 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 3.694498820895972, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.9170984870921484, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.1836255803765119, + "unit": "", + "description": "" + }, + "b": { + "value": 0.4965845235168748, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.410431020910743, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": -0.5766671485562318, + "unit": "", + "description": "" + }, + "dv2": { + "value": -2.1489105875431536, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/042/params.json b/scipy/double_spring/042/params.json new file mode 100644 index 0000000000000000000000000000000000000000..cabf5448d0a4f2ddb8025d775c5b77cd9eac25ba --- /dev/null +++ b/scipy/double_spring/042/params.json @@ -0,0 +1,11 @@ +{ + "k": 3.694498820895972, + "m1": 0.9170984870921484, + "m2": 1.1836255803765119, + "b": 0.4965845235168748, + "R": 2.0, + "du1": -0.410431020910743, + "dv1": 0.0, + "du2": -0.5766671485562318, + "dv2": -2.1489105875431536 +} \ No newline at end of file diff --git a/scipy/double_spring/042/simulation_code.py b/scipy/double_spring/042/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..2c1fc0ad59055b506bc9a7de1a148dd2b262037e --- /dev/null +++ b/scipy/double_spring/042/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 3.694498820895972, 0.9170984870921484, 1.1836255803765119, 0.4965845235168748 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.410431020910743 +x2_0 = 4.0000 + -0.5766671485562318 +v1_0, v2_0 = 0.0000, -2.1489 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/042/video.mp4 b/scipy/double_spring/042/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..dbe3c07b4e0b7bfed926f8c46b5749910cbb655d --- /dev/null +++ b/scipy/double_spring/042/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bba1ec6c84993a95c00a9ee28cb51d7b10e8797fbdd74cd0c1f9e2b61d4e7342 +size 54051 diff --git a/scipy/double_spring/130/cot.json b/scipy/double_spring/130/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..7c741d8591169ef4d9bd8422fd1f4301aa2b4dfb --- /dev/null +++ b/scipy/double_spring/130/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=1.233 kg, m_2=0.904 kg) are coupled by three identical springs (k=5.029 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=0.94 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 5.0285874029149635, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.2326329908347802, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.9036559648421121, + "unit": "", + "description": "" + }, + "b": { + "value": 0.4008903654516213, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.4176386434176079, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.7715310222645007, + "unit": "", + "description": "" + }, + "dv2": { + "value": 0.9431480465124942, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/130/params.json b/scipy/double_spring/130/params.json new file mode 100644 index 0000000000000000000000000000000000000000..9b6c6ba05413c4b549d6deab06070b92a6114313 --- /dev/null +++ b/scipy/double_spring/130/params.json @@ -0,0 +1,11 @@ +{ + "k": 5.0285874029149635, + "m1": 1.2326329908347802, + "m2": 0.9036559648421121, + "b": 0.4008903654516213, + "R": 2.0, + "du1": -0.4176386434176079, + "dv1": 0.0, + "du2": 0.7715310222645007, + "dv2": 0.9431480465124942 +} \ No newline at end of file diff --git a/scipy/double_spring/130/simulation_code.py b/scipy/double_spring/130/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3efa2b201c303a8b9cbbae0ef2c9a17d53c08af2 --- /dev/null +++ b/scipy/double_spring/130/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 5.0285874029149635, 1.2326329908347802, 0.9036559648421121, 0.4008903654516213 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.4176386434176079 +x2_0 = 4.0000 + 0.7715310222645007 +v1_0, v2_0 = 0.0000, 0.9431 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/130/video.mp4 b/scipy/double_spring/130/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2552baeec1e3cfbecade2824fc2d203fbb6260cb --- /dev/null +++ b/scipy/double_spring/130/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2073cffe3a92163ea3e3791e32378accdeaa374a4123b90e848a276b8069c6e +size 62932 diff --git a/scipy/double_spring/151/cot.json b/scipy/double_spring/151/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1eae7cef3839dc12ed59bb52b573c7be8481fe2d --- /dev/null +++ b/scipy/double_spring/151/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=0.678 kg, m_2=1.565 kg) are coupled by three identical springs (k=5.030 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-0.71 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 5.030265541815111, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.6778324140086209, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.5645477331449806, + "unit": "", + "description": "" + }, + "b": { + "value": 0.14189614249479438, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": 0.5300052267185167, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.4797672829147812, + "unit": "", + "description": "" + }, + "dv2": { + "value": -0.7143438575936241, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/151/params.json b/scipy/double_spring/151/params.json new file mode 100644 index 0000000000000000000000000000000000000000..8d39629c6954110fed0b23e314459f1e80b8cc55 --- /dev/null +++ b/scipy/double_spring/151/params.json @@ -0,0 +1,11 @@ +{ + "k": 5.030265541815111, + "m1": 0.6778324140086209, + "m2": 1.5645477331449806, + "b": 0.14189614249479438, + "R": 2.0, + "du1": 0.5300052267185167, + "dv1": 0.0, + "du2": 0.4797672829147812, + "dv2": -0.7143438575936241 +} \ No newline at end of file diff --git a/scipy/double_spring/151/simulation_code.py b/scipy/double_spring/151/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6a78c54197c4e4636704a534382400d957a8cb5a --- /dev/null +++ b/scipy/double_spring/151/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 5.030265541815111, 0.6778324140086209, 1.5645477331449806, 0.14189614249479438 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + 0.5300052267185167 +x2_0 = 4.0000 + 0.4797672829147812 +v1_0, v2_0 = 0.0000, -0.7143 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/151/video.mp4 b/scipy/double_spring/151/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..38738429eabd65e7d604e754204a127e8bb5742c --- /dev/null +++ b/scipy/double_spring/151/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a68c7fc5b221b2ccdf463dbcf4cd064b569ec071684aa53f5bd3c85ba7701df6 +size 53258 diff --git a/scipy/double_spring/215/cot.json b/scipy/double_spring/215/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..ad8ceccf278b1b996088959095f30eadda76161c --- /dev/null +++ b/scipy/double_spring/215/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=0.830 kg, m_2=1.755 kg) are coupled by three identical springs (k=2.233 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=2.08 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 2.2326199026035454, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.8297814644807269, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.7549787535183883, + "unit": "", + "description": "" + }, + "b": { + "value": 0.2694720276327879, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.10900706026363571, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": -0.7129223493001702, + "unit": "", + "description": "" + }, + "dv2": { + "value": 2.0786926047014376, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/215/params.json b/scipy/double_spring/215/params.json new file mode 100644 index 0000000000000000000000000000000000000000..3c3dc273a6770280c575f22563fbf6718958f500 --- /dev/null +++ b/scipy/double_spring/215/params.json @@ -0,0 +1,11 @@ +{ + "k": 2.2326199026035454, + "m1": 0.8297814644807269, + "m2": 1.7549787535183883, + "b": 0.2694720276327879, + "R": 2.0, + "du1": -0.10900706026363571, + "dv1": 0.0, + "du2": -0.7129223493001702, + "dv2": 2.0786926047014376 +} \ No newline at end of file diff --git a/scipy/double_spring/215/simulation_code.py b/scipy/double_spring/215/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9667c0555d95ee7acc84f17e06730dcd7ad6f76f --- /dev/null +++ b/scipy/double_spring/215/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 2.2326199026035454, 0.8297814644807269, 1.7549787535183883, 0.2694720276327879 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.10900706026363571 +x2_0 = 4.0000 + -0.7129223493001702 +v1_0, v2_0 = 0.0000, 2.0787 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/215/video.mp4 b/scipy/double_spring/215/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..02b5edbee84bfbfb59a4b41e8492b83e482606a4 --- /dev/null +++ b/scipy/double_spring/215/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f4e9042d96843584832ce8890db92c7678b39c9894a46e6a6ee447be49d71dc +size 61472 diff --git a/scipy/double_spring/255/cot.json b/scipy/double_spring/255/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..525a8f4e97abef84bb9b523bfc325613b9d66193 --- /dev/null +++ b/scipy/double_spring/255/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=0.847 kg, m_2=1.291 kg) are coupled by three identical springs (k=8.579 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-1.15 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 8.57933286812072, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.8470058686718431, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.2911707345200782, + "unit": "", + "description": "" + }, + "b": { + "value": 0.18398618578883236, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.15148044239205005, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.47073354850429006, + "unit": "", + "description": "" + }, + "dv2": { + "value": -1.1520268723088545, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/255/params.json b/scipy/double_spring/255/params.json new file mode 100644 index 0000000000000000000000000000000000000000..883104b73926b0901e297e4151106e1349305144 --- /dev/null +++ b/scipy/double_spring/255/params.json @@ -0,0 +1,11 @@ +{ + "k": 8.57933286812072, + "m1": 0.8470058686718431, + "m2": 1.2911707345200782, + "b": 0.18398618578883236, + "R": 2.0, + "du1": -0.15148044239205005, + "dv1": 0.0, + "du2": 0.47073354850429006, + "dv2": -1.1520268723088545 +} \ No newline at end of file diff --git a/scipy/double_spring/255/simulation_code.py b/scipy/double_spring/255/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d5ae69ce0a666b42a949b68556fd0d60fffcb001 --- /dev/null +++ b/scipy/double_spring/255/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 8.57933286812072, 0.8470058686718431, 1.2911707345200782, 0.18398618578883236 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.15148044239205005 +x2_0 = 4.0000 + 0.47073354850429006 +v1_0, v2_0 = 0.0000, -1.1520 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/255/video.mp4 b/scipy/double_spring/255/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3ec1cfef8c538607901b3dbb4d73beeaa67a1cd7 --- /dev/null +++ b/scipy/double_spring/255/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b68b5aafba9ff1a8affd0bf2f70d6f6dbaf4655b4e669de2bb9e87a906e0f3b +size 63234 diff --git a/scipy/double_spring/315/cot.json b/scipy/double_spring/315/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..5ede2bcca3ac905ff6b1ef9979d638fc8a1f0b2d --- /dev/null +++ b/scipy/double_spring/315/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=1.101 kg, m_2=1.831 kg) are coupled by three identical springs (k=8.542 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-1.60 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 8.542072135798584, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.1014963434747136, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.8309762470576532, + "unit": "", + "description": "" + }, + "b": { + "value": 0.060178815011458, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.5808595841393509, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": -0.15506554087599245, + "unit": "", + "description": "" + }, + "dv2": { + "value": -1.5967442602106219, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/315/params.json b/scipy/double_spring/315/params.json new file mode 100644 index 0000000000000000000000000000000000000000..9cbcece470e6c57ff0a0d17deecc11705aa0129f --- /dev/null +++ b/scipy/double_spring/315/params.json @@ -0,0 +1,11 @@ +{ + "k": 8.542072135798584, + "m1": 1.1014963434747136, + "m2": 1.8309762470576532, + "b": 0.060178815011458, + "R": 2.0, + "du1": -0.5808595841393509, + "dv1": 0.0, + "du2": -0.15506554087599245, + "dv2": -1.5967442602106219 +} \ No newline at end of file diff --git a/scipy/double_spring/315/simulation_code.py b/scipy/double_spring/315/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..729841266a1f82dd1e8307e8df901f860e2ae92a --- /dev/null +++ b/scipy/double_spring/315/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 8.542072135798584, 1.1014963434747136, 1.8309762470576532, 0.060178815011458 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.5808595841393509 +x2_0 = 4.0000 + -0.15506554087599245 +v1_0, v2_0 = 0.0000, -1.5967 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/315/video.mp4 b/scipy/double_spring/315/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e88bdba778e0cbbb1645d9c71044c2cc5f27c6e7 --- /dev/null +++ b/scipy/double_spring/315/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfc045a628c03631554331ea72ea099a2300aa6fe42c1740f7a24f37336c9c16 +size 67782 diff --git a/scipy/double_spring/366/cot.json b/scipy/double_spring/366/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..cd316518f54717c525e494d99238f2a1d7230868 --- /dev/null +++ b/scipy/double_spring/366/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=0.649 kg, m_2=1.824 kg) are coupled by three identical springs (k=4.444 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-0.85 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 4.443759847326237, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.6489648773705765, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.823629768233464, + "unit": "", + "description": "" + }, + "b": { + "value": 0.4337310827048969, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.20019767540779654, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.2526412259658142, + "unit": "", + "description": "" + }, + "dv2": { + "value": -0.8463773011649365, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/366/params.json b/scipy/double_spring/366/params.json new file mode 100644 index 0000000000000000000000000000000000000000..9ce5685e7b8d1439dfee67b7f52bca27818ffa18 --- /dev/null +++ b/scipy/double_spring/366/params.json @@ -0,0 +1,11 @@ +{ + "k": 4.443759847326237, + "m1": 0.6489648773705765, + "m2": 1.823629768233464, + "b": 0.4337310827048969, + "R": 2.0, + "du1": -0.20019767540779654, + "dv1": 0.0, + "du2": 0.2526412259658142, + "dv2": -0.8463773011649365 +} \ No newline at end of file diff --git a/scipy/double_spring/366/simulation_code.py b/scipy/double_spring/366/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..54bc19c5130ec49d6c4e078fe7f990cc3e464f56 --- /dev/null +++ b/scipy/double_spring/366/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 4.443759847326237, 0.6489648773705765, 1.823629768233464, 0.4337310827048969 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.20019767540779654 +x2_0 = 4.0000 + 0.2526412259658142 +v1_0, v2_0 = 0.0000, -0.8464 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/366/video.mp4 b/scipy/double_spring/366/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f1389e6e6518b302b5709e65625f048a189d7a7f --- /dev/null +++ b/scipy/double_spring/366/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a052983578ac8f05225733070b3bda55e2b63aa682cfad451091c819ba2b26b1 +size 46754 diff --git a/scipy/double_spring/373/cot.json b/scipy/double_spring/373/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..700abe63c2c204ba8416a1e0d3edfb3144169e36 --- /dev/null +++ b/scipy/double_spring/373/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=1.558 kg, m_2=1.931 kg) are coupled by three identical springs (k=2.455 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-2.15 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 2.4548309133072923, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.5578711189600836, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.9310467780382707, + "unit": "", + "description": "" + }, + "b": { + "value": 0.049640808018117655, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.12233995658430585, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.06991183055128869, + "unit": "", + "description": "" + }, + "dv2": { + "value": -2.1456609090009717, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/373/params.json b/scipy/double_spring/373/params.json new file mode 100644 index 0000000000000000000000000000000000000000..159ed68f426c45f0e6867e5cc22eadf7856d8e82 --- /dev/null +++ b/scipy/double_spring/373/params.json @@ -0,0 +1,11 @@ +{ + "k": 2.4548309133072923, + "m1": 1.5578711189600836, + "m2": 1.9310467780382707, + "b": 0.049640808018117655, + "R": 2.0, + "du1": -0.12233995658430585, + "dv1": 0.0, + "du2": 0.06991183055128869, + "dv2": -2.1456609090009717 +} \ No newline at end of file diff --git a/scipy/double_spring/373/simulation_code.py b/scipy/double_spring/373/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..97b4bb7665d197b9787bab4464a17690d3bd43c0 --- /dev/null +++ b/scipy/double_spring/373/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 2.4548309133072923, 1.5578711189600836, 1.9310467780382707, 0.049640808018117655 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.12233995658430585 +x2_0 = 4.0000 + 0.06991183055128869 +v1_0, v2_0 = 0.0000, -2.1457 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/373/video.mp4 b/scipy/double_spring/373/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..5f52a38079131a2631ccf3787836ab7b985d7b43 --- /dev/null +++ b/scipy/double_spring/373/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc00bf03959261b4e460a186a15965d4172caeab3841e47a1144a94ae2adda13 +size 63295 diff --git a/scipy/double_spring/378/cot.json b/scipy/double_spring/378/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..dfc3407eee1b5b1c364099c1fd797ac900969003 --- /dev/null +++ b/scipy/double_spring/378/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=0.535 kg, m_2=0.913 kg) are coupled by three identical springs (k=5.977 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-1.58 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 5.976836114840712, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.5353249101716238, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.912670837016646, + "unit": "", + "description": "" + }, + "b": { + "value": 0.12047587503224266, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.47175434155333706, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.08165297881665567, + "unit": "", + "description": "" + }, + "dv2": { + "value": -1.582429314385101, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/378/params.json b/scipy/double_spring/378/params.json new file mode 100644 index 0000000000000000000000000000000000000000..942189c9f6613d5541c35c2f69722b884b657083 --- /dev/null +++ b/scipy/double_spring/378/params.json @@ -0,0 +1,11 @@ +{ + "k": 5.976836114840712, + "m1": 0.5353249101716238, + "m2": 0.912670837016646, + "b": 0.12047587503224266, + "R": 2.0, + "du1": -0.47175434155333706, + "dv1": 0.0, + "du2": 0.08165297881665567, + "dv2": -1.582429314385101 +} \ No newline at end of file diff --git a/scipy/double_spring/378/simulation_code.py b/scipy/double_spring/378/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..be556d0c7edbf18d1d08098b7919c041a163cdcb --- /dev/null +++ b/scipy/double_spring/378/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 5.976836114840712, 0.5353249101716238, 0.912670837016646, 0.12047587503224266 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.47175434155333706 +x2_0 = 4.0000 + 0.08165297881665567 +v1_0, v2_0 = 0.0000, -1.5824 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/378/video.mp4 b/scipy/double_spring/378/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..71e6d1415ecf155c0c1d05664f207aee2bed4ab0 --- /dev/null +++ b/scipy/double_spring/378/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f497aa57d99bd842320a08428b2fe262b2109c7819df4feebdc36c0b18430b61 +size 64675 diff --git a/scipy/double_spring/440/cot.json b/scipy/double_spring/440/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8d6810c6f4325eb5ab13181f6c8188087eee2035 --- /dev/null +++ b/scipy/double_spring/440/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=1.851 kg, m_2=0.549 kg) are coupled by three identical springs (k=9.824 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=1.51 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 9.824293070360143, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.8509569375092207, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.5485912099886701, + "unit": "", + "description": "" + }, + "b": { + "value": 0.12963281260377874, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": 0.5066177063761779, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.5517657129718496, + "unit": "", + "description": "" + }, + "dv2": { + "value": 1.5140381042577102, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/440/params.json b/scipy/double_spring/440/params.json new file mode 100644 index 0000000000000000000000000000000000000000..78c8563d421023e04a9181afdd4ecff9aafc442b --- /dev/null +++ b/scipy/double_spring/440/params.json @@ -0,0 +1,11 @@ +{ + "k": 9.824293070360143, + "m1": 1.8509569375092207, + "m2": 0.5485912099886701, + "b": 0.12963281260377874, + "R": 2.0, + "du1": 0.5066177063761779, + "dv1": 0.0, + "du2": 0.5517657129718496, + "dv2": 1.5140381042577102 +} \ No newline at end of file diff --git a/scipy/double_spring/440/simulation_code.py b/scipy/double_spring/440/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..bbf434856ca6d6a73b44d4f7cfb29c389c954782 --- /dev/null +++ b/scipy/double_spring/440/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 9.824293070360143, 1.8509569375092207, 0.5485912099886701, 0.12963281260377874 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + 0.5066177063761779 +x2_0 = 4.0000 + 0.5517657129718496 +v1_0, v2_0 = 0.0000, 1.5140 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/440/video.mp4 b/scipy/double_spring/440/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a56f0ef74caa10ed32f8154c4acb94605251fe73 --- /dev/null +++ b/scipy/double_spring/440/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f0f1d430b2892cfc8aaa280917dc0a9f7844f89efbb7e75a0150ca8abe6a3a7 +size 62586 diff --git a/scipy/double_spring/565/cot.json b/scipy/double_spring/565/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..eee3f4750e26456bc7bdd35b60d5124fafa337fb --- /dev/null +++ b/scipy/double_spring/565/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=1.721 kg, m_2=0.856 kg) are coupled by three identical springs (k=6.235 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-1.80 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 6.235166488977434, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.7209964380891227, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.8557494815508451, + "unit": "", + "description": "" + }, + "b": { + "value": 0.4085527633909883, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.41958682096367694, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.030418918924723926, + "unit": "", + "description": "" + }, + "dv2": { + "value": -1.7953849943057003, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/565/params.json b/scipy/double_spring/565/params.json new file mode 100644 index 0000000000000000000000000000000000000000..db24c5ea15a7a6acb29bed72816cebfdb35e1a00 --- /dev/null +++ b/scipy/double_spring/565/params.json @@ -0,0 +1,11 @@ +{ + "k": 6.235166488977434, + "m1": 1.7209964380891227, + "m2": 0.8557494815508451, + "b": 0.4085527633909883, + "R": 2.0, + "du1": -0.41958682096367694, + "dv1": 0.0, + "du2": 0.030418918924723926, + "dv2": -1.7953849943057003 +} \ No newline at end of file diff --git a/scipy/double_spring/565/simulation_code.py b/scipy/double_spring/565/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9a55836d0c212221781ccedb863b24db18a5d656 --- /dev/null +++ b/scipy/double_spring/565/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 6.235166488977434, 1.7209964380891227, 0.8557494815508451, 0.4085527633909883 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.41958682096367694 +x2_0 = 4.0000 + 0.030418918924723926 +v1_0, v2_0 = 0.0000, -1.7954 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/565/video.mp4 b/scipy/double_spring/565/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c1cb0c0ef3c9585b40d18ca1598090d88fce15fd --- /dev/null +++ b/scipy/double_spring/565/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32ed139088097d24044c30c8f1753364ec5a020d40cb4dbf09243ce426264024 +size 53889 diff --git a/scipy/double_spring/596/cot.json b/scipy/double_spring/596/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..b0eb424922ab1fde73a38443dfa33862bdd38520 --- /dev/null +++ b/scipy/double_spring/596/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=0.786 kg, m_2=0.994 kg) are coupled by three identical springs (k=2.375 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=-0.21 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 2.3748262467903514, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.7858876248888906, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.9939150201480946, + "unit": "", + "description": "" + }, + "b": { + "value": 0.3116920419359951, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.452533746323561, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": 0.7554128570203134, + "unit": "", + "description": "" + }, + "dv2": { + "value": -0.21347740405328697, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/596/params.json b/scipy/double_spring/596/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ec012cd05e9e4d3dabc89a9b67a082a2d7aff3c4 --- /dev/null +++ b/scipy/double_spring/596/params.json @@ -0,0 +1,11 @@ +{ + "k": 2.3748262467903514, + "m1": 0.7858876248888906, + "m2": 0.9939150201480946, + "b": 0.3116920419359951, + "R": 2.0, + "du1": -0.452533746323561, + "dv1": 0.0, + "du2": 0.7554128570203134, + "dv2": -0.21347740405328697 +} \ No newline at end of file diff --git a/scipy/double_spring/596/simulation_code.py b/scipy/double_spring/596/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c6737e081ef48420ab89d427cb0d231fb3fb4bd4 --- /dev/null +++ b/scipy/double_spring/596/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 2.3748262467903514, 0.7858876248888906, 0.9939150201480946, 0.3116920419359951 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.452533746323561 +x2_0 = 4.0000 + 0.7554128570203134 +v1_0, v2_0 = 0.0000, -0.2135 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/596/video.mp4 b/scipy/double_spring/596/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ddad21aa8106fa10b55f03e7368cdc3a5db71043 --- /dev/null +++ b/scipy/double_spring/596/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab0ed1692896b23a91dcebfa907e42701b58815a57220dc3dcf94bc347f9f80c +size 58009 diff --git a/scipy/double_spring/682/cot.json b/scipy/double_spring/682/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..ebf16fd8b071e9473c97e539e3430b3026257f32 --- /dev/null +++ b/scipy/double_spring/682/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=1.168 kg, m_2=0.914 kg) are coupled by three identical springs (k=6.828 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=2.13 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 6.82785716708359, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 1.1675247648739613, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.9139550313528687, + "unit": "", + "description": "" + }, + "b": { + "value": 0.10721785963637209, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": -0.4991958602216977, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": -0.529288000575948, + "unit": "", + "description": "" + }, + "dv2": { + "value": 2.1336859833547495, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/682/params.json b/scipy/double_spring/682/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e1412c2a1cc4fabd8abad0ae503de54f34802ea9 --- /dev/null +++ b/scipy/double_spring/682/params.json @@ -0,0 +1,11 @@ +{ + "k": 6.82785716708359, + "m1": 1.1675247648739613, + "m2": 0.9139550313528687, + "b": 0.10721785963637209, + "R": 2.0, + "du1": -0.4991958602216977, + "dv1": 0.0, + "du2": -0.529288000575948, + "dv2": 2.1336859833547495 +} \ No newline at end of file diff --git a/scipy/double_spring/682/simulation_code.py b/scipy/double_spring/682/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..74704165db1989752f9d15673cc74d9befd09f63 --- /dev/null +++ b/scipy/double_spring/682/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 6.82785716708359, 1.1675247648739613, 0.9139550313528687, 0.10721785963637209 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + -0.4991958602216977 +x2_0 = 4.0000 + -0.529288000575948 +v1_0, v2_0 = 0.0000, 2.1337 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/682/video.mp4 b/scipy/double_spring/682/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2d7d33753f7b17709676172051c0ec97e7b3b9ce --- /dev/null +++ b/scipy/double_spring/682/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50d9285bd30e3f10e89404e9f29d3b4d4e52d55ae976b72f55a81dc9dbbf7538 +size 66946 diff --git a/scipy/double_spring/698/cot.json b/scipy/double_spring/698/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..5c14b18ab00c703495a8c610b9759593d3a974db --- /dev/null +++ b/scipy/double_spring/698/cot.json @@ -0,0 +1,103 @@ +{ + "simulation": "double_spring", + "physical_observation": "Two blocks (m_1=0.663 kg, m_2=1.820 kg) are coupled by three identical springs (k=5.641 N/m, rest length R=2.00 m) between two fixed walls. Block 2 starts with velocity v_2=2.59 m/s, creating a coupled oscillation.", + "physical_law": { + "name": "Newton's Second Law for a Coupled Oscillator System", + "statement": "\\SigmaF = ma applied independently to each block; springs transmit forces between them.", + "formula": "m_1\\ddot{x}_1 = -k \\cdot s_1 + k \\cdot s_2 - b \\cdot v_1\nm_2\\ddot{x}_2 = -k \\cdot s_2 + k \\cdot s_3 - b \\cdot v_2" + }, + "ode_system": { + "state_variables": [ + "x_1 (block 1 position, m)", + "x_2 (block 2 position, m)", + "v_1", + "v_2" + ], + "equations_latex": [ + "\\dot{x}_1 = v_1", + "\\dot{x}_2 = v_2", + "\\dot{v}_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b \\cdot v_1] / m_1", + "\\dot{v}_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b \\cdot v_2] / m_2" + ], + "equations_python": [ + "x_dot_1 = v_1", + "x_dot_2 = v_2", + "v_dot_1 = [-k(x_1-wall_1-R) + k(x_2-x_1-R) - b * v_1] / m_1", + "v_dot_2 = [-k(x_2-x_1-R) + k(wall_2-x_2-R) - b * v_2] / m_2" + ] + }, + "derivation_steps": [ + "Label positions: wall_1=0, block_1 at x_1, block_2 at x_2, wall_2=3R.", + "Spring stretches (gap minus rest length):", + " s_1 = (x_1 - wall_1) - R [spring 1: wall1 \\rightarrow block1]", + " s_2 = (x_2 - x_1) - R [spring 2: block1 \\rightarrow block2]", + " s_3 = (wall_2 - x_2) - R [spring 3: block2 \\rightarrow wall2; note: wall is on right]", + "Force on block_1: F_1 = -k \\cdot s_1 (spring 1 pulls left) + k \\cdot s_2 (spring 2 pulls right) - b \\cdot v_1", + "Force on block_2: F_2 = -k \\cdot s_2 (spring 2 pulls left) + k \\cdot s_3 (spring 3 pulls right) - b \\cdot v_2", + "Note: s_3 = (wall_2-x_2)-R; when s_3>0 spring is stretched and pulls block_2 rightward.", + "These equations match DoubleSpringSim.ts evaluate() with S1=S2=S3=+1." + ], + "physical_constants_derived": { + "normal_modes_note": "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + }, + "numerical_method": { + "solver": "RK45", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Newton's 2nd Law; exact translation of DoubleSpringSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m_1v_1^2 + \\tfrac{1}{2} m_2v_2^2 + \\tfrac{1}{2} k(s_1^2+s_2^2+s_3^2) decreases monotonically when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Coupled normal modes visible as beats in the position time-series.", + "Normal modes depend on m_1, m_2 ratio; use eigenvalue analysis for exact values." + ], + "parameters": { + "k": { + "value": 5.641328404147957, + "unit": "N/m", + "description": "" + }, + "m1": { + "value": 0.6625753693402645, + "unit": "", + "description": "" + }, + "m2": { + "value": 1.8195983112653857, + "unit": "", + "description": "" + }, + "b": { + "value": 0.49657734211357757, + "unit": "kg/s", + "description": "" + }, + "R": { + "value": 2.0, + "unit": "m", + "description": "" + }, + "du1": { + "value": 0.2699669185705036, + "unit": "", + "description": "" + }, + "dv1": { + "value": 0.0, + "unit": "", + "description": "" + }, + "du2": { + "value": -0.5375383371266957, + "unit": "", + "description": "" + }, + "dv2": { + "value": 2.5856141383430833, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/double_spring/698/params.json b/scipy/double_spring/698/params.json new file mode 100644 index 0000000000000000000000000000000000000000..36d4bc9a9c6fff425b52b858c658a99bae25c5c7 --- /dev/null +++ b/scipy/double_spring/698/params.json @@ -0,0 +1,11 @@ +{ + "k": 5.641328404147957, + "m1": 0.6625753693402645, + "m2": 1.8195983112653857, + "b": 0.49657734211357757, + "R": 2.0, + "du1": 0.2699669185705036, + "dv1": 0.0, + "du2": -0.5375383371266957, + "dv2": 2.5856141383430833 +} \ No newline at end of file diff --git a/scipy/double_spring/698/simulation_code.py b/scipy/double_spring/698/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5fade3f3b988de3818faf80977f2c2785f8cd9a1 --- /dev/null +++ b/scipy/double_spring/698/simulation_code.py @@ -0,0 +1,63 @@ +""" +Double Spring System — auto-generated simulation script. +Physics (Newton's 2nd Law for each block): + v̇₁ = [-k(x₁-wall₁-R) + k(x₂-x₁-R) - b·v₁] / m₁ + v̇₂ = [-k(x₂-x₁-R) + k(wall₂-x₂-R) - b·v₂] / m₂ +Layout: [wall1=0] ~k~ [block1] ~k~ [block2] ~k~ [wall2=6.00] +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +k, m1, m2, b = 5.641328404147957, 0.6625753693402645, 1.8195983112653857, 0.49657734211357757 +R = 2.0 +wall1, wall2 = 0.0, 6.0000 +x1_0 = 2.0000 + 0.2699669185705036 +x2_0 = 4.0000 + -0.5375383371266957 +v1_0, v2_0 = 0.0000, 2.5856 +duration = 12 + +def ode(t, y): + x1, x2, v1, v2 = y + s1 = (x1-wall1)-R; s2 = (x2-x1)-R; s3 = (wall2-x2)-R + dv1 = (-k*s1 + k*s2 - b*v1)/m1 + dv2 = (-k*s2 + k*s3 - b*v2)/m2 + return [v1, v2, dv1, dv2] + +fps=30; t_eval=np.linspace(0,duration,int(duration*fps)+1) +sol=solve_ivp(ode,(0,duration),[x1_0,x2_0,v1_0,v2_0],t_eval=t_eval,method="RK45",rtol=1e-9,atol=1e-11) +x1a,x2a=sol.y[0],sol.y[1] + +bw,bh,ty=0.3,0.35,0.0 +fig,ax=plt.subplots(figsize=(9,3),facecolor="#1a1a2e") +ax.set_facecolor("#16213e"); ax.set_xlim(wall1-0.4,wall2+0.4); ax.set_ylim(-1,1) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(ty-bh/2,color="#4a4e69",lw=1.5,zorder=1) +for wx,sgn in [(wall1,1),(wall2,-1)]: + ax.add_patch(patches.Rectangle((wx+(sgn*0.02-(0.15 if sgn<0 else 0)),ty-0.6),0.15,1.2, + facecolor="#4a4e69",edgecolor="#adb5bd",lw=1,hatch="////")) + +def sp_path(x1,x2,n=6,r=0.18): + t=np.linspace(0,1,n*20+2) + env=np.where((t<0.08)|(t>0.92),0,np.sin(n*2*np.pi*(t-0.08)/(1-2*0.08))) + return x1+t*(x2-x1), ty+r*env + +s1l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s2l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +s3l,=ax.plot([],[],"-",color="#a8dadc",lw=2.5,zorder=3) +b1p=patches.FancyBboxPatch((x1_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#e63946"); ax.add_patch(b1p) +b2p=patches.FancyBboxPatch((x2_0-bw/2,ty-bh/2),bw,bh,boxstyle="round,pad=0.02", + lw=1.5,edgecolor="white",facecolor="#f4d35e"); ax.add_patch(b2p) + +def update(f): + b1,b2=x1a[f],x2a[f] + b1p.set_x(b1-bw/2); b2p.set_x(b2-bw/2) + s1l.set_data(*sp_path(wall1,b1-bw/2)); s2l.set_data(*sp_path(b1+bw/2,b2-bw/2)) + s3l.set_data(*sp_path(b2+bw/2,wall2)); return s1l,s2l,s3l + +ani=animation.FuncAnimation(fig,update,frames=len(sol.t),interval=1000/fps,blit=False) +ani.save("double_spring.mp4",writer=animation.FFMpegWriter(fps=fps,bitrate=1800),dpi=120) +plt.close(); print("Saved double_spring.mp4") diff --git a/scipy/double_spring/698/video.mp4 b/scipy/double_spring/698/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ef28838958bc76576bacf3c0292128d0739e2272 --- /dev/null +++ b/scipy/double_spring/698/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10b24faa0bfd66b7f16ae2873c5ff5ef274c1ba2ef28aa36891b542e4375c59c +size 61953 diff --git a/scipy/driven_string_fixed/025/cot.json b/scipy/driven_string_fixed/025/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..cec6ac5927efd517f24840296923964d0511945a --- /dev/null +++ b/scipy/driven_string_fixed/025/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=3.536 m, density mu=0.1447 kg/m, tension T=3.775 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.121 m and frequency f=2.441 Hz. Phase speed c=\\sqrt(T/mu)=5.108 m/s; wavelength lambda=c/f=2.093 m; ~1.69 wavelengths fit in L. Linear viscous damping gamma_w=1.069 1/s gives decay length c/gamma_w=4.780 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(3.7751038771809253/0.1446801897821238) = 5.1081 m/s.", + "Driving angular frequency omega = 2 pi f = 15.3357 rad/s; wavelength lambda = c/f = 2.0928 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 4.780 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 5.108106204795664, + "omega_rad_s": 15.33572024084746, + "lambda_m": 2.092837985398161, + "n_wavelengths_in_L": 1.6895073549749435, + "decay_length_m": 4.779612785224967 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=5.108 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.046 m.", + "After a few transit times (~L/c = 0.692 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 3.535865169101137, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.1446801897821238, + "unit": "", + "description": "" + }, + "T": { + "value": 3.7751038771809253, + "unit": "", + "description": "" + }, + "A": { + "value": 0.12114040506644279, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.440755682205305, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.068728040184794, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/025/params.json b/scipy/driven_string_fixed/025/params.json new file mode 100644 index 0000000000000000000000000000000000000000..70afc2698958f6f789e3973838f34d20c745f021 --- /dev/null +++ b/scipy/driven_string_fixed/025/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.535865169101137, + "mu": 0.1446801897821238, + "T": 3.7751038771809253, + "A": 0.12114040506644279, + "f_drive": 2.440755682205305, + "gamma_w": 1.068728040184794, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/025/simulation_code.py b/scipy/driven_string_fixed/025/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5eb32d28ad2dcf5b779311cfe95fa2244ea62778 --- /dev/null +++ b/scipy/driven_string_fixed/025/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 3.535865169101137 +mu = 0.1446801897821238 +T = 3.7751038771809253 +A = 0.12114040506644279 +f_drive = 2.440755682205305 +gamma_w = 1.068728040184794 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/025/video.mp4 b/scipy/driven_string_fixed/025/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..947dc35a87a5ede4f6c730e6cfb1cb88d325b7cd --- /dev/null +++ b/scipy/driven_string_fixed/025/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fda08870760b8c88712aa9c0dab2546e031e03d9bc2a9f7d1add77c475fdf54a +size 50154 diff --git a/scipy/driven_string_fixed/105/cot.json b/scipy/driven_string_fixed/105/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a1e0f3917787b0540c53f1736bd86255e8e4836c --- /dev/null +++ b/scipy/driven_string_fixed/105/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.451 m, density mu=0.0887 kg/m, tension T=5.524 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.076 m and frequency f=1.809 Hz. Phase speed c=\\sqrt(T/mu)=7.889 m/s; wavelength lambda=c/f=4.360 m; ~1.02 wavelengths fit in L. Linear viscous damping gamma_w=0.582 1/s gives decay length c/gamma_w=13.559 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(5.523921460218052/0.08874660772689846) = 7.8895 m/s.", + "Driving angular frequency omega = 2 pi f = 11.3685 rad/s; wavelength lambda = c/f = 4.3604 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 13.559 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 7.889470685405782, + "omega_rad_s": 11.368480451818296, + "lambda_m": 4.3603898077721714, + "n_wavelengths_in_L": 1.0206725135798091, + "decay_length_m": 13.558730194477583 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=7.889 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 2.180 m.", + "After a few transit times (~L/c = 0.564 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.450530025286603, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.08874660772689846, + "unit": "", + "description": "" + }, + "T": { + "value": 5.523921460218052, + "unit": "", + "description": "" + }, + "A": { + "value": 0.07584862170850458, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.8093498593504656, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.5818738607704674, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/105/params.json b/scipy/driven_string_fixed/105/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7bc548c48688ed4e4f7940b6795a69fa376fb782 --- /dev/null +++ b/scipy/driven_string_fixed/105/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.450530025286603, + "mu": 0.08874660772689846, + "T": 5.523921460218052, + "A": 0.07584862170850458, + "f_drive": 1.8093498593504656, + "gamma_w": 0.5818738607704674, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/105/simulation_code.py b/scipy/driven_string_fixed/105/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6ac009bc0520deb45628733763d260b539f19f0a --- /dev/null +++ b/scipy/driven_string_fixed/105/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.450530025286603 +mu = 0.08874660772689846 +T = 5.523921460218052 +A = 0.07584862170850458 +f_drive = 1.8093498593504656 +gamma_w = 0.5818738607704674 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/105/video.mp4 b/scipy/driven_string_fixed/105/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..927ae0fdf1729a16d0190e02501d773b88ab61b4 --- /dev/null +++ b/scipy/driven_string_fixed/105/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c4eaaceae802c97a03976c356d745b31938938d51160e17821c30fc4912fcd3 +size 46746 diff --git a/scipy/driven_string_fixed/158/cot.json b/scipy/driven_string_fixed/158/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..ffe9f0387efc7f17616da57cfe4f2344380e1b30 --- /dev/null +++ b/scipy/driven_string_fixed/158/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.175 m, density mu=0.1331 kg/m, tension T=5.308 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.107 m and frequency f=2.402 Hz. Phase speed c=\\sqrt(T/mu)=6.315 m/s; wavelength lambda=c/f=2.629 m; ~1.59 wavelengths fit in L. Linear viscous damping gamma_w=1.451 1/s gives decay length c/gamma_w=4.351 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(5.308495280754792/0.13310537692450025) = 6.3152 m/s.", + "Driving angular frequency omega = 2 pi f = 15.0949 rad/s; wavelength lambda = c/f = 2.6287 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 4.351 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 6.31521176329535, + "omega_rad_s": 15.094919259712645, + "lambda_m": 2.628675588134308, + "n_wavelengths_in_L": 1.5882839840657452, + "decay_length_m": 4.351157833177315 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=6.315 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.314 m.", + "After a few transit times (~L/c = 0.661 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.175083335938324, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.13310537692450025, + "unit": "", + "description": "" + }, + "T": { + "value": 5.308495280754792, + "unit": "", + "description": "" + }, + "A": { + "value": 0.10652940639011876, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.402431015756321, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.451386505711708, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/158/params.json b/scipy/driven_string_fixed/158/params.json new file mode 100644 index 0000000000000000000000000000000000000000..8d942c037625d6270b34f09df47d69da6586f096 --- /dev/null +++ b/scipy/driven_string_fixed/158/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.175083335938324, + "mu": 0.13310537692450025, + "T": 5.308495280754792, + "A": 0.10652940639011876, + "f_drive": 2.402431015756321, + "gamma_w": 1.451386505711708, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/158/simulation_code.py b/scipy/driven_string_fixed/158/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..1ddfe6720257d160adb53095f7360733dd2cfaa0 --- /dev/null +++ b/scipy/driven_string_fixed/158/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.175083335938324 +mu = 0.13310537692450025 +T = 5.308495280754792 +A = 0.10652940639011876 +f_drive = 2.402431015756321 +gamma_w = 1.451386505711708 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/158/video.mp4 b/scipy/driven_string_fixed/158/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4d97cf226f4b815b0d496196b8808e36bb6762a3 --- /dev/null +++ b/scipy/driven_string_fixed/158/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97c1e3bafc24129d9970ac567a4f88eeb22d562f72bd0ee94b7c4facaf0cd679 +size 42689 diff --git a/scipy/driven_string_fixed/166/cot.json b/scipy/driven_string_fixed/166/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0459f8019827c230db53ccd3ce62ee194a001280 --- /dev/null +++ b/scipy/driven_string_fixed/166/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.737 m, density mu=0.1076 kg/m, tension T=5.724 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.093 m and frequency f=1.549 Hz. Phase speed c=\\sqrt(T/mu)=7.292 m/s; wavelength lambda=c/f=4.707 m; ~1.01 wavelengths fit in L. Linear viscous damping gamma_w=1.147 1/s gives decay length c/gamma_w=6.359 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(5.72398645989543/0.10764769859736739) = 7.2920 m/s.", + "Driving angular frequency omega = 2 pi f = 9.7340 rad/s; wavelength lambda = c/f = 4.7069 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 6.359 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 7.292004435462195, + "omega_rad_s": 9.733966419567494, + "lambda_m": 4.706921428933819, + "n_wavelengths_in_L": 1.0063813806265618, + "decay_length_m": 6.3592644328006545 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=7.292 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 2.353 m.", + "After a few transit times (~L/c = 0.650 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.736958086151166, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.10764769859736739, + "unit": "", + "description": "" + }, + "T": { + "value": 5.72398645989543, + "unit": "", + "description": "" + }, + "A": { + "value": 0.09348649627755133, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.5492088715646848, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.1466741967593816, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/166/params.json b/scipy/driven_string_fixed/166/params.json new file mode 100644 index 0000000000000000000000000000000000000000..04cd975324c33fb7ad0dab4325f0f84e3d78cbb6 --- /dev/null +++ b/scipy/driven_string_fixed/166/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.736958086151166, + "mu": 0.10764769859736739, + "T": 5.72398645989543, + "A": 0.09348649627755133, + "f_drive": 1.5492088715646848, + "gamma_w": 1.1466741967593816, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/166/simulation_code.py b/scipy/driven_string_fixed/166/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6b76a12e0718c543d8fa364028a82261c7453f25 --- /dev/null +++ b/scipy/driven_string_fixed/166/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.736958086151166 +mu = 0.10764769859736739 +T = 5.72398645989543 +A = 0.09348649627755133 +f_drive = 1.5492088715646848 +gamma_w = 1.1466741967593816 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/166/video.mp4 b/scipy/driven_string_fixed/166/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4e17adaf86a36497c2b7b941fca755ce812ebedc --- /dev/null +++ b/scipy/driven_string_fixed/166/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ccf94e49e0ac6d6f6c73ac4ae1bc2b851fa02248aacc93ba8fcb5432e2f6cd2e +size 37820 diff --git a/scipy/driven_string_fixed/181/cot.json b/scipy/driven_string_fixed/181/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..b22042058c52f9b9530ac82a0868ab3f9952407c --- /dev/null +++ b/scipy/driven_string_fixed/181/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.396 m, density mu=0.0805 kg/m, tension T=5.880 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.098 m and frequency f=2.040 Hz. Phase speed c=\\sqrt(T/mu)=8.544 m/s; wavelength lambda=c/f=4.188 m; ~1.05 wavelengths fit in L. Linear viscous damping gamma_w=0.540 1/s gives decay length c/gamma_w=15.831 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(5.879693891754442/0.08054235434932881) = 8.5441 m/s.", + "Driving angular frequency omega = 2 pi f = 12.8193 rad/s; wavelength lambda = c/f = 4.1878 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 15.831 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 8.544077873917075, + "omega_rad_s": 12.819285356587832, + "lambda_m": 4.187754860547335, + "n_wavelengths_in_L": 1.0496560604318466, + "decay_length_m": 15.831256697156002 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=8.544 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 2.094 m.", + "After a few transit times (~L/c = 0.514 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.395702268976432, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.08054235434932881, + "unit": "", + "description": "" + }, + "T": { + "value": 5.879693891754442, + "unit": "", + "description": "" + }, + "A": { + "value": 0.0981258507519377, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.0402526314065037, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.5396967554352127, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/181/params.json b/scipy/driven_string_fixed/181/params.json new file mode 100644 index 0000000000000000000000000000000000000000..b7e4a7cad5c159b0985eb8e9f37e34a22a83cfb2 --- /dev/null +++ b/scipy/driven_string_fixed/181/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.395702268976432, + "mu": 0.08054235434932881, + "T": 5.879693891754442, + "A": 0.0981258507519377, + "f_drive": 2.0402526314065037, + "gamma_w": 0.5396967554352127, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/181/simulation_code.py b/scipy/driven_string_fixed/181/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..e65f83ae6e86ba1ea97dd2fb8a6b8667d259911a --- /dev/null +++ b/scipy/driven_string_fixed/181/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.395702268976432 +mu = 0.08054235434932881 +T = 5.879693891754442 +A = 0.0981258507519377 +f_drive = 2.0402526314065037 +gamma_w = 0.5396967554352127 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/181/video.mp4 b/scipy/driven_string_fixed/181/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..eece83b26b3918255bd1f8dd107a5dcef5a5874b --- /dev/null +++ b/scipy/driven_string_fixed/181/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:139b06837cf76a82917508cad928d2e8d0a661ab807fe494d136c3c9dcf44f87 +size 56527 diff --git a/scipy/driven_string_fixed/183/cot.json b/scipy/driven_string_fixed/183/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..99605b0a668527b726b0f7eb8c9ae28a661f756e --- /dev/null +++ b/scipy/driven_string_fixed/183/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.156 m, density mu=0.1433 kg/m, tension T=4.768 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.128 m and frequency f=1.791 Hz. Phase speed c=\\sqrt(T/mu)=5.769 m/s; wavelength lambda=c/f=3.221 m; ~1.29 wavelengths fit in L. Linear viscous damping gamma_w=0.658 1/s gives decay length c/gamma_w=8.761 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(4.768141871955459/0.14327569603547813) = 5.7688 m/s.", + "Driving angular frequency omega = 2 pi f = 11.2541 rad/s; wavelength lambda = c/f = 3.2208 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 8.761 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 5.768837703907745, + "omega_rad_s": 11.254076748129762, + "lambda_m": 3.220759651094467, + "n_wavelengths_in_L": 1.290364232422217, + "decay_length_m": 8.76143537929385 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=5.769 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.610 m.", + "After a few transit times (~L/c = 0.720 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.15595305500096, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.14327569603547813, + "unit": "", + "description": "" + }, + "T": { + "value": 4.768141871955459, + "unit": "", + "description": "" + }, + "A": { + "value": 0.12793347381278652, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.7911419444004149, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.6584352282665239, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/183/params.json b/scipy/driven_string_fixed/183/params.json new file mode 100644 index 0000000000000000000000000000000000000000..6d5e65be11de5409b467a741b768cc2decdcd158 --- /dev/null +++ b/scipy/driven_string_fixed/183/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.15595305500096, + "mu": 0.14327569603547813, + "T": 4.768141871955459, + "A": 0.12793347381278652, + "f_drive": 1.7911419444004149, + "gamma_w": 0.6584352282665239, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/183/simulation_code.py b/scipy/driven_string_fixed/183/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..28ca453f94715466e3c9e1c3f28da97c7a41ce0b --- /dev/null +++ b/scipy/driven_string_fixed/183/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.15595305500096 +mu = 0.14327569603547813 +T = 4.768141871955459 +A = 0.12793347381278652 +f_drive = 1.7911419444004149 +gamma_w = 0.6584352282665239 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/183/video.mp4 b/scipy/driven_string_fixed/183/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c146b557c780b54114038ae2379e141e104baed5 --- /dev/null +++ b/scipy/driven_string_fixed/183/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d530925c63605f69f8f97084f5ab9d80c31860e011deca62433ec0ef85edf8e +size 46358 diff --git a/scipy/driven_string_fixed/242/cot.json b/scipy/driven_string_fixed/242/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..df8a89b925507d7ea34a86c94dec1a52d0da6889 --- /dev/null +++ b/scipy/driven_string_fixed/242/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.902 m, density mu=0.1008 kg/m, tension T=4.070 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.092 m and frequency f=2.282 Hz. Phase speed c=\\sqrt(T/mu)=6.354 m/s; wavelength lambda=c/f=2.785 m; ~1.76 wavelengths fit in L. Linear viscous damping gamma_w=1.162 1/s gives decay length c/gamma_w=5.470 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(4.070152430096975/0.10082554648497351) = 6.3536 m/s.", + "Driving angular frequency omega = 2 pi f = 14.3356 rad/s; wavelength lambda = c/f = 2.7847 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 5.470 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 6.353602561071651, + "omega_rad_s": 14.33556681944655, + "lambda_m": 2.784742505279272, + "n_wavelengths_in_L": 1.7603015510540665, + "decay_length_m": 5.469541920640381 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=6.354 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.392 m.", + "After a few transit times (~L/c = 0.772 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.901986551329289, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.10082554648497351, + "unit": "", + "description": "" + }, + "T": { + "value": 4.070152430096975, + "unit": "", + "description": "" + }, + "A": { + "value": 0.09221605700429635, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.2815763213390787, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.1616333969568995, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/242/params.json b/scipy/driven_string_fixed/242/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a41ea0f36e47744354577e916fcb73a340599792 --- /dev/null +++ b/scipy/driven_string_fixed/242/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.901986551329289, + "mu": 0.10082554648497351, + "T": 4.070152430096975, + "A": 0.09221605700429635, + "f_drive": 2.2815763213390787, + "gamma_w": 1.1616333969568995, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/242/simulation_code.py b/scipy/driven_string_fixed/242/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..a8bfadd04156b78357d423706ac1acee50a5e2b7 --- /dev/null +++ b/scipy/driven_string_fixed/242/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.901986551329289 +mu = 0.10082554648497351 +T = 4.070152430096975 +A = 0.09221605700429635 +f_drive = 2.2815763213390787 +gamma_w = 1.1616333969568995 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/242/video.mp4 b/scipy/driven_string_fixed/242/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d79eb3ea420d1a38472414bf3d24bea598a2634c --- /dev/null +++ b/scipy/driven_string_fixed/242/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:013ad6d2cca5f037c2b68926c12ab5e8e32f96caf28eda3400026a7dd88f7509 +size 36197 diff --git a/scipy/driven_string_fixed/254/cot.json b/scipy/driven_string_fixed/254/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..472561c0276ffb1044d03827fc419babe8037ef6 --- /dev/null +++ b/scipy/driven_string_fixed/254/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.033 m, density mu=0.0796 kg/m, tension T=4.601 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.088 m and frequency f=2.217 Hz. Phase speed c=\\sqrt(T/mu)=7.602 m/s; wavelength lambda=c/f=3.429 m; ~1.18 wavelengths fit in L. Linear viscous damping gamma_w=0.633 1/s gives decay length c/gamma_w=12.009 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(4.600910663324425/0.0796094507252327) = 7.6022 m/s.", + "Driving angular frequency omega = 2 pi f = 13.9288 rad/s; wavelength lambda = c/f = 3.4293 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 12.009 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 7.602205175164206, + "omega_rad_s": 13.928838996249251, + "lambda_m": 3.4292925542192547, + "n_wavelengths_in_L": 1.1761842666702662, + "decay_length_m": 12.009084936593057 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=7.602 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.715 m.", + "After a few transit times (~L/c = 0.531 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.033479948082178, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.0796094507252327, + "unit": "", + "description": "" + }, + "T": { + "value": 4.600910663324425, + "unit": "", + "description": "" + }, + "A": { + "value": 0.08755610035054236, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.216843577784222, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.6330378388780827, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/254/params.json b/scipy/driven_string_fixed/254/params.json new file mode 100644 index 0000000000000000000000000000000000000000..04833af9b66007198886b4a9e087774d07b450bc --- /dev/null +++ b/scipy/driven_string_fixed/254/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.033479948082178, + "mu": 0.0796094507252327, + "T": 4.600910663324425, + "A": 0.08755610035054236, + "f_drive": 2.216843577784222, + "gamma_w": 0.6330378388780827, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/254/simulation_code.py b/scipy/driven_string_fixed/254/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..be9c6c6d22fc8f327afdf51af322ad11d51e147e --- /dev/null +++ b/scipy/driven_string_fixed/254/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.033479948082178 +mu = 0.0796094507252327 +T = 4.600910663324425 +A = 0.08755610035054236 +f_drive = 2.216843577784222 +gamma_w = 0.6330378388780827 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/254/video.mp4 b/scipy/driven_string_fixed/254/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9c11f21e0afc055830af704074d8b25bdafbd4d4 --- /dev/null +++ b/scipy/driven_string_fixed/254/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c92e75551e9a0f292df808183318904e9a7e2206d9bff8bc411a320d02b06ee +size 37124 diff --git a/scipy/driven_string_fixed/273/cot.json b/scipy/driven_string_fixed/273/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..04898f835cf2c53247b2670bb4157fd61e44da36 --- /dev/null +++ b/scipy/driven_string_fixed/273/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.996 m, density mu=0.0892 kg/m, tension T=5.974 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.119 m and frequency f=2.136 Hz. Phase speed c=\\sqrt(T/mu)=8.184 m/s; wavelength lambda=c/f=3.832 m; ~1.30 wavelengths fit in L. Linear viscous damping gamma_w=0.799 1/s gives decay length c/gamma_w=10.246 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(5.974406265458414/0.08920279938001907) = 8.1839 m/s.", + "Driving angular frequency omega = 2 pi f = 13.4182 rad/s; wavelength lambda = c/f = 3.8322 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 10.246 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 8.183858919237778, + "omega_rad_s": 13.418186798109707, + "lambda_m": 3.8321647247174506, + "n_wavelengths_in_L": 1.3037386909374264, + "decay_length_m": 10.245674987857097 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=8.184 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.916 m.", + "After a few transit times (~L/c = 0.610 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.996141421659712, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.08920279938001907, + "unit": "", + "description": "" + }, + "T": { + "value": 5.974406265458414, + "unit": "", + "description": "" + }, + "A": { + "value": 0.1188104127364299, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.135570756249572, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.7987623000863361, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/273/params.json b/scipy/driven_string_fixed/273/params.json new file mode 100644 index 0000000000000000000000000000000000000000..604a782a0ea43d4997c1aab4a35ffe67a8722258 --- /dev/null +++ b/scipy/driven_string_fixed/273/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.996141421659712, + "mu": 0.08920279938001907, + "T": 5.974406265458414, + "A": 0.1188104127364299, + "f_drive": 2.135570756249572, + "gamma_w": 0.7987623000863361, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/273/simulation_code.py b/scipy/driven_string_fixed/273/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..64e61865bc244dd3bc6c4a500d7674a0be84ce43 --- /dev/null +++ b/scipy/driven_string_fixed/273/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.996141421659712 +mu = 0.08920279938001907 +T = 5.974406265458414 +A = 0.1188104127364299 +f_drive = 2.135570756249572 +gamma_w = 0.7987623000863361 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/273/video.mp4 b/scipy/driven_string_fixed/273/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b7f95e79f07d96530350c71ea99e19a4c8665808 --- /dev/null +++ b/scipy/driven_string_fixed/273/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfc4bda402141a6901105be1a02168a3796056e62aa5dc8bdaf0ca76c2d5d017 +size 43066 diff --git a/scipy/driven_string_fixed/340/cot.json b/scipy/driven_string_fixed/340/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..48a5404f2c70deaa57a528772545f92c353274e5 --- /dev/null +++ b/scipy/driven_string_fixed/340/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=3.442 m, density mu=0.0901 kg/m, tension T=3.993 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.107 m and frequency f=2.200 Hz. Phase speed c=\\sqrt(T/mu)=6.658 m/s; wavelength lambda=c/f=3.026 m; ~1.14 wavelengths fit in L. Linear viscous damping gamma_w=1.298 1/s gives decay length c/gamma_w=5.128 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(3.9926880404068172/0.090058392911427) = 6.6584 m/s.", + "Driving angular frequency omega = 2 pi f = 13.8236 rad/s; wavelength lambda = c/f = 3.0264 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 5.128 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 6.658410907869275, + "omega_rad_s": 13.823623278672374, + "lambda_m": 3.026415632291917, + "n_wavelengths_in_L": 1.137246970503931, + "decay_length_m": 5.128083899210663 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=6.658 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.513 m.", + "After a few transit times (~L/c = 0.517 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 3.441782009309722, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.090058392911427, + "unit": "", + "description": "" + }, + "T": { + "value": 3.9926880404068172, + "unit": "", + "description": "" + }, + "A": { + "value": 0.106515212016047, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.2000979762409014, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.2984208212533663, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/340/params.json b/scipy/driven_string_fixed/340/params.json new file mode 100644 index 0000000000000000000000000000000000000000..440c6aa6f09aeb8eb519c90f8d91dcf601a7d3b6 --- /dev/null +++ b/scipy/driven_string_fixed/340/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.441782009309722, + "mu": 0.090058392911427, + "T": 3.9926880404068172, + "A": 0.106515212016047, + "f_drive": 2.2000979762409014, + "gamma_w": 1.2984208212533663, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/340/simulation_code.py b/scipy/driven_string_fixed/340/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..49eeeb63a9e8910bdda95fa5e8d95352ee8af6b9 --- /dev/null +++ b/scipy/driven_string_fixed/340/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 3.441782009309722 +mu = 0.090058392911427 +T = 3.9926880404068172 +A = 0.106515212016047 +f_drive = 2.2000979762409014 +gamma_w = 1.2984208212533663 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/340/video.mp4 b/scipy/driven_string_fixed/340/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3e22cb5c4bce71dad594d0542c9c044a9cd10215 --- /dev/null +++ b/scipy/driven_string_fixed/340/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb0e2ed25c0bd6d7b97a0eeb15f6049d819d831757dc517b95ea6640671e2995 +size 46654 diff --git a/scipy/driven_string_fixed/362/cot.json b/scipy/driven_string_fixed/362/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f64281f9b270ff6ed207086cfcface6c75e47f2d --- /dev/null +++ b/scipy/driven_string_fixed/362/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=3.159 m, density mu=0.0744 kg/m, tension T=3.594 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.130 m and frequency f=1.548 Hz. Phase speed c=\\sqrt(T/mu)=6.951 m/s; wavelength lambda=c/f=4.490 m; ~0.70 wavelengths fit in L. Linear viscous damping gamma_w=1.328 1/s gives decay length c/gamma_w=5.235 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(3.593732954090476/0.0743701758234624) = 6.9514 m/s.", + "Driving angular frequency omega = 2 pi f = 9.7279 rad/s; wavelength lambda = c/f = 4.4899 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 5.235 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 6.951419485362602, + "omega_rad_s": 9.727862477616634, + "lambda_m": 4.489892499505528, + "n_wavelengths_in_L": 0.7034993855222106, + "decay_length_m": 5.234664948209748 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=6.951 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 2.245 m.", + "After a few transit times (~L/c = 0.454 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 3.158636614462921, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.0743701758234624, + "unit": "", + "description": "" + }, + "T": { + "value": 3.593732954090476, + "unit": "", + "description": "" + }, + "A": { + "value": 0.12975241113243338, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.5482373990308593, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.3279588195496608, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/362/params.json b/scipy/driven_string_fixed/362/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ba858839b0eb0bca0423dacbe480f2f2a2a6f8bb --- /dev/null +++ b/scipy/driven_string_fixed/362/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.158636614462921, + "mu": 0.0743701758234624, + "T": 3.593732954090476, + "A": 0.12975241113243338, + "f_drive": 1.5482373990308593, + "gamma_w": 1.3279588195496608, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/362/simulation_code.py b/scipy/driven_string_fixed/362/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5a17a7337259ac84244c702e5d7598cc7ddd72aa --- /dev/null +++ b/scipy/driven_string_fixed/362/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 3.158636614462921 +mu = 0.0743701758234624 +T = 3.593732954090476 +A = 0.12975241113243338 +f_drive = 1.5482373990308593 +gamma_w = 1.3279588195496608 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/362/video.mp4 b/scipy/driven_string_fixed/362/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d280fbdb398190467412ee785462d8981ef5db5b --- /dev/null +++ b/scipy/driven_string_fixed/362/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c902d014b9ff7e351a6edda7a8dba9e2fdb312878ad8c491c738d55352c9ca93 +size 37181 diff --git a/scipy/driven_string_fixed/416/cot.json b/scipy/driven_string_fixed/416/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..90ab539ad21afe8f00e48cc9d96c00684590b8f3 --- /dev/null +++ b/scipy/driven_string_fixed/416/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.296 m, density mu=0.1412 kg/m, tension T=4.203 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.102 m and frequency f=1.880 Hz. Phase speed c=\\sqrt(T/mu)=5.455 m/s; wavelength lambda=c/f=2.901 m; ~1.48 wavelengths fit in L. Linear viscous damping gamma_w=1.174 1/s gives decay length c/gamma_w=4.648 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(4.202902825819035/0.14124373780020816) = 5.4549 m/s.", + "Driving angular frequency omega = 2 pi f = 11.8144 rad/s; wavelength lambda = c/f = 2.9011 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 4.648 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 5.454941198380355, + "omega_rad_s": 11.81439011823109, + "lambda_m": 2.901072848128007, + "n_wavelengths_in_L": 1.4809607698445997, + "decay_length_m": 4.647846026325891 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=5.455 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.451 m.", + "After a few transit times (~L/c = 0.788 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.296375078538919, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.14124373780020816, + "unit": "", + "description": "" + }, + "T": { + "value": 4.202902825819035, + "unit": "", + "description": "" + }, + "A": { + "value": 0.10249018608798137, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.8803185869325199, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.1736492920555008, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/416/params.json b/scipy/driven_string_fixed/416/params.json new file mode 100644 index 0000000000000000000000000000000000000000..2212870ba23c8a57b0fec18f7e1bf437c4e3f2a4 --- /dev/null +++ b/scipy/driven_string_fixed/416/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.296375078538919, + "mu": 0.14124373780020816, + "T": 4.202902825819035, + "A": 0.10249018608798137, + "f_drive": 1.8803185869325199, + "gamma_w": 1.1736492920555008, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/416/simulation_code.py b/scipy/driven_string_fixed/416/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..02510ee292609b7757375355e33cf1452999810c --- /dev/null +++ b/scipy/driven_string_fixed/416/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.296375078538919 +mu = 0.14124373780020816 +T = 4.202902825819035 +A = 0.10249018608798137 +f_drive = 1.8803185869325199 +gamma_w = 1.1736492920555008 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/416/video.mp4 b/scipy/driven_string_fixed/416/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..097a556cd02eb18ed4f90717798146fcdd360b25 --- /dev/null +++ b/scipy/driven_string_fixed/416/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36537a74dbef63141c3875a844d761cc7d1aa6d89d25b83ab3d365f82ec173cb +size 44368 diff --git a/scipy/driven_string_fixed/421/cot.json b/scipy/driven_string_fixed/421/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..2874d479aba25ba7c3290554f1bf730a8bcb782c --- /dev/null +++ b/scipy/driven_string_fixed/421/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=3.045 m, density mu=0.0714 kg/m, tension T=3.028 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.096 m and frequency f=1.653 Hz. Phase speed c=\\sqrt(T/mu)=6.511 m/s; wavelength lambda=c/f=3.938 m; ~0.77 wavelengths fit in L. Linear viscous damping gamma_w=0.906 1/s gives decay length c/gamma_w=7.190 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(3.0276863299474/0.07142073519475116) = 6.5109 m/s.", + "Driving angular frequency omega = 2 pi f = 10.3892 rad/s; wavelength lambda = c/f = 3.9377 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 7.190 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 6.510933831521761, + "omega_rad_s": 10.38921565617529, + "lambda_m": 3.9376797190574924, + "n_wavelengths_in_L": 0.7732195995821637, + "decay_length_m": 7.190254877449769 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=6.511 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.969 m.", + "After a few transit times (~L/c = 0.468 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 3.044691135652441, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.07142073519475116, + "unit": "", + "description": "" + }, + "T": { + "value": 3.0276863299474, + "unit": "", + "description": "" + }, + "A": { + "value": 0.09567162856113431, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.6534950265280064, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.905521979748102, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/421/params.json b/scipy/driven_string_fixed/421/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a88c27f90925c6002a657a1fa1e3d4d2f014ebba --- /dev/null +++ b/scipy/driven_string_fixed/421/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.044691135652441, + "mu": 0.07142073519475116, + "T": 3.0276863299474, + "A": 0.09567162856113431, + "f_drive": 1.6534950265280064, + "gamma_w": 0.905521979748102, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/421/simulation_code.py b/scipy/driven_string_fixed/421/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..2e59742f94ae8cc6a1f45e041f72825b4de38b21 --- /dev/null +++ b/scipy/driven_string_fixed/421/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 3.044691135652441 +mu = 0.07142073519475116 +T = 3.0276863299474 +A = 0.09567162856113431 +f_drive = 1.6534950265280064 +gamma_w = 0.905521979748102 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/421/video.mp4 b/scipy/driven_string_fixed/421/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..56b4961440ad97a73169838c2f7dc95a20c1c59d --- /dev/null +++ b/scipy/driven_string_fixed/421/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25c93e21f8a8088eb77de366f0e9eb7115b0b63bc2b6fc9b32e09e1a23368c3e +size 32190 diff --git a/scipy/driven_string_fixed/422/cot.json b/scipy/driven_string_fixed/422/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..2ad7b90f963ff269451dfd389e78b59d252401f2 --- /dev/null +++ b/scipy/driven_string_fixed/422/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=4.034 m, density mu=0.0879 kg/m, tension T=3.333 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.096 m and frequency f=1.549 Hz. Phase speed c=\\sqrt(T/mu)=6.158 m/s; wavelength lambda=c/f=3.975 m; ~1.01 wavelengths fit in L. Linear viscous damping gamma_w=0.512 1/s gives decay length c/gamma_w=12.032 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(3.3334408320134097/0.08790182986007894) = 6.1581 m/s.", + "Driving angular frequency omega = 2 pi f = 9.7348 rad/s; wavelength lambda = c/f = 3.9746 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 12.032 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 6.158109648452809, + "omega_rad_s": 9.7348444799662, + "lambda_m": 3.9746442937826862, + "n_wavelengths_in_L": 1.0148819136854557, + "decay_length_m": 12.03172124392222 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=6.158 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 1.987 m.", + "After a few transit times (~L/c = 0.655 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 4.033794607093149, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.08790182986007894, + "unit": "", + "description": "" + }, + "T": { + "value": 3.3334408320134097, + "unit": "", + "description": "" + }, + "A": { + "value": 0.09564982619062612, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.5493486192174721, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.5118228326278383, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/422/params.json b/scipy/driven_string_fixed/422/params.json new file mode 100644 index 0000000000000000000000000000000000000000..d18e1e9327c7f9d12a93810008432954127e88b7 --- /dev/null +++ b/scipy/driven_string_fixed/422/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.033794607093149, + "mu": 0.08790182986007894, + "T": 3.3334408320134097, + "A": 0.09564982619062612, + "f_drive": 1.5493486192174721, + "gamma_w": 0.5118228326278383, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/422/simulation_code.py b/scipy/driven_string_fixed/422/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d019ab5848156772c6060e08773762ffad4618f1 --- /dev/null +++ b/scipy/driven_string_fixed/422/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 4.033794607093149 +mu = 0.08790182986007894 +T = 3.3334408320134097 +A = 0.09564982619062612 +f_drive = 1.5493486192174721 +gamma_w = 0.5118228326278383 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/422/video.mp4 b/scipy/driven_string_fixed/422/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ee614d59870ef11fa7874035778f98bffa7a3f1e --- /dev/null +++ b/scipy/driven_string_fixed/422/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a331e30e1b1100ce47e451b744c372e7b742e1326d71571e6e8762fad0cba87 +size 50935 diff --git a/scipy/driven_string_fixed/573/cot.json b/scipy/driven_string_fixed/573/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..aace0850aece500b6707aba6627a0a9e1e8b9619 --- /dev/null +++ b/scipy/driven_string_fixed/573/cot.json @@ -0,0 +1,94 @@ +{ + "simulation": "driven_string_fixed", + "physical_observation": "A taut string of length L=3.416 m, density mu=0.0956 kg/m, tension T=4.431 N is fixed at x=L and driven sinusoidally at x=0 with amplitude A=0.080 m and frequency f=1.590 Hz. Phase speed c=\\sqrt(T/mu)=6.810 m/s; wavelength lambda=c/f=4.284 m; ~0.80 wavelengths fit in L. Linear viscous damping gamma_w=1.178 1/s gives decay length c/gamma_w=5.783 m.", + "physical_law": { + "name": "Damped wave equation on a string with Dirichlet BCs", + "statement": "Small-amplitude transverse motion of a taut string obeys u_tt = c^2 u_xx - 2 gamma_w u_t with prescribed driver at the left end and zero displacement at the right end.", + "formula": "u(0,t) = A \\sin(omega t); u(L,t) = 0; u_tt = c^2 u_xx - 2 gamma_w u_t, c = \\sqrt(T/mu)." + }, + "ode_system": { + "state_variables": [ + "u(x_i, t) (transverse displacement at grid points)" + ], + "equations_latex": [ + "u^{n+1}_{j} = (1/(1+g dt)) \\cdot (2 u^n_j - (1-g dt) u^{n-1}_j + (c dt/dx)^2 (u^n_{j+1} - 2 u^n_j + u^n_{j-1}))", + "u^{n+1}_0 = A \\sin(\\omega t_{n+1}); u^{n+1}_N = 0" + ], + "equations_python": [ + "u**(n+1)_j = (1/(1+g * dt)) * (2 * u**n_j - (1-g * dt) * u**(n-1)_j + (c * dt/dx)**2 * (u**n_j_1 - 2 * u**n_j + u**n_j_1))", + "u**(n+1)_0 = A * np.sin ( omega * t_n_1); u**(n+1)_N = 0" + ] + }, + "derivation_steps": [ + "Phase speed c = \\sqrt(T/mu) = \\sqrt(4.43094338975512/0.09555614111808047) = 6.8096 m/s.", + "Driving angular frequency omega = 2 pi f = 9.9878 rad/s; wavelength lambda = c/f = 4.2838 m.", + "Discretise u(x,t) on a uniform grid; use centred second differences in x and centred-time damping for stability.", + "Apply Dirichlet BCs at every step: prescribed driver at j=0, zero at j=N.", + "CFL constraint: (c dt/dx)^2 < 1; using dt = 1/(fps \\cdot n_per_frame) so the simulation auto-tightens n_per_frame if needed.", + "Damping reduces wave amplitudes over a length scale c/gamma_w = 5.783 m, ensuring the response remains bounded." + ], + "physical_constants_derived": { + "c_m_s": 6.80955605344472, + "omega_rad_s": 9.987846560211393, + "lambda_m": 4.283776516337884, + "n_wavelengths_in_L": 0.7975325506599031, + "decay_length_m": 5.782801681840717 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM on a uniform grid with centred-time damping; CFL-stable when (c dt/dx)^2 < 1.", + "tolerance": "Spatial second order; temporal second order; CFL margin enforced by adjusting n_per_frame.", + "justification": "Hyperbolic PDE with smooth BCs; standard scheme provides good fidelity for the wavetrain and reflections." + }, + "code_validation": { + "ode_source": "Damped wave equation in 1D with Dirichlet BCs.", + "energy_check": "With damping, total energy decays smoothly; without damping the standing-wave envelope is steady.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain emitted from x=0 propagates rightward at c=6.810 m/s; reflects from the fixed end with a 180-degree phase flip.", + "Outgoing + reflected waves superpose into an approximate standing wave with a node at x=L and antinodes spaced by lambda/2 = 2.142 m.", + "After a few transit times (~L/c = 0.502 s), the response is nearly stationary in shape, modulated at omega." + ], + "parameters": { + "L": { + "value": 3.416451211531947, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.09555614111808047, + "unit": "", + "description": "" + }, + "T": { + "value": 4.43094338975512, + "unit": "", + "description": "" + }, + "A": { + "value": 0.08011617623753244, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.5896151509010268, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.1775531010908156, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_fixed/573/params.json b/scipy/driven_string_fixed/573/params.json new file mode 100644 index 0000000000000000000000000000000000000000..6a215fcfbda2be83633bc14e9e6bcb762893c657 --- /dev/null +++ b/scipy/driven_string_fixed/573/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.416451211531947, + "mu": 0.09555614111808047, + "T": 4.43094338975512, + "A": 0.08011617623753244, + "f_drive": 1.5896151509010268, + "gamma_w": 1.1775531010908156, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_fixed/573/simulation_code.py b/scipy/driven_string_fixed/573/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..bf06b11aa60636d3eccb144f6ff865835ba112b9 --- /dev/null +++ b/scipy/driven_string_fixed/573/simulation_code.py @@ -0,0 +1,87 @@ +""" +Driven String + Fixed End — auto-generated. +""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle, Rectangle + +L = 3.416451211531947 +mu = 0.09555614111808047 +T = 4.43094338975512 +A = 0.08011617623753244 +f_drive = 1.5896151509010268 +gamma_w = 1.1775531010908156 +N = 200 +n_per_frame_in = 16 +duration = 12 +fps = 30 +omega = 2 * np.pi * f_drive +c = np.sqrt(T / mu) + +dx = L / N +x_grid = np.linspace(0.0, L, N + 1) +n_per_frame = n_per_frame_in +dt = 1.0 / (fps * n_per_frame) +factor = (c * dt / dx) ** 2 +while factor >= 1.0: + n_per_frame *= 2 + dt = 1.0 / (fps * n_per_frame) + factor = (c * dt / dx) ** 2 +damp_n = 1.0 / (1.0 + gamma_w * dt) +damp_p = 1.0 - gamma_w * dt + +u_curr = np.zeros(N + 1) +u_prev = np.zeros(N + 1) +n_frames = int(duration * fps) + 1 +U_frames = np.zeros((n_frames, N + 1)) +U_frames[0] = u_curr.copy() + +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame - 1) / fps + (sub + 1) * dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2 * u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n * (2 * u_curr[1:-1] - damp_p * u_prev[1:-1] + factor * lap_int) + u_next[-1] = 0.0 + u_next[0] = A * np.sin(omega * t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w / fig_h +x_lo_d = -0.40; x_hi_d = L + 0.40 +y_lo_d = -4.5 * A; y_hi_d = +4.5 * A +dx_d, dy_d = x_hi_d - x_lo_d, y_hi_d - y_lo_d +if dx_d / dy_d < fig_aspect: + extra = (fig_aspect * dy_d - dx_d) / 2.0 + x_lo, x_hi = x_lo_d - extra, x_hi_d + extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d / fig_aspect - dy_d) / 2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d - extra, y_hi_d + extra + +fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0, 0, 1, 1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo, x_hi); ax.set_ylim(y_lo, y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0, 0], [y_lo, y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0, 0), 0.04, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +ax.add_patch(Rectangle((L, y_lo), 0.12, y_hi - y_lo, facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.5, zorder=2)) +ax.plot([L, L], [y_lo, y_hi], color="#adb5bd", lw=2.0, zorder=3) +anchor = Circle((L, 0), 0.05, facecolor="#e63946", edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(anchor) +str_line, = ax.plot([], [], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f] + str_line.set_data(x_grid, u) + driver_dot.center = (0, u[0]) + return str_line, driver_dot, anchor + +ani = animation.FuncAnimation(fig, update, frames=n_frames, interval=1000.0/fps, blit=False) +ani.save("driven_string_fixed.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close(); print("Saved driven_string_fixed.mp4") diff --git a/scipy/driven_string_fixed/573/video.mp4 b/scipy/driven_string_fixed/573/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..32965708c7b7723fa0b33fb4901cda11e93000b5 --- /dev/null +++ b/scipy/driven_string_fixed/573/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69fe3a127278920b27606311be1ccfb76f21aa66640c354898877f4924a77326 +size 31355 diff --git a/scipy/driven_string_ring/024/cot.json b/scipy/driven_string_ring/024/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..d0e4134bb98d8662087d4091a1212f34466b87db --- /dev/null +++ b/scipy/driven_string_ring/024/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=4.979 m, linear density mu=0.116 kg/m, tension T=4.497 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.116 m, f_drive=1.636 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 6.2198, + "lambda_wavelength_m": 3.8016, + "n_wavelengths_in_L": 1.3097, + "T_drive_period_s": 0.6112, + "decay_length_m": 7.1784 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~6.220 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.801 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 4.979190582885917, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.11623857735239022, + "unit": "", + "description": "" + }, + "T": { + "value": 4.496838431134701, + "unit": "", + "description": "" + }, + "A": { + "value": 0.11586384072724647, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.6360911434504202, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.8664687210282511, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/024/params.json b/scipy/driven_string_ring/024/params.json new file mode 100644 index 0000000000000000000000000000000000000000..297d6d59da3f69ed7e7437e4266fb289c4b221e7 --- /dev/null +++ b/scipy/driven_string_ring/024/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.979190582885917, + "mu": 0.11623857735239022, + "T": 4.496838431134701, + "A": 0.11586384072724647, + "f_drive": 1.6360911434504202, + "gamma_w": 0.8664687210282511, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/024/simulation_code.py b/scipy/driven_string_ring/024/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..7cd35b2696788dd25e6ce84de12d1eba7e8fa968 --- /dev/null +++ b/scipy/driven_string_ring/024/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 4.979190582885917 +mu = 0.11623857735239022 +T = 4.496838431134701 +A = 0.11586384072724647 +f_drive = 1.6360911434504202 +gamma_w = 0.8664687210282511 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/024/video.mp4 b/scipy/driven_string_ring/024/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ce4af3488f75244d0ced34969603408df6ff312b --- /dev/null +++ b/scipy/driven_string_ring/024/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18748f574d46bedd06d0cb39d28c8f1ec938ac7cbdc55be761b337c75ff33631 +size 48170 diff --git a/scipy/driven_string_ring/039/cot.json b/scipy/driven_string_ring/039/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..fafe8a865ac5d6d29809d5312d7002bb46f21274 --- /dev/null +++ b/scipy/driven_string_ring/039/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=4.678 m, linear density mu=0.068 kg/m, tension T=4.361 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.094 m, f_drive=1.704 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 8.0001, + "lambda_wavelength_m": 4.6956, + "n_wavelengths_in_L": 0.9963, + "T_drive_period_s": 0.5869, + "decay_length_m": 6.7694 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~8.000 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.585 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 4.678383117202567, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.06814043125770372, + "unit": "", + "description": "" + }, + "T": { + "value": 4.361080220182524, + "unit": "", + "description": "" + }, + "A": { + "value": 0.09401073787489206, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.703745301714673, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.1817999830945385, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/039/params.json b/scipy/driven_string_ring/039/params.json new file mode 100644 index 0000000000000000000000000000000000000000..fce3a123024f9ae1aac5ac7a5c0827d4b4ec6c43 --- /dev/null +++ b/scipy/driven_string_ring/039/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.678383117202567, + "mu": 0.06814043125770372, + "T": 4.361080220182524, + "A": 0.09401073787489206, + "f_drive": 1.703745301714673, + "gamma_w": 1.1817999830945385, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/039/simulation_code.py b/scipy/driven_string_ring/039/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..eba1ae0cf0ceb35f89bdb615dc7624caf49a494f --- /dev/null +++ b/scipy/driven_string_ring/039/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 4.678383117202567 +mu = 0.06814043125770372 +T = 4.361080220182524 +A = 0.09401073787489206 +f_drive = 1.703745301714673 +gamma_w = 1.1817999830945385 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/039/video.mp4 b/scipy/driven_string_ring/039/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d348847a8ff2a88982496be34b7a92f0bcf1ab60 --- /dev/null +++ b/scipy/driven_string_ring/039/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b81a7390c80a6ad36d733a2432de37400880db4db9d74ff059bbbbb01265ac4 +size 34872 diff --git a/scipy/driven_string_ring/110/cot.json b/scipy/driven_string_ring/110/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c5cfdc91da522a4b367c8abaee636b20e00e4e02 --- /dev/null +++ b/scipy/driven_string_ring/110/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=3.769 m, linear density mu=0.144 kg/m, tension T=5.706 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.096 m, f_drive=1.844 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 6.2968, + "lambda_wavelength_m": 3.4152, + "n_wavelengths_in_L": 1.1035, + "T_drive_period_s": 0.5424, + "decay_length_m": 7.3463 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~6.297 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.598 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 3.768565765333065, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.1439137923771876, + "unit": "", + "description": "" + }, + "T": { + "value": 5.706109881830495, + "unit": "", + "description": "" + }, + "A": { + "value": 0.0964738208347509, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.843765710444989, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.8571370132448721, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/110/params.json b/scipy/driven_string_ring/110/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a52211bbf2622d4082f1b0e94e704dd707069dac --- /dev/null +++ b/scipy/driven_string_ring/110/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.768565765333065, + "mu": 0.1439137923771876, + "T": 5.706109881830495, + "A": 0.0964738208347509, + "f_drive": 1.843765710444989, + "gamma_w": 0.8571370132448721, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/110/simulation_code.py b/scipy/driven_string_ring/110/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5e076ef9d49bbbcb2729e02e9fb3566913e047d9 --- /dev/null +++ b/scipy/driven_string_ring/110/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 3.768565765333065 +mu = 0.1439137923771876 +T = 5.706109881830495 +A = 0.0964738208347509 +f_drive = 1.843765710444989 +gamma_w = 0.8571370132448721 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/110/video.mp4 b/scipy/driven_string_ring/110/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f599fafdba6320656d54412fadadf02f3e9f02e3 --- /dev/null +++ b/scipy/driven_string_ring/110/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38aeaf68954e7e9ceca6669d636072dd08b5dcd179bc8453693a18b75375965d +size 46809 diff --git a/scipy/driven_string_ring/163/cot.json b/scipy/driven_string_ring/163/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..dd8b01a83508bcf162daa03c6cba330be3152ba0 --- /dev/null +++ b/scipy/driven_string_ring/163/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=4.294 m, linear density mu=0.101 kg/m, tension T=3.673 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.100 m, f_drive=1.549 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 6.0408, + "lambda_wavelength_m": 3.9008, + "n_wavelengths_in_L": 1.1009, + "T_drive_period_s": 0.6457, + "decay_length_m": 4.4337 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~6.041 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.711 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 4.294271213564102, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.10066723292347363, + "unit": "", + "description": "" + }, + "T": { + "value": 3.6734822223999766, + "unit": "", + "description": "" + }, + "A": { + "value": 0.09995655827728442, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.548595317113901, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.3624779809040453, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/163/params.json b/scipy/driven_string_ring/163/params.json new file mode 100644 index 0000000000000000000000000000000000000000..865b26087765ba1cb390a9fa9b4079fd70dfe159 --- /dev/null +++ b/scipy/driven_string_ring/163/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.294271213564102, + "mu": 0.10066723292347363, + "T": 3.6734822223999766, + "A": 0.09995655827728442, + "f_drive": 1.548595317113901, + "gamma_w": 1.3624779809040453, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/163/simulation_code.py b/scipy/driven_string_ring/163/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..0144a7df80615482a011b0fda1895e5fbef64841 --- /dev/null +++ b/scipy/driven_string_ring/163/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 4.294271213564102 +mu = 0.10066723292347363 +T = 3.6734822223999766 +A = 0.09995655827728442 +f_drive = 1.548595317113901 +gamma_w = 1.3624779809040453 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/163/video.mp4 b/scipy/driven_string_ring/163/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..073949dadaa19144adfcd6542e4ca86e70b8e972 --- /dev/null +++ b/scipy/driven_string_ring/163/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:adff79bd5a5ba159dfb1cda9e55ede42df53ab5a71206a4a9efad53426b101f0 +size 38678 diff --git a/scipy/driven_string_ring/197/cot.json b/scipy/driven_string_ring/197/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..abfd5338a2ab3004ac54385039e192e62c146ff8 --- /dev/null +++ b/scipy/driven_string_ring/197/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=4.563 m, linear density mu=0.144 kg/m, tension T=4.870 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.105 m, f_drive=2.083 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 5.8213, + "lambda_wavelength_m": 2.7946, + "n_wavelengths_in_L": 1.6327, + "T_drive_period_s": 0.4801, + "decay_length_m": 4.2991 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~5.821 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.784 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 4.562623315621097, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.14371809971464466, + "unit": "", + "description": "" + }, + "T": { + "value": 4.870254910404904, + "unit": "", + "description": "" + }, + "A": { + "value": 0.10476062056840721, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.083077365785919, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.3540628018082548, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/197/params.json b/scipy/driven_string_ring/197/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c7201a8819edd631cc884badc62e57988c13f016 --- /dev/null +++ b/scipy/driven_string_ring/197/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.562623315621097, + "mu": 0.14371809971464466, + "T": 4.870254910404904, + "A": 0.10476062056840721, + "f_drive": 2.083077365785919, + "gamma_w": 1.3540628018082548, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/197/simulation_code.py b/scipy/driven_string_ring/197/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b3e6fafe49bb628a87316d528c75aeaaa524e1ea --- /dev/null +++ b/scipy/driven_string_ring/197/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 4.562623315621097 +mu = 0.14371809971464466 +T = 4.870254910404904 +A = 0.10476062056840721 +f_drive = 2.083077365785919 +gamma_w = 1.3540628018082548 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/197/video.mp4 b/scipy/driven_string_ring/197/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..790dd8f6a0e468b0c1c6969930e688bcad84b658 --- /dev/null +++ b/scipy/driven_string_ring/197/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5fa9b1bbd41ef74b42a2cca89afc32878e9910dc8712444f5e05a48390bfa6b4 +size 46987 diff --git a/scipy/driven_string_ring/204/cot.json b/scipy/driven_string_ring/204/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..dcf7d17fcbe65fb9acb5d88647da4a3c5cea0825 --- /dev/null +++ b/scipy/driven_string_ring/204/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=3.627 m, linear density mu=0.062 kg/m, tension T=4.683 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.126 m, f_drive=1.934 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 8.704, + "lambda_wavelength_m": 4.4999, + "n_wavelengths_in_L": 0.8061, + "T_drive_period_s": 0.517, + "decay_length_m": 7.9991 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~8.704 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.417 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 3.6274365689555736, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.061816546826749114, + "unit": "", + "description": "" + }, + "T": { + "value": 4.683184571657916, + "unit": "", + "description": "" + }, + "A": { + "value": 0.12558062153730848, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.9342617572984468, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.0881157607858623, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/204/params.json b/scipy/driven_string_ring/204/params.json new file mode 100644 index 0000000000000000000000000000000000000000..abbf1e7084121b0747a1985fff9f335418e75160 --- /dev/null +++ b/scipy/driven_string_ring/204/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.6274365689555736, + "mu": 0.061816546826749114, + "T": 4.683184571657916, + "A": 0.12558062153730848, + "f_drive": 1.9342617572984468, + "gamma_w": 1.0881157607858623, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/204/simulation_code.py b/scipy/driven_string_ring/204/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..e02d34205fa2c8f03ef6f02465c58befad72f9ec --- /dev/null +++ b/scipy/driven_string_ring/204/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 3.6274365689555736 +mu = 0.061816546826749114 +T = 4.683184571657916 +A = 0.12558062153730848 +f_drive = 1.9342617572984468 +gamma_w = 1.0881157607858623 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/204/video.mp4 b/scipy/driven_string_ring/204/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..02fac7e4d837ef32dd177f747c6ca829dec42c59 --- /dev/null +++ b/scipy/driven_string_ring/204/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49414fdbe7905e996bf9df03ca6f25b627edabbeaa1462564a31dcafb3773792 +size 62813 diff --git a/scipy/driven_string_ring/227/cot.json b/scipy/driven_string_ring/227/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1be2b5ecd61d92eeb18a5d8eead6bc44da460cdb --- /dev/null +++ b/scipy/driven_string_ring/227/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=4.015 m, linear density mu=0.141 kg/m, tension T=5.836 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.101 m, f_drive=1.889 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 6.4258, + "lambda_wavelength_m": 3.4009, + "n_wavelengths_in_L": 1.1807, + "T_drive_period_s": 0.5293, + "decay_length_m": 7.5047 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~6.426 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.625 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 4.015479808314389, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.14134067974481013, + "unit": "", + "description": "" + }, + "T": { + "value": 5.836022920746737, + "unit": "", + "description": "" + }, + "A": { + "value": 0.10063038341642816, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.8894348039394093, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.8562343279192409, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/227/params.json b/scipy/driven_string_ring/227/params.json new file mode 100644 index 0000000000000000000000000000000000000000..b3776881f1eafa040edcdc59cf1167d900f6bc75 --- /dev/null +++ b/scipy/driven_string_ring/227/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.015479808314389, + "mu": 0.14134067974481013, + "T": 5.836022920746737, + "A": 0.10063038341642816, + "f_drive": 1.8894348039394093, + "gamma_w": 0.8562343279192409, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/227/simulation_code.py b/scipy/driven_string_ring/227/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ff21954c0a1cd03abd96edbde56759dd5f153c8a --- /dev/null +++ b/scipy/driven_string_ring/227/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 4.015479808314389 +mu = 0.14134067974481013 +T = 5.836022920746737 +A = 0.10063038341642816 +f_drive = 1.8894348039394093 +gamma_w = 0.8562343279192409 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/227/video.mp4 b/scipy/driven_string_ring/227/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a090c6f5700e46471216bda83dfe051ec29f3d3b --- /dev/null +++ b/scipy/driven_string_ring/227/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a271a8b8b9af96f40fc57c5f3847c66ce92167ceffbec8610807e048fbdfafa +size 55194 diff --git a/scipy/driven_string_ring/228/cot.json b/scipy/driven_string_ring/228/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a1c5610680e49fa8483bfc0cb32ee9ec5cacf60d --- /dev/null +++ b/scipy/driven_string_ring/228/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=4.204 m, linear density mu=0.083 kg/m, tension T=3.848 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.137 m, f_drive=1.537 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 6.8141, + "lambda_wavelength_m": 4.4333, + "n_wavelengths_in_L": 0.9482, + "T_drive_period_s": 0.6506, + "decay_length_m": 8.4672 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~6.814 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.617 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 4.203704897601963, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.08286859421653214, + "unit": "", + "description": "" + }, + "T": { + "value": 3.847738932370455, + "unit": "", + "description": "" + }, + "A": { + "value": 0.13663233607116249, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.5370326125642633, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.8047650381905198, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/228/params.json b/scipy/driven_string_ring/228/params.json new file mode 100644 index 0000000000000000000000000000000000000000..bdc8684a808d7cd784dd39b1eb148122c9293ff9 --- /dev/null +++ b/scipy/driven_string_ring/228/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.203704897601963, + "mu": 0.08286859421653214, + "T": 3.847738932370455, + "A": 0.13663233607116249, + "f_drive": 1.5370326125642633, + "gamma_w": 0.8047650381905198, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/228/simulation_code.py b/scipy/driven_string_ring/228/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..dd319ee4e0e6fee5c878df3dc214f157bbeee209 --- /dev/null +++ b/scipy/driven_string_ring/228/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 4.203704897601963 +mu = 0.08286859421653214 +T = 3.847738932370455 +A = 0.13663233607116249 +f_drive = 1.5370326125642633 +gamma_w = 0.8047650381905198 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/228/video.mp4 b/scipy/driven_string_ring/228/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..bd4a32999b65fbf266987da128fe1873844fa2aa --- /dev/null +++ b/scipy/driven_string_ring/228/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4e1bd8ef987c92a8f4dbf652fdbe1cf0c200cfd56dd947e3412e0cd4a80a345 +size 45987 diff --git a/scipy/driven_string_ring/233/cot.json b/scipy/driven_string_ring/233/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..7df75ad9c1d643565a77dc7d36a8db06fc0491e0 --- /dev/null +++ b/scipy/driven_string_ring/233/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=3.690 m, linear density mu=0.136 kg/m, tension T=4.319 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.097 m, f_drive=2.497 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 5.6434, + "lambda_wavelength_m": 2.2597, + "n_wavelengths_in_L": 1.6329, + "T_drive_period_s": 0.4004, + "decay_length_m": 5.8187 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~5.643 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.654 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 3.6898086885672825, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.13561897384042815, + "unit": "", + "description": "" + }, + "T": { + "value": 4.319128606949742, + "unit": "", + "description": "" + }, + "A": { + "value": 0.09651351813217642, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.4973956689982995, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.9698723012635432, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/233/params.json b/scipy/driven_string_ring/233/params.json new file mode 100644 index 0000000000000000000000000000000000000000..344d94101fc8516ed8d39bd9d692de794f9d789c --- /dev/null +++ b/scipy/driven_string_ring/233/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.6898086885672825, + "mu": 0.13561897384042815, + "T": 4.319128606949742, + "A": 0.09651351813217642, + "f_drive": 2.4973956689982995, + "gamma_w": 0.9698723012635432, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/233/simulation_code.py b/scipy/driven_string_ring/233/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..638ff6d95676c364a1ccbd98c0ae150da764a182 --- /dev/null +++ b/scipy/driven_string_ring/233/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 3.6898086885672825 +mu = 0.13561897384042815 +T = 4.319128606949742 +A = 0.09651351813217642 +f_drive = 2.4973956689982995 +gamma_w = 0.9698723012635432 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/233/video.mp4 b/scipy/driven_string_ring/233/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3afb81cff62bb66b1acee2d3ee75bb229377f9ac --- /dev/null +++ b/scipy/driven_string_ring/233/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e7e5b9432467cc02926f01a94073e5177d0e9045238bdaa8b1116ff4d422047 +size 39626 diff --git a/scipy/driven_string_ring/312/cot.json b/scipy/driven_string_ring/312/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..efd8432cb9f535bcdc4ad82de24c29eb310a65c9 --- /dev/null +++ b/scipy/driven_string_ring/312/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=3.983 m, linear density mu=0.112 kg/m, tension T=3.703 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.077 m, f_drive=2.002 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 5.7559, + "lambda_wavelength_m": 2.8748, + "n_wavelengths_in_L": 1.3856, + "T_drive_period_s": 0.4994, + "decay_length_m": 5.5053 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~5.756 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.692 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 3.983269652001881, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.11177448626825046, + "unit": "", + "description": "" + }, + "T": { + "value": 3.7031247555471674, + "unit": "", + "description": "" + }, + "A": { + "value": 0.07744547122067409, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.002214639545388, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 1.0455228123618905, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/312/params.json b/scipy/driven_string_ring/312/params.json new file mode 100644 index 0000000000000000000000000000000000000000..2f5914b611b9b9becb999f9f4ce929177f5cf2e5 --- /dev/null +++ b/scipy/driven_string_ring/312/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.983269652001881, + "mu": 0.11177448626825046, + "T": 3.7031247555471674, + "A": 0.07744547122067409, + "f_drive": 2.002214639545388, + "gamma_w": 1.0455228123618905, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/312/simulation_code.py b/scipy/driven_string_ring/312/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..60404564fce0f80ff2f23723679b6f158aabf1b7 --- /dev/null +++ b/scipy/driven_string_ring/312/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 3.983269652001881 +mu = 0.11177448626825046 +T = 3.7031247555471674 +A = 0.07744547122067409 +f_drive = 2.002214639545388 +gamma_w = 1.0455228123618905 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/312/video.mp4 b/scipy/driven_string_ring/312/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..45317df97f0f69dec3a0edda045575af23e6c86a --- /dev/null +++ b/scipy/driven_string_ring/312/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b3bbf9a13db1cca7c2818c4423bbe6335e5a7757ec965754218cd1f9d0dfcd9 +size 38817 diff --git a/scipy/driven_string_ring/358/cot.json b/scipy/driven_string_ring/358/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..457447b0836eae93af4c63c7c5ca13568490d049 --- /dev/null +++ b/scipy/driven_string_ring/358/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=4.069 m, linear density mu=0.147 kg/m, tension T=3.489 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.110 m, f_drive=1.631 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 4.8791, + "lambda_wavelength_m": 2.9917, + "n_wavelengths_in_L": 1.3602, + "T_drive_period_s": 0.6132, + "decay_length_m": 5.1559 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~4.879 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.834 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 4.06922734295542, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.14654379447088275, + "unit": "", + "description": "" + }, + "T": { + "value": 3.4886138988440463, + "unit": "", + "description": "" + }, + "A": { + "value": 0.10954972305327734, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.6309001451056053, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.9463241068113406, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/358/params.json b/scipy/driven_string_ring/358/params.json new file mode 100644 index 0000000000000000000000000000000000000000..2ba75ed4878ffd01857d18f31156f2aa4de92276 --- /dev/null +++ b/scipy/driven_string_ring/358/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.06922734295542, + "mu": 0.14654379447088275, + "T": 3.4886138988440463, + "A": 0.10954972305327734, + "f_drive": 1.6309001451056053, + "gamma_w": 0.9463241068113406, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/358/simulation_code.py b/scipy/driven_string_ring/358/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..82b6116a1527a7870e6c10badb87197cfc890e16 --- /dev/null +++ b/scipy/driven_string_ring/358/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 4.06922734295542 +mu = 0.14654379447088275 +T = 3.4886138988440463 +A = 0.10954972305327734 +f_drive = 1.6309001451056053 +gamma_w = 0.9463241068113406 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/358/video.mp4 b/scipy/driven_string_ring/358/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..47e5786739178c9171cb515b2588c671b7e1967e --- /dev/null +++ b/scipy/driven_string_ring/358/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8908d6d0b6465b30b9bee80619bf666355d183527da543ee4ae21681506259ae +size 46929 diff --git a/scipy/driven_string_ring/391/cot.json b/scipy/driven_string_ring/391/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a924dc3e5e9e4b62774cae7bf952c2311371a740 --- /dev/null +++ b/scipy/driven_string_ring/391/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=4.454 m, linear density mu=0.065 kg/m, tension T=4.697 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.129 m, f_drive=2.186 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 8.5002, + "lambda_wavelength_m": 3.8894, + "n_wavelengths_in_L": 1.1453, + "T_drive_period_s": 0.4576, + "decay_length_m": 13.5083 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~8.500 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.524 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 4.454427366146007, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.06500404519588465, + "unit": "", + "description": "" + }, + "T": { + "value": 4.696805493022789, + "unit": "", + "description": "" + }, + "A": { + "value": 0.12937720064774744, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.185502419572134, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.6292612342022222, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/391/params.json b/scipy/driven_string_ring/391/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c13fed367458f86fafbc8a3f1f04a1aa63c3f122 --- /dev/null +++ b/scipy/driven_string_ring/391/params.json @@ -0,0 +1,10 @@ +{ + "L": 4.454427366146007, + "mu": 0.06500404519588465, + "T": 4.696805493022789, + "A": 0.12937720064774744, + "f_drive": 2.185502419572134, + "gamma_w": 0.6292612342022222, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/391/simulation_code.py b/scipy/driven_string_ring/391/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5309dafc71c0142537331299d6db84ada7aa2e5c --- /dev/null +++ b/scipy/driven_string_ring/391/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 4.454427366146007 +mu = 0.06500404519588465 +T = 4.696805493022789 +A = 0.12937720064774744 +f_drive = 2.185502419572134 +gamma_w = 0.6292612342022222 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/391/video.mp4 b/scipy/driven_string_ring/391/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..78e5c82b4e9fde284f17dc8f790af8e0a4f7b8bb --- /dev/null +++ b/scipy/driven_string_ring/391/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:567cf430fae4e7f539ab386c3252039b4741ae3138954ee7a40fcbfd2213523d +size 60851 diff --git a/scipy/driven_string_ring/408/cot.json b/scipy/driven_string_ring/408/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f0017040722206abf8f3618a4b4c649425ebd4a6 --- /dev/null +++ b/scipy/driven_string_ring/408/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=3.188 m, linear density mu=0.118 kg/m, tension T=3.164 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.063 m, f_drive=1.988 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 5.1704, + "lambda_wavelength_m": 2.6005, + "n_wavelengths_in_L": 1.2257, + "T_drive_period_s": 0.503, + "decay_length_m": 5.3965 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~5.170 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.617 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 3.187592913875811, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.11837328621569462, + "unit": "", + "description": "" + }, + "T": { + "value": 3.164455688100555, + "unit": "", + "description": "" + }, + "A": { + "value": 0.06298856124855588, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.9881880442030933, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.9580990397450453, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/408/params.json b/scipy/driven_string_ring/408/params.json new file mode 100644 index 0000000000000000000000000000000000000000..0c37447b27306b293c124be18977aece26c96294 --- /dev/null +++ b/scipy/driven_string_ring/408/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.187592913875811, + "mu": 0.11837328621569462, + "T": 3.164455688100555, + "A": 0.06298856124855588, + "f_drive": 1.9881880442030933, + "gamma_w": 0.9580990397450453, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/408/simulation_code.py b/scipy/driven_string_ring/408/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d26678197b45bd61ecfbd672937760c5a30cd300 --- /dev/null +++ b/scipy/driven_string_ring/408/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 3.187592913875811 +mu = 0.11837328621569462 +T = 3.164455688100555 +A = 0.06298856124855588 +f_drive = 1.9881880442030933 +gamma_w = 0.9580990397450453 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/408/video.mp4 b/scipy/driven_string_ring/408/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..36472d47f4c7afd94d2508ed61391d50c045cdc4 --- /dev/null +++ b/scipy/driven_string_ring/408/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49b155f779e8557bc5d19865ae325dc68e69ad9aa55a4b205a4bf5c9684dd6ee +size 44189 diff --git a/scipy/driven_string_ring/471/cot.json b/scipy/driven_string_ring/471/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..afed3c62d8a43b6f56b90979d675b08d6dfd2713 --- /dev/null +++ b/scipy/driven_string_ring/471/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=3.656 m, linear density mu=0.113 kg/m, tension T=3.290 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.118 m, f_drive=2.084 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 5.406, + "lambda_wavelength_m": 2.5946, + "n_wavelengths_in_L": 1.4089, + "T_drive_period_s": 0.4799, + "decay_length_m": 8.1965 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~5.406 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.676 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 3.6556491048442377, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.1125828373027313, + "unit": "", + "description": "" + }, + "T": { + "value": 3.2902549613129457, + "unit": "", + "description": "" + }, + "A": { + "value": 0.11811986022421553, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 2.0835518831367463, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.6595542680857649, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/471/params.json b/scipy/driven_string_ring/471/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f276c9f638bf87ab108db34dc4c00d54c061f5a5 --- /dev/null +++ b/scipy/driven_string_ring/471/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.6556491048442377, + "mu": 0.1125828373027313, + "T": 3.2902549613129457, + "A": 0.11811986022421553, + "f_drive": 2.0835518831367463, + "gamma_w": 0.6595542680857649, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/471/simulation_code.py b/scipy/driven_string_ring/471/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..bfe3f91182e10c087032bfcfb8121bce049e8b1b --- /dev/null +++ b/scipy/driven_string_ring/471/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 3.6556491048442377 +mu = 0.1125828373027313 +T = 3.2902549613129457 +A = 0.11811986022421553 +f_drive = 2.0835518831367463 +gamma_w = 0.6595542680857649 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/471/video.mp4 b/scipy/driven_string_ring/471/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..cd9892967f306ef11c99ab1d92240515363e10a9 --- /dev/null +++ b/scipy/driven_string_ring/471/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4806141c036115b67f65aaab9e640f3fdd018ff88240084e386a4a613a63218 +size 58082 diff --git a/scipy/driven_string_ring/481/cot.json b/scipy/driven_string_ring/481/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..3b2e64b1ffe51f5930b0b5e502ba0fdfcdb4a9d5 --- /dev/null +++ b/scipy/driven_string_ring/481/cot.json @@ -0,0 +1,95 @@ +{ + "simulation": "driven_string_ring", + "physical_observation": "A taut string of length L=3.901 m, linear density mu=0.148 kg/m, tension T=5.472 N runs from a driven oscillator at x=0 to a frictionless ring on a vertical rod at x=L. Driver: u(0,t) = A \\sin(omega t) with A=0.074 m, f_drive=1.598 Hz.", + "physical_law": { + "name": "1-D Linear Wave Equation with Linear Viscous Damping; Driven Dirichlet (LEFT), Free-end Neumann (RIGHT)", + "statement": "u_tt = c^2 u_xx - 2 gamma_w u_t with c = \\sqrt(T/mu); u(0,t) = A \\sin(omega t) (driver) and u_x(L,t) = 0 (free end via massless ring on frictionless rod).", + "formula": "\\ddot{u}= c^2 d^2u/dx^2 - 2 gamma_w \\dot{u}" + }, + "ode_system": { + "state_variables": [ + "u(x,t) -- transverse displacement, m" + ], + "equations_latex": [ + "u_tt = c^2 u_xx - 2 gamma_w u_t", + "Driven BC: u(0,t) = A \\sin(2 pi f_drive t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ], + "equations_python": [ + "u_tt = c**2 * u_xx - 2 * gamma_w * u_t", + "Driven * BC: u(0,t) = A * np.sin (2 * pi * f_drive * t)", + "Free BC: u_x(L,t) = 0 (Neumann via ghost-cell mirror)" + ] + }, + "derivation_steps": [ + "Newton II on a small string element: T u_xx dx = mu dx u_tt -> u_tt = c^2 u_xx with c=\\sqrt(T/mu).", + "Linear viscous-damping term -2 gamma_w u_t bounds long-time amplitude under continuous driving.", + "Massless ring on frictionless rod transmits no transverse force -> u_x(L,t) = 0 (free end).", + "Discretise with explicit leapfrog FDM: (1+gamma_w dt) u_{i,n+1} = 2 u_{i,n} - (1-gamma_w dt) u_{i,n-1} + (c dt/dx)^2 lap.", + "Free-end implementation: ghost cell u_{N+1} = u_{N-1}, so the laplacian at i=N becomes 2 (u_{N-1,n} - u_{N,n}).", + "CFL: (c dt/dx)^2 < 1 must hold for stability; sub-step n_per_frame times per video frame." + ], + "physical_constants_derived": { + "c_phase_speed_mps": 6.0909, + "lambda_wavelength_m": 3.8105, + "n_wavelengths_in_L": 1.0236, + "T_drive_period_s": 0.6256, + "decay_length_m": 6.4986 + }, + "numerical_method": { + "solver": "Explicit leapfrog FDM, second-order centred in time and space, with sub-stepping.", + "tolerance": "Bit-exact within IEEE float; CFL must satisfy (c dt/dx)^2 < 1." + }, + "code_validation": { + "ode_source": "Standard 1-D wave equation with viscous damping; Dirichlet+Neumann BCs.", + "energy_check": "Driver pumps energy in at x=0; gamma_w dissipation balances input in steady state so envelope saturates.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Wavetrain forms and propagates rightward at c~6.091 m/s.", + "Leading edge reaches the free end at t = L/c ~ 0.640 s and reflects WITHOUT phase inversion.", + "After ~1-2 round trips a near-standing-wave pattern emerges; the ring is a displacement antinode." + ], + "parameters": { + "L": { + "value": 3.9005457487321453, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.1475072380699032, + "unit": "", + "description": "" + }, + "T": { + "value": 5.472453299062384, + "unit": "", + "description": "" + }, + "A": { + "value": 0.07403205116249638, + "unit": "", + "description": "" + }, + "f_drive": { + "value": 1.5984807156577563, + "unit": "", + "description": "" + }, + "gamma_w": { + "value": 0.9372701602176177, + "unit": "", + "description": "" + }, + "N_grid": { + "value": 200, + "unit": "", + "description": "" + }, + "n_per_frame": { + "value": 16, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/driven_string_ring/481/params.json b/scipy/driven_string_ring/481/params.json new file mode 100644 index 0000000000000000000000000000000000000000..fec7862e7633cf79f69cdc84f8de1f2df626cd43 --- /dev/null +++ b/scipy/driven_string_ring/481/params.json @@ -0,0 +1,10 @@ +{ + "L": 3.9005457487321453, + "mu": 0.1475072380699032, + "T": 5.472453299062384, + "A": 0.07403205116249638, + "f_drive": 1.5984807156577563, + "gamma_w": 0.9372701602176177, + "N_grid": 200, + "n_per_frame": 16 +} \ No newline at end of file diff --git a/scipy/driven_string_ring/481/simulation_code.py b/scipy/driven_string_ring/481/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f00bc92255fa8f3d831db23acce23203f246512c --- /dev/null +++ b/scipy/driven_string_ring/481/simulation_code.py @@ -0,0 +1,93 @@ +"""Driven string + free-end ring standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Arc, Circle + +L = 3.9005457487321453 +mu = 0.1475072380699032 +T = 5.472453299062384 +A = 0.07403205116249638 +f_drive = 1.5984807156577563 +gamma_w = 0.9372701602176177 +N = 200 +n_per_frame = 16 +duration = 12 +fps = 30 + +omega = 2*np.pi*f_drive +c = np.sqrt(T/mu) +dx = L/N +x_grid = np.linspace(0.0, L, N+1) +dt = 1.0/(fps*n_per_frame) +factor = (c*dt/dx)**2 +damp_n = 1.0/(1.0+gamma_w*dt) +damp_p = 1.0 - gamma_w*dt +assert factor < 1.0, f"CFL violated: factor={factor:.3f}" + +u_curr = np.zeros(N+1); u_prev = np.zeros(N+1) +n_frames = int(duration*fps)+1 +U_frames = np.zeros((n_frames, N+1)) +U_frames[0] = u_curr.copy() +for frame in range(1, n_frames): + for sub in range(n_per_frame): + t_curr = (frame-1)/fps + (sub+1)*dt + u_next = np.empty_like(u_curr) + lap_int = u_curr[2:] - 2*u_curr[1:-1] + u_curr[:-2] + u_next[1:-1] = damp_n*(2*u_curr[1:-1] - damp_p*u_prev[1:-1] + factor*lap_int) + lap_right = 2*(u_curr[-2] - u_curr[-1]) + u_next[-1] = damp_n*(2*u_curr[-1] - damp_p*u_prev[-1] + factor*lap_right) + u_next[0] = A*np.sin(omega*t_curr) + u_prev, u_curr = u_curr, u_next + U_frames[frame] = u_curr.copy() + +fig_w, fig_h = 12.0, 4.0 +fig_aspect = fig_w/fig_h +x_lo_d, x_hi_d = -0.40, L+0.40 +y_lo_d, y_hi_d = -4.5*A, 4.5*A +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhline(0.0, color="#3a4357", lw=1, ls="--", zorder=0) +ax.plot([0,0],[y_lo,y_hi], color="#4a4e69", lw=1.5, ls=":", zorder=1) +driver_dot = Circle((0,0), 0.04, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=5) +ax.add_patch(driver_dot) +r_x = 0.22; r_y = 0.11 +back_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=0, theta2=180, + edgecolor="#e63946", lw=10, zorder=2) +ax.add_patch(back_arc) +ax.plot([L,L],[y_lo,y_hi], color="#adb5bd", lw=14, solid_capstyle="butt", zorder=3) +front_arc = Arc((L,0), 2*r_x, 2*r_y, theta1=180, theta2=360, + edgecolor="#e63946", lw=10, zorder=5) +ax.add_patch(front_arc) +n_cut = int(round(r_x/dx)) +n_inside = (N+1) - n_cut +str_x_plot = x_grid[:n_inside] +str_line, = ax.plot([],[], color="#a8dadc", lw=2.4, zorder=4) + +def update(f): + u = U_frames[f]; yy = u[-1] + str_y = u[:n_inside].copy(); str_y[-1] = yy + str_line.set_data(str_x_plot, str_y) + driver_dot.center = (0, u[0]) + back_arc.set_center((L, yy)) + front_arc.set_center((L, yy)) + return str_line, driver_dot, back_arc, front_arc + +ani = animation.FuncAnimation(fig, update, frames=n_frames, + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/driven_string_ring/481/video.mp4 b/scipy/driven_string_ring/481/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..713f77cee086da1e454e524e4bbe253a8490269f --- /dev/null +++ b/scipy/driven_string_ring/481/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b6222ee293dc335ec034a12f00b05cdc3795aad530ef7b192aba1da6b410906 +size 34078 diff --git a/scipy/falling_spring/028/cot.json b/scipy/falling_spring/028/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a5785035d9fc89ef27bb6dc25c187c0bdefb965b --- /dev/null +++ b/scipy/falling_spring/028/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.627 kg, m2=0.557 kg) connected by a Hookean spring (rest length L0=0.750 m, k=159.44 N/m, axial damping c=0.388 N \\cdot s/m) start at COM height 1.688 m, tilted 33.97 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.455 and friction mu=0.268.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2950; omega_s = \\sqrt(k/m_eff) = 23.247 rad/s; T_s = 0.270 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.295018, + "omega_spring_rad_s": 23.2473, + "T_spring_seconds": 0.2703, + "free_fall_time_to_first_contact_s": 0.5183 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.518 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.6266793025325027, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.5574421124770392, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.7497497197674742, + "unit": "", + "description": "" + }, + "k": { + "value": 159.43937543801715, + "unit": "", + "description": "" + }, + "c": { + "value": 0.3876603659732667, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 33.96737042900305, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.6884753784100948, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4553477036074001, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.2679661476689589, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/028/params.json b/scipy/falling_spring/028/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ac8118e802196629e678a72728ce53afddb354e2 --- /dev/null +++ b/scipy/falling_spring/028/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.6266793025325027, + "m2": 0.5574421124770392, + "L0": 0.7497497197674742, + "k": 159.43937543801715, + "c": 0.3876603659732667, + "theta0_deg": 33.96737042900305, + "yCOM0": 1.6884753784100948, + "e_rest": 0.4553477036074001, + "mu_fric": 0.2679661476689589, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/028/simulation_code.py b/scipy/falling_spring/028/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..bd5f7c32f6e674e1ffc5facdb21d553008dac030 --- /dev/null +++ b/scipy/falling_spring/028/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.6266793025325027 +m2 = 0.5574421124770392 +L0 = 0.7497497197674742 +k = 159.43937543801715 +c = 0.3876603659732667 +theta0 = np.deg2rad(33.96737042900305) +yCOM0 = 1.6884753784100948 +e_rest = 0.4553477036074001 +mu_fric = 0.2679661476689589 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/028/video.mp4 b/scipy/falling_spring/028/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..616679d016123ea70bb2a14a3836d3bdc1d3e791 --- /dev/null +++ b/scipy/falling_spring/028/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe3bc72aea2d8be560b69b2631a63b88315fc0be99ca20a788c624c1a203c306 +size 11822 diff --git a/scipy/falling_spring/071/cot.json b/scipy/falling_spring/071/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1b077fc702a87e6a0f5b0840fec47cbe8b76c17e --- /dev/null +++ b/scipy/falling_spring/071/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.493 kg, m2=0.782 kg) connected by a Hookean spring (rest length L0=1.077 m, k=190.69 N/m, axial damping c=0.651 N \\cdot s/m) start at COM height 1.619 m, tilted 42.18 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.431 and friction mu=0.281.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.3024; omega_s = \\sqrt(k/m_eff) = 25.111 rad/s; T_s = 0.250 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.302409, + "omega_spring_rad_s": 25.1109, + "T_spring_seconds": 0.2502, + "free_fall_time_to_first_contact_s": 0.4863 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.486 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.4932120508670728, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7817067545803167, + "unit": "", + "description": "" + }, + "L0": { + "value": 1.0767897056366622, + "unit": "", + "description": "" + }, + "k": { + "value": 190.6859707261287, + "unit": "", + "description": "" + }, + "c": { + "value": 0.6505543272264676, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 42.181699058473825, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.6190216007960918, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.43096984989698595, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.28095804789968726, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/071/params.json b/scipy/falling_spring/071/params.json new file mode 100644 index 0000000000000000000000000000000000000000..488f7dc96e450f5422f0f1c2d175b66bfed5d1f1 --- /dev/null +++ b/scipy/falling_spring/071/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.4932120508670728, + "m2": 0.7817067545803167, + "L0": 1.0767897056366622, + "k": 190.6859707261287, + "c": 0.6505543272264676, + "theta0_deg": 42.181699058473825, + "yCOM0": 1.6190216007960918, + "e_rest": 0.43096984989698595, + "mu_fric": 0.28095804789968726, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/071/simulation_code.py b/scipy/falling_spring/071/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..607cab9e9cf247b3a1e7ab9b18e72cc597a307be --- /dev/null +++ b/scipy/falling_spring/071/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.4932120508670728 +m2 = 0.7817067545803167 +L0 = 1.0767897056366622 +k = 190.6859707261287 +c = 0.6505543272264676 +theta0 = np.deg2rad(42.181699058473825) +yCOM0 = 1.6190216007960918 +e_rest = 0.43096984989698595 +mu_fric = 0.28095804789968726 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/071/video.mp4 b/scipy/falling_spring/071/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..1f3ed1d6eac402c193a2798c5f86ed75344259ca --- /dev/null +++ b/scipy/falling_spring/071/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fbe302bd2a3bb680fdf46466a93d59262602371268459c38509867e7b635032f +size 14921 diff --git a/scipy/falling_spring/118/cot.json b/scipy/falling_spring/118/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f5c0dcd52fb13f3ed7d4dc37be028a8ec6061186 --- /dev/null +++ b/scipy/falling_spring/118/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.758 kg, m2=0.356 kg) connected by a Hookean spring (rest length L0=0.953 m, k=192.15 N/m, axial damping c=0.601 N \\cdot s/m) start at COM height 1.457 m, tilted 26.98 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.359 and friction mu=0.331.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2423; omega_s = \\sqrt(k/m_eff) = 28.160 rad/s; T_s = 0.223 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.242304, + "omega_spring_rad_s": 28.1604, + "T_spring_seconds": 0.2231, + "free_fall_time_to_first_contact_s": 0.4452 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.445 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.7577879283261605, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.3561999585250265, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.9534268444228106, + "unit": "", + "description": "" + }, + "k": { + "value": 192.1494266845001, + "unit": "", + "description": "" + }, + "c": { + "value": 0.6012063621459884, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 26.984878521431625, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.457015220570598, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.3587182398676476, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.33071978144168224, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/118/params.json b/scipy/falling_spring/118/params.json new file mode 100644 index 0000000000000000000000000000000000000000..069dc90e43c68d88d390acc6757c3c891cd8741b --- /dev/null +++ b/scipy/falling_spring/118/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.7577879283261605, + "m2": 0.3561999585250265, + "L0": 0.9534268444228106, + "k": 192.1494266845001, + "c": 0.6012063621459884, + "theta0_deg": 26.984878521431625, + "yCOM0": 1.457015220570598, + "e_rest": 0.3587182398676476, + "mu_fric": 0.33071978144168224, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/118/simulation_code.py b/scipy/falling_spring/118/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..06db02fcc1cefe2843eb13b4c116503506bb9e8b --- /dev/null +++ b/scipy/falling_spring/118/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.7577879283261605 +m2 = 0.3561999585250265 +L0 = 0.9534268444228106 +k = 192.1494266845001 +c = 0.6012063621459884 +theta0 = np.deg2rad(26.984878521431625) +yCOM0 = 1.457015220570598 +e_rest = 0.3587182398676476 +mu_fric = 0.33071978144168224 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/118/video.mp4 b/scipy/falling_spring/118/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..69bdc797c157d4d3e0ab2a4b271b4abc22d487d9 --- /dev/null +++ b/scipy/falling_spring/118/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95e8c55821b7cea4a502f8a83d3eddb11aaf7a7c9ed9401edb86c901c7a96213 +size 11402 diff --git a/scipy/falling_spring/285/cot.json b/scipy/falling_spring/285/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..fea158934f4f91c4d90a24f28bddbc5d81db5d99 --- /dev/null +++ b/scipy/falling_spring/285/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.536 kg, m2=0.351 kg) connected by a Hookean spring (rest length L0=0.772 m, k=183.39 N/m, axial damping c=0.699 N \\cdot s/m) start at COM height 1.855 m, tilted 29.69 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.418 and friction mu=0.364.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2123; omega_s = \\sqrt(k/m_eff) = 29.393 rad/s; T_s = 0.214 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.212261, + "omega_spring_rad_s": 29.3934, + "T_spring_seconds": 0.2138, + "free_fall_time_to_first_contact_s": 0.5454 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.545 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.5361344009161295, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.3513726058634599, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.7722093671936696, + "unit": "", + "description": "" + }, + "k": { + "value": 183.38699508169685, + "unit": "", + "description": "" + }, + "c": { + "value": 0.6990995314952522, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 29.692152499681008, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.8545931223840624, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.41804617040119835, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.3638777749661185, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/285/params.json b/scipy/falling_spring/285/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c14bdad7a5b9617c1e5a1393c619fc18cbd7b39d --- /dev/null +++ b/scipy/falling_spring/285/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.5361344009161295, + "m2": 0.3513726058634599, + "L0": 0.7722093671936696, + "k": 183.38699508169685, + "c": 0.6990995314952522, + "theta0_deg": 29.692152499681008, + "yCOM0": 1.8545931223840624, + "e_rest": 0.41804617040119835, + "mu_fric": 0.3638777749661185, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/285/simulation_code.py b/scipy/falling_spring/285/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..bc4c123195063563a98c6f4f0d79574ff15a6959 --- /dev/null +++ b/scipy/falling_spring/285/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.5361344009161295 +m2 = 0.3513726058634599 +L0 = 0.7722093671936696 +k = 183.38699508169685 +c = 0.6990995314952522 +theta0 = np.deg2rad(29.692152499681008) +yCOM0 = 1.8545931223840624 +e_rest = 0.41804617040119835 +mu_fric = 0.3638777749661185 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/285/video.mp4 b/scipy/falling_spring/285/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..42f0783f1fcd95a3a1ecd5cf891dac9349348b8f --- /dev/null +++ b/scipy/falling_spring/285/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d175582ee100f9318ac831a34670c7a5150737dbefce6d7e6f9f83b582003a9c +size 10666 diff --git a/scipy/falling_spring/336/cot.json b/scipy/falling_spring/336/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1a5933c417aa40d04174ca13960b5196b794e4a4 --- /dev/null +++ b/scipy/falling_spring/336/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.320 kg, m2=0.497 kg) connected by a Hookean spring (rest length L0=0.880 m, k=209.18 N/m, axial damping c=0.422 N \\cdot s/m) start at COM height 1.734 m, tilted 33.51 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.437 and friction mu=0.354.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.1945; omega_s = \\sqrt(k/m_eff) = 32.793 rad/s; T_s = 0.192 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.194513, + "omega_spring_rad_s": 32.793, + "T_spring_seconds": 0.1916, + "free_fall_time_to_first_contact_s": 0.5162 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.516 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.31954975710194605, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.4971063846189372, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.8804520969551985, + "unit": "", + "description": "" + }, + "k": { + "value": 209.17565531415738, + "unit": "", + "description": "" + }, + "c": { + "value": 0.42234973931585024, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 33.51331724304055, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.733830180075651, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4372834091108104, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.3537783752465682, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/336/params.json b/scipy/falling_spring/336/params.json new file mode 100644 index 0000000000000000000000000000000000000000..efc701b911df868f60d706590ac232db39f56032 --- /dev/null +++ b/scipy/falling_spring/336/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.31954975710194605, + "m2": 0.4971063846189372, + "L0": 0.8804520969551985, + "k": 209.17565531415738, + "c": 0.42234973931585024, + "theta0_deg": 33.51331724304055, + "yCOM0": 1.733830180075651, + "e_rest": 0.4372834091108104, + "mu_fric": 0.3537783752465682, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/336/simulation_code.py b/scipy/falling_spring/336/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..51cf774778975830a386ae15356d8d567f18560e --- /dev/null +++ b/scipy/falling_spring/336/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.31954975710194605 +m2 = 0.4971063846189372 +L0 = 0.8804520969551985 +k = 209.17565531415738 +c = 0.42234973931585024 +theta0 = np.deg2rad(33.51331724304055) +yCOM0 = 1.733830180075651 +e_rest = 0.4372834091108104 +mu_fric = 0.3537783752465682 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/336/video.mp4 b/scipy/falling_spring/336/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d1b864b8c5bb7c3c6b5ef1754ed8d4905f2f9ad8 --- /dev/null +++ b/scipy/falling_spring/336/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15a8bf2abe063010e131c7ab2014e3419fad28b9467bbc04bd307177e5cd1226 +size 12967 diff --git a/scipy/falling_spring/339/cot.json b/scipy/falling_spring/339/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..323077cbd0dc34b44273ddb0902a6b1bd72cc91d --- /dev/null +++ b/scipy/falling_spring/339/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.644 kg, m2=0.586 kg) connected by a Hookean spring (rest length L0=0.889 m, k=166.37 N/m, axial damping c=0.354 N \\cdot s/m) start at COM height 1.494 m, tilted 39.89 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.490 and friction mu=0.278.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.3068; omega_s = \\sqrt(k/m_eff) = 23.286 rad/s; T_s = 0.270 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.306818, + "omega_spring_rad_s": 23.2863, + "T_spring_seconds": 0.2698, + "free_fall_time_to_first_contact_s": 0.4722 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.472 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.6444955870489352, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.5855960994116471, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.8887513576822159, + "unit": "", + "description": "" + }, + "k": { + "value": 166.3725070786581, + "unit": "", + "description": "" + }, + "c": { + "value": 0.3541893530177953, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 39.89023010124889, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.4944450277412469, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.49007041149221603, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.2779536277591386, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/339/params.json b/scipy/falling_spring/339/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a7372dedf67e31c272aff6b1b9c44de6c318e1d6 --- /dev/null +++ b/scipy/falling_spring/339/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.6444955870489352, + "m2": 0.5855960994116471, + "L0": 0.8887513576822159, + "k": 166.3725070786581, + "c": 0.3541893530177953, + "theta0_deg": 39.89023010124889, + "yCOM0": 1.4944450277412469, + "e_rest": 0.49007041149221603, + "mu_fric": 0.2779536277591386, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/339/simulation_code.py b/scipy/falling_spring/339/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..a43ca0177b03daecc4a8d290d771cf8e06568f9a --- /dev/null +++ b/scipy/falling_spring/339/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.6444955870489352 +m2 = 0.5855960994116471 +L0 = 0.8887513576822159 +k = 166.3725070786581 +c = 0.3541893530177953 +theta0 = np.deg2rad(39.89023010124889) +yCOM0 = 1.4944450277412469 +e_rest = 0.49007041149221603 +mu_fric = 0.2779536277591386 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/339/video.mp4 b/scipy/falling_spring/339/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..8fcb105ae6c00979da176867793a828a487ddc6d --- /dev/null +++ b/scipy/falling_spring/339/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11599f76010103f8a8bc7c0c637fb4e8197be3a551827a98b755ca675b31d2e0 +size 13947 diff --git a/scipy/falling_spring/359/cot.json b/scipy/falling_spring/359/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..bc5c3dda5b15dea03ff8dda1f881e9eaf7d06272 --- /dev/null +++ b/scipy/falling_spring/359/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.733 kg, m2=0.488 kg) connected by a Hookean spring (rest length L0=0.830 m, k=146.59 N/m, axial damping c=0.552 N \\cdot s/m) start at COM height 1.594 m, tilted 39.97 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.502 and friction mu=0.281.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2930; omega_s = \\sqrt(k/m_eff) = 22.367 rad/s; T_s = 0.281 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.293028, + "omega_spring_rad_s": 22.3668, + "T_spring_seconds": 0.2809, + "free_fall_time_to_first_contact_s": 0.498 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.498 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.7328704589143162, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.4882457508433596, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.830391992235536, + "unit": "", + "description": "" + }, + "k": { + "value": 146.59425261239113, + "unit": "", + "description": "" + }, + "c": { + "value": 0.5523440036383449, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 39.97377756821904, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.5944425271543115, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5022936231957027, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.2813944276599427, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/359/params.json b/scipy/falling_spring/359/params.json new file mode 100644 index 0000000000000000000000000000000000000000..aca3170633a91734f76e25984132388d77282ef1 --- /dev/null +++ b/scipy/falling_spring/359/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.7328704589143162, + "m2": 0.4882457508433596, + "L0": 0.830391992235536, + "k": 146.59425261239113, + "c": 0.5523440036383449, + "theta0_deg": 39.97377756821904, + "yCOM0": 1.5944425271543115, + "e_rest": 0.5022936231957027, + "mu_fric": 0.2813944276599427, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/359/simulation_code.py b/scipy/falling_spring/359/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5c65da645ae32f6d2d96aac11395919768540c88 --- /dev/null +++ b/scipy/falling_spring/359/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.7328704589143162 +m2 = 0.4882457508433596 +L0 = 0.830391992235536 +k = 146.59425261239113 +c = 0.5523440036383449 +theta0 = np.deg2rad(39.97377756821904) +yCOM0 = 1.5944425271543115 +e_rest = 0.5022936231957027 +mu_fric = 0.2813944276599427 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/359/video.mp4 b/scipy/falling_spring/359/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..63716c56a8462799bb955a515416a0d730127dd6 --- /dev/null +++ b/scipy/falling_spring/359/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3805af17c16399cf936c15be04a0289b866aeb756693f2553f01c29e4e1a5533 +size 13173 diff --git a/scipy/falling_spring/409/cot.json b/scipy/falling_spring/409/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..9f4f3a20ae493da2ff3338377aece515b1b589a5 --- /dev/null +++ b/scipy/falling_spring/409/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.547 kg, m2=0.425 kg) connected by a Hookean spring (rest length L0=1.083 m, k=150.89 N/m, axial damping c=0.639 N \\cdot s/m) start at COM height 1.743 m, tilted 46.08 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.358 and friction mu=0.239.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2394; omega_s = \\sqrt(k/m_eff) = 25.105 rad/s; T_s = 0.250 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.239411, + "omega_spring_rad_s": 25.1048, + "T_spring_seconds": 0.2503, + "free_fall_time_to_first_contact_s": 0.5163 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.516 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.5474669945101556, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.42547447574243835, + "unit": "", + "description": "" + }, + "L0": { + "value": 1.0832242157379555, + "unit": "", + "description": "" + }, + "k": { + "value": 150.88967381183622, + "unit": "", + "description": "" + }, + "c": { + "value": 0.6389930141254407, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 46.082535588500015, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.7430634581246638, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.35834725106863735, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.2394570064744299, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/409/params.json b/scipy/falling_spring/409/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5b7484f0e6a6c50dea373d78a51db4a3e1217416 --- /dev/null +++ b/scipy/falling_spring/409/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.5474669945101556, + "m2": 0.42547447574243835, + "L0": 1.0832242157379555, + "k": 150.88967381183622, + "c": 0.6389930141254407, + "theta0_deg": 46.082535588500015, + "yCOM0": 1.7430634581246638, + "e_rest": 0.35834725106863735, + "mu_fric": 0.2394570064744299, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/409/simulation_code.py b/scipy/falling_spring/409/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..450ee8546fc747a0af38ebc25cc86a3037456dc1 --- /dev/null +++ b/scipy/falling_spring/409/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.5474669945101556 +m2 = 0.42547447574243835 +L0 = 1.0832242157379555 +k = 150.88967381183622 +c = 0.6389930141254407 +theta0 = np.deg2rad(46.082535588500015) +yCOM0 = 1.7430634581246638 +e_rest = 0.35834725106863735 +mu_fric = 0.2394570064744299 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/409/video.mp4 b/scipy/falling_spring/409/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..0b0fe791bb0c17dc56fede2c364d48457f2c72c3 --- /dev/null +++ b/scipy/falling_spring/409/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ababf7ed9dbd1e60565c76f7e40466f453c9bdf9a1f7bcc2d65670c2bf6652ed +size 11654 diff --git a/scipy/falling_spring/521/cot.json b/scipy/falling_spring/521/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..2665f259283397ef50994ceee3764bcbda4d549d --- /dev/null +++ b/scipy/falling_spring/521/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.330 kg, m2=0.315 kg) connected by a Hookean spring (rest length L0=0.722 m, k=157.73 N/m, axial damping c=0.617 N \\cdot s/m) start at COM height 1.588 m, tilted 26.26 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.507 and friction mu=0.298.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.1613; omega_s = \\sqrt(k/m_eff) = 31.273 rad/s; T_s = 0.201 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.161275, + "omega_spring_rad_s": 31.2733, + "T_spring_seconds": 0.2009, + "free_fall_time_to_first_contact_s": 0.4954 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.495 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.3300446773514565, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.31538663053244215, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.7222049363626608, + "unit": "", + "description": "" + }, + "k": { + "value": 157.72936175278488, + "unit": "", + "description": "" + }, + "c": { + "value": 0.6169629261225689, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 26.257935243930646, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.587563030751057, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5072380296690863, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.29792969863463076, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/521/params.json b/scipy/falling_spring/521/params.json new file mode 100644 index 0000000000000000000000000000000000000000..f0815ae7e55c5da43c327b1c8a657227d268008c --- /dev/null +++ b/scipy/falling_spring/521/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.3300446773514565, + "m2": 0.31538663053244215, + "L0": 0.7222049363626608, + "k": 157.72936175278488, + "c": 0.6169629261225689, + "theta0_deg": 26.257935243930646, + "yCOM0": 1.587563030751057, + "e_rest": 0.5072380296690863, + "mu_fric": 0.29792969863463076, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/521/simulation_code.py b/scipy/falling_spring/521/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..e9cf031412e9293612e371a46bf929a49dfd7f39 --- /dev/null +++ b/scipy/falling_spring/521/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.3300446773514565 +m2 = 0.31538663053244215 +L0 = 0.7222049363626608 +k = 157.72936175278488 +c = 0.6169629261225689 +theta0 = np.deg2rad(26.257935243930646) +yCOM0 = 1.587563030751057 +e_rest = 0.5072380296690863 +mu_fric = 0.29792969863463076 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/521/video.mp4 b/scipy/falling_spring/521/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..eb23f4dbb4c3490bc1856d1150b3410747e38c42 --- /dev/null +++ b/scipy/falling_spring/521/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4979caadcae8fc51ae6769fff9ce11aae6f8f008dcb710426b5ee35f67427dd8 +size 11527 diff --git a/scipy/falling_spring/549/cot.json b/scipy/falling_spring/549/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e631c3262a5a35681968f9bd187565ae8c5bf686 --- /dev/null +++ b/scipy/falling_spring/549/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.452 kg, m2=0.776 kg) connected by a Hookean spring (rest length L0=0.970 m, k=200.69 N/m, axial damping c=0.474 N \\cdot s/m) start at COM height 1.402 m, tilted 39.90 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.366 and friction mu=0.378.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2858; omega_s = \\sqrt(k/m_eff) = 26.500 rad/s; T_s = 0.237 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.285787, + "omega_spring_rad_s": 26.5, + "T_spring_seconds": 0.2371, + "free_fall_time_to_first_contact_s": 0.4447 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.445 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.4522930795792801, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7763024878587395, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.9697729170693326, + "unit": "", + "description": "" + }, + "k": { + "value": 200.69313560633583, + "unit": "", + "description": "" + }, + "c": { + "value": 0.47448107960381547, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 39.89710723642865, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.4022143826869617, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.36557175355829397, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.37788913813633, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/549/params.json b/scipy/falling_spring/549/params.json new file mode 100644 index 0000000000000000000000000000000000000000..52cf8122e334f5f91bd2363f6b517c5784d5cfb8 --- /dev/null +++ b/scipy/falling_spring/549/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.4522930795792801, + "m2": 0.7763024878587395, + "L0": 0.9697729170693326, + "k": 200.69313560633583, + "c": 0.47448107960381547, + "theta0_deg": 39.89710723642865, + "yCOM0": 1.4022143826869617, + "e_rest": 0.36557175355829397, + "mu_fric": 0.37788913813633, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/549/simulation_code.py b/scipy/falling_spring/549/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9b7bb43a924077163208789bafc3bc316f4a31b1 --- /dev/null +++ b/scipy/falling_spring/549/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.4522930795792801 +m2 = 0.7763024878587395 +L0 = 0.9697729170693326 +k = 200.69313560633583 +c = 0.47448107960381547 +theta0 = np.deg2rad(39.89710723642865) +yCOM0 = 1.4022143826869617 +e_rest = 0.36557175355829397 +mu_fric = 0.37788913813633 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/549/video.mp4 b/scipy/falling_spring/549/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c279a073fe62d8eb9ba1859b3fcef64121b5920b --- /dev/null +++ b/scipy/falling_spring/549/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f1a20f0bd5386a06b75aa5b0fd86a5836d4ba82635a18c6d977dfd3a5cf47c6 +size 13394 diff --git a/scipy/falling_spring/656/cot.json b/scipy/falling_spring/656/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a62e8b1645ed7a74f1da1ea7e463560d0662a401 --- /dev/null +++ b/scipy/falling_spring/656/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.559 kg, m2=0.384 kg) connected by a Hookean spring (rest length L0=0.841 m, k=162.94 N/m, axial damping c=0.317 N \\cdot s/m) start at COM height 1.562 m, tilted 39.81 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.379 and friction mu=0.297.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2278; omega_s = \\sqrt(k/m_eff) = 26.747 rad/s; T_s = 0.235 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.227766, + "omega_spring_rad_s": 26.7469, + "T_spring_seconds": 0.2349, + "free_fall_time_to_first_contact_s": 0.4902 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.490 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.5594063425902525, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.3841935273039827, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.841464793752143, + "unit": "", + "description": "" + }, + "k": { + "value": 162.94363030689524, + "unit": "", + "description": "" + }, + "c": { + "value": 0.3168837045559544, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 39.8096914397531, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.5618974484472212, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.37908754181619037, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.2969095939932974, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/656/params.json b/scipy/falling_spring/656/params.json new file mode 100644 index 0000000000000000000000000000000000000000..046af91d783c3995f131115a62e10ca10d1874c5 --- /dev/null +++ b/scipy/falling_spring/656/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.5594063425902525, + "m2": 0.3841935273039827, + "L0": 0.841464793752143, + "k": 162.94363030689524, + "c": 0.3168837045559544, + "theta0_deg": 39.8096914397531, + "yCOM0": 1.5618974484472212, + "e_rest": 0.37908754181619037, + "mu_fric": 0.2969095939932974, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/656/simulation_code.py b/scipy/falling_spring/656/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b9d1a9b60d471dc92454d53d9af167d755da194d --- /dev/null +++ b/scipy/falling_spring/656/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.5594063425902525 +m2 = 0.3841935273039827 +L0 = 0.841464793752143 +k = 162.94363030689524 +c = 0.3168837045559544 +theta0 = np.deg2rad(39.8096914397531) +yCOM0 = 1.5618974484472212 +e_rest = 0.37908754181619037 +mu_fric = 0.2969095939932974 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/656/video.mp4 b/scipy/falling_spring/656/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c24650bdd39a67eebeccd5740ad0414854bc56e2 --- /dev/null +++ b/scipy/falling_spring/656/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d1ffd40141c0b2501476395db049f71d74605e659cf043c2c50083ac83a17fb +size 12479 diff --git a/scipy/falling_spring/695/cot.json b/scipy/falling_spring/695/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8acfdc8d476877535d32c2f5a747c2f6741b49a1 --- /dev/null +++ b/scipy/falling_spring/695/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.472 kg, m2=0.425 kg) connected by a Hookean spring (rest length L0=0.914 m, k=178.99 N/m, axial damping c=0.536 N \\cdot s/m) start at COM height 1.475 m, tilted 30.28 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.459 and friction mu=0.267.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2237; omega_s = \\sqrt(k/m_eff) = 28.286 rad/s; T_s = 0.222 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.223719, + "omega_spring_rad_s": 28.2856, + "T_spring_seconds": 0.2221, + "free_fall_time_to_first_contact_s": 0.4561 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.456 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.47189795184600924, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.42538899512647266, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.9138535888459299, + "unit": "", + "description": "" + }, + "k": { + "value": 178.99236088864558, + "unit": "", + "description": "" + }, + "c": { + "value": 0.5355988642344023, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 30.284341283254797, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.4751237343658299, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.45922036642601194, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.26687343093756594, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/695/params.json b/scipy/falling_spring/695/params.json new file mode 100644 index 0000000000000000000000000000000000000000..df70fd8b3ea4d27f382197f6544b4a73894ea566 --- /dev/null +++ b/scipy/falling_spring/695/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.47189795184600924, + "m2": 0.42538899512647266, + "L0": 0.9138535888459299, + "k": 178.99236088864558, + "c": 0.5355988642344023, + "theta0_deg": 30.284341283254797, + "yCOM0": 1.4751237343658299, + "e_rest": 0.45922036642601194, + "mu_fric": 0.26687343093756594, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/695/simulation_code.py b/scipy/falling_spring/695/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4cdc46e675818758d4b2bf2b1161c67b3637a6e6 --- /dev/null +++ b/scipy/falling_spring/695/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.47189795184600924 +m2 = 0.42538899512647266 +L0 = 0.9138535888459299 +k = 178.99236088864558 +c = 0.5355988642344023 +theta0 = np.deg2rad(30.284341283254797) +yCOM0 = 1.4751237343658299 +e_rest = 0.45922036642601194 +mu_fric = 0.26687343093756594 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/695/video.mp4 b/scipy/falling_spring/695/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7602c4797df172473a032735de261ffffb1fb138 --- /dev/null +++ b/scipy/falling_spring/695/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88c70efc4c20c5519fe1c4d027efa211a09611e326a6c2443d81fb9042111213 +size 12537 diff --git a/scipy/falling_spring/791/cot.json b/scipy/falling_spring/791/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..31508b859dce3ebd568a342b485a413dcab3570e --- /dev/null +++ b/scipy/falling_spring/791/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.628 kg, m2=0.319 kg) connected by a Hookean spring (rest length L0=0.920 m, k=177.17 N/m, axial damping c=0.645 N \\cdot s/m) start at COM height 1.622 m, tilted 39.14 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.443 and friction mu=0.280.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.2117; omega_s = \\sqrt(k/m_eff) = 28.926 rad/s; T_s = 0.217 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.211749, + "omega_spring_rad_s": 28.926, + "T_spring_seconds": 0.2172, + "free_fall_time_to_first_contact_s": 0.4956 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.496 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.6282960207367565, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.3193898325288376, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.9202652138441781, + "unit": "", + "description": "" + }, + "k": { + "value": 177.17352981570076, + "unit": "", + "description": "" + }, + "c": { + "value": 0.6445361853314301, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 39.139449391209546, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.6218793760840318, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4425223924278109, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.27954843950387687, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/791/params.json b/scipy/falling_spring/791/params.json new file mode 100644 index 0000000000000000000000000000000000000000..bdb81cf44f6c33a0821d7847748577a24d6110c1 --- /dev/null +++ b/scipy/falling_spring/791/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.6282960207367565, + "m2": 0.3193898325288376, + "L0": 0.9202652138441781, + "k": 177.17352981570076, + "c": 0.6445361853314301, + "theta0_deg": 39.139449391209546, + "yCOM0": 1.6218793760840318, + "e_rest": 0.4425223924278109, + "mu_fric": 0.27954843950387687, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/791/simulation_code.py b/scipy/falling_spring/791/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..8e551c288634420c0b321322d8b43c511ef9a401 --- /dev/null +++ b/scipy/falling_spring/791/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.6282960207367565 +m2 = 0.3193898325288376 +L0 = 0.9202652138441781 +k = 177.17352981570076 +c = 0.6445361853314301 +theta0 = np.deg2rad(39.139449391209546) +yCOM0 = 1.6218793760840318 +e_rest = 0.4425223924278109 +mu_fric = 0.27954843950387687 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/791/video.mp4 b/scipy/falling_spring/791/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..93d706587f38fa9b37562b9557d9651afdcc2c91 --- /dev/null +++ b/scipy/falling_spring/791/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e962f8b6e8e5629199c6bf3d86b1d0e07fac72555f8b753de5bbf10f8589b50 +size 11232 diff --git a/scipy/falling_spring/863/cot.json b/scipy/falling_spring/863/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..15e9ae82d3284f0ba00234c46f60ff2db050a024 --- /dev/null +++ b/scipy/falling_spring/863/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.730 kg, m2=0.758 kg) connected by a Hookean spring (rest length L0=0.728 m, k=151.53 N/m, axial damping c=0.690 N \\cdot s/m) start at COM height 1.852 m, tilted 37.55 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.439 and friction mu=0.234.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.3718; omega_s = \\sqrt(k/m_eff) = 20.188 rad/s; T_s = 0.311 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.371785, + "omega_spring_rad_s": 20.1881, + "T_spring_seconds": 0.3112, + "free_fall_time_to_first_contact_s": 0.5536 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.554 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.7298776677689713, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.7577874757389613, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.7282217973880999, + "unit": "", + "description": "" + }, + "k": { + "value": 151.52526533456737, + "unit": "", + "description": "" + }, + "c": { + "value": 0.690131580278855, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 37.55422474756145, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.8520058616281558, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4389632094106699, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.2341722884756208, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/863/params.json b/scipy/falling_spring/863/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7c67c042e1cf05b4f7d9cd4f69f4c2d361cc700e --- /dev/null +++ b/scipy/falling_spring/863/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.7298776677689713, + "m2": 0.7577874757389613, + "L0": 0.7282217973880999, + "k": 151.52526533456737, + "c": 0.690131580278855, + "theta0_deg": 37.55422474756145, + "yCOM0": 1.8520058616281558, + "e_rest": 0.4389632094106699, + "mu_fric": 0.2341722884756208, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/863/simulation_code.py b/scipy/falling_spring/863/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6a27d1b1997f2408045a3e2940645718a0eb1424 --- /dev/null +++ b/scipy/falling_spring/863/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.7298776677689713 +m2 = 0.7577874757389613 +L0 = 0.7282217973880999 +k = 151.52526533456737 +c = 0.690131580278855 +theta0 = np.deg2rad(37.55422474756145) +yCOM0 = 1.8520058616281558 +e_rest = 0.4389632094106699 +mu_fric = 0.2341722884756208 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/863/video.mp4 b/scipy/falling_spring/863/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..31cebaf5d8b7cb994bb67996ac5eff9dc641c2d1 --- /dev/null +++ b/scipy/falling_spring/863/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5530588723242bb79c00bd73207f4f350da36aad23d65df736160b78de07f2f +size 11887 diff --git a/scipy/falling_spring/885/cot.json b/scipy/falling_spring/885/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..2d383cedfe7484f724cb63713cfcd29a8981b257 --- /dev/null +++ b/scipy/falling_spring/885/cot.json @@ -0,0 +1,110 @@ +{ + "simulation": "falling_spring", + "physical_observation": "Two cubes (m1=0.627 kg, m2=0.593 kg) connected by a Hookean spring (rest length L0=0.945 m, k=191.15 N/m, axial damping c=0.407 N \\cdot s/m) start at COM height 1.757 m, tilted 40.57 deg from vertical. They fall under g=9.81, bouncing off the floor with restitution e=0.424 and friction mu=0.367.", + "physical_law": { + "name": "Newton II per cube + Hooke's law for the spring + impulsive (penalty) floor contact with Coulomb friction", + "statement": "Each cube obeys m a = F_spring + F_axial_damping + F_gravity + F_floor; floor contact is modelled as a stiff penalty spring-damper tuned to recover the requested coefficient of restitution.", + "formula": "F_spring,1 = +k(L-L0) u_hat ; F_spring,2 = -F_spring,1 ; gravity (0, -m_i g)" + }, + "ode_system": { + "state_variables": [ + "x1,y1,x2,y2 (positions, m)", + "vx1,vy1,vx2,vy2 (velocities, m/s)" + ], + "equations_latex": [ + "\\dot{x}_i = v_i; \\dot{v}_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) tuned via zeta -> e_rest, plus tangential mu_fric \\cdot Fn \\cdot \\tanh(vx/V_eps)" + ], + "equations_python": [ + "x_dot_i = v_i; v_dot_i = (F_spring + F_axial_damp + F_floor)/m_i + (0,-g)", + "F_spring axial along bond direction; F_axial_damp opposes axial relative velocity", + "F_floor: penalty spring-damper k_floor (pen) + c_floor (-vy) * tuned via zeta -> e_rest, plus tangential mu_fric * Fn * np.tanh (vx/V_eps)" + ] + }, + "derivation_steps": [ + "Bond vector d = r2 - r1, length L=|d|, unit u_hat = d/L.", + "Hooke axial force on cube 1: F_s,1 = +k(L-L0) u_hat; Newton III gives F_s,2 = -F_s,1.", + "Axial damping along bond: F_d = -c (v_rel . u_hat) u_hat per cube (opposite signs).", + "Reduced mass for relative oscillation: m_eff = m1 m2/(m1+m2) = 0.3047; omega_s = \\sqrt(k/m_eff) = 25.046 rad/s; T_s = 0.251 s.", + "Floor penalty contact via stiff spring-damper tuned so the 1-D damped collision recovers Newton restitution: zeta from -\\ln(e)=pi \\cdot zeta/\\sqrt(1-zeta^2).", + "Tangential friction via \\tanh(vx/V_eps) regularises Coulomb friction near vx=0." + ], + "physical_constants_derived": { + "m_eff_kg": 0.304714, + "omega_spring_rad_s": 25.0462, + "T_spring_seconds": 0.2509, + "free_fall_time_to_first_contact_s": 0.5224 + }, + "numerical_method": { + "solver": "LSODA (stiff/non-stiff auto-switch, suitable for stiff penalty contact)", + "tolerance": "rtol=1e-7, atol=1e-9, max_step=1e-3" + }, + "code_validation": { + "ode_source": "Newton II per body + Hooke spring + viscous penalty contact with Coulomb tangential friction.", + "energy_check": "Mechanical energy decreases monotonically due to axial damping c and floor losses.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall ~0.522 s before first contact.", + "Spring oscillates (period ~T_s) throughout; cubes bounce and the spring axis rotates.", + "Energy bleeds away over ~5-10 contacts; the assembly settles." + ], + "parameters": { + "m1": { + "value": 0.6267951320175331, + "unit": "", + "description": "" + }, + "m2": { + "value": 0.5929976488498306, + "unit": "", + "description": "" + }, + "L0": { + "value": 0.9451269675978103, + "unit": "", + "description": "" + }, + "k": { + "value": 191.15065026504223, + "unit": "", + "description": "" + }, + "c": { + "value": 0.4073336071602172, + "unit": "", + "description": "" + }, + "theta0_deg": { + "value": 40.56913519653592, + "unit": "", + "description": "" + }, + "yCOM0": { + "value": 1.7573174009065147, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.42396931579906905, + "unit": "", + "description": "" + }, + "mu_fric": { + "value": 0.36686186229649537, + "unit": "", + "description": "" + }, + "cube_size": { + "value": 0.12, + "unit": "", + "description": "" + }, + "g": { + "value": 9.81, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/falling_spring/885/params.json b/scipy/falling_spring/885/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e03bbf5f0d1f0824ee82c31cd70544db0376f760 --- /dev/null +++ b/scipy/falling_spring/885/params.json @@ -0,0 +1,13 @@ +{ + "m1": 0.6267951320175331, + "m2": 0.5929976488498306, + "L0": 0.9451269675978103, + "k": 191.15065026504223, + "c": 0.4073336071602172, + "theta0_deg": 40.56913519653592, + "yCOM0": 1.7573174009065147, + "e_rest": 0.42396931579906905, + "mu_fric": 0.36686186229649537, + "cube_size": 0.12, + "g": 9.81 +} \ No newline at end of file diff --git a/scipy/falling_spring/885/simulation_code.py b/scipy/falling_spring/885/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..643f4c6cfc1c5314222b0955daeb080a4088c303 --- /dev/null +++ b/scipy/falling_spring/885/simulation_code.py @@ -0,0 +1,135 @@ +"""Falling spring (cube-spring-cube) standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +m1 = 0.6267951320175331 +m2 = 0.5929976488498306 +L0 = 0.9451269675978103 +k = 191.15065026504223 +c = 0.4073336071602172 +theta0 = np.deg2rad(40.56913519653592) +yCOM0 = 1.7573174009065147 +e_rest = 0.42396931579906905 +mu_fric = 0.36686186229649537 +cube_size = 0.12 +g = 9.81 +duration = 12 +fps = 30 + +half = L0/2.0 +x1_0 = -half*np.sin(theta0); y1_0 = yCOM0 - half*np.cos(theta0) +x2_0 = +half*np.sin(theta0); y2_0 = yCOM0 + half*np.cos(theta0) +state0 = np.array([x1_0, y1_0, x2_0, y2_0, 0.0, 0.0, 0.0, 0.0]) + +zeta_eq = -np.log(max(e_rest, 1e-3)) +zeta = zeta_eq / np.sqrt(np.pi**2 + zeta_eq**2) +k_floor = 5.0e4 +m_min = min(m1, m2) +c_floor = 2.0*zeta*np.sqrt(k_floor*m_min) +V_EPS = 0.05 + +def ode(t, s): + x1_,y1_,x2_,y2_,vx1,vy1,vx2,vy2 = s + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-12: ux,uy = 0.0,0.0 + else: ux,uy = dx/L, dy/L + Fs_mag = k*(L-L0) + Fs1x,Fs1y = Fs_mag*ux, Fs_mag*uy + Fs2x,Fs2y = -Fs1x,-Fs1y + vrel = (vx2-vx1)*ux + (vy2-vy1)*uy + Fd1x,Fd1y = c*vrel*ux, c*vrel*uy + Fd2x,Fd2y = -Fd1x,-Fd1y + floor_y = cube_size/2.0 + Fc1x=Fc1y=Fc2x=Fc2y=0.0 + pen1 = floor_y - y1_ + if pen1>0: + Fn1 = k_floor*pen1 + c_floor*(-vy1) + if Fn1>0: + Fc1y = Fn1; Fc1x = -mu_fric*Fn1*np.tanh(vx1/V_EPS) + pen2 = floor_y - y2_ + if pen2>0: + Fn2 = k_floor*pen2 + c_floor*(-vy2) + if Fn2>0: + Fc2y = Fn2; Fc2x = -mu_fric*Fn2*np.tanh(vx2/V_EPS) + ax1 = (Fs1x+Fd1x+Fc1x)/m1 + ay1 = (Fs1y+Fd1y+Fc1y)/m1 - g + ax2 = (Fs2x+Fd2x+Fc2x)/m2 + ay2 = (Fs2y+Fd2y+Fc2y)/m2 - g + return [vx1,vy1,vx2,vy2,ax1,ay1,ax2,ay2] + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +sol = solve_ivp(ode, (0.0, duration), state0, t_eval=t_eval, + method="LSODA", rtol=1e-7, atol=1e-9, max_step=1e-3) +x1=sol.y[0]; y1=sol.y[1]; x2=sol.y[2]; y2=sol.y[3] + +fig_w, fig_h = 6, 6 +fig_aspect = fig_w/fig_h +margin_x=0.30; margin_y=0.20 +x_lo_d = min(x1.min(),x2.min()) - cube_size/2 - margin_x +x_hi_d = max(x1.max(),x2.max()) + cube_size/2 + margin_x +y_lo_d = -0.30 +y_hi_d = max(y1.max(),y2.max()) + cube_size/2 + margin_y +dx_d, dy_d = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_d/dy_d < fig_aspect: + extra = (fig_aspect*dy_d - dx_d)/2.0 + x_lo, x_hi = x_lo_d-extra, x_hi_d+extra + y_lo, y_hi = y_lo_d, y_hi_d +else: + extra = (dx_d/fig_aspect - dy_d)/2.0 + x_lo, x_hi = x_lo_d, x_hi_d + y_lo, y_hi = y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(patches.Rectangle((x_lo,y_lo), x_hi-x_lo, -y_lo, + facecolor="#4a4e69", edgecolor="none", zorder=0)) +ax.plot([x_lo,x_hi],[0,0], color="#adb5bd", lw=2.0, zorder=1) +cube1 = patches.Rectangle((x1[0]-cube_size/2, y1[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +cube2 = patches.Rectangle((x2[0]-cube_size/2, y2[0]-cube_size/2), + cube_size, cube_size, facecolor="#e63946", + edgecolor="#adb5bd", lw=1.0, zorder=4) +ax.add_patch(cube1); ax.add_patch(cube2) +N_COILS=10; COIL_W=0.06; N_PTS=4*N_COILS+2 + +def coil_xy(p1,p2): + x1_,y1_ = p1; x2_,y2_ = p2 + dx,dy = x2_-x1_, y2_-y1_ + L = np.hypot(dx,dy) + if L<1e-9: return np.array([x1_,x2_]), np.array([y1_,y2_]) + ux,uy = dx/L, dy/L + nx,ny = -uy, ux + lead = cube_size/2.0 + s = np.linspace(0.0,1.0,N_PTS) + seg_len = max(L - 2*lead, 1e-6) + arc = np.where(s1.0-lead/L, s*L, + lead + ((s*L-lead)/seg_len)*seg_len)) + middle = (arc>=lead) & (arc<=L-lead) + phase = np.zeros_like(arc) + phase[middle] = (arc[middle]-lead)/seg_len + amp = np.where(middle, COIL_W*np.sin(2*np.pi*N_COILS*phase), 0.0) + return x1_+ux*arc+nx*amp, y1_+uy*arc+ny*amp + +xs0,ys0 = coil_xy((x1[0],y1[0]),(x2[0],y2[0])) +spring_line, = ax.plot(xs0,ys0, color="#a8dadc", lw=2.5, zorder=3) + +def update(f): + cube1.set_xy((x1[f]-cube_size/2, y1[f]-cube_size/2)) + cube2.set_xy((x2[f]-cube_size/2, y2[f]-cube_size/2)) + xs,ys = coil_xy((x1[f],y1[f]),(x2[f],y2[f])) + spring_line.set_data(xs,ys) + return cube1, cube2, spring_line + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/falling_spring/885/video.mp4 b/scipy/falling_spring/885/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..dabb205fc5f1b98dc54dba71fbbdec43c45696f3 --- /dev/null +++ b/scipy/falling_spring/885/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02bc676612de6a16faa75f48baefbfd613ce59824d61b699aab504f170bc56d9 +size 12001 diff --git a/scipy/gear_rack_spring_oscillator/039/cot.json b/scipy/gear_rack_spring_oscillator/039/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..45149e0de6a3db63b85af38bdf720570f0d18ff9 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/039/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.576 kg, R_g=0.246 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.251 kg) attached to walls by springs (k_L=31.11 N/m, k_R=19.95 N/m). The rack is given an initial velocity v_0=1.837 m/s. Light damping gamma=0.353 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.5387 kg, k_eff=51.0584 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.5387 * kg, k_eff=51.0584 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 5.7604 rad/s; T_n = 1.0908 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0199." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.017422, + "m_eff_kg": 1.538745, + "k_eff_N_per_m": 51.0584, + "omega_n_rad_s": 5.7604, + "T_n_seconds": 1.0908, + "damping_ratio_zeta": 0.0199 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 1.091 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.5756862600413732, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.24602116194736484, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.2509018738811133, + "unit": "", + "description": "" + }, + "k_L": { + "value": 31.10923349822552, + "unit": "", + "description": "" + }, + "k_R": { + "value": 19.94915170344931, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.35262837846623796, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.8367569821030596, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/039/params.json b/scipy/gear_rack_spring_oscillator/039/params.json new file mode 100644 index 0000000000000000000000000000000000000000..639ca6f94b58ac3db9f29784f6bbb470a37d694e --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/039/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.5756862600413732, + "R_g": 0.24602116194736484, + "m_r": 1.2509018738811133, + "k_L": 31.10923349822552, + "k_R": 19.94915170344931, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.35262837846623796, + "v_0": 1.8367569821030596, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/039/simulation_code.py b/scipy/gear_rack_spring_oscillator/039/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f1d555cd9471c2f2bde37d4c5b60a14dbaa8f03e --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/039/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.5756862600413732 +R_g = 0.24602116194736484 +m_r = 1.2509018738811133 +k_L = 31.10923349822552 +k_R = 19.94915170344931 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.35262837846623796 +v_0 = 1.8367569821030596 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/039/video.mp4 b/scipy/gear_rack_spring_oscillator/039/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..063fd57acc122687f22f618d1c71a952b9566690 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/039/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:47415ddc2b5d70e365e9331272a13545615ae896f6f3402ddfaf62566f26f9ba +size 60006 diff --git a/scipy/gear_rack_spring_oscillator/111/cot.json b/scipy/gear_rack_spring_oscillator/111/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e78e845477753ce76e2b67e722e41109944065f3 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/111/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.592 kg, R_g=0.182 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.293 kg) attached to walls by springs (k_L=33.30 N/m, k_R=33.39 N/m). The rack is given an initial velocity v_0=1.139 m/s. Light damping gamma=0.302 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.5891 kg, k_eff=66.6897 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.5891 * kg, k_eff=66.6897 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 6.4783 rad/s; T_n = 0.9699 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0147." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.009769, + "m_eff_kg": 1.58907, + "k_eff_N_per_m": 66.6897, + "omega_n_rad_s": 6.4783, + "T_n_seconds": 0.9699, + "damping_ratio_zeta": 0.0147 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 0.970 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.5918195871350549, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.18169836659391514, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.2931600590841388, + "unit": "", + "description": "" + }, + "k_L": { + "value": 33.30093720204778, + "unit": "", + "description": "" + }, + "k_R": { + "value": 33.388729527091, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.30199700960951903, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.1392004011991488, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/111/params.json b/scipy/gear_rack_spring_oscillator/111/params.json new file mode 100644 index 0000000000000000000000000000000000000000..11a672fcf4267db25fa1bdb445d061ddac3d52c2 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/111/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.5918195871350549, + "R_g": 0.18169836659391514, + "m_r": 1.2931600590841388, + "k_L": 33.30093720204778, + "k_R": 33.388729527091, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.30199700960951903, + "v_0": 1.1392004011991488, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/111/simulation_code.py b/scipy/gear_rack_spring_oscillator/111/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..df034ba22ccb56e448ea3ecd40294e7dfddcb956 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/111/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.5918195871350549 +R_g = 0.18169836659391514 +m_r = 1.2931600590841388 +k_L = 33.30093720204778 +k_R = 33.388729527091 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.30199700960951903 +v_0 = 1.1392004011991488 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/111/video.mp4 b/scipy/gear_rack_spring_oscillator/111/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..554c4f94b5f4f03ff4e1565347feab9cf72b2acc --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/111/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f71be655ead52019a25b8192633e6a7cc0deada7d5d61639cfb65c73bae87e54 +size 51707 diff --git a/scipy/gear_rack_spring_oscillator/118/cot.json b/scipy/gear_rack_spring_oscillator/118/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..84645291315ffe233a6ec20aa1162bf076bf66c4 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/118/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.791 kg, R_g=0.157 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=0.898 kg) attached to walls by springs (k_L=32.31 N/m, k_R=26.48 N/m). The rack is given an initial velocity v_0=1.608 m/s. Light damping gamma=0.273 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.2937 kg, k_eff=58.7980 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.2937 * kg, k_eff=58.7980 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 6.7416 rad/s; T_n = 0.9320 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0156." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.009779, + "m_eff_kg": 1.29372, + "k_eff_N_per_m": 58.798, + "omega_n_rad_s": 6.7416, + "T_n_seconds": 0.932, + "damping_ratio_zeta": 0.0156 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 0.932 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.791469310501379, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.15719712390382123, + "unit": "", + "description": "" + }, + "m_r": { + "value": 0.8979858292324112, + "unit": "", + "description": "" + }, + "k_L": { + "value": 32.31368745047877, + "unit": "", + "description": "" + }, + "k_R": { + "value": 26.484312538128485, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.2729577822649752, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.6082562082126193, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/118/params.json b/scipy/gear_rack_spring_oscillator/118/params.json new file mode 100644 index 0000000000000000000000000000000000000000..bff119455899fe3f0c3ece6b8cd39abcdfdaf43d --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/118/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.791469310501379, + "R_g": 0.15719712390382123, + "m_r": 0.8979858292324112, + "k_L": 32.31368745047877, + "k_R": 26.484312538128485, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.2729577822649752, + "v_0": 1.6082562082126193, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/118/simulation_code.py b/scipy/gear_rack_spring_oscillator/118/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..48e6ea57d0342e08cf6ad6ec5b97481f4e95b98e --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/118/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.791469310501379 +R_g = 0.15719712390382123 +m_r = 0.8979858292324112 +k_L = 32.31368745047877 +k_R = 26.484312538128485 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.2729577822649752 +v_0 = 1.6082562082126193 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/118/video.mp4 b/scipy/gear_rack_spring_oscillator/118/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e9c7da9997e1c636b739bba9976fbbac13d58625 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/118/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3862602e628bb4d37a600d12d24a39aa9f13005bb0e74ef68e1a713fe8b26a6f +size 47873 diff --git a/scipy/gear_rack_spring_oscillator/182/cot.json b/scipy/gear_rack_spring_oscillator/182/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c738aba35902a018c361fee31d536f5b5ebf01e8 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/182/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.499 kg, R_g=0.240 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.290 kg) attached to walls by springs (k_L=27.17 N/m, k_R=30.55 N/m). The rack is given an initial velocity v_0=1.858 m/s. Light damping gamma=0.491 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.5395 kg, k_eff=57.7197 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.5395 * kg, k_eff=57.7197 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 6.1232 rad/s; T_n = 1.0261 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0260." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.014355, + "m_eff_kg": 1.53947, + "k_eff_N_per_m": 57.7197, + "omega_n_rad_s": 6.1232, + "T_n_seconds": 1.0261, + "damping_ratio_zeta": 0.026 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 1.026 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.4985142839903703, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.23997992246852554, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.2902133277450032, + "unit": "", + "description": "" + }, + "k_L": { + "value": 27.167704874217883, + "unit": "", + "description": "" + }, + "k_R": { + "value": 30.551983072465788, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.49087695939339177, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.85804348547132, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/182/params.json b/scipy/gear_rack_spring_oscillator/182/params.json new file mode 100644 index 0000000000000000000000000000000000000000..467a28b553958a2b797d21921366dbfb5f89b2a8 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/182/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.4985142839903703, + "R_g": 0.23997992246852554, + "m_r": 1.2902133277450032, + "k_L": 27.167704874217883, + "k_R": 30.551983072465788, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.49087695939339177, + "v_0": 1.85804348547132, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/182/simulation_code.py b/scipy/gear_rack_spring_oscillator/182/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3d4cb6f45ab8c86881e4e1a66aadc7544e142c1e --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/182/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.4985142839903703 +R_g = 0.23997992246852554 +m_r = 1.2902133277450032 +k_L = 27.167704874217883 +k_R = 30.551983072465788 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.49087695939339177 +v_0 = 1.85804348547132 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/182/video.mp4 b/scipy/gear_rack_spring_oscillator/182/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e9f4a08f9aa174cacf8422d279ab100d1e2ab294 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/182/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e56a99c432ff9a9ff52a454da33f78ba2e9155eb264e7b0a1c1effbb6b4d57a +size 57544 diff --git a/scipy/gear_rack_spring_oscillator/267/cot.json b/scipy/gear_rack_spring_oscillator/267/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..79755614d12f03fe772450b9be0b1d666bbc3a82 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/267/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.746 kg, R_g=0.171 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.467 kg) attached to walls by springs (k_L=23.33 N/m, k_R=19.19 N/m). The rack is given an initial velocity v_0=1.181 m/s. Light damping gamma=0.237 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.8399 kg, k_eff=42.5273 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.8399 * kg, k_eff=42.5273 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 4.8076 rad/s; T_n = 1.3069 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0134." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.010861, + "m_eff_kg": 1.839942, + "k_eff_N_per_m": 42.5273, + "omega_n_rad_s": 4.8076, + "T_n_seconds": 1.3069, + "damping_ratio_zeta": 0.0134 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 1.307 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.7461925659840004, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.17061539209465715, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.4668457331217442, + "unit": "", + "description": "" + }, + "k_L": { + "value": 23.332796357303323, + "unit": "", + "description": "" + }, + "k_R": { + "value": 19.19445849060366, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.23696458851777444, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.1805754381411793, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/267/params.json b/scipy/gear_rack_spring_oscillator/267/params.json new file mode 100644 index 0000000000000000000000000000000000000000..b07637c95f9a441af16b8ff37ff6de86e914f8d4 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/267/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.7461925659840004, + "R_g": 0.17061539209465715, + "m_r": 1.4668457331217442, + "k_L": 23.332796357303323, + "k_R": 19.19445849060366, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.23696458851777444, + "v_0": 1.1805754381411793, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/267/simulation_code.py b/scipy/gear_rack_spring_oscillator/267/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..18dd2030bae52362091205160841d0d454321e82 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/267/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.7461925659840004 +R_g = 0.17061539209465715 +m_r = 1.4668457331217442 +k_L = 23.332796357303323 +k_R = 19.19445849060366 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.23696458851777444 +v_0 = 1.1805754381411793 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/267/video.mp4 b/scipy/gear_rack_spring_oscillator/267/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..12a14d9ae768eb220faa858993858b9ee65e8647 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/267/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b51291c0f3343851ff7711b7e45733cc13c752bd78052a0727552d7201ed8772 +size 52050 diff --git a/scipy/gear_rack_spring_oscillator/271/cot.json b/scipy/gear_rack_spring_oscillator/271/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1c5237fd9d136dac7c535a1e6cf8b5d4516744c4 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/271/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.463 kg, R_g=0.199 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=0.772 kg) attached to walls by springs (k_L=32.32 N/m, k_R=31.56 N/m). The rack is given an initial velocity v_0=1.721 m/s. Light damping gamma=0.457 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.0036 kg, k_eff=63.8831 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.0036 * kg, k_eff=63.8831 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 7.9784 rad/s; T_n = 0.7875 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0286." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.009165, + "m_eff_kg": 1.003582, + "k_eff_N_per_m": 63.8831, + "omega_n_rad_s": 7.9784, + "T_n_seconds": 0.7875, + "damping_ratio_zeta": 0.0286 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 0.788 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.4631263773440265, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.19894258479376176, + "unit": "", + "description": "" + }, + "m_r": { + "value": 0.7720183470528601, + "unit": "", + "description": "" + }, + "k_L": { + "value": 32.32371053320943, + "unit": "", + "description": "" + }, + "k_R": { + "value": 31.55943117986222, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.45731922959204097, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.7214470705863398, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/271/params.json b/scipy/gear_rack_spring_oscillator/271/params.json new file mode 100644 index 0000000000000000000000000000000000000000..0f46feb9d50f7ad023dbd68adb8ee1ddce5b3e8f --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/271/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.4631263773440265, + "R_g": 0.19894258479376176, + "m_r": 0.7720183470528601, + "k_L": 32.32371053320943, + "k_R": 31.55943117986222, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.45731922959204097, + "v_0": 1.7214470705863398, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/271/simulation_code.py b/scipy/gear_rack_spring_oscillator/271/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4b303f48222102024411cfb2ea8ef849a574e01d --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/271/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.4631263773440265 +R_g = 0.19894258479376176 +m_r = 0.7720183470528601 +k_L = 32.32371053320943 +k_R = 31.55943117986222 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.45731922959204097 +v_0 = 1.7214470705863398 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/271/video.mp4 b/scipy/gear_rack_spring_oscillator/271/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e682a515779ab8f261b121a5cc3fed7bb2fa15c7 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/271/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c819fc533ff4262c11efe53575924e0a19be5a00c91ad0ad7fdfef8136f89dd +size 48296 diff --git a/scipy/gear_rack_spring_oscillator/321/cot.json b/scipy/gear_rack_spring_oscillator/321/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1641d92f655afa3bb6b36e58d742dd15b305af4f --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/321/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.748 kg, R_g=0.199 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.394 kg) attached to walls by springs (k_L=31.61 N/m, k_R=24.77 N/m). The rack is given an initial velocity v_0=1.846 m/s. Light damping gamma=0.447 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.7680 kg, k_eff=56.3739 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.7680 * kg, k_eff=56.3739 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 5.6467 rad/s; T_n = 1.1127 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0224." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.014837, + "m_eff_kg": 1.768006, + "k_eff_N_per_m": 56.3739, + "omega_n_rad_s": 5.6467, + "T_n_seconds": 1.1127, + "damping_ratio_zeta": 0.0224 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 1.113 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.7481274852528403, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.19916031222290115, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.3939422303682685, + "unit": "", + "description": "" + }, + "k_L": { + "value": 31.60604913220888, + "unit": "", + "description": "" + }, + "k_R": { + "value": 24.76786931697717, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.4472664234939653, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.845739700137322, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/321/params.json b/scipy/gear_rack_spring_oscillator/321/params.json new file mode 100644 index 0000000000000000000000000000000000000000..9f2ca9888c7066ef38634ae49c910fc12aeba913 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/321/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.7481274852528403, + "R_g": 0.19916031222290115, + "m_r": 1.3939422303682685, + "k_L": 31.60604913220888, + "k_R": 24.76786931697717, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.4472664234939653, + "v_0": 1.845739700137322, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/321/simulation_code.py b/scipy/gear_rack_spring_oscillator/321/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9a1588c6e3ac8e081922870b955b9aefe2135206 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/321/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.7481274852528403 +R_g = 0.19916031222290115 +m_r = 1.3939422303682685 +k_L = 31.60604913220888 +k_R = 24.76786931697717 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.4472664234939653 +v_0 = 1.845739700137322 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/321/video.mp4 b/scipy/gear_rack_spring_oscillator/321/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9559074fc9f0121eec5f425a8153825213778a36 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/321/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b7939e9f62eff1e1aaa2d43643d7babaf8b83960cf4109cca7adf6d23bef4bd5 +size 58156 diff --git a/scipy/gear_rack_spring_oscillator/353/cot.json b/scipy/gear_rack_spring_oscillator/353/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..93aebe555a2eb43b46bdd9852c604002bd2ba150 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/353/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.361 kg, R_g=0.193 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=0.747 kg) attached to walls by springs (k_L=33.66 N/m, k_R=18.32 N/m). The rack is given an initial velocity v_0=1.118 m/s. Light damping gamma=0.337 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=0.9271 kg, k_eff=51.9719 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=0.9271 * kg, k_eff=51.9719 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 7.4873 rad/s; T_n = 0.8392 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0243." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.006731, + "m_eff_kg": 0.927092, + "k_eff_N_per_m": 51.9719, + "omega_n_rad_s": 7.4873, + "T_n_seconds": 0.8392, + "damping_ratio_zeta": 0.0243 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 0.839 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.36100666657129526, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.19311320988132308, + "unit": "", + "description": "" + }, + "m_r": { + "value": 0.7465890215000955, + "unit": "", + "description": "" + }, + "k_L": { + "value": 33.65604660134541, + "unit": "", + "description": "" + }, + "k_R": { + "value": 18.31587344922136, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.33718295266727527, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.1179696808448596, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/353/params.json b/scipy/gear_rack_spring_oscillator/353/params.json new file mode 100644 index 0000000000000000000000000000000000000000..81781066bb115f903c179c7aa0a73930e7007039 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/353/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.36100666657129526, + "R_g": 0.19311320988132308, + "m_r": 0.7465890215000955, + "k_L": 33.65604660134541, + "k_R": 18.31587344922136, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.33718295266727527, + "v_0": 1.1179696808448596, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/353/simulation_code.py b/scipy/gear_rack_spring_oscillator/353/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6d60374a9c7d0a5e19b72beabb4e53a11d8714d7 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/353/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.36100666657129526 +R_g = 0.19311320988132308 +m_r = 0.7465890215000955 +k_L = 33.65604660134541 +k_R = 18.31587344922136 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.33718295266727527 +v_0 = 1.1179696808448596 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/353/video.mp4 b/scipy/gear_rack_spring_oscillator/353/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..577b63f6b8994b0a14f51752ddc75dec2b454604 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/353/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c713567de8ac555ab9dc292d41722d33135634e558e38586365e7e9605d445b +size 45419 diff --git a/scipy/gear_rack_spring_oscillator/394/cot.json b/scipy/gear_rack_spring_oscillator/394/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..caab4aab7310fd939d7aa2a20ac07396c26e2cb7 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/394/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.544 kg, R_g=0.208 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=0.818 kg) attached to walls by springs (k_L=25.88 N/m, k_R=21.52 N/m). The rack is given an initial velocity v_0=1.132 m/s. Light damping gamma=0.400 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.0906 kg, k_eff=47.4021 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.0906 * kg, k_eff=47.4021 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 6.5926 rad/s; T_n = 0.9531 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0278." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.011736, + "m_eff_kg": 1.090638, + "k_eff_N_per_m": 47.4021, + "omega_n_rad_s": 6.5926, + "T_n_seconds": 0.9531, + "damping_ratio_zeta": 0.0278 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 0.953 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.5443848276404413, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.2076419772481483, + "unit": "", + "description": "" + }, + "m_r": { + "value": 0.8184460693805177, + "unit": "", + "description": "" + }, + "k_L": { + "value": 25.8824510870444, + "unit": "", + "description": "" + }, + "k_R": { + "value": 21.519600776025754, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.39971829997903685, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.1316956122946815, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/394/params.json b/scipy/gear_rack_spring_oscillator/394/params.json new file mode 100644 index 0000000000000000000000000000000000000000..2387ad3c1456c3180df3fe2631444873d99f263a --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/394/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.5443848276404413, + "R_g": 0.2076419772481483, + "m_r": 0.8184460693805177, + "k_L": 25.8824510870444, + "k_R": 21.519600776025754, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.39971829997903685, + "v_0": 1.1316956122946815, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/394/simulation_code.py b/scipy/gear_rack_spring_oscillator/394/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..20427dfad8fe24905ffcbc20f77f070befac9931 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/394/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.5443848276404413 +R_g = 0.2076419772481483 +m_r = 0.8184460693805177 +k_L = 25.8824510870444 +k_R = 21.519600776025754 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.39971829997903685 +v_0 = 1.1316956122946815 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/394/video.mp4 b/scipy/gear_rack_spring_oscillator/394/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a814897f08675eb3da52438b8d13fe5f4ae0d879 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/394/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ce7822893806c83ce99f2ede848e262f453eb187baf2b8ba14cf35c14470e7b +size 47398 diff --git a/scipy/gear_rack_spring_oscillator/444/cot.json b/scipy/gear_rack_spring_oscillator/444/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..14336044cf4ad6873134ed73176a47a46001b1fd --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/444/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.351 kg, R_g=0.236 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.338 kg) attached to walls by springs (k_L=21.09 N/m, k_R=18.30 N/m). The rack is given an initial velocity v_0=1.719 m/s. Light damping gamma=0.464 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.5135 kg, k_eff=39.3884 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.5135 * kg, k_eff=39.3884 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 5.1014 rad/s; T_n = 1.2317 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0300." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.009741, + "m_eff_kg": 1.513527, + "k_eff_N_per_m": 39.3884, + "omega_n_rad_s": 5.1014, + "T_n_seconds": 1.2317, + "damping_ratio_zeta": 0.03 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 1.232 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.35124901446568485, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.2355112422592624, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.337902925830541, + "unit": "", + "description": "" + }, + "k_L": { + "value": 21.09085420441802, + "unit": "", + "description": "" + }, + "k_R": { + "value": 18.29755791102811, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.4637230427063138, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.7192481968424365, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/444/params.json b/scipy/gear_rack_spring_oscillator/444/params.json new file mode 100644 index 0000000000000000000000000000000000000000..cd7a49c988edeaf229c7f9c0278fc5226ed69d7c --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/444/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.35124901446568485, + "R_g": 0.2355112422592624, + "m_r": 1.337902925830541, + "k_L": 21.09085420441802, + "k_R": 18.29755791102811, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.4637230427063138, + "v_0": 1.7192481968424365, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/444/simulation_code.py b/scipy/gear_rack_spring_oscillator/444/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..e3d7e6913b9b6334618b84a5dacd07ad058a2861 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/444/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.35124901446568485 +R_g = 0.2355112422592624 +m_r = 1.337902925830541 +k_L = 21.09085420441802 +k_R = 18.29755791102811 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.4637230427063138 +v_0 = 1.7192481968424365 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/444/video.mp4 b/scipy/gear_rack_spring_oscillator/444/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7b452d6c7189f99209e72403c7173d731a5ffe9b --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/444/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a795e730ef43b25c0a883722a6643d2da9df40f572125e6735031af1a0de2e4b +size 55409 diff --git a/scipy/gear_rack_spring_oscillator/446/cot.json b/scipy/gear_rack_spring_oscillator/446/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..518dddfa26556ebc0c6272350fd457459ecdac1b --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/446/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.799 kg, R_g=0.226 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.114 kg) attached to walls by springs (k_L=30.83 N/m, k_R=21.40 N/m). The rack is given an initial velocity v_0=1.925 m/s. Light damping gamma=0.227 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.5133 kg, k_eff=52.2346 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.5133 * kg, k_eff=52.2346 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 5.8752 rad/s; T_n = 1.0694 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0128." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.020376, + "m_eff_kg": 1.513262, + "k_eff_N_per_m": 52.2346, + "omega_n_rad_s": 5.8752, + "T_n_seconds": 1.0694, + "damping_ratio_zeta": 0.0128 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 1.069 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.7992747353616184, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.22580211295306835, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.1136250532921095, + "unit": "", + "description": "" + }, + "k_L": { + "value": 30.830438265878698, + "unit": "", + "description": "" + }, + "k_R": { + "value": 21.404126509689412, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.22691966288992033, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.9249340631636251, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/446/params.json b/scipy/gear_rack_spring_oscillator/446/params.json new file mode 100644 index 0000000000000000000000000000000000000000..69e32d9facec947afe590aeda17f2f13d736ed63 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/446/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.7992747353616184, + "R_g": 0.22580211295306835, + "m_r": 1.1136250532921095, + "k_L": 30.830438265878698, + "k_R": 21.404126509689412, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.22691966288992033, + "v_0": 1.9249340631636251, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/446/simulation_code.py b/scipy/gear_rack_spring_oscillator/446/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f1e5ad6babd09fe802fab6ecd9fa441d1bf61b68 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/446/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.7992747353616184 +R_g = 0.22580211295306835 +m_r = 1.1136250532921095 +k_L = 30.830438265878698 +k_R = 21.404126509689412 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.22691966288992033 +v_0 = 1.9249340631636251 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/446/video.mp4 b/scipy/gear_rack_spring_oscillator/446/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..11c463075f771c91f5784c093ee12e0902caa93b --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/446/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67f7e02c68d5e5f38f9eb0bfa8644a93239b686e5075dc5e3a5897a1d1a404b0 +size 59029 diff --git a/scipy/gear_rack_spring_oscillator/523/cot.json b/scipy/gear_rack_spring_oscillator/523/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..bec89573f57c71bd66111f39e32f6fcb2c90f44c --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/523/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.361 kg, R_g=0.157 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=0.942 kg) attached to walls by springs (k_L=23.66 N/m, k_R=29.47 N/m). The rack is given an initial velocity v_0=1.843 m/s. Light damping gamma=0.441 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.1229 kg, k_eff=53.1350 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.1229 * kg, k_eff=53.1350 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 6.8788 rad/s; T_n = 0.9134 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0285." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.00445, + "m_eff_kg": 1.122925, + "k_eff_N_per_m": 53.135, + "omega_n_rad_s": 6.8788, + "T_n_seconds": 0.9134, + "damping_ratio_zeta": 0.0285 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 0.913 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.36148716029065914, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.15690230579527087, + "unit": "", + "description": "" + }, + "m_r": { + "value": 0.9421814415024896, + "unit": "", + "description": "" + }, + "k_L": { + "value": 23.664077491276956, + "unit": "", + "description": "" + }, + "k_R": { + "value": 29.470948105852443, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.44105968977134014, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.8425151732375542, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/523/params.json b/scipy/gear_rack_spring_oscillator/523/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ab694abbf14e9fe55ba08dee03c10ae671ccb743 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/523/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.36148716029065914, + "R_g": 0.15690230579527087, + "m_r": 0.9421814415024896, + "k_L": 23.664077491276956, + "k_R": 29.470948105852443, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.44105968977134014, + "v_0": 1.8425151732375542, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/523/simulation_code.py b/scipy/gear_rack_spring_oscillator/523/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..40be8cd862152e52c30a0902c515c6640adcd178 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/523/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.36148716029065914 +R_g = 0.15690230579527087 +m_r = 0.9421814415024896 +k_L = 23.664077491276956 +k_R = 29.470948105852443 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.44105968977134014 +v_0 = 1.8425151732375542 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/523/video.mp4 b/scipy/gear_rack_spring_oscillator/523/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..94f1f331d0883f4daf005c744e51ab24edf21110 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/523/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:30e3a7fc352cdb8d308e79173a7309040eaf427d526acc77cf8d98ec568409dd +size 45298 diff --git a/scipy/gear_rack_spring_oscillator/594/cot.json b/scipy/gear_rack_spring_oscillator/594/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..46797c057881889a77f330a92821e52afe59f24a --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/594/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.427 kg, R_g=0.173 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.050 kg) attached to walls by springs (k_L=32.12 N/m, k_R=24.79 N/m). The rack is given an initial velocity v_0=1.261 m/s. Light damping gamma=0.240 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.2637 kg, k_eff=56.9036 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.2637 * kg, k_eff=56.9036 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 6.7103 rad/s; T_n = 0.9364 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0141." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.00638, + "m_eff_kg": 1.263742, + "k_eff_N_per_m": 56.9036, + "omega_n_rad_s": 6.7103, + "T_n_seconds": 0.9364, + "damping_ratio_zeta": 0.0141 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 0.936 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.42740811548659574, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.1727865849935431, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.0500377534311194, + "unit": "", + "description": "" + }, + "k_L": { + "value": 32.11851911187905, + "unit": "", + "description": "" + }, + "k_R": { + "value": 24.78509079356645, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.2398324289766774, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.260630204777519, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/594/params.json b/scipy/gear_rack_spring_oscillator/594/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c78bd7b8869e90c4ebed1d497f87ac5a1625699c --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/594/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.42740811548659574, + "R_g": 0.1727865849935431, + "m_r": 1.0500377534311194, + "k_L": 32.11851911187905, + "k_R": 24.78509079356645, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.2398324289766774, + "v_0": 1.260630204777519, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/594/simulation_code.py b/scipy/gear_rack_spring_oscillator/594/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..1f669082ec04485f2b9f75acf93f2c5a196f51fe --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/594/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.42740811548659574 +R_g = 0.1727865849935431 +m_r = 1.0500377534311194 +k_L = 32.11851911187905 +k_R = 24.78509079356645 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.2398324289766774 +v_0 = 1.260630204777519 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/594/video.mp4 b/scipy/gear_rack_spring_oscillator/594/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3462d7477bab42455f4e9ddcee8d6ae6395c5659 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/594/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b2203689a7bd8f8a748e456267f958ca7c7dce8a4978f0eb9b7ac3ed5c308e1 +size 50618 diff --git a/scipy/gear_rack_spring_oscillator/610/cot.json b/scipy/gear_rack_spring_oscillator/610/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..40ad6be34a41600b465a8993c88fe7fc596e78e3 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/610/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.466 kg, R_g=0.171 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=0.925 kg) attached to walls by springs (k_L=18.14 N/m, k_R=23.28 N/m). The rack is given an initial velocity v_0=1.739 m/s. Light damping gamma=0.344 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.1583 kg, k_eff=41.4212 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.1583 * kg, k_eff=41.4212 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 5.9801 rad/s; T_n = 1.0507 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0248." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.00678, + "m_eff_kg": 1.158272, + "k_eff_N_per_m": 41.4212, + "omega_n_rad_s": 5.9801, + "T_n_seconds": 1.0507, + "damping_ratio_zeta": 0.0248 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 1.051 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.46561131795650523, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.1706511414528067, + "unit": "", + "description": "" + }, + "m_r": { + "value": 0.9254667971501802, + "unit": "", + "description": "" + }, + "k_L": { + "value": 18.141833557398844, + "unit": "", + "description": "" + }, + "k_R": { + "value": 23.279329038396938, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.34354252829790555, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.7393142717335217, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/610/params.json b/scipy/gear_rack_spring_oscillator/610/params.json new file mode 100644 index 0000000000000000000000000000000000000000..d432ad56fdaa42de6a76d0612d21a7366ad0b1fa --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/610/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.46561131795650523, + "R_g": 0.1706511414528067, + "m_r": 0.9254667971501802, + "k_L": 18.141833557398844, + "k_R": 23.279329038396938, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.34354252829790555, + "v_0": 1.7393142717335217, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/610/simulation_code.py b/scipy/gear_rack_spring_oscillator/610/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..44e86dc284c8b0372c6ca45024603b237c182f98 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/610/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.46561131795650523 +R_g = 0.1706511414528067 +m_r = 0.9254667971501802 +k_L = 18.141833557398844 +k_R = 23.279329038396938 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.34354252829790555 +v_0 = 1.7393142717335217 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/610/video.mp4 b/scipy/gear_rack_spring_oscillator/610/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..dcbd191bdde894329f3eb866aa1235a479717352 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/610/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef56f50d0ea390f8f60fbb88c9dc498cf7f16b9a95170f36e79e0025d477ffe1 +size 51983 diff --git a/scipy/gear_rack_spring_oscillator/620/cot.json b/scipy/gear_rack_spring_oscillator/620/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8f98f2c5133fb104a4b406cdcfc3ac06bda81c1c --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/620/cot.json @@ -0,0 +1,142 @@ +{ + "simulation": "gear_rack_spring_oscillator", + "physical_observation": "A gear (m_g=0.591 kg, R_g=0.208 m) on a fixed axle meshes (no slip) with a horizontal rack (m_r=1.287 kg) attached to walls by springs (k_L=19.23 N/m, k_R=29.75 N/m). The rack is given an initial velocity v_0=1.481 m/s. Light damping gamma=0.265 acts on the rack.", + "physical_law": { + "name": "Newton II for translation + Newton II for rotation with no-slip constraint (reflected inertia)", + "statement": "No-slip at the gear-rack interface gives v_rack = +omega_gear \\cdot R_g, allowing reduction to a single damped SHO in the rack coordinate with effective mass m_eff = m_r + I_g/R_g^2.", + "formula": "m_eff x'' = -k_eff x - gamma x' with k_eff = k_L + k_R" + }, + "ode_system": { + "state_variables": [ + "x_rack (m)", + "v_rack (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -(k_eff/m_eff) x - (gamma/m_eff) v [m_eff=1.5829 kg, k_eff=48.9758 N/m]", + "Closed-form damped SHM: x(t) = \\exp(-zeta \\cdot omega_n \\cdot t) (A \\cos omega_d t + B \\sin omega_d t)" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -(k_eff/m_eff) * x - (gamma/m_eff) * v [m_eff=1.5829 * kg, k_eff=48.9758 * N/m]", + "Closed-form * damped * SHM: x(t) = np.exp (-zeta * omega_n * t) (A * np.cos * omega_d * t + B * np.sin * omega_d * t)" + ] + }, + "derivation_steps": [ + "Gear inertia: I_g = (1/2) m_g R_g^2 (uniform disc).", + "No-slip constraint at the rack-gear contact: v_rack = +omega_gear R_g, so omega_gear = v_rack/R_g.", + "Kinetic energy: T = (1/2) m_r v^2 + (1/2) I_g (v/R_g)^2 = (1/2) m_eff v^2 with m_eff = m_r + I_g/R_g^2.", + "Both springs unstretched at x=0 -> potential energy V = (1/2)(k_L+k_R) x^2.", + "Lagrangian/Newton II yields m_eff x'' + gamma x' + (k_L+k_R) x = 0.", + "Natural frequency omega_n = \\sqrt(k_eff/m_eff) = 5.5624 rad/s; T_n = 1.1296 s.", + "Damping ratio zeta = gamma/(2 \\sqrt(k_eff m_eff)) = 0.0150." + ], + "physical_constants_derived": { + "I_g_kg_m2": 0.012836, + "m_eff_kg": 1.582914, + "k_eff_N_per_m": 48.9758, + "omega_n_rad_s": 5.5624, + "T_n_seconds": 1.1296, + "damping_ratio_zeta": 0.015 + }, + "numerical_method": { + "solver": "Closed-form damped SHM (no numerical integration required).", + "tolerance": "exact" + }, + "code_validation": { + "ode_source": "Single damped SHO via reflected gear inertia (textbook).", + "energy_check": "Energy E = (1/2) m_eff v^2 + (1/2) k_eff x^2 decreases monotonically when gamma>0.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Underdamped sinusoidal oscillation with period T_n = 1.130 s, decaying with envelope \\exp(-zeta \\cdot omega_n \\cdot t).", + "Gear angle proportional to rack displacement; visible no-slip rolling." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "m_g": { + "value": 0.591287987698939, + "unit": "", + "description": "" + }, + "R_g": { + "value": 0.20836931543636664, + "unit": "", + "description": "" + }, + "m_r": { + "value": 1.2872700880398602, + "unit": "", + "description": "" + }, + "k_L": { + "value": 19.22663699514407, + "unit": "", + "description": "" + }, + "k_R": { + "value": 29.74920487752852, + "unit": "", + "description": "" + }, + "x_left_wall": { + "value": -2.5, + "unit": "", + "description": "" + }, + "x_right_wall": { + "value": 2.5, + "unit": "", + "description": "" + }, + "L_L": { + "value": 1.5, + "unit": "", + "description": "" + }, + "L_R": { + "value": 1.5, + "unit": "", + "description": "" + }, + "gamma": { + "value": 0.2648565407847207, + "unit": "", + "description": "" + }, + "v_0": { + "value": 1.4807721081859853, + "unit": "", + "description": "" + }, + "x_rack_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "rack_length": { + "value": 2.0, + "unit": "", + "description": "" + }, + "rack_height": { + "value": 0.18, + "unit": "", + "description": "" + }, + "y_floor": { + "value": 0.0, + "unit": "", + "description": "" + }, + "N_g": { + "value": 20, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/gear_rack_spring_oscillator/620/params.json b/scipy/gear_rack_spring_oscillator/620/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ea57d31c4017d80b37df7be1b6306f190d799b02 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/620/params.json @@ -0,0 +1,19 @@ +{ + "g": 9.8, + "m_g": 0.591287987698939, + "R_g": 0.20836931543636664, + "m_r": 1.2872700880398602, + "k_L": 19.22663699514407, + "k_R": 29.74920487752852, + "x_left_wall": -2.5, + "x_right_wall": 2.5, + "L_L": 1.5, + "L_R": 1.5, + "gamma": 0.2648565407847207, + "v_0": 1.4807721081859853, + "x_rack_0": 0.0, + "rack_length": 2.0, + "rack_height": 0.18, + "y_floor": 0.0, + "N_g": 20 +} \ No newline at end of file diff --git a/scipy/gear_rack_spring_oscillator/620/simulation_code.py b/scipy/gear_rack_spring_oscillator/620/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..9c8a2294446ebf198f0581ef111be0143aeac854 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/620/simulation_code.py @@ -0,0 +1,163 @@ +"""Gear-rack-spring oscillator standalone script.""" +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon, Circle, Rectangle +from matplotlib.collections import LineCollection + +g = 9.8 +m_g = 0.591287987698939 +R_g = 0.20836931543636664 +m_r = 1.2872700880398602 +k_L = 19.22663699514407 +k_R = 29.74920487752852 +x_left_wall = -2.5 +x_right_wall = 2.5 +L_L = 1.5 +L_R = 1.5 +gamma = 0.2648565407847207 +v_0 = 1.4807721081859853 +x_rack_0 = 0.0 +rack_length = 2.0 +rack_height = 0.18 +y_floor = 0.0 +N_g = 20 +duration = 12 +fps = 30 + +I_g = 0.5*m_g*R_g**2 +m_eff = m_r + I_g/R_g**2 +k_eff = k_L + k_R +omega_n = np.sqrt(k_eff/m_eff) +zeta = gamma/(2.0*np.sqrt(k_eff*m_eff)) +omega_d = omega_n*np.sqrt(max(1.0-zeta**2, 1e-12)) +A_const = x_rack_0 - 0.0 +B_const = (v_0 + zeta*omega_n*A_const)/omega_d + +t_eval = np.linspace(0.0, duration, int(duration*fps)+1) +env = np.exp(-zeta*omega_n*t_eval) +cos_w = np.cos(omega_d*t_eval); sin_w = np.sin(omega_d*t_eval) +x_arr = env*(A_const*cos_w + B_const*sin_w) +th_arr = +(x_arr - x_rack_0)/R_g + +pitch_p = 2.0*np.pi*R_g/N_g +addendum = 0.020; dedendum = 0.020; tooth_frac = 0.50 + +def gear_polygon(cx, cy, R, N, theta=0.0): + r_add = R+addendum; r_ded = R-dedendum + pitch = 2.0*np.pi/N + phi = 0.5*tooth_frac*pitch + pts = np.empty((4*N, 2)) + for i in range(N): + theta_c = i*pitch + theta + for k, (r, dphi) in enumerate(((r_ded,-phi),(r_add,-phi),(r_add,+phi),(r_ded,+phi))): + ang = theta_c+dphi + pts[4*i+k,0] = cx + r*np.cos(ang) + pts[4*i+k,1] = cy + r*np.sin(ang) + return pts + +rack_tooth_h = 0.020 +rack_tooth_half = 0.5*(tooth_frac*pitch_p)/2.0 +N_rack = int(np.ceil(rack_length/pitch_p)) + 4 +phase_offset = 0.5*pitch_p + +def rack_polygon(xc): + half = rack_length/2.0 + y_bot = y_floor; y_top = y_floor + rack_height + bottom = np.array([[xc-half, y_bot],[xc+half, y_bot]]) + profile = [[xc-half, y_top]] + for k in range(N_rack): + x_crest_center = xc + (k - N_rack/2.0)*pitch_p + phase_offset + x_l = x_crest_center - rack_tooth_half + x_r = x_crest_center + rack_tooth_half + if x_r < xc-half or x_l > xc+half: continue + x_l_c = max(x_l, xc-half); x_r_c = min(x_r, xc+half) + profile.append([x_l_c, y_top]) + profile.append([x_l_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top+rack_tooth_h]) + profile.append([x_r_c, y_top]) + profile.append([xc+half, y_top]) + top = np.array(profile[::-1]) + return np.vstack([bottom, top]) + +def spring_path(x1, x2, yc, n=10, r=0.06): + if abs(x2-x1) < 1e-6: + return np.array([[x1,yc],[x2,yc]]) + t = np.linspace(0.0,1.0, n*20+2) + lead = 0.08 + env_t = (t-lead)/(1.0-2.0*lead) + env = np.where((t1.0-lead), 0.0, np.sin(n*2.0*np.pi*env_t)) + xs = x1 + t*(x2-x1); ys = yc + r*env + return np.column_stack([xs, ys]) + +gear_cx = 0.0 +gear_cy = y_floor + rack_height + R_g +x_lo = x_left_wall - 0.20; x_hi = x_right_wall + 0.20 +y_lo = y_floor - 0.45; y_hi = gear_cy + R_g + addendum + 0.30 +fig_w, fig_h = 10.0, 5.0 +fig_aspect = fig_w/fig_h +dx = x_hi-x_lo; dy = y_hi-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy-dx)/2.0 + x_lo -= extra; x_hi += extra +else: + extra = (dx/fig_aspect-dy)/2.0 + y_lo -= extra; y_hi += extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.add_patch(Rectangle((x_lo,y_lo), x_hi-x_lo, y_floor-y_lo, + facecolor="#0f1626", edgecolor="none", zorder=1)) +ax.plot([x_lo,x_hi],[y_floor,y_floor], color="#4a4e69", lw=2.0, zorder=1.5) +wall_w = 0.12 +wall_h_top = gear_cy + R_g + 0.05 +ax.add_patch(Rectangle((x_left_wall-wall_w, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +ax.add_patch(Rectangle((x_right_wall, y_floor), wall_w, wall_h_top-y_floor, + facecolor="#4a4e69", edgecolor="#adb5bd", lw=1.0, + hatch="////", zorder=2)) +gear_patch = Polygon(gear_polygon(gear_cx, gear_cy, R_g, N_g), + facecolor="#a8dadc", edgecolor="#adb5bd", lw=1.2, zorder=4) +ax.add_patch(gear_patch) +ax.add_patch(Circle((gear_cx, gear_cy), R_g - dedendum*1.4, + facecolor="#3a4357", edgecolor="none", zorder=4.2)) +spokes = [ax.plot([],[], color="#e63946", lw=2.6, zorder=4.5)[0] for _ in range(4)] +ax.add_patch(Circle((gear_cx, gear_cy), 0.035, facecolor="#e63946", + edgecolor="#adb5bd", lw=0.8, zorder=4.8)) +rack_patch = Polygon(rack_polygon(x_rack_0), facecolor="#a8dadc", + edgecolor="#adb5bd", lw=1.2, zorder=3) +ax.add_patch(rack_patch) +rack_hatch_lc = LineCollection([], colors="#4a4e69", linewidths=1.2, zorder=3.2) +ax.add_collection(rack_hatch_lc) +y_spring = y_floor + rack_height*0.5 +spring_L_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) +spring_R_line, = ax.plot([],[], color="#a8dadc", lw=2.0, zorder=2.5) + +def update(f): + xc = x_arr[f]; th = th_arr[f] + gear_patch.set_xy(gear_polygon(gear_cx, gear_cy, R_g, N_g, theta=th)) + for i, sp in enumerate(spokes): + ang = th + i*(np.pi/2.0) + sp.set_data([gear_cx, gear_cx + (R_g - dedendum*1.5)*np.cos(ang)], + [gear_cy, gear_cy + (R_g - dedendum*1.5)*np.sin(ang)]) + rack_patch.set_xy(rack_polygon(xc)) + half = rack_length/2.0 + n_ticks = 11 + tick_xs = np.linspace(xc-half+0.10, xc+half-0.10, n_ticks) + tick_y0 = y_floor + 0.005; tick_y1 = y_floor + rack_height*0.45 + rack_hatch_lc.set_segments([[(tx,tick_y0),(tx,tick_y1)] for tx in tick_xs]) + sL = spring_path(x_left_wall, xc-half, y_spring, n=10, r=0.07) + sR = spring_path(xc+half, x_right_wall, y_spring, n=10, r=0.07) + spring_L_line.set_data(sL[:,0], sL[:,1]) + spring_R_line.set_data(sR[:,0], sR[:,1]) + return (gear_patch, rack_patch, rack_hatch_lc, + spring_L_line, spring_R_line, *spokes) + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000.0/fps, blit=False) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/gear_rack_spring_oscillator/620/video.mp4 b/scipy/gear_rack_spring_oscillator/620/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e88feaa5dc8be5ad434700eb275f31302854a2f2 --- /dev/null +++ b/scipy/gear_rack_spring_oscillator/620/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28d0352473010c940c6acd9a942f0440fc98c2c22bb4428014ef92a5b209a9af +size 56208 diff --git a/scipy/half_cylinder_drop/001/cot.json b/scipy/half_cylinder_drop/001/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4fd3d2658b720782107973cc0031973122ca9053 --- /dev/null +++ b/scipy/half_cylinder_drop/001/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.365 m, mass M=1.687 kg) is dropped from height Y_com=0.935 m with initial tilt theta_0=0.386 rad. It bounces (e=0.595, mu=0.258) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1550 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.071949 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.182 rad/s; T ~ 1.502 s." + ], + "physical_constants_derived": { + "h_com_m": 0.154977, + "I_com_kg_m2": 0.071949, + "omega_rock_small_rad_s": 4.1823, + "T_rock_seconds": 1.5023 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 1.6869068414970407, + "unit": "", + "description": "" + }, + "R": { + "value": 0.3651552301109642, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5948813929298673, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.25842145896418645, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.33663778964897867, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.9351841843287342, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.3862882101575359, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/001/params.json b/scipy/half_cylinder_drop/001/params.json new file mode 100644 index 0000000000000000000000000000000000000000..cfd4ebff660ee0836ca5faff9a2d08bae1fc339a --- /dev/null +++ b/scipy/half_cylinder_drop/001/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 1.6869068414970407, + "R": 0.3651552301109642, + "e_rest": 0.5948813929298673, + "mu": 0.25842145896418645, + "gamma_rock": 0.33663778964897867, + "X_com_0": 0.0, + "Y_com_0": 0.9351841843287342, + "theta_0": 0.3862882101575359, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/001/simulation_code.py b/scipy/half_cylinder_drop/001/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..a296be9dd65297ddd3c86ea284f74e1a004c4ef5 --- /dev/null +++ b/scipy/half_cylinder_drop/001/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 0.7453964173125003 +R = 0.39943266925778304 +e_rest = 0.5938029616372877 +mu = 0.2572872737479272 +gamma_rock = 0.32483514053185236 +X_com_0 = 0.0 +Y_com_0 = 0.8676689005206301 +theta_0 = 0.16491264601662498 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/001/video.mp4 b/scipy/half_cylinder_drop/001/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6d20e4c51edb8ca6d61a18dd129f1f8f44696eea --- /dev/null +++ b/scipy/half_cylinder_drop/001/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e646b5ba20af1af2c7d167eb135ce3c6584bd6569c805a305ebaa897de2662a3 +size 12750 diff --git a/scipy/half_cylinder_drop/045/cot.json b/scipy/half_cylinder_drop/045/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..06f41df7e9f2d674b4e85f19750e86746de55750 --- /dev/null +++ b/scipy/half_cylinder_drop/045/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.261 m, mass M=1.912 kg) is dropped from height Y_com=0.905 m with initial tilt theta_0=0.183 rad. It bounces (e=0.376, mu=0.309) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1107 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.041619 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.948 rad/s; T ~ 1.270 s." + ], + "physical_constants_derived": { + "h_com_m": 0.110725, + "I_com_kg_m2": 0.041619, + "omega_rock_small_rad_s": 4.948, + "T_rock_seconds": 1.2698 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 1.9116031650411192, + "unit": "", + "description": "" + }, + "R": { + "value": 0.2608905449825653, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.37591941458977396, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.3094509404301091, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.2674734951819518, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.9048434535946143, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.18254429581848308, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/045/params.json b/scipy/half_cylinder_drop/045/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e2ad874f37bf271f87e5805e1324539825c387be --- /dev/null +++ b/scipy/half_cylinder_drop/045/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 1.9116031650411192, + "R": 0.2608905449825653, + "e_rest": 0.37591941458977396, + "mu": 0.3094509404301091, + "gamma_rock": 0.2674734951819518, + "X_com_0": 0.0, + "Y_com_0": 0.9048434535946143, + "theta_0": 0.18254429581848308, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/045/simulation_code.py b/scipy/half_cylinder_drop/045/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..132d2397b4f5397d20a9aa5f0153ed3c00f9f9ed --- /dev/null +++ b/scipy/half_cylinder_drop/045/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 1.9116031650411192 +R = 0.2608905449825653 +e_rest = 0.37591941458977396 +mu = 0.3094509404301091 +gamma_rock = 0.2674734951819518 +X_com_0 = 0.0 +Y_com_0 = 0.9048434535946143 +theta_0 = 0.18254429581848308 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/045/video.mp4 b/scipy/half_cylinder_drop/045/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ed68b68124a25b52334d2d82ee37dc2a4952cdb9 --- /dev/null +++ b/scipy/half_cylinder_drop/045/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b5e47f411b5d9ab3ddb3c38c048422423fac88761c09bb6d8f34dc536bedd7b6 +size 10323 diff --git a/scipy/half_cylinder_drop/071/cot.json b/scipy/half_cylinder_drop/071/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f909e2949a871b31a93ad482308a217ea3d06b3e --- /dev/null +++ b/scipy/half_cylinder_drop/071/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.369 m, mass M=1.978 kg) is dropped from height Y_com=0.809 m with initial tilt theta_0=0.275 rad. It bounces (e=0.521, mu=0.380) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1565 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.086017 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.162 rad/s; T ~ 1.510 s." + ], + "physical_constants_derived": { + "h_com_m": 0.156493, + "I_com_kg_m2": 0.086017, + "omega_rock_small_rad_s": 4.162, + "T_rock_seconds": 1.5096 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 1.9778371656274971, + "unit": "", + "description": "" + }, + "R": { + "value": 0.36872903164034665, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5212106733652038, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.3796141280787367, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.5225661935316186, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8087297076095669, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.2750085225695171, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/071/params.json b/scipy/half_cylinder_drop/071/params.json new file mode 100644 index 0000000000000000000000000000000000000000..013556a6c863f37d76440ed6c0c73683c84232b6 --- /dev/null +++ b/scipy/half_cylinder_drop/071/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 1.9778371656274971, + "R": 0.36872903164034665, + "e_rest": 0.5212106733652038, + "mu": 0.3796141280787367, + "gamma_rock": 0.5225661935316186, + "X_com_0": 0.0, + "Y_com_0": 0.8087297076095669, + "theta_0": 0.2750085225695171, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/071/simulation_code.py b/scipy/half_cylinder_drop/071/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..cc6c4c2bfa9a83450f7733e94726d9573968fbc5 --- /dev/null +++ b/scipy/half_cylinder_drop/071/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 1.9778371656274971 +R = 0.36872903164034665 +e_rest = 0.5212106733652038 +mu = 0.3796141280787367 +gamma_rock = 0.5225661935316186 +X_com_0 = 0.0 +Y_com_0 = 0.8087297076095669 +theta_0 = 0.2750085225695171 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/071/video.mp4 b/scipy/half_cylinder_drop/071/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d80021a8b396b47f2bef8d5e927ee13ee12d0647 --- /dev/null +++ b/scipy/half_cylinder_drop/071/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8e6bf7a0a2bdb7c23cb4db499671e012b26f1531cac1b4243451e593a1baabd +size 12182 diff --git a/scipy/half_cylinder_drop/194/cot.json b/scipy/half_cylinder_drop/194/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0ff1a8da5a477fd92aedc132d256143194abd9d1 --- /dev/null +++ b/scipy/half_cylinder_drop/194/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.255 m, mass M=0.616 kg) is dropped from height Y_com=0.892 m with initial tilt theta_0=0.368 rad. It bounces (e=0.428, mu=0.413) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1082 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.012803 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 5.006 rad/s; T ~ 1.255 s." + ], + "physical_constants_derived": { + "h_com_m": 0.108185, + "I_com_kg_m2": 0.012803, + "omega_rock_small_rad_s": 5.0058, + "T_rock_seconds": 1.2552 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 0.616005023676897, + "unit": "", + "description": "" + }, + "R": { + "value": 0.25490527297249943, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4284890433164521, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.41256988548051443, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.5065301939834166, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8919357386498004, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.36766257006433, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/194/params.json b/scipy/half_cylinder_drop/194/params.json new file mode 100644 index 0000000000000000000000000000000000000000..db193ad74c0ff203b23c7c89f4fd4de24f05665c --- /dev/null +++ b/scipy/half_cylinder_drop/194/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 0.616005023676897, + "R": 0.25490527297249943, + "e_rest": 0.4284890433164521, + "mu": 0.41256988548051443, + "gamma_rock": 0.5065301939834166, + "X_com_0": 0.0, + "Y_com_0": 0.8919357386498004, + "theta_0": 0.36766257006433, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/194/simulation_code.py b/scipy/half_cylinder_drop/194/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f334d3fb8c4fed28947612580fffa9182dd538d8 --- /dev/null +++ b/scipy/half_cylinder_drop/194/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 0.616005023676897 +R = 0.25490527297249943 +e_rest = 0.4284890433164521 +mu = 0.41256988548051443 +gamma_rock = 0.5065301939834166 +X_com_0 = 0.0 +Y_com_0 = 0.8919357386498004 +theta_0 = 0.36766257006433 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/194/video.mp4 b/scipy/half_cylinder_drop/194/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..661d14d3eb1e0b90fa24ae108370817099b2c3ca --- /dev/null +++ b/scipy/half_cylinder_drop/194/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfab792375c9d3e46f422b56d0a1baa3be2850fc57f94d885b6f46d4fe16c018 +size 8468 diff --git a/scipy/half_cylinder_drop/201/cot.json b/scipy/half_cylinder_drop/201/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a9c9e97832b7ba8ed4403d132d168f6f5ff82fb8 --- /dev/null +++ b/scipy/half_cylinder_drop/201/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.385 m, mass M=0.543 kg) is dropped from height Y_com=0.837 m with initial tilt theta_0=0.352 rad. It bounces (e=0.522, mu=0.323) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1633 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.025724 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.075 rad/s; T ~ 1.542 s." + ], + "physical_constants_derived": { + "h_com_m": 0.163285, + "I_com_kg_m2": 0.025724, + "omega_rock_small_rad_s": 4.0746, + "T_rock_seconds": 1.5421 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 0.5433037692645161, + "unit": "", + "description": "" + }, + "R": { + "value": 0.3847322276273364, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5220912267442531, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.32306604116332305, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.27279915295164564, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8374219194839578, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.3521718826117982, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/201/params.json b/scipy/half_cylinder_drop/201/params.json new file mode 100644 index 0000000000000000000000000000000000000000..73601bcea108581cc3f6c7c213aaf8c36a4d987a --- /dev/null +++ b/scipy/half_cylinder_drop/201/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 0.5433037692645161, + "R": 0.3847322276273364, + "e_rest": 0.5220912267442531, + "mu": 0.32306604116332305, + "gamma_rock": 0.27279915295164564, + "X_com_0": 0.0, + "Y_com_0": 0.8374219194839578, + "theta_0": 0.3521718826117982, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/201/simulation_code.py b/scipy/half_cylinder_drop/201/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ce6985dd2fa252c50e89f0da2d2d983e55e25a3e --- /dev/null +++ b/scipy/half_cylinder_drop/201/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 0.5433037692645161 +R = 0.3847322276273364 +e_rest = 0.5220912267442531 +mu = 0.32306604116332305 +gamma_rock = 0.27279915295164564 +X_com_0 = 0.0 +Y_com_0 = 0.8374219194839578 +theta_0 = 0.3521718826117982 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/201/video.mp4 b/scipy/half_cylinder_drop/201/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..14115621049b6821ed4856ce2dc8e579b23de7d7 --- /dev/null +++ b/scipy/half_cylinder_drop/201/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed41f6426df190e8b88c933427bd2bacabe81d17ea4c9623241381e036017c4c +size 10728 diff --git a/scipy/half_cylinder_drop/260/cot.json b/scipy/half_cylinder_drop/260/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0cb45f5aa94ebcada7e2dbe4961c8ac1c7751d85 --- /dev/null +++ b/scipy/half_cylinder_drop/260/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.224 m, mass M=1.990 kg) is dropped from height Y_com=0.926 m with initial tilt theta_0=0.348 rad. It bounces (e=0.639, mu=0.210) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.0950 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.031890 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 5.342 rad/s; T ~ 1.176 s." + ], + "physical_constants_derived": { + "h_com_m": 0.094991, + "I_com_kg_m2": 0.03189, + "omega_rock_small_rad_s": 5.3421, + "T_rock_seconds": 1.1762 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 1.990155460123154, + "unit": "", + "description": "" + }, + "R": { + "value": 0.2238181098026375, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.6391032552582727, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.21014819545657476, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.2750551895205368, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.9258757399723706, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.34801610284583007, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/260/params.json b/scipy/half_cylinder_drop/260/params.json new file mode 100644 index 0000000000000000000000000000000000000000..3934c0e79414a2edab86a790b4d0ae8f7093e6d5 --- /dev/null +++ b/scipy/half_cylinder_drop/260/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 1.990155460123154, + "R": 0.2238181098026375, + "e_rest": 0.6391032552582727, + "mu": 0.21014819545657476, + "gamma_rock": 0.2750551895205368, + "X_com_0": 0.0, + "Y_com_0": 0.9258757399723706, + "theta_0": 0.34801610284583007, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/260/simulation_code.py b/scipy/half_cylinder_drop/260/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4e9a7707a1ac6246de2bb06c7a767b72573b6d07 --- /dev/null +++ b/scipy/half_cylinder_drop/260/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 1.990155460123154 +R = 0.2238181098026375 +e_rest = 0.6391032552582727 +mu = 0.21014819545657476 +gamma_rock = 0.2750551895205368 +X_com_0 = 0.0 +Y_com_0 = 0.9258757399723706 +theta_0 = 0.34801610284583007 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/260/video.mp4 b/scipy/half_cylinder_drop/260/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..8ad036e94de3947ae821e9ee420dd635ca10e076 --- /dev/null +++ b/scipy/half_cylinder_drop/260/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42c099839a44f6eb041728b46d966d38cd0ce7cad9863f2b116806d1a3f93ed7 +size 8261 diff --git a/scipy/half_cylinder_drop/338/cot.json b/scipy/half_cylinder_drop/338/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..bcb800608caf08b19bbac2722398197116b17bf3 --- /dev/null +++ b/scipy/half_cylinder_drop/338/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.205 m, mass M=0.544 kg) is dropped from height Y_com=0.795 m with initial tilt theta_0=0.191 rad. It bounces (e=0.595, mu=0.219) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.0868 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.007287 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 5.587 rad/s; T ~ 1.125 s." + ], + "physical_constants_derived": { + "h_com_m": 0.086842, + "I_com_kg_m2": 0.007287, + "omega_rock_small_rad_s": 5.5871, + "T_rock_seconds": 1.1246 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 0.5441246998139206, + "unit": "", + "description": "" + }, + "R": { + "value": 0.2046156155089496, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5946313694293619, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.21920234028014782, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.3035013472559934, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.7948921600954452, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.19081341400803017, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/338/params.json b/scipy/half_cylinder_drop/338/params.json new file mode 100644 index 0000000000000000000000000000000000000000..b562421536281984662b549e5a9370e343ee5388 --- /dev/null +++ b/scipy/half_cylinder_drop/338/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 0.5441246998139206, + "R": 0.2046156155089496, + "e_rest": 0.5946313694293619, + "mu": 0.21920234028014782, + "gamma_rock": 0.3035013472559934, + "X_com_0": 0.0, + "Y_com_0": 0.7948921600954452, + "theta_0": 0.19081341400803017, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/338/simulation_code.py b/scipy/half_cylinder_drop/338/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ad17910e82c3be7519aadf5a6eb537afc42d0df4 --- /dev/null +++ b/scipy/half_cylinder_drop/338/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 0.5441246998139206 +R = 0.2046156155089496 +e_rest = 0.5946313694293619 +mu = 0.21920234028014782 +gamma_rock = 0.3035013472559934 +X_com_0 = 0.0 +Y_com_0 = 0.7948921600954452 +theta_0 = 0.19081341400803017 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/338/video.mp4 b/scipy/half_cylinder_drop/338/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..43ae5522a93661ec94deb25535ce22a9acb36a2c --- /dev/null +++ b/scipy/half_cylinder_drop/338/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:deb83ea431c59c05506c8b76042dad7b392221b99b60c7af9d94a10b9502d2d2 +size 7762 diff --git a/scipy/half_cylinder_drop/372/cot.json b/scipy/half_cylinder_drop/372/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f24b0a73bede98fafa08a7be707ee496e60e0f6d --- /dev/null +++ b/scipy/half_cylinder_drop/372/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.388 m, mass M=1.861 kg) is dropped from height Y_com=0.803 m with initial tilt theta_0=0.270 rad. It bounces (e=0.561, mu=0.241) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1647 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.089609 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.057 rad/s; T ~ 1.549 s." + ], + "physical_constants_derived": { + "h_com_m": 0.164678, + "I_com_kg_m2": 0.089609, + "omega_rock_small_rad_s": 4.0573, + "T_rock_seconds": 1.5486 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 1.860708913025645, + "unit": "", + "description": "" + }, + "R": { + "value": 0.38801354670402477, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5611991754186566, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.24057352722723796, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.49483618309260424, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8028218352867369, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.270325807283477, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/372/params.json b/scipy/half_cylinder_drop/372/params.json new file mode 100644 index 0000000000000000000000000000000000000000..72462b8cfb519fc555405fdbe4a3f96d87811617 --- /dev/null +++ b/scipy/half_cylinder_drop/372/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 1.860708913025645, + "R": 0.38801354670402477, + "e_rest": 0.5611991754186566, + "mu": 0.24057352722723796, + "gamma_rock": 0.49483618309260424, + "X_com_0": 0.0, + "Y_com_0": 0.8028218352867369, + "theta_0": 0.270325807283477, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/372/simulation_code.py b/scipy/half_cylinder_drop/372/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..6cda7163b823830a561c962166f0cd4db889b99d --- /dev/null +++ b/scipy/half_cylinder_drop/372/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 1.860708913025645 +R = 0.38801354670402477 +e_rest = 0.5611991754186566 +mu = 0.24057352722723796 +gamma_rock = 0.49483618309260424 +X_com_0 = 0.0 +Y_com_0 = 0.8028218352867369 +theta_0 = 0.270325807283477 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/372/video.mp4 b/scipy/half_cylinder_drop/372/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..05afe7918d13cacef861cbfdee71b49d4f0ce481 --- /dev/null +++ b/scipy/half_cylinder_drop/372/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:228531125cb5fbe55878fb3387386371c737506e24881d35046d9233fa2ae48e +size 12546 diff --git a/scipy/half_cylinder_drop/441/cot.json b/scipy/half_cylinder_drop/441/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..7b1a4bceb1e54dcb49016143d8facefbe30b6436 --- /dev/null +++ b/scipy/half_cylinder_drop/441/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.302 m, mass M=0.560 kg) is dropped from height Y_com=0.805 m with initial tilt theta_0=0.385 rad. It bounces (e=0.598, mu=0.357) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1282 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.016344 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.599 rad/s; T ~ 1.366 s." + ], + "physical_constants_derived": { + "h_com_m": 0.12819, + "I_com_kg_m2": 0.016344, + "omega_rock_small_rad_s": 4.5986, + "T_rock_seconds": 1.3663 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 0.5600726303957101, + "unit": "", + "description": "" + }, + "R": { + "value": 0.30204081921215653, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5981784211960329, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.356857083846015, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.3002132367277991, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8048074757144382, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.38505454746058015, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/441/params.json b/scipy/half_cylinder_drop/441/params.json new file mode 100644 index 0000000000000000000000000000000000000000..05128e703268c65dc86f1e041dc02fdffd7ef539 --- /dev/null +++ b/scipy/half_cylinder_drop/441/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 0.5600726303957101, + "R": 0.30204081921215653, + "e_rest": 0.5981784211960329, + "mu": 0.356857083846015, + "gamma_rock": 0.3002132367277991, + "X_com_0": 0.0, + "Y_com_0": 0.8048074757144382, + "theta_0": 0.38505454746058015, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/441/simulation_code.py b/scipy/half_cylinder_drop/441/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..daf6788e57a014560107f00a838125d2e4c7daa6 --- /dev/null +++ b/scipy/half_cylinder_drop/441/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 0.5600726303957101 +R = 0.30204081921215653 +e_rest = 0.5981784211960329 +mu = 0.356857083846015 +gamma_rock = 0.3002132367277991 +X_com_0 = 0.0 +Y_com_0 = 0.8048074757144382 +theta_0 = 0.38505454746058015 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/441/video.mp4 b/scipy/half_cylinder_drop/441/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2dae1a4ec211be451e25a711b022cdb9f027887f --- /dev/null +++ b/scipy/half_cylinder_drop/441/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cbc7e7fd769d1f6e3e7f8081de983a5b4f4971be4f5b8bbcc52d6df4ae8b4ae +size 9136 diff --git a/scipy/half_cylinder_drop/446/cot.json b/scipy/half_cylinder_drop/446/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..8bdbdde77ad9a46927a6c0a1c3db79a9274a134c --- /dev/null +++ b/scipy/half_cylinder_drop/446/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.250 m, mass M=1.753 kg) is dropped from height Y_com=0.886 m with initial tilt theta_0=0.390 rad. It bounces (e=0.551, mu=0.270) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1060 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.035008 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 5.056 rad/s; T ~ 1.243 s." + ], + "physical_constants_derived": { + "h_com_m": 0.106043, + "I_com_kg_m2": 0.035008, + "omega_rock_small_rad_s": 5.0561, + "T_rock_seconds": 1.2427 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 1.7530863406924913, + "unit": "", + "description": "" + }, + "R": { + "value": 0.2498578766098849, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5514715498965459, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.26968742525435896, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.4307553565979595, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8857794580767309, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.3895562730458081, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/446/params.json b/scipy/half_cylinder_drop/446/params.json new file mode 100644 index 0000000000000000000000000000000000000000..2a27f0ac21587103b6286ceaa0fa2f646b6d55ba --- /dev/null +++ b/scipy/half_cylinder_drop/446/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 1.7530863406924913, + "R": 0.2498578766098849, + "e_rest": 0.5514715498965459, + "mu": 0.26968742525435896, + "gamma_rock": 0.4307553565979595, + "X_com_0": 0.0, + "Y_com_0": 0.8857794580767309, + "theta_0": 0.3895562730458081, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/446/simulation_code.py b/scipy/half_cylinder_drop/446/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..cfe60d388f7e544eeb66796882c24b6ab29b8454 --- /dev/null +++ b/scipy/half_cylinder_drop/446/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 1.7530863406924913 +R = 0.2498578766098849 +e_rest = 0.5514715498965459 +mu = 0.26968742525435896 +gamma_rock = 0.4307553565979595 +X_com_0 = 0.0 +Y_com_0 = 0.8857794580767309 +theta_0 = 0.3895562730458081 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/446/video.mp4 b/scipy/half_cylinder_drop/446/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..fc4af5a8ae2bfa360481a73ed5c051dd1489b198 --- /dev/null +++ b/scipy/half_cylinder_drop/446/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38b7ccd0aa6238a69cb32329a706d4716307996460040f3dd269a758db5cbc7b +size 8071 diff --git a/scipy/half_cylinder_drop/532/cot.json b/scipy/half_cylinder_drop/532/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a1ac6900e4d1d1a2fa4c1ea15c7be9a2d0865098 --- /dev/null +++ b/scipy/half_cylinder_drop/532/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.261 m, mass M=1.954 kg) is dropped from height Y_com=0.773 m with initial tilt theta_0=0.382 rad. It bounces (e=0.599, mu=0.339) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1108 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.042598 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.947 rad/s; T ~ 1.270 s." + ], + "physical_constants_derived": { + "h_com_m": 0.110792, + "I_com_kg_m2": 0.042598, + "omega_rock_small_rad_s": 4.9465, + "T_rock_seconds": 1.2702 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 1.9541925540651177, + "unit": "", + "description": "" + }, + "R": { + "value": 0.2610474665237088, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5990598578484323, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.3392224212237518, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.4885792446012691, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.7731204546667977, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.38181069461660894, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/532/params.json b/scipy/half_cylinder_drop/532/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7b3a1fde0d1e0c722e7624c0642df63556dfa253 --- /dev/null +++ b/scipy/half_cylinder_drop/532/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 1.9541925540651177, + "R": 0.2610474665237088, + "e_rest": 0.5990598578484323, + "mu": 0.3392224212237518, + "gamma_rock": 0.4885792446012691, + "X_com_0": 0.0, + "Y_com_0": 0.7731204546667977, + "theta_0": 0.38181069461660894, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/532/simulation_code.py b/scipy/half_cylinder_drop/532/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..981c0f99870fdb9a3af975f57082193c87e76ef8 --- /dev/null +++ b/scipy/half_cylinder_drop/532/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 1.9541925540651177 +R = 0.2610474665237088 +e_rest = 0.5990598578484323 +mu = 0.3392224212237518 +gamma_rock = 0.4885792446012691 +X_com_0 = 0.0 +Y_com_0 = 0.7731204546667977 +theta_0 = 0.38181069461660894 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/532/video.mp4 b/scipy/half_cylinder_drop/532/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c5a5076adf71c1d0311e38846bd3b392627af583 --- /dev/null +++ b/scipy/half_cylinder_drop/532/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:55f46cfea1ff72412a736ea5fd1fb98a719b45f4aece25d110d1eba0bb269134 +size 7726 diff --git a/scipy/half_cylinder_drop/551/cot.json b/scipy/half_cylinder_drop/551/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..6dc609b1ab2c048b13c1d14f929d6baf40d7afe0 --- /dev/null +++ b/scipy/half_cylinder_drop/551/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.310 m, mass M=1.105 kg) is dropped from height Y_com=0.837 m with initial tilt theta_0=0.428 rad. It bounces (e=0.588, mu=0.390) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1317 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.034048 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.537 rad/s; T ~ 1.385 s." + ], + "physical_constants_derived": { + "h_com_m": 0.13172, + "I_com_kg_m2": 0.034048, + "omega_rock_small_rad_s": 4.5366, + "T_rock_seconds": 1.385 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 1.1050827767867926, + "unit": "", + "description": "" + }, + "R": { + "value": 0.310356982752298, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5877726423207664, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.3896470606828355, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.4197767617023605, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8372322558654753, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.4278874043967409, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/551/params.json b/scipy/half_cylinder_drop/551/params.json new file mode 100644 index 0000000000000000000000000000000000000000..6e898b374b5b514d284e1271ad9a7df00f721d63 --- /dev/null +++ b/scipy/half_cylinder_drop/551/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 1.1050827767867926, + "R": 0.310356982752298, + "e_rest": 0.5877726423207664, + "mu": 0.3896470606828355, + "gamma_rock": 0.4197767617023605, + "X_com_0": 0.0, + "Y_com_0": 0.8372322558654753, + "theta_0": 0.4278874043967409, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/551/simulation_code.py b/scipy/half_cylinder_drop/551/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c0e39ff0dd74443158491a68e57c88d4e59e36b3 --- /dev/null +++ b/scipy/half_cylinder_drop/551/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 1.1050827767867926 +R = 0.310356982752298 +e_rest = 0.5877726423207664 +mu = 0.3896470606828355 +gamma_rock = 0.4197767617023605 +X_com_0 = 0.0 +Y_com_0 = 0.8372322558654753 +theta_0 = 0.4278874043967409 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/551/video.mp4 b/scipy/half_cylinder_drop/551/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7f66b30d7a2b36b0b30cb72d7afd522abe47112c --- /dev/null +++ b/scipy/half_cylinder_drop/551/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:46191cd4dcb477405e81a603ee97f5cc40bf17384d56c654fe005a99dcc74136 +size 9282 diff --git a/scipy/half_cylinder_drop/590/cot.json b/scipy/half_cylinder_drop/590/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..208091c89fda08819d02c2a1072f0a2088c0d870 --- /dev/null +++ b/scipy/half_cylinder_drop/590/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.305 m, mass M=0.823 kg) is dropped from height Y_com=0.821 m with initial tilt theta_0=0.203 rad. It bounces (e=0.495, mu=0.268) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1296 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.024546 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.574 rad/s; T ~ 1.374 s." + ], + "physical_constants_derived": { + "h_com_m": 0.129599, + "I_com_kg_m2": 0.024546, + "omega_rock_small_rad_s": 4.5735, + "T_rock_seconds": 1.3738 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 0.8229524048059551, + "unit": "", + "description": "" + }, + "R": { + "value": 0.3053599154095342, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4949986775723112, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.26834802136322394, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.5408614706156705, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8205881476560535, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.20330460660193855, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/590/params.json b/scipy/half_cylinder_drop/590/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a92fa3b23b003107ed28006da076e18f597a5fb6 --- /dev/null +++ b/scipy/half_cylinder_drop/590/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 0.8229524048059551, + "R": 0.3053599154095342, + "e_rest": 0.4949986775723112, + "mu": 0.26834802136322394, + "gamma_rock": 0.5408614706156705, + "X_com_0": 0.0, + "Y_com_0": 0.8205881476560535, + "theta_0": 0.20330460660193855, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/590/simulation_code.py b/scipy/half_cylinder_drop/590/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..65f7ff8ca95d22acac02db0a62f67bf7e0fe8211 --- /dev/null +++ b/scipy/half_cylinder_drop/590/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 0.8229524048059551 +R = 0.3053599154095342 +e_rest = 0.4949986775723112 +mu = 0.26834802136322394 +gamma_rock = 0.5408614706156705 +X_com_0 = 0.0 +Y_com_0 = 0.8205881476560535 +theta_0 = 0.20330460660193855 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/590/video.mp4 b/scipy/half_cylinder_drop/590/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..fe4d7ffaec85d0b4c500a8608ff76c7368b8a3b5 --- /dev/null +++ b/scipy/half_cylinder_drop/590/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad460bd009c9c304c99c060b58e6eac09c7833f53294c100a35680f444e47488 +size 9961 diff --git a/scipy/half_cylinder_drop/680/cot.json b/scipy/half_cylinder_drop/680/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..20d5ca045815bc1dc07512a4ce2d4f4e54ea5410 --- /dev/null +++ b/scipy/half_cylinder_drop/680/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.215 m, mass M=0.540 kg) is dropped from height Y_com=0.845 m with initial tilt theta_0=0.330 rad. It bounces (e=0.576, mu=0.435) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.0911 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.007947 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 5.456 rad/s; T ~ 1.152 s." + ], + "physical_constants_derived": { + "h_com_m": 0.091071, + "I_com_kg_m2": 0.007947, + "omega_rock_small_rad_s": 5.4559, + "T_rock_seconds": 1.1516 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 0.5395466092277235, + "unit": "", + "description": "" + }, + "R": { + "value": 0.21458136991984808, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5763567199721856, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.4354775144931888, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.25229732621410683, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.8448466355801952, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.3303967585641414, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/680/params.json b/scipy/half_cylinder_drop/680/params.json new file mode 100644 index 0000000000000000000000000000000000000000..aa17ea86c73b593afdf74730cfeba15da8fa0658 --- /dev/null +++ b/scipy/half_cylinder_drop/680/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 0.5395466092277235, + "R": 0.21458136991984808, + "e_rest": 0.5763567199721856, + "mu": 0.4354775144931888, + "gamma_rock": 0.25229732621410683, + "X_com_0": 0.0, + "Y_com_0": 0.8448466355801952, + "theta_0": 0.3303967585641414, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/680/simulation_code.py b/scipy/half_cylinder_drop/680/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..1f3f9b47bc1cb5daabed0a5c22869cbf07b9423e --- /dev/null +++ b/scipy/half_cylinder_drop/680/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 0.5395466092277235 +R = 0.21458136991984808 +e_rest = 0.5763567199721856 +mu = 0.4354775144931888 +gamma_rock = 0.25229732621410683 +X_com_0 = 0.0 +Y_com_0 = 0.8448466355801952 +theta_0 = 0.3303967585641414 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/680/video.mp4 b/scipy/half_cylinder_drop/680/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..8a782f85daba34f0df8942a1525aa10b32528d62 --- /dev/null +++ b/scipy/half_cylinder_drop/680/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3395c333f67142a5e63d30482399c0fdd6df0088ab309d428959367b67afc305 +size 8118 diff --git a/scipy/half_cylinder_drop/686/cot.json b/scipy/half_cylinder_drop/686/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..720532811e583919492eb28137debc4f68183307 --- /dev/null +++ b/scipy/half_cylinder_drop/686/cot.json @@ -0,0 +1,115 @@ +{ + "simulation": "half_cylinder_drop", + "physical_observation": "A 2D half-disc (R=0.309 m, mass M=0.872 kg) is dropped from height Y_com=0.777 m with initial tilt theta_0=0.261 rad. It bounces (e=0.404, mu=0.324) and eventually rocks on its curved face.", + "physical_law": { + "name": "Newton-Euler equations for a 2D rigid body with impulsive contact (Newton restitution + Coulomb friction)", + "statement": "Free flight: F = M a, tau = I alpha (no external torque, gravity acts at COM). At contact, decoupled normal impulse Jn (Newton e) and tangential Jt clipped by Coulomb cone.", + "formula": "Jn = -(1+e) v_cy /(1/M + rx^2/I_com); Jt = clip(Jt_stick, -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) theta'' + (1/2)dM_eff/dtheta theta'^2 + M g h_com \\sin(theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R^2 - 2 R h_com \\cos(theta) + h_com^2]" + ], + "equations_python": [ + "Free flight: X'' = 0, Y'' = -g, theta'' = 0", + "Rocking single-DOF (no slip): M_eff(theta) * theta'' + (1/2) *dM_eff/dtheta theta'**2 + M g h_com np.sin (theta) + gamma_rock theta' = 0", + "where M_eff(theta) = I_com + M[R**2 - 2 R h_com np.cos (theta) + h_com**2]" + ] + }, + "derivation_steps": [ + "Half-disc COM offset below the diameter: h_com = 4R/(3 pi) = 0.1313 m.", + "Moment of inertia about COM: I_com = M R^2 (1/2 - 16/(9 pi^2)) = 0.026689 kg \\cdot m^2.", + "Free flight: gravity at COM gives X''=0, Y''=-g, no torque -> theta''=0.", + "At contact, contact-point velocity v_c = (V_x - r_y omega, V_y + r_x omega).", + "Decoupled impulses: Jn from Newton e on the normal; tangential Jt clipped to Coulomb cone.", + "Rocking: rolling without slipping on the curved face yields a single-DOF Lagrangian for theta.", + "Small-angle rocking frequency: omega_rock ~ \\sqrt(M g h_com / I_pivot_eff) ~ 4.544 rad/s; T ~ 1.383 s." + ], + "physical_constants_derived": { + "h_com_m": 0.131293, + "I_com_kg_m2": 0.026689, + "omega_rock_small_rad_s": 4.5439, + "T_rock_seconds": 1.3828 + }, + "numerical_method": { + "solver": "RK45 with terminal contact event for free flight; RK45 for rocking ODE.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard Newton-Euler + impulsive contact + holonomic rolling Lagrangian.", + "energy_check": "Energy strictly decreases at each impulse and via rocking damping gamma_rock.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Free fall, one or more bounces with energy loss, transition to rocking on curved face.", + "Rocking damps via gamma_rock and the body settles upright." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "M": { + "value": 0.8718550617860047, + "unit": "", + "description": "" + }, + "R": { + "value": 0.3093528287079612, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.40445541055622686, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.32352712378666615, + "unit": "", + "description": "" + }, + "gamma_rock": { + "value": 0.4805832828382115, + "unit": "", + "description": "" + }, + "X_com_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Y_com_0": { + "value": 0.7768503792758574, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.26097124827801366, + "unit": "", + "description": "" + }, + "V_x_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "V_y_0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "omega_0": { + "value": 0.0, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/half_cylinder_drop/686/params.json b/scipy/half_cylinder_drop/686/params.json new file mode 100644 index 0000000000000000000000000000000000000000..643e64781f05b1b23b4d056e674e365904bc6800 --- /dev/null +++ b/scipy/half_cylinder_drop/686/params.json @@ -0,0 +1,14 @@ +{ + "g": 9.8, + "M": 0.8718550617860047, + "R": 0.3093528287079612, + "e_rest": 0.40445541055622686, + "mu": 0.32352712378666615, + "gamma_rock": 0.4805832828382115, + "X_com_0": 0.0, + "Y_com_0": 0.7768503792758574, + "theta_0": 0.26097124827801366, + "V_x_0": 0.0, + "V_y_0": 0.0, + "omega_0": 0.0 +} \ No newline at end of file diff --git a/scipy/half_cylinder_drop/686/simulation_code.py b/scipy/half_cylinder_drop/686/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4d286960f28f3633dbed26886a8d11ea1c7e9b69 --- /dev/null +++ b/scipy/half_cylinder_drop/686/simulation_code.py @@ -0,0 +1,157 @@ +"""Half-cylinder drop standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Polygon + +g = 9.8 +M = 0.8718550617860047 +R = 0.3093528287079612 +e_rest = 0.40445541055622686 +mu = 0.32352712378666615 +gamma_rock = 0.4805832828382115 +X_com_0 = 0.0 +Y_com_0 = 0.7768503792758574 +theta_0 = 0.26097124827801366 +V_x_0 = 0.0 +V_y_0 = 0.0 +omega_0 = 0.0 +duration = 12 +fps = 30 + +h_com = 4.0*R/(3.0*np.pi) +I_com = M*R*R*(0.5 - 16.0/(9.0*np.pi*np.pi)) + +_phi = np.linspace(np.pi, 2.0*np.pi, 80) +_curve_x = R*np.cos(_phi); _curve_y = h_com + R*np.sin(_phi) +_body_verts = np.column_stack([ + np.concatenate([[+R,-R], _curve_x]), + np.concatenate([[h_com, h_com], _curve_y]), +]) + +def lab_polygon(Xc, Yc, th): + c, s = np.cos(th), np.sin(th) + Rmat = np.array([[c,-s],[s,c]]) + return _body_verts @ Rmat.T + np.array([Xc, Yc]) + +def gap(Yc, th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return Yc + h_com*cos_t - R + return Yc + h_com*cos_t - R*abs(sin_t) +def contact_r(th): + cos_t = np.cos(th); sin_t = np.sin(th) + if cos_t >= 0: + return -h_com*sin_t, h_com*cos_t - R + sgn = -1.0 if sin_t > 0 else 1.0 + return sgn*R*cos_t - h_com*sin_t, sgn*R*sin_t + h_com*cos_t +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_contact(t, y): return gap(y[1], y[2]) +ev_contact.terminal = True; ev_contact.direction = -1 + +def contact_impulse(state): + s = state.copy() + Xc, Yc, th, Vx, Vy, om = s + rx, ry = contact_r(th) + vcx = Vx - ry*om; vcy = Vy + rx*om + if vcy > 0.0: return s + Jn = -(1.0+e_rest)*vcy / (1.0/M + rx*rx/I_com) + Jt_stk = -vcx / (1.0/M + ry*ry/I_com) + Jt = np.clip(Jt_stk, -mu*Jn, mu*Jn) + s[3] = Vx + Jt/M + s[4] = Vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + cos_t2 = np.cos(s[2]); sin_t2 = np.sin(s[2]) + if cos_t2 >= 0: + s[1] = R - h_com*cos_t2 + 1e-6 + else: + s[1] = R*abs(sin_t2) - h_com*cos_t2 + 1e-6 + return s + +def M_eff(th): return I_com + M*(R*R - 2.0*R*h_com*np.cos(th) + h_com*h_com) +def dM_eff(th): return 2.0*M*R*h_com*np.sin(th) +def rocking_ode(t, z): + th, om = z + Meff = M_eff(th) + return [om, -(0.5*dM_eff(th)*om*om + M*g*h_com*np.sin(th) + gamma_rock*om)/Meff] + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +N = t_eval.size +Xc_arr = np.zeros(N); Yc_arr = np.zeros(N); th_arr = np.zeros(N) +state = np.array([X_com_0, Y_com_0, theta_0, V_x_0, V_y_0, omega_0], dtype=float) +Xc_arr[0], Yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0; rocking_started_at = None +VY_THRESH = 0.10; GAP_EPS = 5e-4 + +for _seg in range(300): + if t_cur >= duration - 1e-12: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_contact], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < N and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + Xc_arr[last_idx], Yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy(); t_cur = seg_end + if sol.status != 1: break + state = contact_impulse(state) + if abs(state[4]) < VY_THRESH and abs(gap(state[1], state[2])) < GAP_EPS and np.cos(state[2]) >= 0: + rocking_started_at = t_cur; break + +if rocking_started_at is not None and t_cur < duration - 1e-12: + sol_r = solve_ivp(rocking_ode, (t_cur, duration), [state[2], state[5]], + dense_output=True, max_step=0.01, + rtol=1e-9, atol=1e-11) + rock_start_idx = np.searchsorted(t_eval, t_cur, side='left') + Xc_cur = state[0]; prev_t = t_cur + prev_Vx_rock = -state[5]*(R - h_com*np.cos(state[2])) + for k in range(rock_start_idx, N): + t_q = max(t_eval[k], t_cur); t_q = min(t_q, sol_r.t[-1]) + zq = sol_r.sol(t_q) + th_q, om_q = zq[0], zq[1] + Vx_q = -om_q*(R - h_com*np.cos(th_q)) + dt = t_q - prev_t + if dt > 0: Xc_cur += 0.5*(prev_Vx_rock + Vx_q)*dt + Xc_arr[k] = Xc_cur + Yc_arr[k] = R - h_com*np.cos(th_q) + th_arr[k] = th_q + prev_t = t_q; prev_Vx_rock = Vx_q +elif last_idx < N: + Xc_arr[last_idx:] = state[0] + Yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +fig_w, fig_h = 8.0, 5.0 +fig_aspect = fig_w/fig_h +x_lo_d = X_com_0 - 1.0; x_hi_d = X_com_0 + 1.0 +y_lo = -0.20; y_hi_d = Y_com_0 + 0.50 +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +body_poly = Polygon(lab_polygon(Xc_arr[0], Yc_arr[0], th_arr[0]), + closed=True, facecolor="#ffd166", edgecolor="white", + lw=1.5, zorder=3) +ax.add_patch(body_poly) + +def update(f): + body_poly.set_xy(lab_polygon(Xc_arr[f], Yc_arr[f], th_arr[f])) + return (body_poly,) + +ani = animation.FuncAnimation(fig, update, frames=N, + interval=1000.0/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/half_cylinder_drop/686/video.mp4 b/scipy/half_cylinder_drop/686/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b902fafbac931f942798ebb9105af9c23d7eccf1 --- /dev/null +++ b/scipy/half_cylinder_drop/686/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4043918431ddf2c0475b2699b6f0986697e47fa73dfbe975de21efb0134fde90 +size 7728 diff --git a/scipy/hammer_projectile_bounce/127/cot.json b/scipy/hammer_projectile_bounce/127/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0659642866d6b2b4dd1ade373df9f6e3838858f1 --- /dev/null +++ b/scipy/hammer_projectile_bounce/127/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.432 kg, length L=0.313 m, with a heavy head m_head=1.544 kg at one end) is launched at v=(4.73, 7.44) m/s, angular velocity omega0=4.08 rad/s, and bounces on the floor with e=0.489, mu=0.277.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 1.9756 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.2789 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.011796 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 1.975588, + "x_com_m": 0.278878, + "I_com_kg_m2": 0.011796, + "T_rotation_initial_s": 1.5392 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.4317669775423887, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.543820871548005, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.31309076289285864, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4893527727599439, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.2768351209401648, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.2895949750536266, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.364942497817906, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.730163245564729, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 7.442145855939777, + "unit": "", + "description": "" + }, + "omega0": { + "value": 4.082017620278331, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/127/params.json b/scipy/hammer_projectile_bounce/127/params.json new file mode 100644 index 0000000000000000000000000000000000000000..eb544c79d8cc8db099c1abd7be04fab452bcd13e --- /dev/null +++ b/scipy/hammer_projectile_bounce/127/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.4317669775423887, + "m_head": 1.543820871548005, + "L_rod": 0.31309076289285864, + "g": 9.8, + "e_rest": 0.4893527727599439, + "mu": 0.2768351209401648, + "Xc0": 0.0, + "Yc0": 1.2895949750536266, + "theta0": 0.364942497817906, + "Vx0": 4.730163245564729, + "Vy0": 7.442145855939777, + "omega0": 4.082017620278331 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/127/simulation_code.py b/scipy/hammer_projectile_bounce/127/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..0ee86662930485d95703fd4924aaa52128d2db31 --- /dev/null +++ b/scipy/hammer_projectile_bounce/127/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.4317669775423887 +m_head = 1.543820871548005 +L_rod = 0.31309076289285864 +g = 9.8 +e_rest = 0.4893527727599439 +mu = 0.2768351209401648 +Xc0 = 0.0 +Yc0 = 1.2895949750536266 +theta0 = 0.364942497817906 +Vx0 = 4.730163245564729 +Vy0 = 7.442145855939777 +omega0 = 4.082017620278331 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/127/video.mp4 b/scipy/hammer_projectile_bounce/127/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c7d6295f8391bc9a3edb1253b08c3cd35e1ad2c4 --- /dev/null +++ b/scipy/hammer_projectile_bounce/127/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bbed4cd6b0e9bfbd6ebed2dcd69ebd2b26a7dc3b02debdd340a2be8fff2d3e2 +size 5950 diff --git a/scipy/hammer_projectile_bounce/307/cot.json b/scipy/hammer_projectile_bounce/307/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c5d00b7052542708566b03806d69f450247e45bd --- /dev/null +++ b/scipy/hammer_projectile_bounce/307/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.239 kg, length L=0.373 m, with a heavy head m_head=2.018 kg at one end) is launched at v=(4.65, 6.92) m/s, angular velocity omega0=4.60 rad/s, and bounces on the floor with e=0.361, mu=0.226.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.2570 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3537 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.010222 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.256989, + "x_com_m": 0.353673, + "I_com_kg_m2": 0.010222, + "T_rotation_initial_s": 1.3661 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.23887299626169398, + "unit": "", + "description": "" + }, + "m_head": { + "value": 2.0181158739255016, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.37343457685130754, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.3608384286344552, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.22585522832330104, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.6109835621873394, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.40107381516830576, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.646470917827935, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 6.9244157963356034, + "unit": "", + "description": "" + }, + "omega0": { + "value": 4.59925888727353, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/307/params.json b/scipy/hammer_projectile_bounce/307/params.json new file mode 100644 index 0000000000000000000000000000000000000000..3bdf41588f4afe96484abfbfc24fe007b34304ca --- /dev/null +++ b/scipy/hammer_projectile_bounce/307/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.23887299626169398, + "m_head": 2.0181158739255016, + "L_rod": 0.37343457685130754, + "g": 9.8, + "e_rest": 0.3608384286344552, + "mu": 0.22585522832330104, + "Xc0": 0.0, + "Yc0": 1.6109835621873394, + "theta0": 0.40107381516830576, + "Vx0": 4.646470917827935, + "Vy0": 6.9244157963356034, + "omega0": 4.59925888727353 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/307/simulation_code.py b/scipy/hammer_projectile_bounce/307/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b195c9377c2b18da94a807d273fc92a3e6d26ab8 --- /dev/null +++ b/scipy/hammer_projectile_bounce/307/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.23887299626169398 +m_head = 2.0181158739255016 +L_rod = 0.37343457685130754 +g = 9.8 +e_rest = 0.3608384286344552 +mu = 0.22585522832330104 +Xc0 = 0.0 +Yc0 = 1.6109835621873394 +theta0 = 0.40107381516830576 +Vx0 = 4.646470917827935 +Vy0 = 6.9244157963356034 +omega0 = 4.59925888727353 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/307/video.mp4 b/scipy/hammer_projectile_bounce/307/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..20d3bb858c807d6bb3db6c3751a263240d074d3a --- /dev/null +++ b/scipy/hammer_projectile_bounce/307/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5f4c1420c028414ace17a5003d6aa04cad87eb025f59e25e10b124575e7a05c +size 5621 diff --git a/scipy/hammer_projectile_bounce/316/cot.json b/scipy/hammer_projectile_bounce/316/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..d703249242b082a366ab47ab7a595e46cfa95e6d --- /dev/null +++ b/scipy/hammer_projectile_bounce/316/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.486 kg, length L=0.356 m, with a heavy head m_head=1.857 kg at one end) is launched at v=(4.00, 6.70) m/s, angular velocity omega0=5.56 rad/s, and bounces on the floor with e=0.428, mu=0.167.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.3424 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3195 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.017373 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.342361, + "x_com_m": 0.319472, + "I_com_kg_m2": 0.017373, + "T_rotation_initial_s": 1.1305 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.4857943942451757, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.8565665362899102, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.3564335295192052, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4278960966342467, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.1667024281749574, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.386366201179371, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.5624280536732094, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 3.99605909428214, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 6.696961405422771, + "unit": "", + "description": "" + }, + "omega0": { + "value": 5.557988745084759, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/316/params.json b/scipy/hammer_projectile_bounce/316/params.json new file mode 100644 index 0000000000000000000000000000000000000000..85e728346f1d357faf3c66f923aaa9d577990c6a --- /dev/null +++ b/scipy/hammer_projectile_bounce/316/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.4857943942451757, + "m_head": 1.8565665362899102, + "L_rod": 0.3564335295192052, + "g": 9.8, + "e_rest": 0.4278960966342467, + "mu": 0.1667024281749574, + "Xc0": 0.0, + "Yc0": 1.386366201179371, + "theta0": 0.5624280536732094, + "Vx0": 3.99605909428214, + "Vy0": 6.696961405422771, + "omega0": 5.557988745084759 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/316/simulation_code.py b/scipy/hammer_projectile_bounce/316/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9b3f5c9f34db20289034d70297686b83976d00 --- /dev/null +++ b/scipy/hammer_projectile_bounce/316/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.4857943942451757 +m_head = 1.8565665362899102 +L_rod = 0.3564335295192052 +g = 9.8 +e_rest = 0.4278960966342467 +mu = 0.1667024281749574 +Xc0 = 0.0 +Yc0 = 1.386366201179371 +theta0 = 0.5624280536732094 +Vx0 = 3.99605909428214 +Vy0 = 6.696961405422771 +omega0 = 5.557988745084759 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/316/video.mp4 b/scipy/hammer_projectile_bounce/316/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..68edc467344d3d5dd2b0e1cdab2b3de491244660 --- /dev/null +++ b/scipy/hammer_projectile_bounce/316/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b1c1a4ac85acf236622449d42e96e55ae2812d035a71d2f74feca302396c939 +size 6385 diff --git a/scipy/hammer_projectile_bounce/321/cot.json b/scipy/hammer_projectile_bounce/321/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..a5bae8d6fdfd44edb6417035ad4c82768a9723aa --- /dev/null +++ b/scipy/hammer_projectile_bounce/321/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.343 kg, length L=0.336 m, with a heavy head m_head=1.784 kg at one end) is launched at v=(4.77, 7.35) m/s, angular velocity omega0=4.95 rad/s, and bounces on the floor with e=0.382, mu=0.230.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.1270 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3092 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.011377 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.126971, + "x_com_m": 0.309154, + "I_com_kg_m2": 0.011377, + "T_rotation_initial_s": 1.2702 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.34336745098991206, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.7836039328336863, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.3362993035664709, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.38167559889426406, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.23018518853478104, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.5447694539362025, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.2842359317147153, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.768245409584057, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 7.348011761831835, + "unit": "", + "description": "" + }, + "omega0": { + "value": 4.946737893147086, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/321/params.json b/scipy/hammer_projectile_bounce/321/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7e4b482e8461014514a710d9f167cc8e0d5661d3 --- /dev/null +++ b/scipy/hammer_projectile_bounce/321/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.34336745098991206, + "m_head": 1.7836039328336863, + "L_rod": 0.3362993035664709, + "g": 9.8, + "e_rest": 0.38167559889426406, + "mu": 0.23018518853478104, + "Xc0": 0.0, + "Yc0": 1.5447694539362025, + "theta0": 0.2842359317147153, + "Vx0": 4.768245409584057, + "Vy0": 7.348011761831835, + "omega0": 4.946737893147086 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/321/simulation_code.py b/scipy/hammer_projectile_bounce/321/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4bfe5466e3ba53c3b8ff259ee117bc2f2a095366 --- /dev/null +++ b/scipy/hammer_projectile_bounce/321/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.34336745098991206 +m_head = 1.7836039328336863 +L_rod = 0.3362993035664709 +g = 9.8 +e_rest = 0.38167559889426406 +mu = 0.23018518853478104 +Xc0 = 0.0 +Yc0 = 1.5447694539362025 +theta0 = 0.2842359317147153 +Vx0 = 4.768245409584057 +Vy0 = 7.348011761831835 +omega0 = 4.946737893147086 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/321/video.mp4 b/scipy/hammer_projectile_bounce/321/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..25398946e756952441b26405f785c666668940ec --- /dev/null +++ b/scipy/hammer_projectile_bounce/321/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6da2b047bfb47c6e2f232f42c6f2739ad2a82c3f3b5e4d53073cbd3ad02b0d97 +size 6083 diff --git a/scipy/hammer_projectile_bounce/334/cot.json b/scipy/hammer_projectile_bounce/334/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..c6ce52295193a891c9fe027b1204cdcbbdc73e9f --- /dev/null +++ b/scipy/hammer_projectile_bounce/334/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.448 kg, length L=0.384 m, with a heavy head m_head=1.792 kg at one end) is launched at v=(4.32, 7.03) m/s, angular velocity omega0=4.62 rad/s, and bounces on the floor with e=0.436, mu=0.261.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.2403 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3458 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.018730 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.240298, + "x_com_m": 0.345783, + "I_com_kg_m2": 0.01873, + "T_rotation_initial_s": 1.3612 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.44783222730091377, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.7924653240677706, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.384182179108689, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4356556127799628, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.2608238277607084, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.3304173395730787, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.25392916499888196, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.320751001132875, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 7.027902887481347, + "unit": "", + "description": "" + }, + "omega0": { + "value": 4.615808296888557, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/334/params.json b/scipy/hammer_projectile_bounce/334/params.json new file mode 100644 index 0000000000000000000000000000000000000000..65a487971b6f058bfa2b0544a50457cd8c57bd37 --- /dev/null +++ b/scipy/hammer_projectile_bounce/334/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.44783222730091377, + "m_head": 1.7924653240677706, + "L_rod": 0.384182179108689, + "g": 9.8, + "e_rest": 0.4356556127799628, + "mu": 0.2608238277607084, + "Xc0": 0.0, + "Yc0": 1.3304173395730787, + "theta0": 0.25392916499888196, + "Vx0": 4.320751001132875, + "Vy0": 7.027902887481347, + "omega0": 4.615808296888557 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/334/simulation_code.py b/scipy/hammer_projectile_bounce/334/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f26d7cdebfa782dd54c2e07978483557675b16c7 --- /dev/null +++ b/scipy/hammer_projectile_bounce/334/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.44783222730091377 +m_head = 1.7924653240677706 +L_rod = 0.384182179108689 +g = 9.8 +e_rest = 0.4356556127799628 +mu = 0.2608238277607084 +Xc0 = 0.0 +Yc0 = 1.3304173395730787 +theta0 = 0.25392916499888196 +Vx0 = 4.320751001132875 +Vy0 = 7.027902887481347 +omega0 = 4.615808296888557 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/334/video.mp4 b/scipy/hammer_projectile_bounce/334/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..103d4dadc06904d82c168c53f53c659a5b1406b9 --- /dev/null +++ b/scipy/hammer_projectile_bounce/334/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c7ce1d19f07d2f64b9bd047975ba56b490343eadae0dd3645e7c1272ac79cf2 +size 6113 diff --git a/scipy/hammer_projectile_bounce/412/cot.json b/scipy/hammer_projectile_bounce/412/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f785feb9cddc546598f8a583d77e3a6b52d92ab3 --- /dev/null +++ b/scipy/hammer_projectile_bounce/412/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.226 kg, length L=0.425 m, with a heavy head m_head=1.678 kg at one end) is launched at v=(4.06, 6.57) m/s, angular velocity omega0=4.78 rad/s, and bounces on the floor with e=0.485, mu=0.157.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 1.9044 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3995 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.012378 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 1.90441, + "x_com_m": 0.399514, + "I_com_kg_m2": 0.012378, + "T_rotation_initial_s": 1.315 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.2259687802027608, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.6784408791431762, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.4247111643168241, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.48545304364742203, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.1566034026660696, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.2844255256324797, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.3471476695657798, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.055705797450734, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 6.567803478900197, + "unit": "", + "description": "" + }, + "omega0": { + "value": 4.778204944758677, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/412/params.json b/scipy/hammer_projectile_bounce/412/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a5daff89d1d195724ef712fe8d1798d091bcb6cb --- /dev/null +++ b/scipy/hammer_projectile_bounce/412/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.2259687802027608, + "m_head": 1.6784408791431762, + "L_rod": 0.4247111643168241, + "g": 9.8, + "e_rest": 0.48545304364742203, + "mu": 0.1566034026660696, + "Xc0": 0.0, + "Yc0": 1.2844255256324797, + "theta0": 0.3471476695657798, + "Vx0": 4.055705797450734, + "Vy0": 6.567803478900197, + "omega0": 4.778204944758677 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/412/simulation_code.py b/scipy/hammer_projectile_bounce/412/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..97fa110ab2071261760be1873ec799624db56090 --- /dev/null +++ b/scipy/hammer_projectile_bounce/412/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.2259687802027608 +m_head = 1.6784408791431762 +L_rod = 0.4247111643168241 +g = 9.8 +e_rest = 0.48545304364742203 +mu = 0.1566034026660696 +Xc0 = 0.0 +Yc0 = 1.2844255256324797 +theta0 = 0.3471476695657798 +Vx0 = 4.055705797450734 +Vy0 = 6.567803478900197 +omega0 = 4.778204944758677 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/412/video.mp4 b/scipy/hammer_projectile_bounce/412/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b6fe7211328046ee20b5f2fc7a4cd4468dd01503 --- /dev/null +++ b/scipy/hammer_projectile_bounce/412/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c898a58fa5195373e8a0e3dfb44f2b3e854cde76cecbb0ee73e775ccbb2aa7d +size 6493 diff --git a/scipy/hammer_projectile_bounce/418/cot.json b/scipy/hammer_projectile_bounce/418/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..628877c405f2c26e49a6d9fa0e9ed6515be40361 --- /dev/null +++ b/scipy/hammer_projectile_bounce/418/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.384 kg, length L=0.428 m, with a heavy head m_head=2.123 kg at one end) is launched at v=(5.38, 5.69) m/s, angular velocity omega0=5.66 rad/s, and bounces on the floor with e=0.458, mu=0.293.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.5074 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3954 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.020787 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.507401, + "x_com_m": 0.395424, + "I_com_kg_m2": 0.020787, + "T_rotation_initial_s": 1.1106 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.38420841839152686, + "unit": "", + "description": "" + }, + "m_head": { + "value": 2.1231927754632425, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.4282333736341751, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4584567911162976, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.2930231920418145, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.2114754627397202, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.26480328438894035, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 5.378129983989958, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 5.694349179870921, + "unit": "", + "description": "" + }, + "omega0": { + "value": 5.657436096891761, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/418/params.json b/scipy/hammer_projectile_bounce/418/params.json new file mode 100644 index 0000000000000000000000000000000000000000..68633ba6fe13ca24b24770b939049ea9d2f366b6 --- /dev/null +++ b/scipy/hammer_projectile_bounce/418/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.38420841839152686, + "m_head": 2.1231927754632425, + "L_rod": 0.4282333736341751, + "g": 9.8, + "e_rest": 0.4584567911162976, + "mu": 0.2930231920418145, + "Xc0": 0.0, + "Yc0": 1.2114754627397202, + "theta0": 0.26480328438894035, + "Vx0": 5.378129983989958, + "Vy0": 5.694349179870921, + "omega0": 5.657436096891761 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/418/simulation_code.py b/scipy/hammer_projectile_bounce/418/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f13c3c3a026a5347247cea243332668b4067fad9 --- /dev/null +++ b/scipy/hammer_projectile_bounce/418/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.38420841839152686 +m_head = 2.1231927754632425 +L_rod = 0.4282333736341751 +g = 9.8 +e_rest = 0.4584567911162976 +mu = 0.2930231920418145 +Xc0 = 0.0 +Yc0 = 1.2114754627397202 +theta0 = 0.26480328438894035 +Vx0 = 5.378129983989958 +Vy0 = 5.694349179870921 +omega0 = 5.657436096891761 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/418/video.mp4 b/scipy/hammer_projectile_bounce/418/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4495394c80c8da2541509020f10954b3b12018fa --- /dev/null +++ b/scipy/hammer_projectile_bounce/418/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08e555d111f3f6374dd07542d495103f170e21ba7366fe6bf03cd3ab800acf40 +size 5619 diff --git a/scipy/hammer_projectile_bounce/519/cot.json b/scipy/hammer_projectile_bounce/519/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..fec49010543ae978ef760e596e5389871b6e5d37 --- /dev/null +++ b/scipy/hammer_projectile_bounce/519/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.276 kg, length L=0.387 m, with a heavy head m_head=1.259 kg at one end) is launched at v=(3.94, 5.67) m/s, angular velocity omega0=5.50 rad/s, and bounces on the floor with e=0.503, mu=0.275.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 1.5358 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3524 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.011949 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 1.535828, + "x_com_m": 0.352392, + "I_com_kg_m2": 0.011949, + "T_rotation_initial_s": 1.1423 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.27636117598577437, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.2594666722186916, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.38723225658668736, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.5027703247544629, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.2749282479472599, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.40341969231493, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.48281141365617114, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 3.9393760143276353, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 5.668265960695326, + "unit": "", + "description": "" + }, + "omega0": { + "value": 5.5006294689204775, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/519/params.json b/scipy/hammer_projectile_bounce/519/params.json new file mode 100644 index 0000000000000000000000000000000000000000..48607684086c5e3c17ba0efa3c00b5638f3e531d --- /dev/null +++ b/scipy/hammer_projectile_bounce/519/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.27636117598577437, + "m_head": 1.2594666722186916, + "L_rod": 0.38723225658668736, + "g": 9.8, + "e_rest": 0.5027703247544629, + "mu": 0.2749282479472599, + "Xc0": 0.0, + "Yc0": 1.40341969231493, + "theta0": 0.48281141365617114, + "Vx0": 3.9393760143276353, + "Vy0": 5.668265960695326, + "omega0": 5.5006294689204775 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/519/simulation_code.py b/scipy/hammer_projectile_bounce/519/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..dec4ad4ce5ad0078b39878e1c050991456ee1945 --- /dev/null +++ b/scipy/hammer_projectile_bounce/519/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.27636117598577437 +m_head = 1.2594666722186916 +L_rod = 0.38723225658668736 +g = 9.8 +e_rest = 0.5027703247544629 +mu = 0.2749282479472599 +Xc0 = 0.0 +Yc0 = 1.40341969231493 +theta0 = 0.48281141365617114 +Vx0 = 3.9393760143276353 +Vy0 = 5.668265960695326 +omega0 = 5.5006294689204775 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/519/video.mp4 b/scipy/hammer_projectile_bounce/519/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..70cdb83f627e85069a19da5bd3cb21b5a4c4d3d8 --- /dev/null +++ b/scipy/hammer_projectile_bounce/519/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:202ed4421accf0214fa0809c096ec492cf7c3b83845c8267349e1781d0712af6 +size 6102 diff --git a/scipy/hammer_projectile_bounce/638/cot.json b/scipy/hammer_projectile_bounce/638/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..ac68564dc3461c6bdb945ee09b9065b07ff347c0 --- /dev/null +++ b/scipy/hammer_projectile_bounce/638/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.356 kg, length L=0.339 m, with a heavy head m_head=1.696 kg at one end) is launched at v=(3.69, 6.03) m/s, angular velocity omega0=5.34 rad/s, and bounces on the floor with e=0.492, mu=0.165.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.0524 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3100 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.011899 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.052398, + "x_com_m": 0.309978, + "I_com_kg_m2": 0.011899, + "T_rotation_initial_s": 1.1774 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.35619249810594, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.6962057856348611, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.33943204440977154, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4917593833765056, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.1652662981768957, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.4584836044260938, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.42033613362269884, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 3.6869617684488083, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 6.025566850311282, + "unit": "", + "description": "" + }, + "omega0": { + "value": 5.336372000066215, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/638/params.json b/scipy/hammer_projectile_bounce/638/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ff17beb2b570f376024ce6cf4b3eaae565310158 --- /dev/null +++ b/scipy/hammer_projectile_bounce/638/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.35619249810594, + "m_head": 1.6962057856348611, + "L_rod": 0.33943204440977154, + "g": 9.8, + "e_rest": 0.4917593833765056, + "mu": 0.1652662981768957, + "Xc0": 0.0, + "Yc0": 1.4584836044260938, + "theta0": 0.42033613362269884, + "Vx0": 3.6869617684488083, + "Vy0": 6.025566850311282, + "omega0": 5.336372000066215 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/638/simulation_code.py b/scipy/hammer_projectile_bounce/638/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d7b15b34a45309d2f4b98a1c01b6f59c920c86f8 --- /dev/null +++ b/scipy/hammer_projectile_bounce/638/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.35619249810594 +m_head = 1.6962057856348611 +L_rod = 0.33943204440977154 +g = 9.8 +e_rest = 0.4917593833765056 +mu = 0.1652662981768957 +Xc0 = 0.0 +Yc0 = 1.4584836044260938 +theta0 = 0.42033613362269884 +Vx0 = 3.6869617684488083 +Vy0 = 6.025566850311282 +omega0 = 5.336372000066215 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/638/video.mp4 b/scipy/hammer_projectile_bounce/638/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e5f42f004df100e88f365f01e76a5b882edad964 --- /dev/null +++ b/scipy/hammer_projectile_bounce/638/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1de052fc178710987cbcf176e52d5c4130855c7bc988911075123adb410aff75 +size 6322 diff --git a/scipy/hammer_projectile_bounce/679/cot.json b/scipy/hammer_projectile_bounce/679/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..25903de9c280e06839ca9934837c0f42078e47c5 --- /dev/null +++ b/scipy/hammer_projectile_bounce/679/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.493 kg, length L=0.332 m, with a heavy head m_head=1.429 kg at one end) is launched at v=(4.87, 7.20) m/s, angular velocity omega0=4.93 rad/s, and bounces on the floor with e=0.400, mu=0.165.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 1.9214 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.2892 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.014595 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 1.921375, + "x_com_m": 0.289224, + "I_com_kg_m2": 0.014595, + "T_rotation_initial_s": 1.2755 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.4925300181505824, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.4288447984477026, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.33174398612033434, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4004955721437321, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.16547110002000087, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.6352515288376321, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.4456915552947752, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.865083051492926, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 7.197061676739859, + "unit": "", + "description": "" + }, + "omega0": { + "value": 4.926136383126099, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/679/params.json b/scipy/hammer_projectile_bounce/679/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c7cd2ae4d4e7e299e6e6c50b282e26602f1107b6 --- /dev/null +++ b/scipy/hammer_projectile_bounce/679/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.4925300181505824, + "m_head": 1.4288447984477026, + "L_rod": 0.33174398612033434, + "g": 9.8, + "e_rest": 0.4004955721437321, + "mu": 0.16547110002000087, + "Xc0": 0.0, + "Yc0": 1.6352515288376321, + "theta0": 0.4456915552947752, + "Vx0": 4.865083051492926, + "Vy0": 7.197061676739859, + "omega0": 4.926136383126099 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/679/simulation_code.py b/scipy/hammer_projectile_bounce/679/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..7a725db2e248275701522892eff8c9c7ddd25c5f --- /dev/null +++ b/scipy/hammer_projectile_bounce/679/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.4925300181505824 +m_head = 1.4288447984477026 +L_rod = 0.33174398612033434 +g = 9.8 +e_rest = 0.4004955721437321 +mu = 0.16547110002000087 +Xc0 = 0.0 +Yc0 = 1.6352515288376321 +theta0 = 0.4456915552947752 +Vx0 = 4.865083051492926 +Vy0 = 7.197061676739859 +omega0 = 4.926136383126099 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/679/video.mp4 b/scipy/hammer_projectile_bounce/679/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..48226306298fa95177d2d8fafcbaa01d59ffe343 --- /dev/null +++ b/scipy/hammer_projectile_bounce/679/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8aaa8c79fc92ec33ce2c3f61a6a4e0330f0f9d4c7776ecf07f219cd7c70565ac +size 5748 diff --git a/scipy/hammer_projectile_bounce/682/cot.json b/scipy/hammer_projectile_bounce/682/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..987601366a036aed5ba6944291d87b7a66fbd91a --- /dev/null +++ b/scipy/hammer_projectile_bounce/682/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.372 kg, length L=0.361 m, with a heavy head m_head=1.717 kg at one end) is launched at v=(4.35, 5.55) m/s, angular velocity omega0=5.30 rad/s, and bounces on the floor with e=0.393, mu=0.284.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.0897 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3291 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.014027 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.089697, + "x_com_m": 0.329058, + "I_com_kg_m2": 0.014027, + "T_rotation_initial_s": 1.1857 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.37222618271104413, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.7174703823184598, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.36123005030886035, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.3926750314069047, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.2842588201097679, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.207322526585358, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.5241302746607768, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.349642140409135, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 5.545684514063336, + "unit": "", + "description": "" + }, + "omega0": { + "value": 5.299011483466286, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/682/params.json b/scipy/hammer_projectile_bounce/682/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5b78f69ae98cda7d2b3933d24de05507f9ea17dc --- /dev/null +++ b/scipy/hammer_projectile_bounce/682/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.37222618271104413, + "m_head": 1.7174703823184598, + "L_rod": 0.36123005030886035, + "g": 9.8, + "e_rest": 0.3926750314069047, + "mu": 0.2842588201097679, + "Xc0": 0.0, + "Yc0": 1.207322526585358, + "theta0": 0.5241302746607768, + "Vx0": 4.349642140409135, + "Vy0": 5.545684514063336, + "omega0": 5.299011483466286 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/682/simulation_code.py b/scipy/hammer_projectile_bounce/682/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3609d3b0e73ee3f75def42fbab1e514e754f3830 --- /dev/null +++ b/scipy/hammer_projectile_bounce/682/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.37222618271104413 +m_head = 1.7174703823184598 +L_rod = 0.36123005030886035 +g = 9.8 +e_rest = 0.3926750314069047 +mu = 0.2842588201097679 +Xc0 = 0.0 +Yc0 = 1.207322526585358 +theta0 = 0.5241302746607768 +Vx0 = 4.349642140409135 +Vy0 = 5.545684514063336 +omega0 = 5.299011483466286 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/682/video.mp4 b/scipy/hammer_projectile_bounce/682/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..323b0b94b4c2270c8959b8110e81472ca0d4b0c2 --- /dev/null +++ b/scipy/hammer_projectile_bounce/682/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6631bc1e4bd79ea0cc69e4e92d715f7c06462c567e795f823c3c1b89eca5ccf +size 6195 diff --git a/scipy/hammer_projectile_bounce/713/cot.json b/scipy/hammer_projectile_bounce/713/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..df0f12a6c0ddc0b61c91aa90f1434614e9866d84 --- /dev/null +++ b/scipy/hammer_projectile_bounce/713/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.339 kg, length L=0.303 m, with a heavy head m_head=1.723 kg at one end) is launched at v=(4.53, 5.52) m/s, angular velocity omega0=5.58 rad/s, and bounces on the floor with e=0.378, mu=0.246.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.0616 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.2777 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.009068 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.061601, + "x_com_m": 0.277677, + "I_com_kg_m2": 0.009068, + "T_rotation_initial_s": 1.1267 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.3390093509162054, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.7225915872812716, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.30255325685887535, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.3784226709859981, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.2464583277544317, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.580582903233124, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.5377576436780478, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.534184284446901, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 5.515092399759564, + "unit": "", + "description": "" + }, + "omega0": { + "value": 5.576786194756317, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/713/params.json b/scipy/hammer_projectile_bounce/713/params.json new file mode 100644 index 0000000000000000000000000000000000000000..7df570331d63e25f3603ec4ba7f0b01528154bde --- /dev/null +++ b/scipy/hammer_projectile_bounce/713/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.3390093509162054, + "m_head": 1.7225915872812716, + "L_rod": 0.30255325685887535, + "g": 9.8, + "e_rest": 0.3784226709859981, + "mu": 0.2464583277544317, + "Xc0": 0.0, + "Yc0": 1.580582903233124, + "theta0": 0.5377576436780478, + "Vx0": 4.534184284446901, + "Vy0": 5.515092399759564, + "omega0": 5.576786194756317 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/713/simulation_code.py b/scipy/hammer_projectile_bounce/713/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..51b90f012537d7305dfe56e86fbc8fd0d57a61f5 --- /dev/null +++ b/scipy/hammer_projectile_bounce/713/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.3390093509162054 +m_head = 1.7225915872812716 +L_rod = 0.30255325685887535 +g = 9.8 +e_rest = 0.3784226709859981 +mu = 0.2464583277544317 +Xc0 = 0.0 +Yc0 = 1.580582903233124 +theta0 = 0.5377576436780478 +Vx0 = 4.534184284446901 +Vy0 = 5.515092399759564 +omega0 = 5.576786194756317 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/713/video.mp4 b/scipy/hammer_projectile_bounce/713/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ff2b2ff08d222179bf3a8b8d35d0954f249b505d --- /dev/null +++ b/scipy/hammer_projectile_bounce/713/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d3075a50e09cbe20d0deb0e78ded9834718409fbc21e99a7c5947b0e71423866 +size 5532 diff --git a/scipy/hammer_projectile_bounce/737/cot.json b/scipy/hammer_projectile_bounce/737/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e051aa54fca3012e4448c4db57c20b5b125fc040 --- /dev/null +++ b/scipy/hammer_projectile_bounce/737/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.477 kg, length L=0.442 m, with a heavy head m_head=1.390 kg at one end) is launched at v=(4.89, 6.60) m/s, angular velocity omega0=5.36 rad/s, and bounces on the floor with e=0.434, mu=0.246.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 1.8672 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3859 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.025175 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 1.867196, + "x_com_m": 0.385886, + "I_com_kg_m2": 0.025175, + "T_rotation_initial_s": 1.1726 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.4773328238456156, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.389863427098354, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.4424386581557553, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4336972087762573, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.24552630134719672, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.5277785270092694, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.22025394318970257, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.888466772673565, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 6.596306617875908, + "unit": "", + "description": "" + }, + "omega0": { + "value": 5.358318436575004, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/737/params.json b/scipy/hammer_projectile_bounce/737/params.json new file mode 100644 index 0000000000000000000000000000000000000000..b9624c00d11732c34841d36f0ef2cde98135512d --- /dev/null +++ b/scipy/hammer_projectile_bounce/737/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.4773328238456156, + "m_head": 1.389863427098354, + "L_rod": 0.4424386581557553, + "g": 9.8, + "e_rest": 0.4336972087762573, + "mu": 0.24552630134719672, + "Xc0": 0.0, + "Yc0": 1.5277785270092694, + "theta0": 0.22025394318970257, + "Vx0": 4.888466772673565, + "Vy0": 6.596306617875908, + "omega0": 5.358318436575004 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/737/simulation_code.py b/scipy/hammer_projectile_bounce/737/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4c04391823da7638daee06575eb679a48f31b7ec --- /dev/null +++ b/scipy/hammer_projectile_bounce/737/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.4773328238456156 +m_head = 1.389863427098354 +L_rod = 0.4424386581557553 +g = 9.8 +e_rest = 0.4336972087762573 +mu = 0.24552630134719672 +Xc0 = 0.0 +Yc0 = 1.5277785270092694 +theta0 = 0.22025394318970257 +Vx0 = 4.888466772673565 +Vy0 = 6.596306617875908 +omega0 = 5.358318436575004 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/737/video.mp4 b/scipy/hammer_projectile_bounce/737/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..5956a2e0fa1df533090acbfd32ac3f4e7e4b5f14 --- /dev/null +++ b/scipy/hammer_projectile_bounce/737/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84e25a7aef4f6f83ddd03c4087157a048daf1282128ba58f976508897e66d9da +size 6450 diff --git a/scipy/hammer_projectile_bounce/868/cot.json b/scipy/hammer_projectile_bounce/868/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..4e9db5b1376b48547c26637c1bb26e19597587a4 --- /dev/null +++ b/scipy/hammer_projectile_bounce/868/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.232 kg, length L=0.381 m, with a heavy head m_head=1.976 kg at one end) is launched at v=(5.35, 5.97) m/s, angular velocity omega0=4.17 rad/s, and bounces on the floor with e=0.470, mu=0.228.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 2.2076 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3609 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.010330 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 2.207634, + "x_com_m": 0.360863, + "I_com_kg_m2": 0.01033, + "T_rotation_initial_s": 1.507 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.23190795911723772, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.9757263194830976, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.38086780536209974, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.4703539776860947, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.2277145124497103, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.7364699690597507, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.3098308822143356, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 5.351707419867292, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 5.965244993262854, + "unit": "", + "description": "" + }, + "omega0": { + "value": 4.169297136264113, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/868/params.json b/scipy/hammer_projectile_bounce/868/params.json new file mode 100644 index 0000000000000000000000000000000000000000..2774505e48b4aa2f30bce33a385a92206c2d4c31 --- /dev/null +++ b/scipy/hammer_projectile_bounce/868/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.23190795911723772, + "m_head": 1.9757263194830976, + "L_rod": 0.38086780536209974, + "g": 9.8, + "e_rest": 0.4703539776860947, + "mu": 0.2277145124497103, + "Xc0": 0.0, + "Yc0": 1.7364699690597507, + "theta0": 0.3098308822143356, + "Vx0": 5.351707419867292, + "Vy0": 5.965244993262854, + "omega0": 4.169297136264113 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/868/simulation_code.py b/scipy/hammer_projectile_bounce/868/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..eaf74e29ada3ab2bfd286ba717c89ccd68e4b894 --- /dev/null +++ b/scipy/hammer_projectile_bounce/868/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.23190795911723772 +m_head = 1.9757263194830976 +L_rod = 0.38086780536209974 +g = 9.8 +e_rest = 0.4703539776860947 +mu = 0.2277145124497103 +Xc0 = 0.0 +Yc0 = 1.7364699690597507 +theta0 = 0.3098308822143356 +Vx0 = 5.351707419867292 +Vy0 = 5.965244993262854 +omega0 = 4.169297136264113 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/868/video.mp4 b/scipy/hammer_projectile_bounce/868/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..020fa9c7dc29a851ff2dd51bb3811cdf3d10bd0a --- /dev/null +++ b/scipy/hammer_projectile_bounce/868/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7e21ca1ceea328f5229018eb877fd70551d4b38a7b2f8cec5ac558844d50b34 +size 6043 diff --git a/scipy/hammer_projectile_bounce/921/cot.json b/scipy/hammer_projectile_bounce/921/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..93a1e17c8a964afaac78db1698dbbfc30571d7c6 --- /dev/null +++ b/scipy/hammer_projectile_bounce/921/cot.json @@ -0,0 +1,114 @@ +{ + "simulation": "hammer_projectile_bounce", + "physical_observation": "A 'hammer' (rod m_rod=0.345 kg, length L=0.410 m, with a heavy head m_head=1.578 kg at one end) is launched at v=(4.28, 7.40) m/s, angular velocity omega0=4.35 rad/s, and bounces on the floor with e=0.481, mu=0.268.", + "physical_law": { + "name": "Newton-Euler equations + impulsive endpoint contacts (Newton restitution + Coulomb friction)", + "statement": "Free flight: F=M a, no torque so omega is constant. At endpoint contact: decoupled normal and tangential impulses with cone clamp.", + "formula": "Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(-v_p_x/(1/M + ry^2/I_com), -mu Jn, +mu Jn)" + }, + "ode_system": { + "state_variables": [ + "X_com, Y_com, theta", + "V_x, V_y, omega" + ], + "equations_latex": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com \\sin theta = 0; head at Y_com + (L_rod-x_com) \\sin theta = 0." + ], + "equations_python": [ + "Free flight: X''=0, Y''=-g, theta''=0.", + "Endpoint contact events: tail at Y_com - x_com np.sin theta = 0; head at Y_com + (L_rod-x_com) * np.sin theta = 0." + ] + }, + "derivation_steps": [ + "Total mass M = m_rod + m_head = 1.9231 kg.", + "COM offset from tail: x_com = (m_rod L/2 + m_head L)/M = 0.3731 m.", + "Moment of inertia about COM (parallel axis on the rod + point head): I_com = 0.016739 kg \\cdot m^2.", + "Free flight has no torque about COM (gravity acts at COM): theta''=0; X''=0; Y''=-g.", + "At an endpoint contact, contact-point velocity v_p = (Vx - ry omega, Vy + rx omega).", + "Decoupled impulse: Jn = -(1+e) v_p_y/(1/M + rx^2/I_com); Jt = clip(stick value, -mu Jn, mu Jn).", + "Apply Delta V_x = Jt/M, Delta V_y = Jn/M, Delta omega = (rx Jn - ry Jt)/I_com.", + "Iterate over both endpoints (up to 8 passes) to handle simultaneous contacts." + ], + "physical_constants_derived": { + "M_total_kg": 1.923114, + "x_com_m": 0.373051, + "I_com_kg_m2": 0.016739, + "T_rotation_initial_s": 1.4455 + }, + "numerical_method": { + "solver": "RK45 with terminal endpoint events; iterative impulse solver at contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Standard rigid-body Newton-Euler + impulsive contact mechanics.", + "energy_check": "KE strictly decreases at each impulse for e<1; rest detection for chatter.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Tumbling rod-with-head bounces on the floor; the head end carries most of the inertia.", + "After several impacts, the body settles to rest flat on the floor." + ], + "parameters": { + "m_rod": { + "value": 0.3454688006205137, + "unit": "", + "description": "" + }, + "m_head": { + "value": 1.5776454743502424, + "unit": "", + "description": "" + }, + "L_rod": { + "value": 0.40986496384345145, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "e_rest": { + "value": 0.48096085163472657, + "unit": "", + "description": "" + }, + "mu": { + "value": 0.26847706325222265, + "unit": "", + "description": "" + }, + "Xc0": { + "value": 0.0, + "unit": "", + "description": "" + }, + "Yc0": { + "value": 1.2272649837260636, + "unit": "", + "description": "" + }, + "theta0": { + "value": 0.22890532783502288, + "unit": "", + "description": "" + }, + "Vx0": { + "value": 4.2812428155711455, + "unit": "", + "description": "" + }, + "Vy0": { + "value": 7.398067938944385, + "unit": "", + "description": "" + }, + "omega0": { + "value": 4.346671350931482, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hammer_projectile_bounce/921/params.json b/scipy/hammer_projectile_bounce/921/params.json new file mode 100644 index 0000000000000000000000000000000000000000..42a10db5c9f9837bfb33edde10bf827105111d29 --- /dev/null +++ b/scipy/hammer_projectile_bounce/921/params.json @@ -0,0 +1,14 @@ +{ + "m_rod": 0.3454688006205137, + "m_head": 1.5776454743502424, + "L_rod": 0.40986496384345145, + "g": 9.8, + "e_rest": 0.48096085163472657, + "mu": 0.26847706325222265, + "Xc0": 0.0, + "Yc0": 1.2272649837260636, + "theta0": 0.22890532783502288, + "Vx0": 4.2812428155711455, + "Vy0": 7.398067938944385, + "omega0": 4.346671350931482 +} \ No newline at end of file diff --git a/scipy/hammer_projectile_bounce/921/simulation_code.py b/scipy/hammer_projectile_bounce/921/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c60ce7763086b1e89e46a79dda1f9068fcba38c8 --- /dev/null +++ b/scipy/hammer_projectile_bounce/921/simulation_code.py @@ -0,0 +1,144 @@ +"""Hammer projectile bounce standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from matplotlib.patches import Circle + +m_rod = 0.3454688006205137 +m_head = 1.5776454743502424 +L_rod = 0.40986496384345145 +g = 9.8 +e_rest = 0.48096085163472657 +mu = 0.26847706325222265 +Xc0 = 0.0 +Yc0 = 1.2272649837260636 +theta0 = 0.22890532783502288 +Vx0 = 4.2812428155711455 +Vy0 = 7.398067938944385 +omega0 = 4.346671350931482 +duration = 12 +fps = 30 + +M = m_rod + m_head +x_com = (m_rod*L_rod/2.0 + m_head*L_rod)/M +d_tail = x_com; d_head = L_rod - x_com +I_com = (m_rod*L_rod**2/12.0 + + m_rod*(L_rod/2.0 - x_com)**2 + + m_head*(L_rod - x_com)**2) + +def free_flight(t, y): return [y[3], y[4], y[5], 0.0, -g, 0.0] +def ev_tail(t, y): return y[1] - x_com*np.sin(y[2]) +ev_tail.terminal = True; ev_tail.direction = -1 +def ev_head(t, y): return y[1] + (L_rod - x_com)*np.sin(y[2]) +ev_head.terminal = True; ev_head.direction = -1 + +def contact_step(state): + s = state.copy() + for _ in range(8): + any_imp = False + for sgn, dist in ((-1.0, d_tail), (+1.0, d_head)): + xc, yc, th, vx, vy, om = s + rx = sgn*dist*np.cos(th); ry = sgn*dist*np.sin(th) + ey = yc + ry + vp_y = vy + rx*om + if ey > 1e-9 or vp_y > -1e-12: continue + vp_x = vx - ry*om + Jn = -(1.0+e_rest)*vp_y / (1.0/M + rx*rx/I_com) + Jt_s = -vp_x / (1.0/M + ry*ry/I_com) + mt = mu*Jn + Jt = max(-mt, min(mt, Jt_s)) + s[3] = vx + Jt/M + s[4] = vy + Jn/M + s[5] = om + (rx*Jn - ry*Jt)/I_com + any_imp = True + if not any_imp: break + th_f = s[2] + tail_y = s[1] - x_com*np.sin(th_f) + head_y = s[1] + (L_rod - x_com)*np.sin(th_f) + lower_y = min(tail_y, head_y) + if lower_y < 0.0: s[1] -= lower_y + return s + +t_eval = np.linspace(0, duration, int(duration*fps)+1) +xc_arr = np.zeros_like(t_eval); yc_arr = np.zeros_like(t_eval); th_arr = np.zeros_like(t_eval) +state = np.array([Xc0, Yc0, theta0, Vx0, Vy0, omega0], dtype=float) +xc_arr[0], yc_arr[0], th_arr[0] = state[0], state[1], state[2] +last_idx = 1; t_cur = 0.0 +settled = False; short_seg_count = 0 + +for _seg in range(2000): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(free_flight, (t_cur, duration), state, + events=[ev_tail, ev_head], dense_output=True, + max_step=0.02, rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + while last_idx < len(t_eval) and t_eval[last_idx] <= seg_end + 1e-12: + st = sol.sol(t_eval[last_idx]) + xc_arr[last_idx], yc_arr[last_idx], th_arr[last_idx] = st[0], st[1], st[2] + last_idx += 1 + state = sol.y[:, -1].copy() + seg_dt = seg_end - t_cur; t_cur = seg_end + if sol.status != 1: break + state = contact_step(state) + KE = 0.5*M*(state[3]**2 + state[4]**2) + 0.5*I_com*state[5]**2 + tail_y = state[1] - x_com*np.sin(state[2]) + head_y = state[1] + (L_rod - x_com)*np.sin(state[2]) + lower_y = min(tail_y, head_y) + if seg_dt < 1e-3: short_seg_count += 1 + else: short_seg_count = 0 + if KE < 0.05 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + if short_seg_count > 25 and lower_y < 0.05: + th_rest = round(state[2]/np.pi)*np.pi + state = np.array([state[0], 0.0, th_rest, 0.0, 0.0, 0.0]) + settled = True; break + +if last_idx < len(t_eval): + xc_arr[last_idx:] = state[0] + yc_arr[last_idx:] = state[1] + th_arr[last_idx:] = state[2] + +xs_tail = xc_arr - x_com*np.cos(th_arr) +ys_tail = yc_arr - x_com*np.sin(th_arr) +xs_head = xc_arr + (L_rod - x_com)*np.cos(th_arr) +ys_head = yc_arr + (L_rod - x_com)*np.sin(th_arr) + +fig_w, fig_h = 9, 5 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.30, 0.30 +y_lo = -0.30 +x_lo_d = min(xs_tail.min(), xs_head.min()) - xpad +x_hi_d = max(xs_tail.max(), xs_head.max()) + xpad +y_hi_d = max(ys_tail.max(), ys_head.max(), yc_arr.max()) + ypad +dx, dy = x_hi_d-x_lo_d, y_hi_d-y_lo +if dx/dy < fig_aspect: + extra = (fig_aspect*dy - dx)/2.0 + x_lo, x_hi, y_hi = x_lo_d-extra, x_hi_d+extra, y_hi_d +else: + extra = dx/fig_aspect - dy + x_lo, x_hi, y_hi = x_lo_d, x_hi_d, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2, zorder=1) +rod_ln, = ax.plot([],[],"-", color="#a8dadc", lw=4, solid_capstyle="round", zorder=3) +head_patch = Circle((xs_head[0], ys_head[0]), 0.05, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(head_patch) + +def update(f): + rod_ln.set_data([xs_tail[f], xs_head[f]],[ys_tail[f], ys_head[f]]) + head_patch.center = (xs_head[f], ys_head[f]) + return rod_ln, head_patch + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hammer_projectile_bounce/921/video.mp4 b/scipy/hammer_projectile_bounce/921/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3f1701c932fd162dd851b6626f6cb676dbbd40f4 --- /dev/null +++ b/scipy/hammer_projectile_bounce/921/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:762652e2dd3192db43cb49f59acaa79ee5cb8804627f9a3ac7705cf7a576ba67 +size 6627 diff --git a/scipy/hemisphere_roll_off/000/cot.json b/scipy/hemisphere_roll_off/000/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..47a890be83011c6c83dfd4d8f44c2a03b0795df4 --- /dev/null +++ b/scipy/hemisphere_roll_off/000/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.360 m) starts near the top of a fixed hemisphere (radius R=1.583 m) at angle theta_0=0.025 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.3465 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 1.5828856342545476, + "unit": "", + "description": "" + }, + "r": { + "value": 0.3597748246685971, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.0250601782509249, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.44498729517673175, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.4235968519284043, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.08924554069420247, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/000/params.json b/scipy/hemisphere_roll_off/000/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c565790913e18df957980a9cd5224fcf72858f52 --- /dev/null +++ b/scipy/hemisphere_roll_off/000/params.json @@ -0,0 +1,9 @@ +{ + "R": 1.5828856342545476, + "r": 0.3597748246685971, + "g": 9.8, + "theta_0": 0.0250601782509249, + "e_g": 0.44498729517673175, + "mu_g": 0.4235968519284043, + "mu_r": 0.08924554069420247 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/000/simulation_code.py b/scipy/hemisphere_roll_off/000/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..32f0da8352ea047832dad4d5845aa81612427e1d --- /dev/null +++ b/scipy/hemisphere_roll_off/000/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 1.5828856342545476 +r = 0.3597748246685971 +g = 9.8 +theta_0 = 0.0250601782509249 +e_g = 0.44498729517673175 +mu_g = 0.4235968519284043 +mu_r = 0.08924554069420247 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/000/video.mp4 b/scipy/hemisphere_roll_off/000/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..74b55e631dda18da684b6d3d48d2b90b551b709d --- /dev/null +++ b/scipy/hemisphere_roll_off/000/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b7d03c40da6fd9f95aad2a3bfce49aeee81f300aa4cfd4f405776e57d197b9f +size 14304 diff --git a/scipy/hemisphere_roll_off/130/cot.json b/scipy/hemisphere_roll_off/130/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..49622ec16d74d1b4011968f1956caa551d6dc139 --- /dev/null +++ b/scipy/hemisphere_roll_off/130/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.358 m) starts near the top of a fixed hemisphere (radius R=1.821 m) at angle theta_0=0.054 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.5438 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 1.8209535979498375, + "unit": "", + "description": "" + }, + "r": { + "value": 0.35760151820895847, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.05397078316757713, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.48243435485844854, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.43421247860924145, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.0806344657214477, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/130/params.json b/scipy/hemisphere_roll_off/130/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e5f49a5612a80e57fa2eaf1c17f7ff08bc072fc0 --- /dev/null +++ b/scipy/hemisphere_roll_off/130/params.json @@ -0,0 +1,9 @@ +{ + "R": 1.8209535979498375, + "r": 0.35760151820895847, + "g": 9.8, + "theta_0": 0.05397078316757713, + "e_g": 0.48243435485844854, + "mu_g": 0.43421247860924145, + "mu_r": 0.0806344657214477 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/130/simulation_code.py b/scipy/hemisphere_roll_off/130/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..2875f1013db7c4fdf93c3e5c314e4c8a1c78f62d --- /dev/null +++ b/scipy/hemisphere_roll_off/130/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 1.8209535979498375 +r = 0.35760151820895847 +g = 9.8 +theta_0 = 0.05397078316757713 +e_g = 0.48243435485844854 +mu_g = 0.43421247860924145 +mu_r = 0.0806344657214477 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/130/video.mp4 b/scipy/hemisphere_roll_off/130/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3580003e4c54012458a180304289a79a41ba6731 --- /dev/null +++ b/scipy/hemisphere_roll_off/130/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91a9914ed2457c7f9252d955df13d3de3ba6ab4a037c8b668e890beb80731b50 +size 13781 diff --git a/scipy/hemisphere_roll_off/178/cot.json b/scipy/hemisphere_roll_off/178/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f2debd4c2bb38d41142884c692ded2f17d31bf53 --- /dev/null +++ b/scipy/hemisphere_roll_off/178/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.234 m) starts near the top of a fixed hemisphere (radius R=2.186 m) at angle theta_0=0.024 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.7356 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 2.186272138890076, + "unit": "", + "description": "" + }, + "r": { + "value": 0.23441989669230556, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.02393919981067242, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.44319766792582493, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.5996132912988053, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.14812605726214215, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/178/params.json b/scipy/hemisphere_roll_off/178/params.json new file mode 100644 index 0000000000000000000000000000000000000000..21b1c3e20643cfd36d73836726578a99d12086e1 --- /dev/null +++ b/scipy/hemisphere_roll_off/178/params.json @@ -0,0 +1,9 @@ +{ + "R": 2.186272138890076, + "r": 0.23441989669230556, + "g": 9.8, + "theta_0": 0.02393919981067242, + "e_g": 0.44319766792582493, + "mu_g": 0.5996132912988053, + "mu_r": 0.14812605726214215 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/178/simulation_code.py b/scipy/hemisphere_roll_off/178/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d6e913e6713c15dde417f1f79370687214d687b6 --- /dev/null +++ b/scipy/hemisphere_roll_off/178/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 2.186272138890076 +r = 0.23441989669230556 +g = 9.8 +theta_0 = 0.02393919981067242 +e_g = 0.44319766792582493 +mu_g = 0.5996132912988053 +mu_r = 0.14812605726214215 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/178/video.mp4 b/scipy/hemisphere_roll_off/178/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f2ec2bc6da157e4bdde5d6680ecd62df03e114ef --- /dev/null +++ b/scipy/hemisphere_roll_off/178/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02dc0cc965625122fe58263af7d2e5419cf3a87199aa38db02bf98e0721428c2 +size 11872 diff --git a/scipy/hemisphere_roll_off/196/cot.json b/scipy/hemisphere_roll_off/196/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..bc6300502bb35fcabf822dae8e2b0b19eadbe5de --- /dev/null +++ b/scipy/hemisphere_roll_off/196/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.315 m) starts near the top of a fixed hemisphere (radius R=2.970 m) at angle theta_0=0.047 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 4.3513 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 2.969731577190749, + "unit": "", + "description": "" + }, + "r": { + "value": 0.3147463913879074, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.046552975288641316, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.40031484563580244, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.3248979193260718, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.18730358317953605, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/196/params.json b/scipy/hemisphere_roll_off/196/params.json new file mode 100644 index 0000000000000000000000000000000000000000..a1865e614c91056088b1b1e73368c8081843c2a8 --- /dev/null +++ b/scipy/hemisphere_roll_off/196/params.json @@ -0,0 +1,9 @@ +{ + "R": 2.969731577190749, + "r": 0.3147463913879074, + "g": 9.8, + "theta_0": 0.046552975288641316, + "e_g": 0.40031484563580244, + "mu_g": 0.3248979193260718, + "mu_r": 0.18730358317953605 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/196/simulation_code.py b/scipy/hemisphere_roll_off/196/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3ef4f2f6f0d03cbd337582b1cdca87dffe59710d --- /dev/null +++ b/scipy/hemisphere_roll_off/196/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 2.969731577190749 +r = 0.3147463913879074 +g = 9.8 +theta_0 = 0.046552975288641316 +e_g = 0.40031484563580244 +mu_g = 0.3248979193260718 +mu_r = 0.18730358317953605 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/196/video.mp4 b/scipy/hemisphere_roll_off/196/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..44c5e3cabc6bba36eb31700124bde693cd9bbf97 --- /dev/null +++ b/scipy/hemisphere_roll_off/196/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97cc09f56fa71f3ccd2428124d2b18d61c92d44d8edeb38c9617d9ae992018c4 +size 12133 diff --git a/scipy/hemisphere_roll_off/215/cot.json b/scipy/hemisphere_roll_off/215/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..79f2a7b5e934c627db7de48b11c2a725ce9e175a --- /dev/null +++ b/scipy/hemisphere_roll_off/215/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.219 m) starts near the top of a fixed hemisphere (radius R=1.620 m) at angle theta_0=0.026 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.2554 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 1.619765155936039, + "unit": "", + "description": "" + }, + "r": { + "value": 0.2186085712396895, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.02607218426672405, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.38269612148618315, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.5939651551313001, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.17305010300576232, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/215/params.json b/scipy/hemisphere_roll_off/215/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ebc92d8dfe73695f303daf1865fa625a76ebb247 --- /dev/null +++ b/scipy/hemisphere_roll_off/215/params.json @@ -0,0 +1,9 @@ +{ + "R": 1.619765155936039, + "r": 0.2186085712396895, + "g": 9.8, + "theta_0": 0.02607218426672405, + "e_g": 0.38269612148618315, + "mu_g": 0.5939651551313001, + "mu_r": 0.17305010300576232 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/215/simulation_code.py b/scipy/hemisphere_roll_off/215/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..3558c0a949ea6de022812088be1b14a649570a55 --- /dev/null +++ b/scipy/hemisphere_roll_off/215/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 1.619765155936039 +r = 0.2186085712396895 +g = 9.8 +theta_0 = 0.02607218426672405 +e_g = 0.38269612148618315 +mu_g = 0.5939651551313001 +mu_r = 0.17305010300576232 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/215/video.mp4 b/scipy/hemisphere_roll_off/215/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6c52823cdddd780cf7cf760971b5547d200b959d --- /dev/null +++ b/scipy/hemisphere_roll_off/215/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b64a10a08478eb586a6934ddb976697d5d08fbaece828a2cd4f5ed763443ecd +size 12015 diff --git a/scipy/hemisphere_roll_off/293/cot.json b/scipy/hemisphere_roll_off/293/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..51be9e633e7965add3b4f051364a9f8e99ca7c54 --- /dev/null +++ b/scipy/hemisphere_roll_off/293/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.381 m) starts near the top of a fixed hemisphere (radius R=2.809 m) at angle theta_0=0.055 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 4.2883 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 2.8092881084654957, + "unit": "", + "description": "" + }, + "r": { + "value": 0.3807950274117913, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.05547107750242308, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.40045969094356315, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.5890186498372605, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.09165544550302422, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/293/params.json b/scipy/hemisphere_roll_off/293/params.json new file mode 100644 index 0000000000000000000000000000000000000000..3263b19ff393d0a67ddda09674c405283f890fed --- /dev/null +++ b/scipy/hemisphere_roll_off/293/params.json @@ -0,0 +1,9 @@ +{ + "R": 2.8092881084654957, + "r": 0.3807950274117913, + "g": 9.8, + "theta_0": 0.05547107750242308, + "e_g": 0.40045969094356315, + "mu_g": 0.5890186498372605, + "mu_r": 0.09165544550302422 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/293/simulation_code.py b/scipy/hemisphere_roll_off/293/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4f9b75ef57cab1d907191018199558e24a3389fd --- /dev/null +++ b/scipy/hemisphere_roll_off/293/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 2.8092881084654957 +r = 0.3807950274117913 +g = 9.8 +theta_0 = 0.05547107750242308 +e_g = 0.40045969094356315 +mu_g = 0.5890186498372605 +mu_r = 0.09165544550302422 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/293/video.mp4 b/scipy/hemisphere_roll_off/293/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..1ccbcffa41303cf47b06e10766375ca8f0e3db66 --- /dev/null +++ b/scipy/hemisphere_roll_off/293/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9507329c497633de00840fdb9be2f57f5fccd6517db9306e5289f424f1a266e +size 13403 diff --git a/scipy/hemisphere_roll_off/302/cot.json b/scipy/hemisphere_roll_off/302/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0548eea7a3f28b83ecce77525e8a9d4c97bc1f43 --- /dev/null +++ b/scipy/hemisphere_roll_off/302/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.305 m) starts near the top of a fixed hemisphere (radius R=1.520 m) at angle theta_0=0.052 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.2439 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 1.519928390264396, + "unit": "", + "description": "" + }, + "r": { + "value": 0.3054797776240179, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.05161509497540907, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.4926852600728731, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.43274868106622116, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.1950957791407011, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/302/params.json b/scipy/hemisphere_roll_off/302/params.json new file mode 100644 index 0000000000000000000000000000000000000000..da6392893a5fb05fe62562b82c3d42f686eb283a --- /dev/null +++ b/scipy/hemisphere_roll_off/302/params.json @@ -0,0 +1,9 @@ +{ + "R": 1.519928390264396, + "r": 0.3054797776240179, + "g": 9.8, + "theta_0": 0.05161509497540907, + "e_g": 0.4926852600728731, + "mu_g": 0.43274868106622116, + "mu_r": 0.1950957791407011 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/302/simulation_code.py b/scipy/hemisphere_roll_off/302/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..c8fe858a964f63b8c5b05389588937de6070df58 --- /dev/null +++ b/scipy/hemisphere_roll_off/302/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 1.519928390264396 +r = 0.3054797776240179 +g = 9.8 +theta_0 = 0.05161509497540907 +e_g = 0.4926852600728731 +mu_g = 0.43274868106622116 +mu_r = 0.1950957791407011 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/302/video.mp4 b/scipy/hemisphere_roll_off/302/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..32b73e35605e8cde118ffc99218b5001f25990ac --- /dev/null +++ b/scipy/hemisphere_roll_off/302/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8dff7c55545ee2ffc12b22144eea5376695f9a838e16d71a007cda0c8413c5b6 +size 13181 diff --git a/scipy/hemisphere_roll_off/308/cot.json b/scipy/hemisphere_roll_off/308/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..00b15aea7fde7ad2f37af4b31e9fc62974696ef2 --- /dev/null +++ b/scipy/hemisphere_roll_off/308/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.343 m) starts near the top of a fixed hemisphere (radius R=2.681 m) at angle theta_0=0.038 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 4.1752 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 2.6809609222108, + "unit": "", + "description": "" + }, + "r": { + "value": 0.343062643185178, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.037826567222749435, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.5250992209845163, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.5501356966011202, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.1627701021569054, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/308/params.json b/scipy/hemisphere_roll_off/308/params.json new file mode 100644 index 0000000000000000000000000000000000000000..5ad838e4ae70db47a1c0b2f56251390fda5ba231 --- /dev/null +++ b/scipy/hemisphere_roll_off/308/params.json @@ -0,0 +1,9 @@ +{ + "R": 2.6809609222108, + "r": 0.343062643185178, + "g": 9.8, + "theta_0": 0.037826567222749435, + "e_g": 0.5250992209845163, + "mu_g": 0.5501356966011202, + "mu_r": 0.1627701021569054 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/308/simulation_code.py b/scipy/hemisphere_roll_off/308/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..07bc0e381aa7434f2b50b873cf287688d63d36c2 --- /dev/null +++ b/scipy/hemisphere_roll_off/308/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 2.6809609222108 +r = 0.343062643185178 +g = 9.8 +theta_0 = 0.037826567222749435 +e_g = 0.5250992209845163 +mu_g = 0.5501356966011202 +mu_r = 0.1627701021569054 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/308/video.mp4 b/scipy/hemisphere_roll_off/308/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a6ab0b881ac9719b0c94ee58742187783d5d0a13 --- /dev/null +++ b/scipy/hemisphere_roll_off/308/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:249740b2617c6861de58038550ab2a862f6244a7c213c455c9c45d17814bc8f9 +size 12847 diff --git a/scipy/hemisphere_roll_off/311/cot.json b/scipy/hemisphere_roll_off/311/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..597b48ee4e055c346db970ee33e60525b466f8d4 --- /dev/null +++ b/scipy/hemisphere_roll_off/311/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.282 m) starts near the top of a fixed hemisphere (radius R=1.729 m) at angle theta_0=0.029 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.4046 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 1.7287298895007932, + "unit": "", + "description": "" + }, + "r": { + "value": 0.2820180617070053, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.029271157311934158, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.597508126851092, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.3491038350965305, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.16255471791423776, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/311/params.json b/scipy/hemisphere_roll_off/311/params.json new file mode 100644 index 0000000000000000000000000000000000000000..68ee6385abbef8440b4a3e2892b6c001dda497e9 --- /dev/null +++ b/scipy/hemisphere_roll_off/311/params.json @@ -0,0 +1,9 @@ +{ + "R": 1.7287298895007932, + "r": 0.2820180617070053, + "g": 9.8, + "theta_0": 0.029271157311934158, + "e_g": 0.597508126851092, + "mu_g": 0.3491038350965305, + "mu_r": 0.16255471791423776 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/311/simulation_code.py b/scipy/hemisphere_roll_off/311/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..7645b98e368c18cb258f8380d577abbeb7349749 --- /dev/null +++ b/scipy/hemisphere_roll_off/311/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 1.7287298895007932 +r = 0.2820180617070053 +g = 9.8 +theta_0 = 0.029271157311934158 +e_g = 0.597508126851092 +mu_g = 0.3491038350965305 +mu_r = 0.16255471791423776 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/311/video.mp4 b/scipy/hemisphere_roll_off/311/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c92648f937d9f6f28abd561c258277904ddba982 --- /dev/null +++ b/scipy/hemisphere_roll_off/311/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:80a8dbc45a8d687ece08887a5c2873367330bb7a0aae044b159dd2fab185a3e4 +size 12979 diff --git a/scipy/hemisphere_roll_off/388/cot.json b/scipy/hemisphere_roll_off/388/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..099edc442efcec33a1311cf6909afcffc2a1b25e --- /dev/null +++ b/scipy/hemisphere_roll_off/388/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.343 m) starts near the top of a fixed hemisphere (radius R=2.779 m) at angle theta_0=0.056 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 4.2421 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 2.7789902066002057, + "unit": "", + "description": "" + }, + "r": { + "value": 0.34263547605658484, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.056369770643484626, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.31542040279215194, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.3465752665199586, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.13227090029750044, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/388/params.json b/scipy/hemisphere_roll_off/388/params.json new file mode 100644 index 0000000000000000000000000000000000000000..b9cbf000c963ab9a54db462bde3fe3247f7f36fe --- /dev/null +++ b/scipy/hemisphere_roll_off/388/params.json @@ -0,0 +1,9 @@ +{ + "R": 2.7789902066002057, + "r": 0.34263547605658484, + "g": 9.8, + "theta_0": 0.056369770643484626, + "e_g": 0.31542040279215194, + "mu_g": 0.3465752665199586, + "mu_r": 0.13227090029750044 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/388/simulation_code.py b/scipy/hemisphere_roll_off/388/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..8c5538b92cc89d1b8a347bcb956fd5a89febbccd --- /dev/null +++ b/scipy/hemisphere_roll_off/388/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 2.7789902066002057 +r = 0.34263547605658484 +g = 9.8 +theta_0 = 0.056369770643484626 +e_g = 0.31542040279215194 +mu_g = 0.3465752665199586 +mu_r = 0.13227090029750044 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/388/video.mp4 b/scipy/hemisphere_roll_off/388/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..8505a1eb6e9a6976dd65ae3de260939d18454d6b --- /dev/null +++ b/scipy/hemisphere_roll_off/388/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d23e6ab6e38536acd9832b87370e26a8655e59c2905d7accdc7f27b98503f702 +size 12875 diff --git a/scipy/hemisphere_roll_off/415/cot.json b/scipy/hemisphere_roll_off/415/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..96404689e0213abc2c089c7960621569545081f2 --- /dev/null +++ b/scipy/hemisphere_roll_off/415/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.216 m) starts near the top of a fixed hemisphere (radius R=1.595 m) at angle theta_0=0.034 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.2312 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 1.5953834197716343, + "unit": "", + "description": "" + }, + "r": { + "value": 0.21573501081757926, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.034194252959521255, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.565062993030047, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.5288801759163041, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.13504230485608185, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/415/params.json b/scipy/hemisphere_roll_off/415/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e0cbf6491be047fafc0caa4e47c6e0cf6be69659 --- /dev/null +++ b/scipy/hemisphere_roll_off/415/params.json @@ -0,0 +1,9 @@ +{ + "R": 1.5953834197716343, + "r": 0.21573501081757926, + "g": 9.8, + "theta_0": 0.034194252959521255, + "e_g": 0.565062993030047, + "mu_g": 0.5288801759163041, + "mu_r": 0.13504230485608185 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/415/simulation_code.py b/scipy/hemisphere_roll_off/415/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f4503e61651f861eab91d9a4cb579887b9c6f09a --- /dev/null +++ b/scipy/hemisphere_roll_off/415/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 1.5953834197716343 +r = 0.21573501081757926 +g = 9.8 +theta_0 = 0.034194252959521255 +e_g = 0.565062993030047 +mu_g = 0.5288801759163041 +mu_r = 0.13504230485608185 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/415/video.mp4 b/scipy/hemisphere_roll_off/415/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..bb1e8cf7d120659d87bf3fb17e8b981ca29bdbbf --- /dev/null +++ b/scipy/hemisphere_roll_off/415/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6129883d400db3372c2728e1e8bffdba352ee3a2dada72e6827901ea3965daee +size 11408 diff --git a/scipy/hemisphere_roll_off/430/cot.json b/scipy/hemisphere_roll_off/430/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..0ad70f2f18b312b06b1d161410e387abe045fa92 --- /dev/null +++ b/scipy/hemisphere_roll_off/430/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.398 m) starts near the top of a fixed hemisphere (radius R=1.827 m) at angle theta_0=0.050 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.5813 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 1.8266615102626766, + "unit": "", + "description": "" + }, + "r": { + "value": 0.3982615318279912, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.05016635589080998, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.5946701347840425, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.33426317498404473, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.08652282017300315, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/430/params.json b/scipy/hemisphere_roll_off/430/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c01adf8bbf59fb00fe8348f4f4ea470b3be2da03 --- /dev/null +++ b/scipy/hemisphere_roll_off/430/params.json @@ -0,0 +1,9 @@ +{ + "R": 1.8266615102626766, + "r": 0.3982615318279912, + "g": 9.8, + "theta_0": 0.05016635589080998, + "e_g": 0.5946701347840425, + "mu_g": 0.33426317498404473, + "mu_r": 0.08652282017300315 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/430/simulation_code.py b/scipy/hemisphere_roll_off/430/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..f0232e0c85318cefbc1c8ef44951920c883feb68 --- /dev/null +++ b/scipy/hemisphere_roll_off/430/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 1.8266615102626766 +r = 0.3982615318279912 +g = 9.8 +theta_0 = 0.05016635589080998 +e_g = 0.5946701347840425 +mu_g = 0.33426317498404473 +mu_r = 0.08652282017300315 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/430/video.mp4 b/scipy/hemisphere_roll_off/430/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..462214c6bc28d3fce303f34760d5bc951be04143 --- /dev/null +++ b/scipy/hemisphere_roll_off/430/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:55ec56527389d6cd1c19d086a6319b5dce7714574ef772cf1dd79e354868717f +size 14213 diff --git a/scipy/hemisphere_roll_off/561/cot.json b/scipy/hemisphere_roll_off/561/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e272d6480ec9ecf2d20ff3cce2e00164b3ebd54c --- /dev/null +++ b/scipy/hemisphere_roll_off/561/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.253 m) starts near the top of a fixed hemisphere (radius R=2.774 m) at angle theta_0=0.045 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 4.1778 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 2.774490407827547, + "unit": "", + "description": "" + }, + "r": { + "value": 0.2532573269568078, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.04475270351231801, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.4918415907546192, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.5103078336333654, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.10772009233781438, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/561/params.json b/scipy/hemisphere_roll_off/561/params.json new file mode 100644 index 0000000000000000000000000000000000000000..e6c5f2159d6755d2f3782dc7f52e9ea7c175b790 --- /dev/null +++ b/scipy/hemisphere_roll_off/561/params.json @@ -0,0 +1,9 @@ +{ + "R": 2.774490407827547, + "r": 0.2532573269568078, + "g": 9.8, + "theta_0": 0.04475270351231801, + "e_g": 0.4918415907546192, + "mu_g": 0.5103078336333654, + "mu_r": 0.10772009233781438 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/561/simulation_code.py b/scipy/hemisphere_roll_off/561/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d59486fe4fa6e792c1dc3d1af00afdd86d14e82f --- /dev/null +++ b/scipy/hemisphere_roll_off/561/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 2.774490407827547 +r = 0.2532573269568078 +g = 9.8 +theta_0 = 0.04475270351231801 +e_g = 0.4918415907546192 +mu_g = 0.5103078336333654 +mu_r = 0.10772009233781438 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/561/video.mp4 b/scipy/hemisphere_roll_off/561/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f8e6b4f4ee759cb68f97503e575fdc04f80c6f7c --- /dev/null +++ b/scipy/hemisphere_roll_off/561/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43b6a4845d2c6701640ad2f34f7a708cc9f6b34e2abbed91357498a92a89be7f +size 11415 diff --git a/scipy/hemisphere_roll_off/567/cot.json b/scipy/hemisphere_roll_off/567/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..53896f3857a255a0de791d5b04f94adf78fb81a8 --- /dev/null +++ b/scipy/hemisphere_roll_off/567/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.353 m) starts near the top of a fixed hemisphere (radius R=2.428 m) at angle theta_0=0.042 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 4.0039 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 2.4276830087002974, + "unit": "", + "description": "" + }, + "r": { + "value": 0.3531904123327119, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.04221486594805768, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.44671289661272623, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.3853418404936671, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.104207653130548, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/567/params.json b/scipy/hemisphere_roll_off/567/params.json new file mode 100644 index 0000000000000000000000000000000000000000..59b36aa5b6bf08f74c1438e68db900f223d79cfe --- /dev/null +++ b/scipy/hemisphere_roll_off/567/params.json @@ -0,0 +1,9 @@ +{ + "R": 2.4276830087002974, + "r": 0.3531904123327119, + "g": 9.8, + "theta_0": 0.04221486594805768, + "e_g": 0.44671289661272623, + "mu_g": 0.3853418404936671, + "mu_r": 0.104207653130548 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/567/simulation_code.py b/scipy/hemisphere_roll_off/567/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..858b01d41c1e47bdbf886127dfcf17e4857dc604 --- /dev/null +++ b/scipy/hemisphere_roll_off/567/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 2.4276830087002974 +r = 0.3531904123327119 +g = 9.8 +theta_0 = 0.04221486594805768 +e_g = 0.44671289661272623 +mu_g = 0.3853418404936671 +mu_r = 0.104207653130548 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/567/video.mp4 b/scipy/hemisphere_roll_off/567/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..bcecc2d325d40b59e988a03b6f5b606e3905dc64 --- /dev/null +++ b/scipy/hemisphere_roll_off/567/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20e33e24bfd276105fd18b31820e72a83395e35974c0912cd7974592198041f7 +size 12833 diff --git a/scipy/hemisphere_roll_off/582/cot.json b/scipy/hemisphere_roll_off/582/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..cde234a6a06f1ac9f5c3c86032f5cb0b6e639fc8 --- /dev/null +++ b/scipy/hemisphere_roll_off/582/cot.json @@ -0,0 +1,92 @@ +{ + "simulation": "hemisphere_roll_off", + "physical_observation": "A small uniform solid sphere (radius r=0.266 m) starts near the top of a fixed hemisphere (radius R=1.646 m) at angle theta_0=0.020 rad and rolls without slipping until it loses contact at the textbook angle theta_c with \\cos theta_c = 10/17.", + "physical_law": { + "name": "Lagrangian mechanics with rolling constraint + Newton II for radial detachment + impulsive ground contact + rolling resistance.", + "statement": "Phase 1: rolling without slipping on the hemisphere. Phase 2: projectile flight after detachment. Phase 3: ground bounces with Newton+Coulomb. Phase 3b: rolling-resistance coast.", + "formula": "Phase 1 EOM: theta'' = (5g)/(7(R+r)) \\sin(theta); detachment when N=0 -> \\cos(theta_c) = 10/17." + }, + "ode_system": { + "state_variables": [ + "theta (polar from vertical)", + "theta'", + "x, y, vx, vy" + ], + "equations_latex": [ + "Phase 1: \\dot{theta} = omega; \\dot{omega} = (5g)/(7(R+r)) \\sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 (ground bounce): Jn=-(1+e_g)vy; Jt clipped to mu_g \\cdot Jn cone.", + "Phase 3b (rolling on the floor): vx decays at -mu_r \\cdot g until vx=0." + ], + "equations_python": [ + "Phase 1: theta_dot = omega; omega_dot = (5 * g)/(7 * (R+r)) * np.sin(theta).", + "Phase 2 (free flight): x''=0, y''=-g.", + "Phase 3 * (ground * bounce): Jn=-(1+e_g) *vy; Jt * clipped * to * mu_g * Jn * cone.", + "Phase 3 * b (rolling on the floor): vx decays at -mu_r * g until vx=0." + ] + }, + "derivation_steps": [ + "Rolling without slipping on the hemisphere: KE = (1/2)mv^2 + (1/2)I omega^2 with v=(R+r)theta_dot and omega=(R+r)/r theta_dot for a solid sphere I=(2/5)m r^2.", + "Total T = (7/10) m (R+r)^2 theta_dot^2; PE = m g (R+r) \\cos(theta).", + "Lagrange yields theta'' = (5g)/(7(R+r)) \\sin(theta).", + "Radial Newton's law: N = (m g/7)(17 \\cos theta - 10); zero at \\cos(theta_c) = 10/17 -> theta_c = 53.968 deg.", + "After detachment: projectile flight with initial position/velocity at the detachment angle.", + "Ground impact: decoupled normal/tangent impulse with cone clamp using effective tangential mass 2/(7m) for a solid sphere.", + "Once |vy_post| drops below threshold, switch to closed-form coast under -mu_r \\cdot g." + ], + "physical_constants_derived": { + "\\cos_theta_c": 0.5882, + "theta_c_deg": 53.968, + "v_at_detach_mps_approx": 3.3196 + }, + "numerical_method": { + "solver": "RK45 with terminal events for detachment and ground contact.", + "tolerance": "rtol=1e-9, atol=1e-11" + }, + "code_validation": { + "ode_source": "Lagrangian rolling + textbook detachment criterion + impulsive contact mechanics.", + "energy_check": "Phase 1 conserves energy; subsequent bounces dissipate via e_g and mu_g; final coast drains to zero via mu_r.", + "physical_plausibility": true + }, + "expected_behavior": [ + "Sphere accelerates down the hemisphere; detaches at theta_c~54.0 deg.", + "Lands and bounces a few times before coasting to rest under rolling resistance." + ], + "parameters": { + "R": { + "value": 1.6459901338881526, + "unit": "", + "description": "" + }, + "r": { + "value": 0.26555624704380454, + "unit": "", + "description": "" + }, + "g": { + "value": 9.8, + "unit": "", + "description": "" + }, + "theta_0": { + "value": 0.020102229263759434, + "unit": "", + "description": "" + }, + "e_g": { + "value": 0.48681861734444165, + "unit": "", + "description": "" + }, + "mu_g": { + "value": 0.44625212816851134, + "unit": "", + "description": "" + }, + "mu_r": { + "value": 0.10299644727826908, + "unit": "", + "description": "" + } + } +} diff --git a/scipy/hemisphere_roll_off/582/params.json b/scipy/hemisphere_roll_off/582/params.json new file mode 100644 index 0000000000000000000000000000000000000000..07e441be1c614761c83499802c05bc2a9c099bca --- /dev/null +++ b/scipy/hemisphere_roll_off/582/params.json @@ -0,0 +1,9 @@ +{ + "R": 1.6459901338881526, + "r": 0.26555624704380454, + "g": 9.8, + "theta_0": 0.020102229263759434, + "e_g": 0.48681861734444165, + "mu_g": 0.44625212816851134, + "mu_r": 0.10299644727826908 +} \ No newline at end of file diff --git a/scipy/hemisphere_roll_off/582/simulation_code.py b/scipy/hemisphere_roll_off/582/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..a2e650fe01a15fcb964f5eff5645599c1f8f966c --- /dev/null +++ b/scipy/hemisphere_roll_off/582/simulation_code.py @@ -0,0 +1,144 @@ +"""Hemisphere roll-off standalone script.""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import matplotlib.patches as patches + +R = 1.6459901338881526 +r = 0.26555624704380454 +g = 9.8 +theta_0 = 0.020102229263759434 +e_g = 0.48681861734444165 +mu_g = 0.44625212816851134 +mu_r = 0.10299644727826908 +duration = 12 +fps = 30 +vy_settle = 0.50 + +def derivs_hemi(t, s): + return [s[1], (5.0/7.0)*g*np.sin(s[0])/(R+r)] +def event_detach(t, s): + return 17.0*np.cos(s[0]) - 10.0 +event_detach.terminal = True; event_detach.direction = -1 +def derivs_flight(t, s): + return [s[2], s[3], 0.0, -g] +def event_ground(t, s): + return s[1] - r +event_ground.terminal = True; event_ground.direction = -1 + +t_eval_g = np.linspace(0, duration, int(duration*fps)+1) +xb_arr = np.zeros_like(t_eval_g); yb_arr = np.zeros_like(t_eval_g) +phi_arr = np.zeros_like(t_eval_g) + +sol1 = solve_ivp(derivs_hemi, (0, duration), [theta_0, 0.0], + events=event_detach, dense_output=True, + rtol=1e-9, atol=1e-11, max_step=0.05) +t1_end = sol1.t[-1] +idx1 = np.where(t_eval_g <= t1_end + 1e-12)[0] +for i in idx1: + th = sol1.sol(t_eval_g[i])[0] + xb_arr[i] = (R+r)*np.sin(th) + yb_arr[i] = (R+r)*np.cos(th) + phi_arr[i] = -((R+r)/r)*(th-theta_0) +phi_at_detach = phi_arr[idx1[-1]] if len(idx1) else 0.0 + +if sol1.status == 1: + th_d = sol1.y[0,-1]; thd_d = sol1.y[1,-1] + state = np.array([(R+r)*np.sin(th_d), (R+r)*np.cos(th_d), + (R+r)*thd_d*np.cos(th_d), -(R+r)*thd_d*np.sin(th_d)]) + omega_curr = -((R+r)/r)*thd_d + phi_curr = phi_at_detach; t_cur = t1_end + for _ in range(50): + if t_cur >= duration - 1e-9: break + sol = solve_ivp(derivs_flight, (t_cur, duration), state, + events=event_ground, dense_output=True, + rtol=1e-9, atol=1e-11) + seg_end = sol.t[-1] + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= seg_end + 1e-12))[0]: + s = sol.sol(t_eval_g[i]) + xb_arr[i] = s[0]; yb_arr[i] = s[1] + phi_arr[i] = phi_curr + omega_curr*(t_eval_g[i]-t_cur) + state = sol.y[:,-1].copy() + phi_curr = phi_curr + omega_curr*(seg_end-t_cur) + t_cur = seg_end + if sol.status != 1: break + x_l, y_l, vx_l, vy_l = state + vc_x_pre = vx_l + omega_curr*r + Jn = -(1.0+e_g)*vy_l + Jt_stick = -vc_x_pre*(2.0/7.0) + Jt_max = mu_g*Jn + Jt = max(-Jt_max, min(Jt_max, Jt_stick)) + vx_post = vx_l + Jt; vy_post = vy_l + Jn + omega_curr = omega_curr + Jt/(0.4*r) + state = np.array([x_l, r+1e-9, vx_post, vy_post]) + if abs(vy_post) < vy_settle: break + if t_cur < duration - 1e-9: + x_curr = state[0]; vx_curr = state[2] + if abs(vx_curr) < 1e-3: + i_rest = np.where(t_eval_g > t_cur)[0] + xb_arr[i_rest] = x_curr; yb_arr[i_rest] = r + phi_arr[i_rest] = phi_curr + else: + sign_vx = np.sign(vx_curr); decel = mu_r*g + t_stop = abs(vx_curr)/decel + t_end_roll = t_cur + t_stop + for i in np.where((t_eval_g > t_cur) & (t_eval_g <= min(t_end_roll, duration)))[0]: + dt = t_eval_g[i] - t_cur + xb_arr[i] = x_curr + vx_curr*dt - 0.5*sign_vx*decel*dt*dt + yb_arr[i] = r + phi_arr[i] = phi_curr - (vx_curr/r)*dt + (sign_vx*decel/(2*r))*dt*dt + if t_end_roll < duration: + x_stop = x_curr + sign_vx*0.5*vx_curr*vx_curr/decel + phi_stop = phi_curr - (vx_curr/r)*t_stop + (sign_vx*decel/(2*r))*t_stop*t_stop + i_stop = np.where(t_eval_g > t_end_roll)[0] + xb_arr[i_stop] = x_stop; yb_arr[i_stop] = r + phi_arr[i_stop] = phi_stop + +fig_w, fig_h = 10, 4 +fig_aspect = fig_w/fig_h +xpad, ypad = 0.40, 0.30 +x_lo_d = -R - xpad +x_hi_d = max(R+xpad, xb_arr.max()+r+0.4) +y_lo_d = -ypad +y_hi_d = max(R+r+ypad, yb_arr.max()+r+0.2) +dx_v, dy_v = x_hi_d-x_lo_d, y_hi_d-y_lo_d +if dx_v/dy_v < fig_aspect: + extra = (fig_aspect*dy_v - dx_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d-extra, x_hi_d+extra, y_lo_d, y_hi_d +else: + extra = (dx_v/fig_aspect - dy_v)/2.0 + x_lo, x_hi, y_lo, y_hi = x_lo_d, x_hi_d, y_lo_d-extra, y_hi_d+extra + +fig = plt.figure(figsize=(fig_w,fig_h), facecolor="#1a1a2e") +ax = fig.add_axes([0,0,1,1]); ax.set_facecolor("#16213e") +ax.set_xlim(x_lo,x_hi); ax.set_ylim(y_lo,y_hi) +ax.set_aspect("equal"); ax.axis("off") +ax.axhspan(y_lo, 0.0, color="#4a4e69", alpha=0.55, zorder=0) +ax.axhline(0, color="#adb5bd", lw=2.5, zorder=1) +hemi = patches.Wedge((0,0), R, 0, 180, facecolor="#a8dadc", + edgecolor="white", lw=2, zorder=2) +ax.add_patch(hemi) +trail, = ax.plot([],[],"-",color="#e63946", alpha=0.40, lw=1.2, zorder=3) +tx, ty = [], [] +ball = plt.Circle((xb_arr[0], yb_arr[0]), r, facecolor="#e63946", + edgecolor="white", lw=1.5, zorder=4) +ax.add_patch(ball) +spoke, = ax.plot([],[],"-",color="white", lw=2.0, zorder=5) + +def update(f): + cx, cy = xb_arr[f], yb_arr[f] + ball.set_center((cx, cy)) + sx = cx + r*np.cos(phi_arr[f]) + sy = cy + r*np.sin(phi_arr[f]) + spoke.set_data([cx,sx],[cy,sy]) + tx.append(cx); ty.append(cy) + if len(tx)>200: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, spoke, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t_eval_g), + interval=1000/fps, blit=True) +ani.save("video.mp4", writer=animation.FFMpegWriter(fps=fps, bitrate=1800), dpi=120) +plt.close() +print("Saved video.mp4") diff --git a/scipy/hemisphere_roll_off/582/video.mp4 b/scipy/hemisphere_roll_off/582/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..7b51de975103e6366cdce8e0af92fcc8898f7394 --- /dev/null +++ b/scipy/hemisphere_roll_off/582/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9dca563dbe06688c21d66dcf049e73ed0d20817ed913c28f0d754c8ee16c3c0d +size 12314 diff --git a/scipy/lagrange_roller/043/cot.json b/scipy/lagrange_roller/043/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e0065bcc358ee79ff8a87efa5ac1a03581b212ee --- /dev/null +++ b/scipy/lagrange_roller/043/cot.json @@ -0,0 +1,87 @@ +{ + "simulation": "lagrange_roller", + "physical_observation": "A point mass (m=1.380 kg) rolls along the 'hump path' y = 3 + x^2(-7+x^2)/6 (a W-shaped track with a local maximum at x=0 and two symmetric minima at x \\approx \\pm 1.8708 m). Gravity g=9.800 m/s^2, damping b=0.061. Initial position x_0=0.078 m, velocity v_0=-0.273 m/s.", + "physical_law": { + "name": "Euler-Lagrange Equation on the Hump Path", + "statement": "The particle is constrained to y=f(x); the EOM is derived from the Lagrangian for 1-DOF constrained motion.", + "formula": "\\ddot{x} = -x(-7 + 2x^2)[3g + (-7 + 6x^2)\\dot{x}^2] / [9 + 49x^2 - 28x^4 + 4x^6]" + }, + "ode_system": { + "state_variables": [ + "x (m)", + "v = \\dot{x} (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -x \\cdot (-7 + 2x^2) \\cdot [3g + (-7 + 6x^2) \\cdot v^2] / [9 + 49x^2 - 28x^4 + 4x^6] - (b/m) \\cdot v \\cdot \\sqrt(1+f'^2)", + "where f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -x * (-7 + 2 * x**2) * [3 * g + (-7 + 6 * x**2) * v**2] / [9 + 49 * x**2 - 28 * x**4 + 4 * x**6] - (b/m) * v * np.sqrt (1+f'**2)", + "where f'(x) = x(-7+2 * x**2)/3, f''(x) = (-7+6 * x**2)/3" + ] + }, + "derivation_steps": [ + "Track: y = f(x) = 3 + x^2(-7+x^2)/6.", + "f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3.", + "Constrained Lagrangian (no damping): L = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 - mgf(x).", + "Euler-Lagrange: d/dt[(1+f'^2)\\dot{x}] = f'f''\\dot{x}^2/... - gf' \\rightarrow (1+f'^2)\\ddot{x} + f'f''\\dot{x}^2 + gf' = 0.", + "Substituting f' and f'' and simplifying the denominator 1+f'^2 = 1+(x(-7+2x^2)/3)^2:", + " (9 + x^2(-7+2x^2)^2)/9 \\rightarrow multiply through by 9/m gives the formula above.", + "Full EOM numerator: -x(-7+2x^2) \\cdot [3g + (-7+6x^2) \\cdot \\dot{x}^2].", + "Add damping as a generalized force: -(b/m) \\cdot \\sqrt(1+f'^2) \\cdot \\dot{x}.", + "Equilibrium points: x=0 (local MAX, unstable: f''(0)=-7/3<0).", + "Stable minima: x= \\pm 1.8708 m, f''=14/3, \\omega_small = \\sqrt(g \\cdot f'') = 6.7626 rad/s." + ], + "physical_constants_derived": { + "stable_equilibrium_x_m": 1.8708, + "track_height_at_minima_m": 0.9583, + "f_double_prime_at_minima": 4.6667, + "omega_small_osc_rad_s": 6.7626, + "T_small_osc_s": 0.9291 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Polynomial track with polynomial EOM; RK45 is efficient for smooth nonlinear ODEs." + }, + "code_validation": { + "ode_source": "Euler-Lagrange on hump path; matches LagrangeRollerSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 + mgf(x) decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Track has unstable equilibrium at x=0 and stable minima at x \\approx \\pm 1.871 m.", + "Small oscillations near minima: \\omega \\approx 6.763 rad/s (T \\approx 0.929 s).", + "Initial x_0=0.078: near unstable top.", + "With sufficient initial energy, mass can transit over the central hump between minima." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "m": { + "value": 1.3800580878495072, + "unit": "kg", + "description": "" + }, + "b": { + "value": 0.0613718166078713, + "unit": "dimensionless or kg/s", + "description": "Damping coefficient" + }, + "x0": { + "value": 0.07750921011936862, + "unit": "m", + "description": "Horizontal position on track" + }, + "v0": { + "value": -0.27332333354420557, + "unit": "m/s", + "description": "Horizontal velocity" + } + } +} diff --git a/scipy/lagrange_roller/043/params.json b/scipy/lagrange_roller/043/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ce33b31a8337ee67a920d07056b9302b36d1d5cd --- /dev/null +++ b/scipy/lagrange_roller/043/params.json @@ -0,0 +1,7 @@ +{ + "g": 9.8, + "m": 1.3800580878495072, + "b": 0.0613718166078713, + "x0": 0.07750921011936862, + "v0": -0.27332333354420557 +} \ No newline at end of file diff --git a/scipy/lagrange_roller/043/simulation_code.py b/scipy/lagrange_roller/043/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..17ae057e426272229761a5ee9ffbb4d612af8f27 --- /dev/null +++ b/scipy/lagrange_roller/043/simulation_code.py @@ -0,0 +1,73 @@ +""" +Lagrange Roller (Hump Path) — auto-generated simulation script. +Track: y = 3 - (7/6)*x^2 + (1/6)*x^4 (HumpPath from myphysicslab) +Physics: v' = -(x*(-7+2x^2)*(3g+(-7+6x^2)*v^2)) / (9+49x^2-28x^4+4x^6) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + + +g = 9.8 +m = 1.3800580878495072 +b = 0.0613718166078713 +x0 = 0.07750921011936862 +v0 = -0.27332333354420557 +duration = 12 + + +def hump(x): + x2 = x * x + y = 3.0 + x2 * (-7.0 + x2) / 6.0 + dydx = x * (-7.0 + 2.0 * x2) / 3.0 + return y, dydx + + +def ode(t, state): + x, v = state + x2 = x * x + num = -(x * (-7.0 + 2.0*x2) * (3.0*g + (-7.0 + 6.0*x2)*v*v)) + den = 9.0 + 49.0*x2 - 28.0*x2*x2 + 4.0*x2*x2*x2 + dv = num / den + if b != 0.0: + _, dydx = hump(np.array([x])) + dv -= (b / m) * v / np.sqrt(1.0 + dydx[0]**2) + return [v, dv] + + +fps = 30 +t_eval = np.linspace(0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0, duration), [x0, v0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +t, x_ball = sol.t, sol.y[0] +y_ball, _ = hump(x_ball) + + +x_range = np.linspace(-3, 3, 600) +y_track, _ = hump(x_range) + + +fig, ax = plt.subplots(figsize=(8, 5), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(-3.3, 3.3) +ax.set_ylim(y_track.min() - 0.5, y_track.max() + 0.5) +ax.set_aspect("equal"); ax.axis("off") +ax.plot(x_range, y_track, "-", color="#a8dadc", lw=2.0, alpha=0.7) + +ball, = ax.plot([], [], "o", color="#e63946", ms=12, zorder=5) +trail, = ax.plot([], [], "-", color="#e63946", alpha=0.4, lw=1.5) +tx, ty = [], [] + +def update(frame): + ball.set_data([x_ball[frame]], [y_ball[frame]]) + tx.append(x_ball[frame]); ty.append(y_ball[frame]) + if len(tx) > 60: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t), interval=1000/fps, blit=True) +writer = animation.FFMpegWriter(fps=fps, bitrate=1800) +ani.save("lagrange_roller.mp4", writer=writer, dpi=120) +plt.close() +print("Saved lagrange_roller.mp4") diff --git a/scipy/lagrange_roller/043/video.mp4 b/scipy/lagrange_roller/043/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..0195ce31d9c1709f9d91be9d4e2d1dad56fe477f --- /dev/null +++ b/scipy/lagrange_roller/043/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:72ec6e288c1dc958afff8a9efbd20f27a74737afc65c12ba55eda832b9f62689 +size 10233 diff --git a/scipy/lagrange_roller/086/cot.json b/scipy/lagrange_roller/086/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..1bf7879ae17dbe1377d2316be5375606d328e2ed --- /dev/null +++ b/scipy/lagrange_roller/086/cot.json @@ -0,0 +1,87 @@ +{ + "simulation": "lagrange_roller", + "physical_observation": "A point mass (m=0.638 kg) rolls along the 'hump path' y = 3 + x^2(-7+x^2)/6 (a W-shaped track with a local maximum at x=0 and two symmetric minima at x \\approx \\pm 1.8708 m). Gravity g=9.800 m/s^2, damping b=0.289. Initial position x_0=-1.365 m, velocity v_0=0.976 m/s.", + "physical_law": { + "name": "Euler-Lagrange Equation on the Hump Path", + "statement": "The particle is constrained to y=f(x); the EOM is derived from the Lagrangian for 1-DOF constrained motion.", + "formula": "\\ddot{x} = -x(-7 + 2x^2)[3g + (-7 + 6x^2)\\dot{x}^2] / [9 + 49x^2 - 28x^4 + 4x^6]" + }, + "ode_system": { + "state_variables": [ + "x (m)", + "v = \\dot{x} (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -x \\cdot (-7 + 2x^2) \\cdot [3g + (-7 + 6x^2) \\cdot v^2] / [9 + 49x^2 - 28x^4 + 4x^6] - (b/m) \\cdot v \\cdot \\sqrt(1+f'^2)", + "where f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -x * (-7 + 2 * x**2) * [3 * g + (-7 + 6 * x**2) * v**2] / [9 + 49 * x**2 - 28 * x**4 + 4 * x**6] - (b/m) * v * np.sqrt (1+f'**2)", + "where f'(x) = x(-7+2 * x**2)/3, f''(x) = (-7+6 * x**2)/3" + ] + }, + "derivation_steps": [ + "Track: y = f(x) = 3 + x^2(-7+x^2)/6.", + "f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3.", + "Constrained Lagrangian (no damping): L = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 - mgf(x).", + "Euler-Lagrange: d/dt[(1+f'^2)\\dot{x}] = f'f''\\dot{x}^2/... - gf' \\rightarrow (1+f'^2)\\ddot{x} + f'f''\\dot{x}^2 + gf' = 0.", + "Substituting f' and f'' and simplifying the denominator 1+f'^2 = 1+(x(-7+2x^2)/3)^2:", + " (9 + x^2(-7+2x^2)^2)/9 \\rightarrow multiply through by 9/m gives the formula above.", + "Full EOM numerator: -x(-7+2x^2) \\cdot [3g + (-7+6x^2) \\cdot \\dot{x}^2].", + "Add damping as a generalized force: -(b/m) \\cdot \\sqrt(1+f'^2) \\cdot \\dot{x}.", + "Equilibrium points: x=0 (local MAX, unstable: f''(0)=-7/3<0).", + "Stable minima: x= \\pm 1.8708 m, f''=14/3, \\omega_small = \\sqrt(g \\cdot f'') = 6.7626 rad/s." + ], + "physical_constants_derived": { + "stable_equilibrium_x_m": 1.8708, + "track_height_at_minima_m": 0.9583, + "f_double_prime_at_minima": 4.6667, + "omega_small_osc_rad_s": 6.7626, + "T_small_osc_s": 0.9291 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Polynomial track with polynomial EOM; RK45 is efficient for smooth nonlinear ODEs." + }, + "code_validation": { + "ode_source": "Euler-Lagrange on hump path; matches LagrangeRollerSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 + mgf(x) decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Track has unstable equilibrium at x=0 and stable minima at x \\approx \\pm 1.871 m.", + "Small oscillations near minima: \\omega \\approx 6.763 rad/s (T \\approx 0.929 s).", + "Initial x_0=-1.365: on the slope.", + "With sufficient initial energy, mass can transit over the central hump between minima." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "m": { + "value": 0.6383943295345567, + "unit": "kg", + "description": "" + }, + "b": { + "value": 0.28930956568568067, + "unit": "dimensionless or kg/s", + "description": "Damping coefficient" + }, + "x0": { + "value": -1.3654701134415468, + "unit": "m", + "description": "Horizontal position on track" + }, + "v0": { + "value": 0.9757423025089018, + "unit": "m/s", + "description": "Horizontal velocity" + } + } +} diff --git a/scipy/lagrange_roller/086/params.json b/scipy/lagrange_roller/086/params.json new file mode 100644 index 0000000000000000000000000000000000000000..08058398f06640df47e2f0808f402ad9ac966b60 --- /dev/null +++ b/scipy/lagrange_roller/086/params.json @@ -0,0 +1,7 @@ +{ + "g": 9.8, + "m": 0.6383943295345567, + "b": 0.28930956568568067, + "x0": -1.3654701134415468, + "v0": 0.9757423025089018 +} \ No newline at end of file diff --git a/scipy/lagrange_roller/086/simulation_code.py b/scipy/lagrange_roller/086/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..4a3447147b3f6c0a6e3bb6652c56b19d61c20f03 --- /dev/null +++ b/scipy/lagrange_roller/086/simulation_code.py @@ -0,0 +1,73 @@ +""" +Lagrange Roller (Hump Path) — auto-generated simulation script. +Track: y = 3 - (7/6)*x^2 + (1/6)*x^4 (HumpPath from myphysicslab) +Physics: v' = -(x*(-7+2x^2)*(3g+(-7+6x^2)*v^2)) / (9+49x^2-28x^4+4x^6) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + + +g = 9.8 +m = 0.6383943295345567 +b = 0.28930956568568067 +x0 = -1.3654701134415468 +v0 = 0.9757423025089018 +duration = 12 + + +def hump(x): + x2 = x * x + y = 3.0 + x2 * (-7.0 + x2) / 6.0 + dydx = x * (-7.0 + 2.0 * x2) / 3.0 + return y, dydx + + +def ode(t, state): + x, v = state + x2 = x * x + num = -(x * (-7.0 + 2.0*x2) * (3.0*g + (-7.0 + 6.0*x2)*v*v)) + den = 9.0 + 49.0*x2 - 28.0*x2*x2 + 4.0*x2*x2*x2 + dv = num / den + if b != 0.0: + _, dydx = hump(np.array([x])) + dv -= (b / m) * v / np.sqrt(1.0 + dydx[0]**2) + return [v, dv] + + +fps = 30 +t_eval = np.linspace(0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0, duration), [x0, v0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +t, x_ball = sol.t, sol.y[0] +y_ball, _ = hump(x_ball) + + +x_range = np.linspace(-3, 3, 600) +y_track, _ = hump(x_range) + + +fig, ax = plt.subplots(figsize=(8, 5), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(-3.3, 3.3) +ax.set_ylim(y_track.min() - 0.5, y_track.max() + 0.5) +ax.set_aspect("equal"); ax.axis("off") +ax.plot(x_range, y_track, "-", color="#a8dadc", lw=2.0, alpha=0.7) + +ball, = ax.plot([], [], "o", color="#e63946", ms=12, zorder=5) +trail, = ax.plot([], [], "-", color="#e63946", alpha=0.4, lw=1.5) +tx, ty = [], [] + +def update(frame): + ball.set_data([x_ball[frame]], [y_ball[frame]]) + tx.append(x_ball[frame]); ty.append(y_ball[frame]) + if len(tx) > 60: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t), interval=1000/fps, blit=True) +writer = animation.FFMpegWriter(fps=fps, bitrate=1800) +ani.save("lagrange_roller.mp4", writer=writer, dpi=120) +plt.close() +print("Saved lagrange_roller.mp4") diff --git a/scipy/lagrange_roller/086/video.mp4 b/scipy/lagrange_roller/086/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..3fb33f873245c466e11f01cf64a27f647344b3c3 --- /dev/null +++ b/scipy/lagrange_roller/086/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5fc206d72bafe5efa50e1aae6e612dd999afac1a18c87665cb30fd0c50bcaa01 +size 9188 diff --git a/scipy/lagrange_roller/109/cot.json b/scipy/lagrange_roller/109/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..08a014e9c43d664b3450468ae0e0520fd27cd4be --- /dev/null +++ b/scipy/lagrange_roller/109/cot.json @@ -0,0 +1,87 @@ +{ + "simulation": "lagrange_roller", + "physical_observation": "A point mass (m=1.793 kg) rolls along the 'hump path' y = 3 + x^2(-7+x^2)/6 (a W-shaped track with a local maximum at x=0 and two symmetric minima at x \\approx \\pm 1.8708 m). Gravity g=9.800 m/s^2, damping b=0.206. Initial position x_0=-1.111 m, velocity v_0=-0.032 m/s.", + "physical_law": { + "name": "Euler-Lagrange Equation on the Hump Path", + "statement": "The particle is constrained to y=f(x); the EOM is derived from the Lagrangian for 1-DOF constrained motion.", + "formula": "\\ddot{x} = -x(-7 + 2x^2)[3g + (-7 + 6x^2)\\dot{x}^2] / [9 + 49x^2 - 28x^4 + 4x^6]" + }, + "ode_system": { + "state_variables": [ + "x (m)", + "v = \\dot{x} (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -x \\cdot (-7 + 2x^2) \\cdot [3g + (-7 + 6x^2) \\cdot v^2] / [9 + 49x^2 - 28x^4 + 4x^6] - (b/m) \\cdot v \\cdot \\sqrt(1+f'^2)", + "where f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -x * (-7 + 2 * x**2) * [3 * g + (-7 + 6 * x**2) * v**2] / [9 + 49 * x**2 - 28 * x**4 + 4 * x**6] - (b/m) * v * np.sqrt (1+f'**2)", + "where f'(x) = x(-7+2 * x**2)/3, f''(x) = (-7+6 * x**2)/3" + ] + }, + "derivation_steps": [ + "Track: y = f(x) = 3 + x^2(-7+x^2)/6.", + "f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3.", + "Constrained Lagrangian (no damping): L = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 - mgf(x).", + "Euler-Lagrange: d/dt[(1+f'^2)\\dot{x}] = f'f''\\dot{x}^2/... - gf' \\rightarrow (1+f'^2)\\ddot{x} + f'f''\\dot{x}^2 + gf' = 0.", + "Substituting f' and f'' and simplifying the denominator 1+f'^2 = 1+(x(-7+2x^2)/3)^2:", + " (9 + x^2(-7+2x^2)^2)/9 \\rightarrow multiply through by 9/m gives the formula above.", + "Full EOM numerator: -x(-7+2x^2) \\cdot [3g + (-7+6x^2) \\cdot \\dot{x}^2].", + "Add damping as a generalized force: -(b/m) \\cdot \\sqrt(1+f'^2) \\cdot \\dot{x}.", + "Equilibrium points: x=0 (local MAX, unstable: f''(0)=-7/3<0).", + "Stable minima: x= \\pm 1.8708 m, f''=14/3, \\omega_small = \\sqrt(g \\cdot f'') = 6.7626 rad/s." + ], + "physical_constants_derived": { + "stable_equilibrium_x_m": 1.8708, + "track_height_at_minima_m": 0.9583, + "f_double_prime_at_minima": 4.6667, + "omega_small_osc_rad_s": 6.7626, + "T_small_osc_s": 0.9291 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Polynomial track with polynomial EOM; RK45 is efficient for smooth nonlinear ODEs." + }, + "code_validation": { + "ode_source": "Euler-Lagrange on hump path; matches LagrangeRollerSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 + mgf(x) decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Track has unstable equilibrium at x=0 and stable minima at x \\approx \\pm 1.871 m.", + "Small oscillations near minima: \\omega \\approx 6.763 rad/s (T \\approx 0.929 s).", + "Initial x_0=-1.111: on the slope.", + "With sufficient initial energy, mass can transit over the central hump between minima." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "m": { + "value": 1.792816771746323, + "unit": "kg", + "description": "" + }, + "b": { + "value": 0.20582522341831946, + "unit": "dimensionless or kg/s", + "description": "Damping coefficient" + }, + "x0": { + "value": -1.1106604813374141, + "unit": "m", + "description": "Horizontal position on track" + }, + "v0": { + "value": -0.03162159258756514, + "unit": "m/s", + "description": "Horizontal velocity" + } + } +} diff --git a/scipy/lagrange_roller/109/params.json b/scipy/lagrange_roller/109/params.json new file mode 100644 index 0000000000000000000000000000000000000000..15748847826950aeef9fe1ee5ce3e007baf062f8 --- /dev/null +++ b/scipy/lagrange_roller/109/params.json @@ -0,0 +1,7 @@ +{ + "g": 9.8, + "m": 1.792816771746323, + "b": 0.20582522341831946, + "x0": -1.1106604813374141, + "v0": -0.03162159258756514 +} \ No newline at end of file diff --git a/scipy/lagrange_roller/109/simulation_code.py b/scipy/lagrange_roller/109/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..cc1e25733c0878044848bc419a25cc2eb390c6e2 --- /dev/null +++ b/scipy/lagrange_roller/109/simulation_code.py @@ -0,0 +1,73 @@ +""" +Lagrange Roller (Hump Path) — auto-generated simulation script. +Track: y = 3 - (7/6)*x^2 + (1/6)*x^4 (HumpPath from myphysicslab) +Physics: v' = -(x*(-7+2x^2)*(3g+(-7+6x^2)*v^2)) / (9+49x^2-28x^4+4x^6) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + + +g = 9.8 +m = 1.792816771746323 +b = 0.20582522341831946 +x0 = -1.1106604813374141 +v0 = -0.03162159258756514 +duration = 12 + + +def hump(x): + x2 = x * x + y = 3.0 + x2 * (-7.0 + x2) / 6.0 + dydx = x * (-7.0 + 2.0 * x2) / 3.0 + return y, dydx + + +def ode(t, state): + x, v = state + x2 = x * x + num = -(x * (-7.0 + 2.0*x2) * (3.0*g + (-7.0 + 6.0*x2)*v*v)) + den = 9.0 + 49.0*x2 - 28.0*x2*x2 + 4.0*x2*x2*x2 + dv = num / den + if b != 0.0: + _, dydx = hump(np.array([x])) + dv -= (b / m) * v / np.sqrt(1.0 + dydx[0]**2) + return [v, dv] + + +fps = 30 +t_eval = np.linspace(0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0, duration), [x0, v0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +t, x_ball = sol.t, sol.y[0] +y_ball, _ = hump(x_ball) + + +x_range = np.linspace(-3, 3, 600) +y_track, _ = hump(x_range) + + +fig, ax = plt.subplots(figsize=(8, 5), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(-3.3, 3.3) +ax.set_ylim(y_track.min() - 0.5, y_track.max() + 0.5) +ax.set_aspect("equal"); ax.axis("off") +ax.plot(x_range, y_track, "-", color="#a8dadc", lw=2.0, alpha=0.7) + +ball, = ax.plot([], [], "o", color="#e63946", ms=12, zorder=5) +trail, = ax.plot([], [], "-", color="#e63946", alpha=0.4, lw=1.5) +tx, ty = [], [] + +def update(frame): + ball.set_data([x_ball[frame]], [y_ball[frame]]) + tx.append(x_ball[frame]); ty.append(y_ball[frame]) + if len(tx) > 60: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t), interval=1000/fps, blit=True) +writer = animation.FFMpegWriter(fps=fps, bitrate=1800) +ani.save("lagrange_roller.mp4", writer=writer, dpi=120) +plt.close() +print("Saved lagrange_roller.mp4") diff --git a/scipy/lagrange_roller/109/video.mp4 b/scipy/lagrange_roller/109/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..1364eb1f8858ca7f4f509c68d11a18cbec285203 --- /dev/null +++ b/scipy/lagrange_roller/109/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a04cfa0b6ef5076b6b8d3e13d8b8d80bf44d7edc3309fb788a920da58844a3c9 +size 9912 diff --git a/scipy/lagrange_roller/164/cot.json b/scipy/lagrange_roller/164/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e61817e90cafb935ad891181fcd7c84502cda997 --- /dev/null +++ b/scipy/lagrange_roller/164/cot.json @@ -0,0 +1,87 @@ +{ + "simulation": "lagrange_roller", + "physical_observation": "A point mass (m=0.886 kg) rolls along the 'hump path' y = 3 + x^2(-7+x^2)/6 (a W-shaped track with a local maximum at x=0 and two symmetric minima at x \\approx \\pm 1.8708 m). Gravity g=9.800 m/s^2, damping b=0.101. Initial position x_0=1.028 m, velocity v_0=-1.135 m/s.", + "physical_law": { + "name": "Euler-Lagrange Equation on the Hump Path", + "statement": "The particle is constrained to y=f(x); the EOM is derived from the Lagrangian for 1-DOF constrained motion.", + "formula": "\\ddot{x} = -x(-7 + 2x^2)[3g + (-7 + 6x^2)\\dot{x}^2] / [9 + 49x^2 - 28x^4 + 4x^6]" + }, + "ode_system": { + "state_variables": [ + "x (m)", + "v = \\dot{x} (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -x \\cdot (-7 + 2x^2) \\cdot [3g + (-7 + 6x^2) \\cdot v^2] / [9 + 49x^2 - 28x^4 + 4x^6] - (b/m) \\cdot v \\cdot \\sqrt(1+f'^2)", + "where f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -x * (-7 + 2 * x**2) * [3 * g + (-7 + 6 * x**2) * v**2] / [9 + 49 * x**2 - 28 * x**4 + 4 * x**6] - (b/m) * v * np.sqrt (1+f'**2)", + "where f'(x) = x(-7+2 * x**2)/3, f''(x) = (-7+6 * x**2)/3" + ] + }, + "derivation_steps": [ + "Track: y = f(x) = 3 + x^2(-7+x^2)/6.", + "f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3.", + "Constrained Lagrangian (no damping): L = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 - mgf(x).", + "Euler-Lagrange: d/dt[(1+f'^2)\\dot{x}] = f'f''\\dot{x}^2/... - gf' \\rightarrow (1+f'^2)\\ddot{x} + f'f''\\dot{x}^2 + gf' = 0.", + "Substituting f' and f'' and simplifying the denominator 1+f'^2 = 1+(x(-7+2x^2)/3)^2:", + " (9 + x^2(-7+2x^2)^2)/9 \\rightarrow multiply through by 9/m gives the formula above.", + "Full EOM numerator: -x(-7+2x^2) \\cdot [3g + (-7+6x^2) \\cdot \\dot{x}^2].", + "Add damping as a generalized force: -(b/m) \\cdot \\sqrt(1+f'^2) \\cdot \\dot{x}.", + "Equilibrium points: x=0 (local MAX, unstable: f''(0)=-7/3<0).", + "Stable minima: x= \\pm 1.8708 m, f''=14/3, \\omega_small = \\sqrt(g \\cdot f'') = 6.7626 rad/s." + ], + "physical_constants_derived": { + "stable_equilibrium_x_m": 1.8708, + "track_height_at_minima_m": 0.9583, + "f_double_prime_at_minima": 4.6667, + "omega_small_osc_rad_s": 6.7626, + "T_small_osc_s": 0.9291 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Polynomial track with polynomial EOM; RK45 is efficient for smooth nonlinear ODEs." + }, + "code_validation": { + "ode_source": "Euler-Lagrange on hump path; matches LagrangeRollerSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 + mgf(x) decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Track has unstable equilibrium at x=0 and stable minima at x \\approx \\pm 1.871 m.", + "Small oscillations near minima: \\omega \\approx 6.763 rad/s (T \\approx 0.929 s).", + "Initial x_0=1.028: on the slope.", + "With sufficient initial energy, mass can transit over the central hump between minima." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "m": { + "value": 0.8855895215777566, + "unit": "kg", + "description": "" + }, + "b": { + "value": 0.1011968901143946, + "unit": "dimensionless or kg/s", + "description": "Damping coefficient" + }, + "x0": { + "value": 1.0282340154307037, + "unit": "m", + "description": "Horizontal position on track" + }, + "v0": { + "value": -1.1348857399954566, + "unit": "m/s", + "description": "Horizontal velocity" + } + } +} diff --git a/scipy/lagrange_roller/164/params.json b/scipy/lagrange_roller/164/params.json new file mode 100644 index 0000000000000000000000000000000000000000..ac6358251a25b14767b3ba937c70ee74af22f753 --- /dev/null +++ b/scipy/lagrange_roller/164/params.json @@ -0,0 +1,7 @@ +{ + "g": 9.8, + "m": 0.8855895215777566, + "b": 0.1011968901143946, + "x0": 1.0282340154307037, + "v0": -1.1348857399954566 +} \ No newline at end of file diff --git a/scipy/lagrange_roller/164/simulation_code.py b/scipy/lagrange_roller/164/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..ea2188289282027e3db031d856d872001af7cc3b --- /dev/null +++ b/scipy/lagrange_roller/164/simulation_code.py @@ -0,0 +1,73 @@ +""" +Lagrange Roller (Hump Path) — auto-generated simulation script. +Track: y = 3 - (7/6)*x^2 + (1/6)*x^4 (HumpPath from myphysicslab) +Physics: v' = -(x*(-7+2x^2)*(3g+(-7+6x^2)*v^2)) / (9+49x^2-28x^4+4x^6) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + + +g = 9.8 +m = 0.8855895215777566 +b = 0.1011968901143946 +x0 = 1.0282340154307037 +v0 = -1.1348857399954566 +duration = 12 + + +def hump(x): + x2 = x * x + y = 3.0 + x2 * (-7.0 + x2) / 6.0 + dydx = x * (-7.0 + 2.0 * x2) / 3.0 + return y, dydx + + +def ode(t, state): + x, v = state + x2 = x * x + num = -(x * (-7.0 + 2.0*x2) * (3.0*g + (-7.0 + 6.0*x2)*v*v)) + den = 9.0 + 49.0*x2 - 28.0*x2*x2 + 4.0*x2*x2*x2 + dv = num / den + if b != 0.0: + _, dydx = hump(np.array([x])) + dv -= (b / m) * v / np.sqrt(1.0 + dydx[0]**2) + return [v, dv] + + +fps = 30 +t_eval = np.linspace(0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0, duration), [x0, v0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +t, x_ball = sol.t, sol.y[0] +y_ball, _ = hump(x_ball) + + +x_range = np.linspace(-3, 3, 600) +y_track, _ = hump(x_range) + + +fig, ax = plt.subplots(figsize=(8, 5), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(-3.3, 3.3) +ax.set_ylim(y_track.min() - 0.5, y_track.max() + 0.5) +ax.set_aspect("equal"); ax.axis("off") +ax.plot(x_range, y_track, "-", color="#a8dadc", lw=2.0, alpha=0.7) + +ball, = ax.plot([], [], "o", color="#e63946", ms=12, zorder=5) +trail, = ax.plot([], [], "-", color="#e63946", alpha=0.4, lw=1.5) +tx, ty = [], [] + +def update(frame): + ball.set_data([x_ball[frame]], [y_ball[frame]]) + tx.append(x_ball[frame]); ty.append(y_ball[frame]) + if len(tx) > 60: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t), interval=1000/fps, blit=True) +writer = animation.FFMpegWriter(fps=fps, bitrate=1800) +ani.save("lagrange_roller.mp4", writer=writer, dpi=120) +plt.close() +print("Saved lagrange_roller.mp4") diff --git a/scipy/lagrange_roller/164/video.mp4 b/scipy/lagrange_roller/164/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d1e378b3a3fc869df685a309e8c989348f05d9ef --- /dev/null +++ b/scipy/lagrange_roller/164/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b00c4186017065490232e4ab06ac88fca98b754d437e44a219cc1282a3ed8ce +size 9416 diff --git a/scipy/lagrange_roller/220/cot.json b/scipy/lagrange_roller/220/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..e1d90b182ecd20dc8fd417a2ba594634bca805fb --- /dev/null +++ b/scipy/lagrange_roller/220/cot.json @@ -0,0 +1,87 @@ +{ + "simulation": "lagrange_roller", + "physical_observation": "A point mass (m=1.294 kg) rolls along the 'hump path' y = 3 + x^2(-7+x^2)/6 (a W-shaped track with a local maximum at x=0 and two symmetric minima at x \\approx \\pm 1.8708 m). Gravity g=9.800 m/s^2, damping b=0.244. Initial position x_0=0.981 m, velocity v_0=-0.951 m/s.", + "physical_law": { + "name": "Euler-Lagrange Equation on the Hump Path", + "statement": "The particle is constrained to y=f(x); the EOM is derived from the Lagrangian for 1-DOF constrained motion.", + "formula": "\\ddot{x} = -x(-7 + 2x^2)[3g + (-7 + 6x^2)\\dot{x}^2] / [9 + 49x^2 - 28x^4 + 4x^6]" + }, + "ode_system": { + "state_variables": [ + "x (m)", + "v = \\dot{x} (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -x \\cdot (-7 + 2x^2) \\cdot [3g + (-7 + 6x^2) \\cdot v^2] / [9 + 49x^2 - 28x^4 + 4x^6] - (b/m) \\cdot v \\cdot \\sqrt(1+f'^2)", + "where f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -x * (-7 + 2 * x**2) * [3 * g + (-7 + 6 * x**2) * v**2] / [9 + 49 * x**2 - 28 * x**4 + 4 * x**6] - (b/m) * v * np.sqrt (1+f'**2)", + "where f'(x) = x(-7+2 * x**2)/3, f''(x) = (-7+6 * x**2)/3" + ] + }, + "derivation_steps": [ + "Track: y = f(x) = 3 + x^2(-7+x^2)/6.", + "f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3.", + "Constrained Lagrangian (no damping): L = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 - mgf(x).", + "Euler-Lagrange: d/dt[(1+f'^2)\\dot{x}] = f'f''\\dot{x}^2/... - gf' \\rightarrow (1+f'^2)\\ddot{x} + f'f''\\dot{x}^2 + gf' = 0.", + "Substituting f' and f'' and simplifying the denominator 1+f'^2 = 1+(x(-7+2x^2)/3)^2:", + " (9 + x^2(-7+2x^2)^2)/9 \\rightarrow multiply through by 9/m gives the formula above.", + "Full EOM numerator: -x(-7+2x^2) \\cdot [3g + (-7+6x^2) \\cdot \\dot{x}^2].", + "Add damping as a generalized force: -(b/m) \\cdot \\sqrt(1+f'^2) \\cdot \\dot{x}.", + "Equilibrium points: x=0 (local MAX, unstable: f''(0)=-7/3<0).", + "Stable minima: x= \\pm 1.8708 m, f''=14/3, \\omega_small = \\sqrt(g \\cdot f'') = 6.7626 rad/s." + ], + "physical_constants_derived": { + "stable_equilibrium_x_m": 1.8708, + "track_height_at_minima_m": 0.9583, + "f_double_prime_at_minima": 4.6667, + "omega_small_osc_rad_s": 6.7626, + "T_small_osc_s": 0.9291 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Polynomial track with polynomial EOM; RK45 is efficient for smooth nonlinear ODEs." + }, + "code_validation": { + "ode_source": "Euler-Lagrange on hump path; matches LagrangeRollerSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 + mgf(x) decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Track has unstable equilibrium at x=0 and stable minima at x \\approx \\pm 1.871 m.", + "Small oscillations near minima: \\omega \\approx 6.763 rad/s (T \\approx 0.929 s).", + "Initial x_0=0.981: on the slope.", + "With sufficient initial energy, mass can transit over the central hump between minima." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "m": { + "value": 1.2942333487889766, + "unit": "kg", + "description": "" + }, + "b": { + "value": 0.24391866595116726, + "unit": "dimensionless or kg/s", + "description": "Damping coefficient" + }, + "x0": { + "value": 0.9805526024260613, + "unit": "m", + "description": "Horizontal position on track" + }, + "v0": { + "value": -0.9510734451785507, + "unit": "m/s", + "description": "Horizontal velocity" + } + } +} diff --git a/scipy/lagrange_roller/220/params.json b/scipy/lagrange_roller/220/params.json new file mode 100644 index 0000000000000000000000000000000000000000..c4a1097dfb53a60f1d72d3f58bf71fec216c29d6 --- /dev/null +++ b/scipy/lagrange_roller/220/params.json @@ -0,0 +1,7 @@ +{ + "g": 9.8, + "m": 1.2942333487889766, + "b": 0.24391866595116726, + "x0": 0.9805526024260613, + "v0": -0.9510734451785507 +} \ No newline at end of file diff --git a/scipy/lagrange_roller/220/simulation_code.py b/scipy/lagrange_roller/220/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..5b1ced8338376cfc63859ef94ec5fbc55247048f --- /dev/null +++ b/scipy/lagrange_roller/220/simulation_code.py @@ -0,0 +1,73 @@ +""" +Lagrange Roller (Hump Path) — auto-generated simulation script. +Track: y = 3 - (7/6)*x^2 + (1/6)*x^4 (HumpPath from myphysicslab) +Physics: v' = -(x*(-7+2x^2)*(3g+(-7+6x^2)*v^2)) / (9+49x^2-28x^4+4x^6) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + + +g = 9.8 +m = 1.2942333487889766 +b = 0.24391866595116726 +x0 = 0.9805526024260613 +v0 = -0.9510734451785507 +duration = 12 + + +def hump(x): + x2 = x * x + y = 3.0 + x2 * (-7.0 + x2) / 6.0 + dydx = x * (-7.0 + 2.0 * x2) / 3.0 + return y, dydx + + +def ode(t, state): + x, v = state + x2 = x * x + num = -(x * (-7.0 + 2.0*x2) * (3.0*g + (-7.0 + 6.0*x2)*v*v)) + den = 9.0 + 49.0*x2 - 28.0*x2*x2 + 4.0*x2*x2*x2 + dv = num / den + if b != 0.0: + _, dydx = hump(np.array([x])) + dv -= (b / m) * v / np.sqrt(1.0 + dydx[0]**2) + return [v, dv] + + +fps = 30 +t_eval = np.linspace(0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0, duration), [x0, v0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +t, x_ball = sol.t, sol.y[0] +y_ball, _ = hump(x_ball) + + +x_range = np.linspace(-3, 3, 600) +y_track, _ = hump(x_range) + + +fig, ax = plt.subplots(figsize=(8, 5), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(-3.3, 3.3) +ax.set_ylim(y_track.min() - 0.5, y_track.max() + 0.5) +ax.set_aspect("equal"); ax.axis("off") +ax.plot(x_range, y_track, "-", color="#a8dadc", lw=2.0, alpha=0.7) + +ball, = ax.plot([], [], "o", color="#e63946", ms=12, zorder=5) +trail, = ax.plot([], [], "-", color="#e63946", alpha=0.4, lw=1.5) +tx, ty = [], [] + +def update(frame): + ball.set_data([x_ball[frame]], [y_ball[frame]]) + tx.append(x_ball[frame]); ty.append(y_ball[frame]) + if len(tx) > 60: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t), interval=1000/fps, blit=True) +writer = animation.FFMpegWriter(fps=fps, bitrate=1800) +ani.save("lagrange_roller.mp4", writer=writer, dpi=120) +plt.close() +print("Saved lagrange_roller.mp4") diff --git a/scipy/lagrange_roller/220/video.mp4 b/scipy/lagrange_roller/220/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..49f403080603148a99f8503b8377caab6b1dfc81 --- /dev/null +++ b/scipy/lagrange_roller/220/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:196e03e8c7ce9a4063c9704e2f1c17271d4caa174c7a55b3edae73c77145c7c4 +size 9512 diff --git a/scipy/lagrange_roller/226/cot.json b/scipy/lagrange_roller/226/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..63809a8947f9b138c40440b8fd81f7a495c13cb3 --- /dev/null +++ b/scipy/lagrange_roller/226/cot.json @@ -0,0 +1,87 @@ +{ + "simulation": "lagrange_roller", + "physical_observation": "A point mass (m=1.760 kg) rolls along the 'hump path' y = 3 + x^2(-7+x^2)/6 (a W-shaped track with a local maximum at x=0 and two symmetric minima at x \\approx \\pm 1.8708 m). Gravity g=9.800 m/s^2, damping b=0.161. Initial position x_0=-0.328 m, velocity v_0=-0.588 m/s.", + "physical_law": { + "name": "Euler-Lagrange Equation on the Hump Path", + "statement": "The particle is constrained to y=f(x); the EOM is derived from the Lagrangian for 1-DOF constrained motion.", + "formula": "\\ddot{x} = -x(-7 + 2x^2)[3g + (-7 + 6x^2)\\dot{x}^2] / [9 + 49x^2 - 28x^4 + 4x^6]" + }, + "ode_system": { + "state_variables": [ + "x (m)", + "v = \\dot{x} (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -x \\cdot (-7 + 2x^2) \\cdot [3g + (-7 + 6x^2) \\cdot v^2] / [9 + 49x^2 - 28x^4 + 4x^6] - (b/m) \\cdot v \\cdot \\sqrt(1+f'^2)", + "where f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -x * (-7 + 2 * x**2) * [3 * g + (-7 + 6 * x**2) * v**2] / [9 + 49 * x**2 - 28 * x**4 + 4 * x**6] - (b/m) * v * np.sqrt (1+f'**2)", + "where f'(x) = x(-7+2 * x**2)/3, f''(x) = (-7+6 * x**2)/3" + ] + }, + "derivation_steps": [ + "Track: y = f(x) = 3 + x^2(-7+x^2)/6.", + "f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3.", + "Constrained Lagrangian (no damping): L = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 - mgf(x).", + "Euler-Lagrange: d/dt[(1+f'^2)\\dot{x}] = f'f''\\dot{x}^2/... - gf' \\rightarrow (1+f'^2)\\ddot{x} + f'f''\\dot{x}^2 + gf' = 0.", + "Substituting f' and f'' and simplifying the denominator 1+f'^2 = 1+(x(-7+2x^2)/3)^2:", + " (9 + x^2(-7+2x^2)^2)/9 \\rightarrow multiply through by 9/m gives the formula above.", + "Full EOM numerator: -x(-7+2x^2) \\cdot [3g + (-7+6x^2) \\cdot \\dot{x}^2].", + "Add damping as a generalized force: -(b/m) \\cdot \\sqrt(1+f'^2) \\cdot \\dot{x}.", + "Equilibrium points: x=0 (local MAX, unstable: f''(0)=-7/3<0).", + "Stable minima: x= \\pm 1.8708 m, f''=14/3, \\omega_small = \\sqrt(g \\cdot f'') = 6.7626 rad/s." + ], + "physical_constants_derived": { + "stable_equilibrium_x_m": 1.8708, + "track_height_at_minima_m": 0.9583, + "f_double_prime_at_minima": 4.6667, + "omega_small_osc_rad_s": 6.7626, + "T_small_osc_s": 0.9291 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Polynomial track with polynomial EOM; RK45 is efficient for smooth nonlinear ODEs." + }, + "code_validation": { + "ode_source": "Euler-Lagrange on hump path; matches LagrangeRollerSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 + mgf(x) decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Track has unstable equilibrium at x=0 and stable minima at x \\approx \\pm 1.871 m.", + "Small oscillations near minima: \\omega \\approx 6.763 rad/s (T \\approx 0.929 s).", + "Initial x_0=-0.328: on the slope.", + "With sufficient initial energy, mass can transit over the central hump between minima." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "m": { + "value": 1.7604750907484765, + "unit": "kg", + "description": "" + }, + "b": { + "value": 0.16070402169402273, + "unit": "dimensionless or kg/s", + "description": "Damping coefficient" + }, + "x0": { + "value": -0.3275163510915753, + "unit": "m", + "description": "Horizontal position on track" + }, + "v0": { + "value": -0.5875326059102614, + "unit": "m/s", + "description": "Horizontal velocity" + } + } +} diff --git a/scipy/lagrange_roller/226/params.json b/scipy/lagrange_roller/226/params.json new file mode 100644 index 0000000000000000000000000000000000000000..91ec2a18468e0691b69036bd64278f42f9de551f --- /dev/null +++ b/scipy/lagrange_roller/226/params.json @@ -0,0 +1,7 @@ +{ + "g": 9.8, + "m": 1.7604750907484765, + "b": 0.16070402169402273, + "x0": -0.3275163510915753, + "v0": -0.5875326059102614 +} \ No newline at end of file diff --git a/scipy/lagrange_roller/226/simulation_code.py b/scipy/lagrange_roller/226/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..009fa4f4f00a1600456ad0c1e18c295085368021 --- /dev/null +++ b/scipy/lagrange_roller/226/simulation_code.py @@ -0,0 +1,73 @@ +""" +Lagrange Roller (Hump Path) — auto-generated simulation script. +Track: y = 3 - (7/6)*x^2 + (1/6)*x^4 (HumpPath from myphysicslab) +Physics: v' = -(x*(-7+2x^2)*(3g+(-7+6x^2)*v^2)) / (9+49x^2-28x^4+4x^6) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + + +g = 9.8 +m = 1.7604750907484765 +b = 0.16070402169402273 +x0 = -0.3275163510915753 +v0 = -0.5875326059102614 +duration = 12 + + +def hump(x): + x2 = x * x + y = 3.0 + x2 * (-7.0 + x2) / 6.0 + dydx = x * (-7.0 + 2.0 * x2) / 3.0 + return y, dydx + + +def ode(t, state): + x, v = state + x2 = x * x + num = -(x * (-7.0 + 2.0*x2) * (3.0*g + (-7.0 + 6.0*x2)*v*v)) + den = 9.0 + 49.0*x2 - 28.0*x2*x2 + 4.0*x2*x2*x2 + dv = num / den + if b != 0.0: + _, dydx = hump(np.array([x])) + dv -= (b / m) * v / np.sqrt(1.0 + dydx[0]**2) + return [v, dv] + + +fps = 30 +t_eval = np.linspace(0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0, duration), [x0, v0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +t, x_ball = sol.t, sol.y[0] +y_ball, _ = hump(x_ball) + + +x_range = np.linspace(-3, 3, 600) +y_track, _ = hump(x_range) + + +fig, ax = plt.subplots(figsize=(8, 5), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(-3.3, 3.3) +ax.set_ylim(y_track.min() - 0.5, y_track.max() + 0.5) +ax.set_aspect("equal"); ax.axis("off") +ax.plot(x_range, y_track, "-", color="#a8dadc", lw=2.0, alpha=0.7) + +ball, = ax.plot([], [], "o", color="#e63946", ms=12, zorder=5) +trail, = ax.plot([], [], "-", color="#e63946", alpha=0.4, lw=1.5) +tx, ty = [], [] + +def update(frame): + ball.set_data([x_ball[frame]], [y_ball[frame]]) + tx.append(x_ball[frame]); ty.append(y_ball[frame]) + if len(tx) > 60: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t), interval=1000/fps, blit=True) +writer = animation.FFMpegWriter(fps=fps, bitrate=1800) +ani.save("lagrange_roller.mp4", writer=writer, dpi=120) +plt.close() +print("Saved lagrange_roller.mp4") diff --git a/scipy/lagrange_roller/226/video.mp4 b/scipy/lagrange_roller/226/video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..36964d85b5300ef5259cf6868a66f7e8321a392a --- /dev/null +++ b/scipy/lagrange_roller/226/video.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5d465ec452b103feca2df15d6e3a27402396a1ba7c3f32979862a36f36830c9 +size 10389 diff --git a/scipy/lagrange_roller/238/cot.json b/scipy/lagrange_roller/238/cot.json new file mode 100644 index 0000000000000000000000000000000000000000..f32ab5395146e0c073c5d18c00b77da2d1034c05 --- /dev/null +++ b/scipy/lagrange_roller/238/cot.json @@ -0,0 +1,87 @@ +{ + "simulation": "lagrange_roller", + "physical_observation": "A point mass (m=1.091 kg) rolls along the 'hump path' y = 3 + x^2(-7+x^2)/6 (a W-shaped track with a local maximum at x=0 and two symmetric minima at x \\approx \\pm 1.8708 m). Gravity g=9.800 m/s^2, damping b=0.272. Initial position x_0=-0.274 m, velocity v_0=-1.078 m/s.", + "physical_law": { + "name": "Euler-Lagrange Equation on the Hump Path", + "statement": "The particle is constrained to y=f(x); the EOM is derived from the Lagrangian for 1-DOF constrained motion.", + "formula": "\\ddot{x} = -x(-7 + 2x^2)[3g + (-7 + 6x^2)\\dot{x}^2] / [9 + 49x^2 - 28x^4 + 4x^6]" + }, + "ode_system": { + "state_variables": [ + "x (m)", + "v = \\dot{x} (m/s)" + ], + "equations_latex": [ + "\\dot{x} = v", + "\\dot{v} = -x \\cdot (-7 + 2x^2) \\cdot [3g + (-7 + 6x^2) \\cdot v^2] / [9 + 49x^2 - 28x^4 + 4x^6] - (b/m) \\cdot v \\cdot \\sqrt(1+f'^2)", + "where f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3" + ], + "equations_python": [ + "x_dot = v", + "v_dot = -x * (-7 + 2 * x**2) * [3 * g + (-7 + 6 * x**2) * v**2] / [9 + 49 * x**2 - 28 * x**4 + 4 * x**6] - (b/m) * v * np.sqrt (1+f'**2)", + "where f'(x) = x(-7+2 * x**2)/3, f''(x) = (-7+6 * x**2)/3" + ] + }, + "derivation_steps": [ + "Track: y = f(x) = 3 + x^2(-7+x^2)/6.", + "f'(x) = x(-7+2x^2)/3, f''(x) = (-7+6x^2)/3.", + "Constrained Lagrangian (no damping): L = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 - mgf(x).", + "Euler-Lagrange: d/dt[(1+f'^2)\\dot{x}] = f'f''\\dot{x}^2/... - gf' \\rightarrow (1+f'^2)\\ddot{x} + f'f''\\dot{x}^2 + gf' = 0.", + "Substituting f' and f'' and simplifying the denominator 1+f'^2 = 1+(x(-7+2x^2)/3)^2:", + " (9 + x^2(-7+2x^2)^2)/9 \\rightarrow multiply through by 9/m gives the formula above.", + "Full EOM numerator: -x(-7+2x^2) \\cdot [3g + (-7+6x^2) \\cdot \\dot{x}^2].", + "Add damping as a generalized force: -(b/m) \\cdot \\sqrt(1+f'^2) \\cdot \\dot{x}.", + "Equilibrium points: x=0 (local MAX, unstable: f''(0)=-7/3<0).", + "Stable minima: x= \\pm 1.8708 m, f''=14/3, \\omega_small = \\sqrt(g \\cdot f'') = 6.7626 rad/s." + ], + "physical_constants_derived": { + "stable_equilibrium_x_m": 1.8708, + "track_height_at_minima_m": 0.9583, + "f_double_prime_at_minima": 4.6667, + "omega_small_osc_rad_s": 6.7626, + "T_small_osc_s": 0.9291 + }, + "numerical_method": { + "solver": "RK45 (Dormand-Prince, 4th/5th order Runge-Kutta)", + "tolerance": "rtol=1e-9, atol=1e-11", + "justification": "Polynomial track with polynomial EOM; RK45 is efficient for smooth nonlinear ODEs." + }, + "code_validation": { + "ode_source": "Euler-Lagrange on hump path; matches LagrangeRollerSim.ts evaluate()", + "energy_check": "E = \\tfrac{1}{2} m(1+f'^2)\\dot{x}^2 + mgf(x) decreases when b>0", + "physical_plausibility": true + }, + "expected_behavior": [ + "Track has unstable equilibrium at x=0 and stable minima at x \\approx \\pm 1.871 m.", + "Small oscillations near minima: \\omega \\approx 6.763 rad/s (T \\approx 0.929 s).", + "Initial x_0=-0.274: near unstable top.", + "With sufficient initial energy, mass can transit over the central hump between minima." + ], + "parameters": { + "g": { + "value": 9.8, + "unit": "m/s^2", + "description": "" + }, + "m": { + "value": 1.0907371211103731, + "unit": "kg", + "description": "" + }, + "b": { + "value": 0.2717652398540512, + "unit": "dimensionless or kg/s", + "description": "Damping coefficient" + }, + "x0": { + "value": -0.2739241928964047, + "unit": "m", + "description": "Horizontal position on track" + }, + "v0": { + "value": -1.0775924894139495, + "unit": "m/s", + "description": "Horizontal velocity" + } + } +} diff --git a/scipy/lagrange_roller/238/params.json b/scipy/lagrange_roller/238/params.json new file mode 100644 index 0000000000000000000000000000000000000000..67dc7beee28f6b4e6b407de38733298479cbe632 --- /dev/null +++ b/scipy/lagrange_roller/238/params.json @@ -0,0 +1,7 @@ +{ + "g": 9.8, + "m": 1.0907371211103731, + "b": 0.2717652398540512, + "x0": -0.2739241928964047, + "v0": -1.0775924894139495 +} \ No newline at end of file diff --git a/scipy/lagrange_roller/238/simulation_code.py b/scipy/lagrange_roller/238/simulation_code.py new file mode 100644 index 0000000000000000000000000000000000000000..d561a768c51133e5623010da9d4b57a7b40ed7a3 --- /dev/null +++ b/scipy/lagrange_roller/238/simulation_code.py @@ -0,0 +1,73 @@ +""" +Lagrange Roller (Hump Path) — auto-generated simulation script. +Track: y = 3 - (7/6)*x^2 + (1/6)*x^4 (HumpPath from myphysicslab) +Physics: v' = -(x*(-7+2x^2)*(3g+(-7+6x^2)*v^2)) / (9+49x^2-28x^4+4x^6) +""" +import numpy as np +from scipy.integrate import solve_ivp +import matplotlib.pyplot as plt +import matplotlib.animation as animation + + +g = 9.8 +m = 1.0907371211103731 +b = 0.2717652398540512 +x0 = -0.2739241928964047 +v0 = -1.0775924894139495 +duration = 12 + + +def hump(x): + x2 = x * x + y = 3.0 + x2 * (-7.0 + x2) / 6.0 + dydx = x * (-7.0 + 2.0 * x2) / 3.0 + return y, dydx + + +def ode(t, state): + x, v = state + x2 = x * x + num = -(x * (-7.0 + 2.0*x2) * (3.0*g + (-7.0 + 6.0*x2)*v*v)) + den = 9.0 + 49.0*x2 - 28.0*x2*x2 + 4.0*x2*x2*x2 + dv = num / den + if b != 0.0: + _, dydx = hump(np.array([x])) + dv -= (b / m) * v / np.sqrt(1.0 + dydx[0]**2) + return [v, dv] + + +fps = 30 +t_eval = np.linspace(0, duration, int(duration * fps) + 1) +sol = solve_ivp(ode, (0, duration), [x0, v0], + t_eval=t_eval, method="RK45", rtol=1e-8, atol=1e-10) +t, x_ball = sol.t, sol.y[0] +y_ball, _ = hump(x_ball) + + +x_range = np.linspace(-3, 3, 600) +y_track, _ = hump(x_range) + + +fig, ax = plt.subplots(figsize=(8, 5), facecolor="#1a1a2e") +ax.set_facecolor("#16213e") +ax.set_xlim(-3.3, 3.3) +ax.set_ylim(y_track.min() - 0.5, y_track.max() + 0.5) +ax.set_aspect("equal"); ax.axis("off") +ax.plot(x_range, y_track, "-", color="#a8dadc", lw=2.0, alpha=0.7) + +ball, = ax.plot([], [], "o", color="#e63946", ms=12, zorder=5) +trail, = ax.plot([], [], "-", color="#e63946", alpha=0.4, lw=1.5) +tx, ty = [], [] + +def update(frame): + ball.set_data([x_ball[frame]], [y_ball[frame]]) + tx.append(x_ball[frame]); ty.append(y_ball[frame]) + if len(tx) > 60: tx.pop(0); ty.pop(0) + trail.set_data(tx, ty) + return ball, trail + +ani = animation.FuncAnimation(fig, update, frames=len(t), interval=1000/fps, blit=True) +writer = animation.FFMpegWriter(fps=fps, bitrate=1800) +ani.save("lagrange_roller.mp4", writer=writer, dpi=120) +plt.close() +print("Saved lagrange_roller.mp4")