Physics-based slackline simulator using Lagrangian mechanics to model elastic behavior under load.
poetry installfrom src.api import Constraints
# Create a 50m slackline with 2000N standing tension
constraints = Constraints(gap_length=50, anchor_tension=2000)
# Add a 75kg person at the 25m mark
constraints.add_slackliner(position=25, mass=75)
# Compute the rig
rig = constraints.rig()
# Access results: x, y (curve), T (tension), A (angle), n/l (lengths)
print(f"Max drop: {min(rig.y):.2f}m, Max tension: {max(rig.T):.0f}N")python src/server.pycurl -X POST http://localhost:5000/rig \
-H "Content-Type: application/json" \
-d '{"gap_length": 50, "anchor_tension": 2000, "slackliners": [[25, 75]]}'c = Constraints(gap_length=25, anchor_tension=2000)
c.add_slackliner(position=12.5, mass=80)
rig = c.rig()c = Constraints(gap_length=100, anchor_tension=3000)
c.add_slackliner(position=30, mass=70)
c.add_slackliner(position=70, mass=80)
rig = c.rig()c = Constraints(gap_length=500, anchor_tension=8000)
c.add_slackliner(position=100, mass=75)
rig = c.rig()Note: This is a static equilibrium solver - it computes the steady-state shape of the slackline under fixed loads. Dynamics (oscillations, bouncing, wave propagation) are not modeled.
Slacklines are modeled as elastic continua using Lagrangian mechanics. The system has two generalized coordinates:
y(x)- vertical drop at horizontal positionxn(x)- natural (unstretched) length of webbing from anchor to positionx
The arc length element is dl = √(1 + y'²) dx, and the stretch ratio is dl/dn. For Hookean elastic webbing with stiffness K, the strain energy density is K/2 · (dl/dn - 1)².
The Lagrangian combines gravitational potential energy and elastic energy:
L = m g y n' + K/2 · (1 + y'²)/n' - K√(1 + y'²) + K/2 · n'
where:
m= mass per meter of webbing (kg/m)g= gravitational acceleration (9.81 m/s²)K= stiffness (N per 100% strain)- Primes denote derivatives with respect to
x
Applying the Euler-Lagrange equations ∂L/∂q - d/dx(∂L/∂q') = 0 for each coordinate yields two coupled second-order ODEs. These are symbolically derived using SymPy and converted to a first-order system:
dy/dx = a
dn/dx = b
da/dx = f₁(x, y, n, a, b; m, g, K)
db/dx = f₂(x, y, n, a, b; m, g, K)
The functions f₁ and f₂ are highly nonlinear (10th order polynomials in the derivatives) - see generate_equations.py for the full symbolic forms.
At anchors: We specify either the anchor tension T or the natural length n. The angle is determined by shooting method (binary search on initial angle until the line reaches the target length/tension).
At point masses: Slackliners create discontinuities in the derivative fields. We use conservation of canonical momentum:
[∂L/∂y']_right - [∂L/∂y']_left = -M g (weight causes momentum jump)
[∂L/∂n']_right - [∂L/∂n']_left = 0 (natural length continuous)
These jump conditions are solved numerically to propagate the solution across each point mass.
The system is integrated using scipy.integrate.RK45 with adaptive step sizing. For a given gap length and anchor tension:
-
Standing tension solve: Integrate the empty line (no slackliners) using a shooting method to find the initial anchor angle that produces the correct gap length at the target tension. This determines the natural length
n₀. -
Loaded configuration: If slackliners are present, re-integrate with natural length
n₀fixed, applying jump boundary conditions at each mass location. -
Post-process: Compute arc length
l, tensionT = K(dl/dn - 1), and angleA = arctan(|y'|)from the solution.
The result is a physically accurate model of the slackline's 3D catenary shape under arbitrary loading conditions.
Material properties (Dyneemite Pro):
K = 40,000 N(stiffness at 100% strain)m = 0.115 kg/m(linear mass density)g = 9.81 m/s²


