| Crates.io | navaltoolbox |
| lib.rs | navaltoolbox |
| version | 0.2.0 |
| created_at | 2026-01-18 17:26:45.880567+00 |
| updated_at | 2026-01-21 19:12:09.193279+00 |
| description | High-performance naval architecture library for hydrostatics, stability, and tank calculations |
| homepage | https://github.com/NavalToolbox/navaltoolbox-lib |
| repository | https://github.com/NavalToolbox/navaltoolbox-lib |
| max_upload_size | |
| id | 2052705 |
| size | 1,388,298 |
High-performance naval architecture library written in Rust with Python bindings.
NavalToolbox is built as a Rust library (navaltoolbox) with optional Python bindings via PyO3/Maturin. This architecture provides:
pip install navaltoolbox
Add to your Cargo.toml:
[dependencies]
navaltoolbox = "0.2"
from navaltoolbox import Hull, Vessel, HydrostaticsCalculator, StabilityCalculator
# Load a hull
hull = Hull("ship.stl")
print(f"Bounds: {hull.get_bounds()}")
# Create a vessel
vessel = Vessel(hull)
# Calculate hydrostatics
# Calculate hydrostatics
calc = HydrostaticsCalculator(vessel, water_density=1025.0)
# Option 1: At draft with VCG
state = calc.calculate_at_draft(5.0, vcg=6.0)
print(f"Volume: {state.volume:.1f} m³")
print(f"Waterplane Area: {state.waterplane_area:.1f} m²")
print(f"GMT (wet): {state.gmt:.3f} m")
# Option 2: Find draft for displacement
state_disp = calc.calculate_at_displacement(512500.0)
print(f"Draft: {state_disp.draft:.3f} m")
# Calculate GZ curve
stab = StabilityCalculator(vessel, water_density=1025.0)
heels = [0, 10, 20, 30, 40, 50, 60]
curve = stab.calculate_gz_curve(
displacement_mass=1000000,
cog=(50.0, 0.0, 5.0),
heels=heels
)
for heel, gz in zip(curve.heels(), curve.values()):
print(f"Heel: {heel}°, GZ: {gz:.3f}m")
# Complete stability analysis (hydrostatics + GZ + wind data)
result = stab.calculate_complete_stability(
displacement_mass=1000000,
cog=(50.0, 0.0, 5.0),
heels=heels
)
print(f"GM0: {result.gm0:.3f}m")
print(f"Max GZ: {result.max_gz:.3f}m at {result.heel_at_max_gz}°")
use navaltoolbox::{Hull, Vessel, HydrostaticsCalculator, StabilityCalculator};
// Load a hull
let hull = Hull::from_stl("ship.stl")?;
println!("Bounds: {:?}", hull.get_bounds());
// Create a vessel
let vessel = Vessel::new(hull);
// Calculate hydrostatics
let calc = HydrostaticsCalculator::new(&vessel, 1025.0);
let state = calc.calculate_at_draft(5.0, 0.0, 0.0, 0.0)?;
println!("Volume: {} m³", state.volume);
// Calculate GZ curve
let stab = StabilityCalculator::new(&vessel, 1025.0);
let heels = vec![0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0];
let curve = stab.calculate_gz_curve(1000000.0, [50.0, 0.0, 5.0], &heels);
for point in &curve.points {
println!("Heel: {}°, GZ: {:.3}m", point.heel, point.value);
}
# Build Rust library
cd rust
cargo build --release
# Build Python package
cd python
maturin develop --release
AGPL-3.0-or-later
NavalToolbox has been developed with care to ensure that all models and methods are correct, and that calculations reflect the most accurate results achievable with the implemented algorithms. However, results must not be considered as a guarantee of performance. The author cannot be held responsible for any inaccuracies in the calculations or for any consequences arising from the use of this software. Users are advised to independently verify critical calculations and to use this software as a tool to support, not replace, professional engineering judgment.