Marketplace › From Ordinate 2D
Bungee jump by energy
A cord that is slack, then a spring: the script's force gives the lowest point the energy method predicts.
Use in Ordinate 2DOpens in the Script tab: it runs when you press Run. Free, no account needed.
"""A bungee jump by energy: the cord is slack for the first 20 m, then pulls like a spring.
A 70 kg jumper falls from the platform; once the distance passes L₀ = 20 m the script adds the cord's force k(d − L₀). Energy
conservation gives the lowest point, mg(L₀ + x) = ½kx², and the script compares it with the fall it simulated.
Runs in the studio (Script tab → Run) and locally: python3 bungee_jump.py
"""
import math
import studio as s
M, K, L0, G = 70.0, 90.0, 20.0, 9.81
TOP = 40.0
s.clear()
s.gravity = (0, -G)
s.box(0, TOP + 0.1, 3, 0.2, static=True, name="Platform", color="#8b939b", collide=False)
s.ground(0, width=20)
jumper = s.circle(0, TOP, 0.5, mass=M, name="Jumper", color="#e5484d", collide=False)
lowest = TOP
@s.on_step
def cord(t, dt):
global lowest
d = TOP - jumper.y
stretch = max(0.0, d - L0)
jumper.force = (0, K * stretch)
lowest = min(lowest, jumper.y)
if round(t / dt) % 12 == 0:
s.record(t=t, y=jumper.y, v=jumper.vy, cord_force=K * stretch)
@s.on_end
def report():
x = (M * G + math.sqrt((M * G) ** 2 + 2 * K * M * G * L0)) / K
print(f"lowest point {TOP - lowest:.2f} m below the platform; energy method: {L0 + x:.2f} m (stretch {x:.2f} m)")
print(f"equilibrium stretch mg/k = {M * G / K:.2f} m")
s.run(14)