Open Work / Python package
rt4-roll-period
Ships sway side to side. Surveyors time how long one full sway takes to estimate how stable the ship is. The textbook formula they use has a small consistent error baked in. This library removes it.
GitHub · PyPI · CI · Back to r4rpi.org
Why it matters
Bernoulli's amplitude correction has been in the textbooks since 1749. This package closes that gap.
Workboats, fishing vessels, traditional sail. Roll-period is their working method, not a sanity check, and their GM margins are tight. The bias compounds.
Sub-µm round-trip against S4 benchmarks. Useful for validating stability simulation codes and for re-processing decades of inclining records to see real trends without the systematic bias on top.
The intuition
Think of a kid on a swing. A small push gives a short, fast swing. A big push gives a long, slow swing: the period grows with amplitude. Ships do the same.
The textbook formula uses the actually-measured period as if it were the small-amplitude limit. Because T_obs > T₀ in real measurements and T sits in the denominator, the textbook returns a GM smaller than the ship actually has. The bias is small (about 1.5% at 20° amplitude) but systematic, and it pushes toward over-conservative loading. Wall-sided hull effects can push the bias the other way; the demo below shows both regimes.
Try it
Pick a vessel preset or set the inputs directly. The chart shows how period changes with amplitude for the recovered GM.
Inputs
Advanced: wall-sided correction
Wall-sided adds a finite-beam correction on top of the linear-GZ pendulum formula. Validated for φ ≤ 30° and BM/GM ≤ 4.
pip install rt4-roll-period · MIT licensedRoll period vs amplitude
Flat dashed line is what the textbook formula assumes. The amber curve is the exact linear-GZ K(m) prediction. The white dot is your observation.
The maths, for those who want it
Show the formulas
The roll equation for a ship with linear restoring moment is the classic nonlinear pendulum:
The exact period at amplitude φ_max involves the complete elliptic integral of the first kind K(m) with m = sin²(φ_max/2):
This result is due to Bernoulli (1749) and is classical mechanics, not novel research. The factor (2/π)·K(m) ≥ 1 grows monotonically with amplitude: the finite-amplitude period is always longer than the small-amplitude limit T₀.
Inverting to recover GM from an observed period:
Because (2K/π)² > 1 for φ_max > 0, the corrected GM is always larger than the small-angle estimate in the linear-GZ regime.
For wall-sided hulls (GZ shape with positive curvature at large angles), the period ratio gains a multiplicative shape factor H(φ_max, BM/GM) from numerical integration of the wall-sided righting arm:
The H grid in the package is bilinear-interpolated on a 13×13 mesh validated against numerical ground truth for φ ≤ 30° and BM/GM ≤ 4. Outside that envelope, fall back to a measured GZ table.
What's in the package
recover_gm_rt4(T_obs, φ, C, B): exact linear-GZ K(m) inversion, closed form via SciPyspecial.ellipk.recover_gm_wall_sided(T_obs, φ, C, B, BM): bilinear interpolation on the 13×13 validated grid H(φ, BM/GM); iteratively solves for GM since ρ = BM/GM depends on GM.build_roll_period_report(...): auto-selects the highest-fidelity method available (GZ table → wall-sided → linear), returns per-method results and envelope warnings.- Also exposes GZ-table workflows (
roll_period_gz_numerical, PCHIP interpolation,assess_gz_table_quality) for vessels with measured righting-arm curves.
Validation (from tests/test_core.py, S4 benchmark)
Open technical reference implementation. Not class-approved software, not a loading computer, not a statutory stability booklet, not a substitute for professional naval architecture review.