Skip to main content

High-performance naval architecture library for hydrostatics, stability, and tank calculations

Project description

NavalToolbox

High-performance naval architecture library for Python, powered by Rust.

PyPI version License: AGPL v3 Python 3.9+

Overview

NavalToolbox provides fast and accurate naval architecture calculations through a Python API, with a high-performance Rust backend that handles the heavy computational work.

Features

  • Hull Geometry: Load and manipulate ship hulls from STL/VTK files
  • 🚢 Multi-hull Support: Catamarans, trimarans, and arbitrary configurations
  • 📊 Hydrostatics: Volume, COB, Waterplane ($A_{wp}$, LCF, $BM_t$, $BM_l$), Free Surface Correction ($GM_{dry}/GM_{wet}$)
  • ⚖️ Stability Analysis: GZ curve calculation with automatic trim optimization
  • 🌊 Downflooding Detection: Automatic detection of submerged openings
  • 🛢️ Tank Management: Fill levels, free surface effects, sounding tables
  • 💨 Wind Heeling: Silhouette-based wind calculations (DXF/VTK support)
  • 📝 Scriptable Verification: Rhai scripting engine for custom stability criteria
  • 🧊 3D Visualization: Interactive vessel and hydrostatic visualization with Plotly
  • 📈 Plotting: Built-in 2D plotting utilities with Matplotlib integration
  • High Performance: Rust backend with Python convenience

Installation

pip install navaltoolbox

Requirements:

  • Python 3.9 or higher
  • No additional dependencies required (all native code included in wheels)

Quick Start

Loading a Hull

from navaltoolbox import Hull

# Load hull from STL file
hull = Hull("ship.stl")

# Get hull dimensions
bounds = hull.get_bounds()
loa = bounds[1] - bounds[0]  # Length overall
boa = bounds[3] - bounds[2]  # Beam overall

print(f"LOA: {loa:.2f}m, BOA: {boa:.2f}m")
print(f"Triangles: {hull.num_triangles()}")

Hydrostatics Calculation

from navaltoolbox import Hull, Vessel, HydrostaticsCalculator

# Create vessel
hull = Hull("ship.stl")
vessel = Vessel(hull)

# Calculate hydrostatics at a given draft
calc = HydrostaticsCalculator(vessel, water_density=1025.0)

# Option 1: At draft with VCG (computes stability)
state = calc.from_draft(draft=5.0, vcg=7.0)

print(f"Volume: {state.volume:.1f} m³")
print(f"Displacement: {state.displacement:.0f} kg")
print(f"COB: ({state.cob[0]:.2f}, {state.cob[1]:.2f}, {state.cob[2]:.2f})")
print(f"Waterplane Area: {state.waterplane_area:.1f} m²")
print(f"LCF: {state.lcf:.2f} m")
print(f"GMT (wet): {state.gmt:.3f} m")
print(f"GMT (dry): {state.gmt_dry:.3f} m")

# Option 2: Find draft for displacement
state_disp = calc.from_displacement(512500.0)
print(f"Draft for {state_disp.displacement:.0f}kg: {state_disp.draft:.3f} m")

Stability Analysis (GZ Curve)

from navaltoolbox import Hull, Vessel, StabilityCalculator

# Create vessel and calculator
hull = Hull("ship.stl")
vessel = Vessel(hull)
calc = StabilityCalculator(vessel, water_density=1025.0)

# Calculate GZ curve
displacement_mass = 8635000.0  # kg
cog = (71.67, 0.0, 7.555)      # LCG, TCG, VCG in meters
heels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]

curve = calc.gz_curve(displacement_mass, cog, heels)

# Display results
print("Heel (°)  |  GZ (m)")
print("-" * 25)
for heel, gz in zip(curve.heels(), curve.values()):
    print(f"{heel:7.1f}  |  {gz:7.3f}")

# Get max GZ
gz_values = curve.values()
max_gz = max(gz_values)
max_idx = gz_values.index(max_gz)
max_heel = heels[max_idx]
print(f"\nMax GZ: {max_gz:.3f}m at {max_heel}°")

Documentation

For more detailed documentation, examples, and API reference, visit:

Performance

NavalToolbox is built with performance in mind:

  • Written in Rust for maximum speed and memory safety
  • Efficient mesh operations using parry3d
  • Parallel processing where applicable
  • Zero-copy data transfer between Python and Rust

Example benchmark (DTMB 5415 hull, 3436 triangles):

  • Load STL: ~10ms
  • Hydrostatics calculation: ~50ms
  • GZ curve (13 points): ~650ms

Use Cases

NavalToolbox is suitable for:

  • 🎓 Naval architecture education: Teaching hydrostatics and stability
  • 🔬 Research: Rapid prototyping of new methods and algorithms
  • 🏭 Engineering: Production stability calculations and analysis
  • 🤖 Optimization: Integration with optimization frameworks
  • 📊 Batch processing: Analyzing multiple design variants

Requirements and Compatibility

  • Python: 3.9, 3.10, 3.11, 3.12, 3.13
  • Operating Systems:
    • macOS (Intel and Apple Silicon)
    • Linux (x86_64, aarch64)
    • Windows (x86_64)
  • File Formats:
    • Hull geometry: STL (binary and ASCII), VTK
    • Silhouettes: DXF, VTK

Contributing

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests on GitHub.

License

This project is licensed under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later).

This means:

  • ✅ Free to use, modify, and distribute
  • ✅ Can be used in commercial projects
  • ⚠️ Source code must be made available under AGPL
  • ⚠️ Network use is considered distribution (AGPL provision)

See the LICENSE file for details.

Disclaimer

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.

Citation

If you use NavalToolbox in your research, please cite:

@software{navaltoolbox2026,
  author = {Anceau, Antoine},
  title = {NavalToolbox: High-performance naval architecture library},
  year = {2026},
  url = {https://github.com/NavalToolbox/navaltoolbox-lib}
}

Author

Antoine ANCEAU

Support


Note: This package uses a Rust backend for high performance. Pre-built wheels are provided for common platforms. If a wheel is not available for your platform, the package will attempt to build from source (requires Rust toolchain).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

navaltoolbox-0.4.3.tar.gz (308.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

navaltoolbox-0.4.3-cp313-cp313-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.13Windows x86-64

navaltoolbox-0.4.3-cp313-cp313-manylinux_2_35_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

navaltoolbox-0.4.3-cp313-cp313-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

navaltoolbox-0.4.3-cp312-cp312-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86-64

navaltoolbox-0.4.3-cp312-cp312-manylinux_2_35_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

navaltoolbox-0.4.3-cp312-cp312-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

navaltoolbox-0.4.3-cp311-cp311-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.11Windows x86-64

navaltoolbox-0.4.3-cp311-cp311-manylinux_2_35_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

navaltoolbox-0.4.3-cp311-cp311-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

navaltoolbox-0.4.3-cp310-cp310-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.10Windows x86-64

navaltoolbox-0.4.3-cp310-cp310-manylinux_2_35_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

navaltoolbox-0.4.3-cp310-cp310-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

navaltoolbox-0.4.3-cp39-cp39-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.9Windows x86-64

navaltoolbox-0.4.3-cp39-cp39-manylinux_2_35_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.35+ x86-64

navaltoolbox-0.4.3-cp39-cp39-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page