subsea-compute-open-artifacts / scripts /optimize_container_style_design.py
monish133's picture
Upload open subsea compute engineering artifacts
aa6138d verified
Raw
History Blame Contribute Delete
9.48 kB
"""Optimize viable 40-foot container-style subsea concepts with screening physics.
This script focuses on the most credible container-style concept:
an ISO handling envelope with an internal rounded pressure hull.
It searches for geometries that satisfy a target minimum safety factor at depth,
then ranks them by rough payload efficiency.
"""
from __future__ import annotations
import argparse
import json
import math
from dataclasses import asdict
from pathlib import Path
import pandas as pd
from simulate_subsea_container import (
G,
RHO_SEAWATER,
InternalHullDesign,
default_hull_design,
default_material,
evaluate_internal_hull,
gross_cylinder_volume,
hydrostatic_pressure,
)
def shell_mass_kg(design: InternalHullDesign, density_kg_m3: float) -> float:
radius = design.hull_outer_diameter_m / 2.0
cyl_area = 2.0 * math.pi * radius * design.hull_cyl_length_m
head_area = 4.0 * math.pi * radius**2
hatch_area = math.pi * (design.hatch_diameter_m / 2.0) ** 2
return density_kg_m3 * (
cyl_area * design.shell_thickness_m
+ head_area * design.endcap_thickness_m
+ hatch_area * design.hatch_thickness_m
)
def displaced_mass_kg(design: InternalHullDesign) -> float:
return gross_cylinder_volume(design) * RHO_SEAWATER
def broadside_current_drag_n(design: InternalHullDesign, current_speed_m_s: float, cd: float = 0.9) -> float:
projected_area = design.envelope_length_m * design.envelope_height_m
return 0.5 * RHO_SEAWATER * cd * projected_area * current_speed_m_s**2
def evaluate_design(
design: InternalHullDesign,
target_depth_m: float,
min_sf: float,
current_speed_m_s: float,
) -> dict | None:
material = default_material()
checks = evaluate_internal_hull(target_depth_m, material, design)
governing = min(checks, key=lambda c: c.governing_safety_factor)
if governing.governing_safety_factor < min_sf:
return None
shell_mass = shell_mass_kg(design, material.density_kg_m3)
displaced_mass = displaced_mass_kg(design)
gross_volume = gross_cylinder_volume(design)
drag = broadside_current_drag_n(design, current_speed_m_s)
# Simple score: maximize usable volume per tonne of shell mass,
# while slightly penalizing thicker shells.
score = gross_volume / max(shell_mass / 1000.0, 1e-6)
return {
"score": score,
"depth_m": target_depth_m,
"min_sf_required": min_sf,
"governing_component": governing.component,
"governing_sf": governing.governing_safety_factor,
"governing_stress_mpa": governing.stress_pa / 1e6,
"hull_outer_diameter_m": design.hull_outer_diameter_m,
"hull_cyl_length_m": design.hull_cyl_length_m,
"shell_thickness_mm": design.shell_thickness_m * 1000.0,
"endcap_thickness_mm": design.endcap_thickness_m * 1000.0,
"hatch_diameter_m": design.hatch_diameter_m,
"hatch_thickness_mm": design.hatch_thickness_m * 1000.0,
"shell_buckling_knockdown": design.shell_buckling_knockdown,
"head_buckling_knockdown": design.head_buckling_knockdown,
"gross_internal_hull_volume_m3": gross_volume,
"shell_mass_tonnes": shell_mass / 1000.0,
"displaced_mass_tonnes": displaced_mass / 1000.0,
"net_buoyancy_shell_only_tonnes": (displaced_mass - shell_mass) / 1000.0,
"broadside_drag_at_current_kn": drag / 1000.0,
}
def optimize(target_depth_m: float, min_sf: float, current_speed_m_s: float) -> pd.DataFrame:
base = default_hull_design()
rows = []
for diameter in [2.00, 2.05, 2.10, 2.15, 2.20, 2.25]:
# Leave some room in the ISO frame for saddles and service clearance.
if diameter > 2.25:
continue
for cyl_length in [8.8, 9.1, 9.4, 9.7, 10.0]:
if cyl_length + diameter > 12.0:
continue
for shell_mm in [28, 30, 32, 34, 36, 38, 40]:
for head_mm in [32, 35, 38, 40, 42]:
for hatch_d in [0.60, 0.70, 0.80]:
for hatch_mm in [50, 60, 70]:
design = InternalHullDesign(
**{
**asdict(base),
"hull_outer_diameter_m": diameter,
"hull_cyl_length_m": cyl_length,
"shell_thickness_m": shell_mm / 1000.0,
"endcap_thickness_m": head_mm / 1000.0,
"endcap_radius_m": diameter / 2.0,
"hatch_diameter_m": hatch_d,
"hatch_thickness_m": hatch_mm / 1000.0,
}
)
result = evaluate_design(design, target_depth_m, min_sf, current_speed_m_s)
if result:
rows.append(result)
df = pd.DataFrame(rows)
if df.empty:
return df
return df.sort_values(["score", "gross_internal_hull_volume_m3", "governing_sf"], ascending=[False, False, False])
def build_markdown(best: pd.Series, target_depth_m: float, min_sf: float, current_speed_m_s: float) -> str:
pressure_bar = hydrostatic_pressure(target_depth_m) / 1e5
return f"""# Final Recommended Container-Style Subsea Design
## Recommendation
The most viable container-style design from the current screening sweep is:
- a `40-foot ISO handling envelope`
- with a `single internal rounded pressure hull`
- `surface-service only`
- `small pressure hatch only`
- no large cargo-door-style openings in the pressure boundary
This is the best compromise between:
- subsea structural efficiency
- manufacturability
- transportability
- future serviceability at the surface
## Target design point
- Design depth: `{target_depth_m:.0f} m`
- Hydrostatic pressure: `{pressure_bar:.2f} bar(g)`
- Required minimum screening safety factor: `{min_sf:.2f}`
- Reference broadside current for drag check: `{current_speed_m_s:.2f} m/s`
## Final geometry
- Pressure hull OD: `{best['hull_outer_diameter_m']:.2f} m`
- Cylindrical body length: `{best['hull_cyl_length_m']:.2f} m`
- Shell thickness: `{best['shell_thickness_mm']:.0f} mm`
- Endcap thickness: `{best['endcap_thickness_mm']:.0f} mm`
- Hatch diameter: `{best['hatch_diameter_m']:.2f} m`
- Hatch thickness: `{best['hatch_thickness_mm']:.0f} mm`
## Performance in the screening model
- Governing component: `{best['governing_component']}`
- Governing safety factor: `{best['governing_sf']:.2f}`
- Governing stress: `{best['governing_stress_mpa']:.1f} MPa`
- Gross internal hull volume: `{best['gross_internal_hull_volume_m3']:.1f} m^3`
- Shell-only mass: `{best['shell_mass_tonnes']:.1f} tonnes`
- Displaced seawater mass: `{best['displaced_mass_tonnes']:.1f} tonnes`
- Net buoyancy with shell only: `{best['net_buoyancy_shell_only_tonnes']:.1f} tonnes`
- Broadside current drag at `{current_speed_m_s:.2f} m/s`: `{best['broadside_drag_at_current_kn']:.1f} kN`
## Why this wins
This design avoids the main failure mechanisms of flat 40-foot pressure boxes:
- no large flat cargo doors under external pressure
- no large unsupported flat wall panels
- rounded shell carries hydrostatic load more efficiently
- small hatch keeps local pressure-boundary problems manageable
It still preserves the 40-foot logistics advantage:
- ISO-friendly transport envelope
- crane and yard handling compatibility
- modular factory build strategy
## What this is not
This is not a certified subsea vessel design.
It is a strong first-principles screening result aligned with the logic of real subsea design rules:
- hydrostatic pressure loading
- external-pressure shell buckling
- pressure-hatch penalty
- broadside current load screening
For class or fabrication release, the next step would be:
1. shell and plate FEA
2. hatch-ring and penetrator local stress analysis
3. corrosion allowance and fatigue assessment
4. support saddle and lifting analysis
5. thermal / cooling and electrical integration
"""
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Optimize container-style subsea design.")
parser.add_argument("--target-depth-m", type=float, default=100.0)
parser.add_argument("--min-sf", type=float, default=1.5)
parser.add_argument("--current-speed-m-s", type=float, default=1.5)
parser.add_argument(
"--output-dir",
type=Path,
default=Path("underwater_datacenter_project") / "optimized_container_design",
)
return parser.parse_args()
def main() -> None:
args = parse_args()
out = args.output_dir
out.mkdir(parents=True, exist_ok=True)
df = optimize(args.target_depth_m, args.min_sf, args.current_speed_m_s)
if df.empty:
raise SystemExit("No feasible design found in the search space.")
best = df.iloc[0]
df.to_csv(out / "candidate_designs.csv", index=False)
(out / "best_design.json").write_text(best.to_json(indent=2), encoding="utf-8")
(out / "final_design.md").write_text(
build_markdown(best, args.target_depth_m, args.min_sf, args.current_speed_m_s),
encoding="utf-8",
)
print(f"Wrote optimized design to {out.resolve()}")
print(f"Best final design: {(out / 'final_design.md').resolve()}")
if __name__ == "__main__":
main()