navaltoolbox 0.1.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- navaltoolbox-0.3.0/PKG-INFO +234 -0
- navaltoolbox-0.3.0/README.md +205 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/navaltoolbox/__init__.py +11 -1
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/navaltoolbox/navaltoolbox.pyi +604 -30
- navaltoolbox-0.3.0/navaltoolbox/plotting.py +173 -0
- navaltoolbox-0.3.0/navaltoolbox/visualization.py +825 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/pyproject.toml +11 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/Cargo.lock +308 -3
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/Cargo.toml +11 -1
- navaltoolbox-0.3.0/rust/README.md +164 -0
- navaltoolbox-0.3.0/rust/src/downflooding/loader.rs +375 -0
- navaltoolbox-0.1.0/rust/src/downflooding.rs → navaltoolbox-0.3.0/rust/src/downflooding/mod.rs +30 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/hull.rs +141 -5
- navaltoolbox-0.3.0/rust/src/hydrostatics/calculator.rs +869 -0
- navaltoolbox-0.3.0/rust/src/hydrostatics/dataclasses.rs +163 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/hydrostatics/mod.rs +2 -0
- navaltoolbox-0.3.0/rust/src/hydrostatics/waterplane.rs +493 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/lib.rs +17 -2
- navaltoolbox-0.3.0/rust/src/mesh/clipper.rs +419 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/mesh/loader.rs +51 -7
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/mesh/mod.rs +1 -1
- navaltoolbox-0.3.0/rust/src/python.rs +1721 -0
- navaltoolbox-0.3.0/rust/src/scripting/context.rs +453 -0
- navaltoolbox-0.3.0/rust/src/scripting/engine.rs +481 -0
- navaltoolbox-0.3.0/rust/src/scripting/mod.rs +29 -0
- navaltoolbox-0.3.0/rust/src/scripting/result.rs +307 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/silhouette/core.rs +15 -0
- navaltoolbox-0.3.0/rust/src/stability/calculator.rs +678 -0
- navaltoolbox-0.3.0/rust/src/stability/complete.rs +113 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/stability/mod.rs +3 -1
- navaltoolbox-0.3.0/rust/src/tanks/tank.rs +511 -0
- navaltoolbox-0.3.0/rust/tests/dtmb_validation.rs +90 -0
- navaltoolbox-0.3.0/rust/tests/extended_hydrostatics.rs +129 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/tests/integration_tests.rs +173 -15
- navaltoolbox-0.1.0/PKG-INFO +0 -20
- navaltoolbox-0.1.0/rust/README.md +0 -117
- navaltoolbox-0.1.0/rust/src/hydrostatics/calculator.rs +0 -221
- navaltoolbox-0.1.0/rust/src/hydrostatics/dataclasses.rs +0 -78
- navaltoolbox-0.1.0/rust/src/mesh/clipper.rs +0 -289
- navaltoolbox-0.1.0/rust/src/python.rs +0 -820
- navaltoolbox-0.1.0/rust/src/stability/calculator.rs +0 -293
- navaltoolbox-0.1.0/rust/src/tanks/tank.rs +0 -288
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/navaltoolbox/py.typed +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/mesh/transform.rs +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/silhouette/loader.rs +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/silhouette/mod.rs +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/stability/dataclasses.rs +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/tanks/dataclasses.rs +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/tanks/mod.rs +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/src/vessel.rs +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/tests/data/box_10x10.stl +0 -0
- {navaltoolbox-0.1.0 → navaltoolbox-0.3.0}/rust/tests/data/dtmb5415.stl +0 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: navaltoolbox
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Intended Audience :: Science/Research
|
|
6
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Rust
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Requires-Dist: plotly>=5.0.0
|
|
16
|
+
Requires-Dist: numpy>=1.20.0
|
|
17
|
+
Summary: High-performance naval architecture library for hydrostatics, stability, and tank calculations
|
|
18
|
+
Keywords: naval-architecture,hydrostatics,stability,marine-engineering,ship-design
|
|
19
|
+
Home-Page: https://github.com/NavalToolbox/navaltoolbox-lib
|
|
20
|
+
Author: Antoine ANCEAU
|
|
21
|
+
License: AGPL-3.0-or-later
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
24
|
+
Project-URL: Documentation, https://navaltoolbox.github.io/navaltoolbox-lib
|
|
25
|
+
Project-URL: Homepage, https://www.navaltoolbox.com
|
|
26
|
+
Project-URL: Issues, https://github.com/NavalToolbox/navaltoolbox-lib/issues
|
|
27
|
+
Project-URL: Repository, https://github.com/NavalToolbox/navaltoolbox-lib
|
|
28
|
+
|
|
29
|
+
# NavalToolbox
|
|
30
|
+
|
|
31
|
+
High-performance naval architecture library for Python, powered by Rust.
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/navaltoolbox/)
|
|
34
|
+
[](https://www.gnu.org/licenses/agpl-3.0)
|
|
35
|
+
[](https://www.python.org/downloads/)
|
|
36
|
+
|
|
37
|
+
## Overview
|
|
38
|
+
|
|
39
|
+
NavalToolbox provides fast and accurate naval architecture calculations through a Python API, with a high-performance Rust backend that handles the heavy computational work.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- ⚓ **Hull Geometry**: Load and manipulate ship hulls from STL/VTK files
|
|
44
|
+
- 🚢 **Multi-hull Support**: Catamarans, trimarans, and arbitrary configurations
|
|
45
|
+
- 📊 **Hydrostatics**: Volume, COB, Waterplane ($A_{wp}$, LCF, $BM_t$, $BM_l$), Free Surface Correction ($GM_{dry}/GM_{wet}$)
|
|
46
|
+
- ⚖️ **Stability Analysis**: GZ curve calculation with automatic trim optimization
|
|
47
|
+
- 🌊 **Downflooding Detection**: Automatic detection of submerged openings
|
|
48
|
+
- 🛢️ **Tank Management**: Fill levels, free surface effects, sounding tables
|
|
49
|
+
- 💨 **Wind Heeling**: Silhouette-based wind calculations (DXF/VTK support)
|
|
50
|
+
- 📝 **Scriptable Verification**: Rhai scripting engine for custom stability criteria
|
|
51
|
+
- 🧊 **3D Visualization**: Interactive vessel and hydrostatic visualization with Plotly
|
|
52
|
+
- 📈 **Plotting**: Built-in 2D plotting utilities with Matplotlib integration
|
|
53
|
+
- ⚡ **High Performance**: Rust backend with Python convenience
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install navaltoolbox
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Requirements:**
|
|
62
|
+
- Python 3.9 or higher
|
|
63
|
+
- No additional dependencies required (all native code included in wheels)
|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
### Loading a Hull
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from navaltoolbox import Hull
|
|
71
|
+
|
|
72
|
+
# Load hull from STL file
|
|
73
|
+
hull = Hull("ship.stl")
|
|
74
|
+
|
|
75
|
+
# Get hull dimensions
|
|
76
|
+
bounds = hull.get_bounds()
|
|
77
|
+
loa = bounds[1] - bounds[0] # Length overall
|
|
78
|
+
boa = bounds[3] - bounds[2] # Beam overall
|
|
79
|
+
|
|
80
|
+
print(f"LOA: {loa:.2f}m, BOA: {boa:.2f}m")
|
|
81
|
+
print(f"Triangles: {hull.num_triangles()}")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Hydrostatics Calculation
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from navaltoolbox import Hull, Vessel, HydrostaticsCalculator
|
|
88
|
+
|
|
89
|
+
# Create vessel
|
|
90
|
+
hull = Hull("ship.stl")
|
|
91
|
+
vessel = Vessel(hull)
|
|
92
|
+
|
|
93
|
+
# Calculate hydrostatics at a given draft
|
|
94
|
+
calc = HydrostaticsCalculator(vessel, water_density=1025.0)
|
|
95
|
+
|
|
96
|
+
# Option 1: At draft with VCG (computes stability)
|
|
97
|
+
state = calc.from_draft(draft=5.0, vcg=7.0)
|
|
98
|
+
|
|
99
|
+
print(f"Volume: {state.volume:.1f} m³")
|
|
100
|
+
print(f"Displacement: {state.displacement:.0f} kg")
|
|
101
|
+
print(f"COB: ({state.cob[0]:.2f}, {state.cob[1]:.2f}, {state.cob[2]:.2f})")
|
|
102
|
+
print(f"Waterplane Area: {state.waterplane_area:.1f} m²")
|
|
103
|
+
print(f"LCF: {state.lcf:.2f} m")
|
|
104
|
+
print(f"GMT (wet): {state.gmt:.3f} m")
|
|
105
|
+
print(f"GMT (dry): {state.gmt_dry:.3f} m")
|
|
106
|
+
|
|
107
|
+
# Option 2: Find draft for displacement
|
|
108
|
+
state_disp = calc.from_displacement(512500.0)
|
|
109
|
+
print(f"Draft for {state_disp.displacement:.0f}kg: {state_disp.draft:.3f} m")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Stability Analysis (GZ Curve)
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from navaltoolbox import Hull, Vessel, StabilityCalculator
|
|
116
|
+
|
|
117
|
+
# Create vessel and calculator
|
|
118
|
+
hull = Hull("ship.stl")
|
|
119
|
+
vessel = Vessel(hull)
|
|
120
|
+
calc = StabilityCalculator(vessel, water_density=1025.0)
|
|
121
|
+
|
|
122
|
+
# Calculate GZ curve
|
|
123
|
+
displacement_mass = 8635000.0 # kg
|
|
124
|
+
cog = (71.67, 0.0, 7.555) # LCG, TCG, VCG in meters
|
|
125
|
+
heels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]
|
|
126
|
+
|
|
127
|
+
curve = calc.gz_curve(displacement_mass, cog, heels)
|
|
128
|
+
|
|
129
|
+
# Display results
|
|
130
|
+
print("Heel (°) | GZ (m)")
|
|
131
|
+
print("-" * 25)
|
|
132
|
+
for heel, gz in zip(curve.heels(), curve.values()):
|
|
133
|
+
print(f"{heel:7.1f} | {gz:7.3f}")
|
|
134
|
+
|
|
135
|
+
# Get max GZ
|
|
136
|
+
gz_values = curve.values()
|
|
137
|
+
max_gz = max(gz_values)
|
|
138
|
+
max_idx = gz_values.index(max_gz)
|
|
139
|
+
max_heel = heels[max_idx]
|
|
140
|
+
print(f"\nMax GZ: {max_gz:.3f}m at {max_heel}°")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Documentation
|
|
144
|
+
|
|
145
|
+
For more detailed documentation, examples, and API reference, visit:
|
|
146
|
+
- **Documentation**: [GitHub Pages](https://navaltoolbox.github.io/navaltoolbox-lib/)
|
|
147
|
+
- **GitHub Repository**: [NavalToolbox/navaltoolbox-lib](https://github.com/NavalToolbox/navaltoolbox-lib)
|
|
148
|
+
- **Issue Tracker**: [GitHub Issues](https://github.com/NavalToolbox/navaltoolbox-lib/issues)
|
|
149
|
+
|
|
150
|
+
## Performance
|
|
151
|
+
|
|
152
|
+
NavalToolbox is built with performance in mind:
|
|
153
|
+
|
|
154
|
+
- Written in **Rust** for maximum speed and memory safety
|
|
155
|
+
- Efficient mesh operations using `parry3d`
|
|
156
|
+
- Parallel processing where applicable
|
|
157
|
+
- Zero-copy data transfer between Python and Rust
|
|
158
|
+
|
|
159
|
+
Example benchmark (DTMB 5415 hull, 3436 triangles):
|
|
160
|
+
- Load STL: ~10ms
|
|
161
|
+
- Hydrostatics calculation: ~50ms
|
|
162
|
+
- GZ curve (13 points): ~650ms
|
|
163
|
+
|
|
164
|
+
## Use Cases
|
|
165
|
+
|
|
166
|
+
NavalToolbox is suitable for:
|
|
167
|
+
|
|
168
|
+
- 🎓 **Naval architecture education**: Teaching hydrostatics and stability
|
|
169
|
+
- 🔬 **Research**: Rapid prototyping of new methods and algorithms
|
|
170
|
+
- 🏭 **Engineering**: Production stability calculations and analysis
|
|
171
|
+
- 🤖 **Optimization**: Integration with optimization frameworks
|
|
172
|
+
- 📊 **Batch processing**: Analyzing multiple design variants
|
|
173
|
+
|
|
174
|
+
## Requirements and Compatibility
|
|
175
|
+
|
|
176
|
+
- **Python**: 3.9, 3.10, 3.11, 3.12, 3.13
|
|
177
|
+
- **Operating Systems**:
|
|
178
|
+
- macOS (Intel and Apple Silicon)
|
|
179
|
+
- Linux (x86_64, aarch64)
|
|
180
|
+
- Windows (x86_64)
|
|
181
|
+
- **File Formats**:
|
|
182
|
+
- Hull geometry: STL (binary and ASCII), VTK
|
|
183
|
+
- Silhouettes: DXF, VTK
|
|
184
|
+
|
|
185
|
+
## Contributing
|
|
186
|
+
|
|
187
|
+
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests on GitHub.
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
This project is licensed under the **GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later)**.
|
|
192
|
+
|
|
193
|
+
This means:
|
|
194
|
+
- ✅ Free to use, modify, and distribute
|
|
195
|
+
- ✅ Can be used in commercial projects
|
|
196
|
+
- ⚠️ Source code must be made available under AGPL
|
|
197
|
+
- ⚠️ Network use is considered distribution (AGPL provision)
|
|
198
|
+
|
|
199
|
+
See the [LICENSE](https://github.com/NavalToolbox/navaltoolbox-lib/blob/main/LICENSE) file for details.
|
|
200
|
+
|
|
201
|
+
## Disclaimer
|
|
202
|
+
|
|
203
|
+
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.
|
|
204
|
+
|
|
205
|
+
## Citation
|
|
206
|
+
|
|
207
|
+
If you use NavalToolbox in your research, please cite:
|
|
208
|
+
|
|
209
|
+
```bibtex
|
|
210
|
+
@software{navaltoolbox2026,
|
|
211
|
+
author = {Anceau, Antoine},
|
|
212
|
+
title = {NavalToolbox: High-performance naval architecture library},
|
|
213
|
+
year = {2026},
|
|
214
|
+
url = {https://github.com/NavalToolbox/navaltoolbox-lib}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Author
|
|
219
|
+
|
|
220
|
+
**Antoine ANCEAU**
|
|
221
|
+
- GitHub: [@antoineanceau](https://github.com/antoineanceau)
|
|
222
|
+
- Website: [antoine.anceau.fr](https://antoine.anceau.fr)
|
|
223
|
+
|
|
224
|
+
## Support
|
|
225
|
+
|
|
226
|
+
- 📖 **Documentation**: [GitHub Pages](https://navaltoolbox.github.io/navaltoolbox-lib)
|
|
227
|
+
- 🐛 **Bug Reports**: [Open an issue](https://github.com/NavalToolbox/navaltoolbox-lib/issues)
|
|
228
|
+
- 💬 **Discussions**: [GitHub Discussions](https://github.com/NavalToolbox/navaltoolbox-lib/discussions)
|
|
229
|
+
- 📧 **Email**: For private inquiries
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
**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).
|
|
234
|
+
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# NavalToolbox
|
|
2
|
+
|
|
3
|
+
High-performance naval architecture library for Python, powered by Rust.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/navaltoolbox/)
|
|
6
|
+
[](https://www.gnu.org/licenses/agpl-3.0)
|
|
7
|
+
[](https://www.python.org/downloads/)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
NavalToolbox provides fast and accurate naval architecture calculations through a Python API, with a high-performance Rust backend that handles the heavy computational work.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- ⚓ **Hull Geometry**: Load and manipulate ship hulls from STL/VTK files
|
|
16
|
+
- 🚢 **Multi-hull Support**: Catamarans, trimarans, and arbitrary configurations
|
|
17
|
+
- 📊 **Hydrostatics**: Volume, COB, Waterplane ($A_{wp}$, LCF, $BM_t$, $BM_l$), Free Surface Correction ($GM_{dry}/GM_{wet}$)
|
|
18
|
+
- ⚖️ **Stability Analysis**: GZ curve calculation with automatic trim optimization
|
|
19
|
+
- 🌊 **Downflooding Detection**: Automatic detection of submerged openings
|
|
20
|
+
- 🛢️ **Tank Management**: Fill levels, free surface effects, sounding tables
|
|
21
|
+
- 💨 **Wind Heeling**: Silhouette-based wind calculations (DXF/VTK support)
|
|
22
|
+
- 📝 **Scriptable Verification**: Rhai scripting engine for custom stability criteria
|
|
23
|
+
- 🧊 **3D Visualization**: Interactive vessel and hydrostatic visualization with Plotly
|
|
24
|
+
- 📈 **Plotting**: Built-in 2D plotting utilities with Matplotlib integration
|
|
25
|
+
- ⚡ **High Performance**: Rust backend with Python convenience
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install navaltoolbox
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Requirements:**
|
|
34
|
+
- Python 3.9 or higher
|
|
35
|
+
- No additional dependencies required (all native code included in wheels)
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
### Loading a Hull
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from navaltoolbox import Hull
|
|
43
|
+
|
|
44
|
+
# Load hull from STL file
|
|
45
|
+
hull = Hull("ship.stl")
|
|
46
|
+
|
|
47
|
+
# Get hull dimensions
|
|
48
|
+
bounds = hull.get_bounds()
|
|
49
|
+
loa = bounds[1] - bounds[0] # Length overall
|
|
50
|
+
boa = bounds[3] - bounds[2] # Beam overall
|
|
51
|
+
|
|
52
|
+
print(f"LOA: {loa:.2f}m, BOA: {boa:.2f}m")
|
|
53
|
+
print(f"Triangles: {hull.num_triangles()}")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Hydrostatics Calculation
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from navaltoolbox import Hull, Vessel, HydrostaticsCalculator
|
|
60
|
+
|
|
61
|
+
# Create vessel
|
|
62
|
+
hull = Hull("ship.stl")
|
|
63
|
+
vessel = Vessel(hull)
|
|
64
|
+
|
|
65
|
+
# Calculate hydrostatics at a given draft
|
|
66
|
+
calc = HydrostaticsCalculator(vessel, water_density=1025.0)
|
|
67
|
+
|
|
68
|
+
# Option 1: At draft with VCG (computes stability)
|
|
69
|
+
state = calc.from_draft(draft=5.0, vcg=7.0)
|
|
70
|
+
|
|
71
|
+
print(f"Volume: {state.volume:.1f} m³")
|
|
72
|
+
print(f"Displacement: {state.displacement:.0f} kg")
|
|
73
|
+
print(f"COB: ({state.cob[0]:.2f}, {state.cob[1]:.2f}, {state.cob[2]:.2f})")
|
|
74
|
+
print(f"Waterplane Area: {state.waterplane_area:.1f} m²")
|
|
75
|
+
print(f"LCF: {state.lcf:.2f} m")
|
|
76
|
+
print(f"GMT (wet): {state.gmt:.3f} m")
|
|
77
|
+
print(f"GMT (dry): {state.gmt_dry:.3f} m")
|
|
78
|
+
|
|
79
|
+
# Option 2: Find draft for displacement
|
|
80
|
+
state_disp = calc.from_displacement(512500.0)
|
|
81
|
+
print(f"Draft for {state_disp.displacement:.0f}kg: {state_disp.draft:.3f} m")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Stability Analysis (GZ Curve)
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from navaltoolbox import Hull, Vessel, StabilityCalculator
|
|
88
|
+
|
|
89
|
+
# Create vessel and calculator
|
|
90
|
+
hull = Hull("ship.stl")
|
|
91
|
+
vessel = Vessel(hull)
|
|
92
|
+
calc = StabilityCalculator(vessel, water_density=1025.0)
|
|
93
|
+
|
|
94
|
+
# Calculate GZ curve
|
|
95
|
+
displacement_mass = 8635000.0 # kg
|
|
96
|
+
cog = (71.67, 0.0, 7.555) # LCG, TCG, VCG in meters
|
|
97
|
+
heels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]
|
|
98
|
+
|
|
99
|
+
curve = calc.gz_curve(displacement_mass, cog, heels)
|
|
100
|
+
|
|
101
|
+
# Display results
|
|
102
|
+
print("Heel (°) | GZ (m)")
|
|
103
|
+
print("-" * 25)
|
|
104
|
+
for heel, gz in zip(curve.heels(), curve.values()):
|
|
105
|
+
print(f"{heel:7.1f} | {gz:7.3f}")
|
|
106
|
+
|
|
107
|
+
# Get max GZ
|
|
108
|
+
gz_values = curve.values()
|
|
109
|
+
max_gz = max(gz_values)
|
|
110
|
+
max_idx = gz_values.index(max_gz)
|
|
111
|
+
max_heel = heels[max_idx]
|
|
112
|
+
print(f"\nMax GZ: {max_gz:.3f}m at {max_heel}°")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Documentation
|
|
116
|
+
|
|
117
|
+
For more detailed documentation, examples, and API reference, visit:
|
|
118
|
+
- **Documentation**: [GitHub Pages](https://navaltoolbox.github.io/navaltoolbox-lib/)
|
|
119
|
+
- **GitHub Repository**: [NavalToolbox/navaltoolbox-lib](https://github.com/NavalToolbox/navaltoolbox-lib)
|
|
120
|
+
- **Issue Tracker**: [GitHub Issues](https://github.com/NavalToolbox/navaltoolbox-lib/issues)
|
|
121
|
+
|
|
122
|
+
## Performance
|
|
123
|
+
|
|
124
|
+
NavalToolbox is built with performance in mind:
|
|
125
|
+
|
|
126
|
+
- Written in **Rust** for maximum speed and memory safety
|
|
127
|
+
- Efficient mesh operations using `parry3d`
|
|
128
|
+
- Parallel processing where applicable
|
|
129
|
+
- Zero-copy data transfer between Python and Rust
|
|
130
|
+
|
|
131
|
+
Example benchmark (DTMB 5415 hull, 3436 triangles):
|
|
132
|
+
- Load STL: ~10ms
|
|
133
|
+
- Hydrostatics calculation: ~50ms
|
|
134
|
+
- GZ curve (13 points): ~650ms
|
|
135
|
+
|
|
136
|
+
## Use Cases
|
|
137
|
+
|
|
138
|
+
NavalToolbox is suitable for:
|
|
139
|
+
|
|
140
|
+
- 🎓 **Naval architecture education**: Teaching hydrostatics and stability
|
|
141
|
+
- 🔬 **Research**: Rapid prototyping of new methods and algorithms
|
|
142
|
+
- 🏭 **Engineering**: Production stability calculations and analysis
|
|
143
|
+
- 🤖 **Optimization**: Integration with optimization frameworks
|
|
144
|
+
- 📊 **Batch processing**: Analyzing multiple design variants
|
|
145
|
+
|
|
146
|
+
## Requirements and Compatibility
|
|
147
|
+
|
|
148
|
+
- **Python**: 3.9, 3.10, 3.11, 3.12, 3.13
|
|
149
|
+
- **Operating Systems**:
|
|
150
|
+
- macOS (Intel and Apple Silicon)
|
|
151
|
+
- Linux (x86_64, aarch64)
|
|
152
|
+
- Windows (x86_64)
|
|
153
|
+
- **File Formats**:
|
|
154
|
+
- Hull geometry: STL (binary and ASCII), VTK
|
|
155
|
+
- Silhouettes: DXF, VTK
|
|
156
|
+
|
|
157
|
+
## Contributing
|
|
158
|
+
|
|
159
|
+
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests on GitHub.
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
This project is licensed under the **GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later)**.
|
|
164
|
+
|
|
165
|
+
This means:
|
|
166
|
+
- ✅ Free to use, modify, and distribute
|
|
167
|
+
- ✅ Can be used in commercial projects
|
|
168
|
+
- ⚠️ Source code must be made available under AGPL
|
|
169
|
+
- ⚠️ Network use is considered distribution (AGPL provision)
|
|
170
|
+
|
|
171
|
+
See the [LICENSE](https://github.com/NavalToolbox/navaltoolbox-lib/blob/main/LICENSE) file for details.
|
|
172
|
+
|
|
173
|
+
## Disclaimer
|
|
174
|
+
|
|
175
|
+
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.
|
|
176
|
+
|
|
177
|
+
## Citation
|
|
178
|
+
|
|
179
|
+
If you use NavalToolbox in your research, please cite:
|
|
180
|
+
|
|
181
|
+
```bibtex
|
|
182
|
+
@software{navaltoolbox2026,
|
|
183
|
+
author = {Anceau, Antoine},
|
|
184
|
+
title = {NavalToolbox: High-performance naval architecture library},
|
|
185
|
+
year = {2026},
|
|
186
|
+
url = {https://github.com/NavalToolbox/navaltoolbox-lib}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Author
|
|
191
|
+
|
|
192
|
+
**Antoine ANCEAU**
|
|
193
|
+
- GitHub: [@antoineanceau](https://github.com/antoineanceau)
|
|
194
|
+
- Website: [antoine.anceau.fr](https://antoine.anceau.fr)
|
|
195
|
+
|
|
196
|
+
## Support
|
|
197
|
+
|
|
198
|
+
- 📖 **Documentation**: [GitHub Pages](https://navaltoolbox.github.io/navaltoolbox-lib)
|
|
199
|
+
- 🐛 **Bug Reports**: [Open an issue](https://github.com/NavalToolbox/navaltoolbox-lib/issues)
|
|
200
|
+
- 💬 **Discussions**: [GitHub Discussions](https://github.com/NavalToolbox/navaltoolbox-lib/discussions)
|
|
201
|
+
- 📧 **Email**: For private inquiries
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
**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).
|
|
@@ -36,7 +36,7 @@ Example:
|
|
|
36
36
|
>>> hull = Hull("ship.stl")
|
|
37
37
|
>>> vessel = Vessel(hull)
|
|
38
38
|
>>> calc = HydrostaticsCalculator(vessel)
|
|
39
|
-
>>> state = calc.
|
|
39
|
+
>>> state = calc.from_draft(5.0)
|
|
40
40
|
>>> print(f"Displacement: {state.displacement:.0f} kg")
|
|
41
41
|
"""
|
|
42
42
|
|
|
@@ -53,6 +53,11 @@ from .navaltoolbox import (
|
|
|
53
53
|
StabilityCurve,
|
|
54
54
|
StabilityCalculator,
|
|
55
55
|
Tank,
|
|
56
|
+
CompleteStabilityResult,
|
|
57
|
+
CriterionResult,
|
|
58
|
+
CriteriaResult,
|
|
59
|
+
CriteriaContext,
|
|
60
|
+
ScriptEngine,
|
|
56
61
|
)
|
|
57
62
|
|
|
58
63
|
__all__ = [
|
|
@@ -67,4 +72,9 @@ __all__ = [
|
|
|
67
72
|
"StabilityCurve",
|
|
68
73
|
"StabilityCalculator",
|
|
69
74
|
"Tank",
|
|
75
|
+
"CompleteStabilityResult",
|
|
76
|
+
"CriterionResult",
|
|
77
|
+
"CriteriaResult",
|
|
78
|
+
"CriteriaContext",
|
|
79
|
+
"ScriptEngine",
|
|
70
80
|
]
|