subsea-compute-open-artifacts / scripts /optimize_deepwater_container_bundle.py
monish133's picture
Upload open subsea compute engineering artifacts
aa6138d verified
Raw
History Blame Contribute Delete
7.12 kB
"""Optimize deep-water container-format subsea concepts.
The concept space here is intentionally limited to designs that preserve an ISO-like
external handling frame while using multiple internal rounded pressure tubes.
This is a screening optimizer, not certifiable FEA.
"""
from __future__ import annotations
import argparse
import json
import math
from pathlib import Path
import pandas as pd
from simulate_subsea_container import (
G,
RHO_SEAWATER,
default_material,
hydrostatic_pressure,
required_cylinder_thickness,
)
ISO_LENGTH = 12.192
ISO_WIDTH = 2.438
ISO_HEIGHT = 2.591
def tube_volume(radius_m: float, cyl_length_m: float) -> float:
return math.pi * radius_m**2 * cyl_length_m + 4.0 / 3.0 * math.pi * radius_m**3
def tube_area(radius_m: float, cyl_length_m: float) -> float:
return 2.0 * math.pi * radius_m * cyl_length_m + 4.0 * math.pi * radius_m**2
def shell_mass_kg(count: int, radius_m: float, cyl_length_m: float, shell_thickness_m: float, density_kg_m3: float) -> float:
return count * tube_area(radius_m, cyl_length_m) * shell_thickness_m * density_kg_m3
def bundle_fits(layout: str, diameter_m: float, clearance_m: float) -> bool:
if layout == "single":
return diameter_m + 2 * clearance_m <= min(ISO_WIDTH, ISO_HEIGHT)
if layout == "twin":
return 2 * diameter_m + 3 * clearance_m <= ISO_WIDTH and diameter_m + 2 * clearance_m <= ISO_HEIGHT
if layout == "quad":
return 2 * diameter_m + 3 * clearance_m <= ISO_WIDTH and 2 * diameter_m + 3 * clearance_m <= ISO_HEIGHT
raise ValueError(layout)
def tube_count(layout: str) -> int:
return {"single": 1, "twin": 2, "quad": 4}[layout]
def current_drag_kn(current_speed_m_s: float, cd: float = 1.05) -> float:
projected_area = ISO_LENGTH * ISO_HEIGHT
drag = 0.5 * RHO_SEAWATER * cd * projected_area * current_speed_m_s**2
return drag / 1000.0
def optimize(target_depth_m: float, min_sf: float, current_speed_m_s: float) -> pd.DataFrame:
material = default_material()
p = hydrostatic_pressure(target_depth_m)
rows: list[dict] = []
clearance = 0.08
for layout in ["single", "twin", "quad"]:
count = tube_count(layout)
for radius_m in [0.40, 0.45, 0.50, 0.52, 0.55, 0.58, 0.60, 0.70, 0.80, 1.00]:
diameter_m = 2.0 * radius_m
if not bundle_fits(layout, diameter_m, clearance):
continue
# Keep room for endcaps, supports, and cable terminations.
for cyl_length_m in [8.8, 9.2, 9.6, 10.0, 10.4]:
if cyl_length_m + diameter_m + 0.6 > ISO_LENGTH:
continue
shell_thickness_m = required_cylinder_thickness(radius_m, p, material, min_sf, 0.2)
total_volume = count * tube_volume(radius_m, cyl_length_m)
total_shell_mass = shell_mass_kg(
count=count,
radius_m=radius_m,
cyl_length_m=cyl_length_m,
shell_thickness_m=shell_thickness_m,
density_kg_m3=material.density_kg_m3,
)
displaced_mass = total_volume * RHO_SEAWATER
score = total_volume / max(total_shell_mass / 1000.0, 1e-6)
rows.append(
{
"layout": layout,
"tube_count": count,
"tube_od_m": diameter_m,
"tube_radius_m": radius_m,
"tube_cyl_length_m": cyl_length_m,
"shell_thickness_mm": shell_thickness_m * 1000.0,
"gross_internal_volume_m3": total_volume,
"shell_mass_tonnes": total_shell_mass / 1000.0,
"displaced_mass_tonnes": displaced_mass / 1000.0,
"net_buoyancy_shell_only_tonnes": (displaced_mass - total_shell_mass) / 1000.0,
"current_drag_kn": current_drag_kn(current_speed_m_s),
"depth_m": target_depth_m,
"min_sf": min_sf,
"score": score,
}
)
df = pd.DataFrame(rows)
if df.empty:
return df
# Prefer higher payload volume, then better volume-per-mass.
return df.sort_values(
["gross_internal_volume_m3", "score", "shell_mass_tonnes"],
ascending=[False, False, True],
)
def build_markdown(best: pd.Series) -> str:
pressure_bar = hydrostatic_pressure(float(best["depth_m"])) / 1e5
return f"""# Deep-Water Container-Format Design
## Recommended concept
The best deep-water container-format concept from the screening sweep is:
- layout: `{best['layout']}`
- tube count: `{int(best['tube_count'])}`
- each tube OD: `{best['tube_od_m']:.2f} m`
- each cylindrical body length: `{best['tube_cyl_length_m']:.2f} m`
- shell thickness: `{best['shell_thickness_mm']:.1f} mm`
## Why this wins
This design keeps the ISO external handling logic while replacing one large pressure boundary with multiple smaller rounded ones. That reduces shell thickness demand at depth and avoids the flat-wall penalty.
## Screened design point
- design depth: `{best['depth_m']:.0f} m`
- hydrostatic pressure: `{pressure_bar:.2f} bar(g)`
- minimum screening safety factor baked into sizing: `{best['min_sf']:.2f}`
- gross internal pressure volume: `{best['gross_internal_volume_m3']:.1f} m^3`
- shell-only mass: `{best['shell_mass_tonnes']:.1f} t`
- shell-only net buoyancy: `{best['net_buoyancy_shell_only_tonnes']:.1f} t`
- broadside current drag at reference current: `{best['current_drag_kn']:.1f} kN`
## Interpretation
For deeper water, the most plausible container-like architecture is not a single container pressure box. It is an ISO frame carrying multiple smaller pressure tubes.
"""
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Optimize deep-water container-format bundle.")
parser.add_argument("--target-depth-m", type=float, default=300.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_deepwater_container_bundle",
)
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.")
best = df.iloc[0]
df.to_csv(out / "candidate_bundle_designs.csv", index=False)
(out / "best_bundle_design.json").write_text(best.to_json(indent=2), encoding="utf-8")
(out / "final_design.md").write_text(build_markdown(best), encoding="utf-8")
print(f"Wrote outputs to {out.resolve()}")
print(f"Best design file: {(out / 'final_design.md').resolve()}")
if __name__ == "__main__":
main()