| """Structural screening simulator for subsea 40-foot datacenter concepts. |
| |
| This is a first-pass engineering model meant to answer: |
| 1. How badly does a flat-wall 40-foot box behave under subsea hydrostatic load? |
| 2. Can a 40-foot transport envelope work if the actual pressure boundary is rounded? |
| 3. Which components become the likely first failure mode as depth increases? |
| |
| It is not a nonlinear FEA, CFD, or fatigue model. It uses conservative classical |
| screening formulas: |
| - Hydrostatic pressure: p = rho * g * h |
| - Flat panels / hatches: fixed-fixed beam strip approximation |
| - Cylindrical shell: membrane compression + elastic shell buckling with an |
| imperfection knockdown factor |
| - Dished/spherical endcaps: membrane compression + elastic shell buckling |
| |
| The main value is design ranking and failure-mode identification, not code sign-off. |
| """ |
|
|
| from __future__ import annotations |
|
|
| import argparse |
| import json |
| import math |
| from dataclasses import asdict, dataclass |
| from pathlib import Path |
|
|
| import matplotlib.pyplot as plt |
| import numpy as np |
| import pandas as pd |
|
|
|
|
| RHO_SEAWATER = 1025.0 |
| G = 9.81 |
|
|
|
|
| @dataclass(frozen=True) |
| class Material: |
| name: str |
| youngs_modulus_pa: float |
| poisson_ratio: float |
| yield_strength_pa: float |
| density_kg_m3: float |
|
|
|
|
| @dataclass(frozen=True) |
| class BoxContainerDesign: |
| name: str |
| outer_length_m: float |
| outer_width_m: float |
| outer_height_m: float |
| wall_thickness_m: float |
| roof_thickness_m: float |
| door_thickness_m: float |
| wall_bay_span_m: float |
| roof_bay_span_m: float |
| door_clear_span_m: float |
| access_lid_span_m: float |
| access_lid_thickness_m: float |
|
|
|
|
| @dataclass(frozen=True) |
| class InternalHullDesign: |
| name: str |
| envelope_length_m: float |
| envelope_width_m: float |
| envelope_height_m: float |
| hull_outer_diameter_m: float |
| hull_cyl_length_m: float |
| shell_thickness_m: float |
| endcap_thickness_m: float |
| endcap_radius_m: float |
| hatch_diameter_m: float |
| hatch_thickness_m: float |
| shell_buckling_knockdown: float |
| head_buckling_knockdown: float |
|
|
|
|
| @dataclass |
| class ComponentCheck: |
| component: str |
| stress_pa: float |
| yield_safety_factor: float |
| buckling_safety_factor: float | None |
| governing_safety_factor: float |
| deflection_m: float | None |
| pressure_pa: float |
| note: str |
|
|
|
|
| def hydrostatic_pressure(depth_m: float, rho: float = RHO_SEAWATER, gravity: float = G) -> float: |
| return rho * gravity * depth_m |
|
|
|
|
| def beam_strip_check( |
| component: str, |
| span_m: float, |
| thickness_m: float, |
| pressure_pa: float, |
| material: Material, |
| note: str, |
| ) -> ComponentCheck: |
| """Model a 1 m wide clamped strip under uniform pressure as a fixed-fixed beam.""" |
| line_load_n_per_m = pressure_pa * 1.0 |
| max_moment_nm = line_load_n_per_m * span_m**2 / 12.0 |
| stress_pa = 6.0 * max_moment_nm / max(thickness_m**2, 1e-12) |
| inertia_m4 = thickness_m**3 / 12.0 |
| deflection_m = line_load_n_per_m * span_m**4 / (384.0 * material.youngs_modulus_pa * inertia_m4) |
| yield_sf = material.yield_strength_pa / max(abs(stress_pa), 1.0) |
| return ComponentCheck( |
| component=component, |
| stress_pa=stress_pa, |
| yield_safety_factor=yield_sf, |
| buckling_safety_factor=None, |
| governing_safety_factor=yield_sf, |
| deflection_m=deflection_m, |
| pressure_pa=pressure_pa, |
| note=note, |
| ) |
|
|
|
|
| def cylinder_shell_check( |
| component: str, |
| radius_m: float, |
| thickness_m: float, |
| pressure_pa: float, |
| material: Material, |
| knockdown: float, |
| note: str, |
| ) -> ComponentCheck: |
| membrane_stress_pa = pressure_pa * radius_m / max(thickness_m, 1e-12) |
| yield_sf = material.yield_strength_pa / max(abs(membrane_stress_pa), 1.0) |
| buckling_pressure_pa = ( |
| knockdown |
| * (2.0 * material.youngs_modulus_pa / math.sqrt(3.0 * (1.0 - material.poisson_ratio**2))) |
| * (thickness_m / radius_m) ** 3 |
| ) |
| buckling_sf = buckling_pressure_pa / max(pressure_pa, 1.0) |
| return ComponentCheck( |
| component=component, |
| stress_pa=membrane_stress_pa, |
| yield_safety_factor=yield_sf, |
| buckling_safety_factor=buckling_sf, |
| governing_safety_factor=min(yield_sf, buckling_sf), |
| deflection_m=None, |
| pressure_pa=pressure_pa, |
| note=note, |
| ) |
|
|
|
|
| def spherical_head_check( |
| component: str, |
| radius_m: float, |
| thickness_m: float, |
| pressure_pa: float, |
| material: Material, |
| knockdown: float, |
| note: str, |
| ) -> ComponentCheck: |
| membrane_stress_pa = pressure_pa * radius_m / max(2.0 * thickness_m, 1e-12) |
| yield_sf = material.yield_strength_pa / max(abs(membrane_stress_pa), 1.0) |
| buckling_pressure_pa = ( |
| knockdown |
| * (2.0 * material.youngs_modulus_pa / math.sqrt(3.0 * (1.0 - material.poisson_ratio**2))) |
| * (thickness_m / radius_m) ** 2 |
| ) |
| buckling_sf = buckling_pressure_pa / max(pressure_pa, 1.0) |
| return ComponentCheck( |
| component=component, |
| stress_pa=membrane_stress_pa, |
| yield_safety_factor=yield_sf, |
| buckling_safety_factor=buckling_sf, |
| governing_safety_factor=min(yield_sf, buckling_sf), |
| deflection_m=None, |
| pressure_pa=pressure_pa, |
| note=note, |
| ) |
|
|
|
|
| def evaluate_box(depth_m: float, material: Material, design: BoxContainerDesign) -> list[ComponentCheck]: |
| pressure = hydrostatic_pressure(depth_m) |
| return [ |
| beam_strip_check( |
| component="side_wall_bay", |
| span_m=design.wall_bay_span_m, |
| thickness_m=design.wall_thickness_m, |
| pressure_pa=pressure, |
| material=material, |
| note="1 m strip spanning between wall stiffeners; screens local bay yielding.", |
| ), |
| beam_strip_check( |
| component="roof_bay", |
| span_m=design.roof_bay_span_m, |
| thickness_m=design.roof_thickness_m, |
| pressure_pa=pressure, |
| material=material, |
| note="1 m strip spanning between roof stiffeners; ignores shell action and is conservative.", |
| ), |
| beam_strip_check( |
| component="cargo_door", |
| span_m=design.door_clear_span_m, |
| thickness_m=design.door_thickness_m, |
| pressure_pa=pressure, |
| material=material, |
| note="Represents the large flat door / end opening penalty.", |
| ), |
| beam_strip_check( |
| component="service_lid", |
| span_m=design.access_lid_span_m, |
| thickness_m=design.access_lid_thickness_m, |
| pressure_pa=pressure, |
| material=material, |
| note="Access lid behaves like a pressure hatch, not a normal container lid.", |
| ), |
| ] |
|
|
|
|
| def evaluate_internal_hull(depth_m: float, material: Material, design: InternalHullDesign) -> list[ComponentCheck]: |
| pressure = hydrostatic_pressure(depth_m) |
| radius_m = design.hull_outer_diameter_m / 2.0 |
| return [ |
| cylinder_shell_check( |
| component="cylindrical_shell", |
| radius_m=radius_m, |
| thickness_m=design.shell_thickness_m, |
| pressure_pa=pressure, |
| material=material, |
| knockdown=design.shell_buckling_knockdown, |
| note="External-pressure shell buckling with imperfection knockdown; likely governing hull mode.", |
| ), |
| spherical_head_check( |
| component="dished_endcap", |
| radius_m=design.endcap_radius_m, |
| thickness_m=design.endcap_thickness_m, |
| pressure_pa=pressure, |
| material=material, |
| knockdown=design.head_buckling_knockdown, |
| note="Approximated as rounded head; usually stronger than the cylindrical bay.", |
| ), |
| beam_strip_check( |
| component="surface_service_hatch", |
| span_m=design.hatch_diameter_m, |
| thickness_m=design.hatch_thickness_m, |
| pressure_pa=pressure, |
| material=material, |
| note="Circular hatch approximated as a clamped strip; conservative screening for hatch thickness.", |
| ), |
| ] |
|
|
|
|
| def required_box_thickness(span_m: float, pressure_pa: float, material: Material, target_sf: float) -> float: |
| max_moment_nm = pressure_pa * span_m**2 / 12.0 |
| return math.sqrt(6.0 * max_moment_nm * target_sf / material.yield_strength_pa) |
|
|
|
|
| def required_cylinder_thickness( |
| radius_m: float, |
| pressure_pa: float, |
| material: Material, |
| target_sf: float, |
| knockdown: float, |
| ) -> float: |
| t_yield = pressure_pa * radius_m * target_sf / material.yield_strength_pa |
| coeff = knockdown * (2.0 * material.youngs_modulus_pa / math.sqrt(3.0 * (1.0 - material.poisson_ratio**2))) |
| t_buckling = radius_m * ((pressure_pa * target_sf) / coeff) ** (1.0 / 3.0) |
| return max(t_yield, t_buckling) |
|
|
|
|
| def gross_cylinder_volume(design: InternalHullDesign) -> float: |
| radius = design.hull_outer_diameter_m / 2.0 |
| cyl = math.pi * radius**2 * design.hull_cyl_length_m |
| heads = 4.0 / 3.0 * math.pi * radius**3 |
| return cyl + heads |
|
|
|
|
| def gross_box_volume(design: BoxContainerDesign) -> float: |
| return design.outer_length_m * design.outer_width_m * design.outer_height_m |
|
|
|
|
| def run_depth_sweep( |
| depths_m: np.ndarray, |
| material: Material, |
| box_design: BoxContainerDesign, |
| hull_design: InternalHullDesign, |
| ) -> tuple[pd.DataFrame, pd.DataFrame]: |
| box_rows: list[dict[str, float | str]] = [] |
| hull_rows: list[dict[str, float | str]] = [] |
| for depth in depths_m: |
| for item in evaluate_box(float(depth), material, box_design): |
| box_rows.append( |
| { |
| "depth_m": float(depth), |
| "component": item.component, |
| "governing_sf": item.governing_safety_factor, |
| "yield_sf": item.yield_safety_factor, |
| "buckling_sf": item.buckling_safety_factor, |
| "stress_mpa": item.stress_pa / 1e6, |
| "deflection_mm": None if item.deflection_m is None else item.deflection_m * 1000.0, |
| "pressure_bar_g": item.pressure_pa / 1e5, |
| } |
| ) |
| for item in evaluate_internal_hull(float(depth), material, hull_design): |
| hull_rows.append( |
| { |
| "depth_m": float(depth), |
| "component": item.component, |
| "governing_sf": item.governing_safety_factor, |
| "yield_sf": item.yield_safety_factor, |
| "buckling_sf": item.buckling_safety_factor, |
| "stress_mpa": item.stress_pa / 1e6, |
| "deflection_mm": None if item.deflection_m is None else item.deflection_m * 1000.0, |
| "pressure_bar_g": item.pressure_pa / 1e5, |
| } |
| ) |
| return pd.DataFrame(box_rows), pd.DataFrame(hull_rows) |
|
|
|
|
| def plot_safety_factor_curves( |
| box_df: pd.DataFrame, |
| hull_df: pd.DataFrame, |
| output_path: Path, |
| ) -> None: |
| fig, axes = plt.subplots(1, 2, figsize=(14, 5), sharey=True) |
| for ax, df, title in [ |
| (axes[0], box_df, "Naive Flat-Wall Box"), |
| (axes[1], hull_df, "ISO Frame + Internal Hull"), |
| ]: |
| for component, group in df.groupby("component"): |
| ax.plot(group["depth_m"], group["governing_sf"], label=component, linewidth=2) |
| ax.axhline(1.0, color="red", linestyle="--", linewidth=1.5, label="failure threshold") |
| ax.axhline(1.5, color="orange", linestyle=":", linewidth=1.5, label="preferred min SF") |
| ax.set_title(title) |
| ax.set_xlabel("Depth (m)") |
| ax.set_yscale("log") |
| ax.grid(True, which="both", alpha=0.25) |
| axes[0].set_ylabel("Governing safety factor (log scale)") |
| axes[1].legend(loc="upper right", fontsize=8) |
| fig.tight_layout() |
| fig.savefig(output_path, dpi=180) |
| plt.close(fig) |
|
|
|
|
| def plot_failure_heatmap(box_df: pd.DataFrame, hull_df: pd.DataFrame, output_path: Path) -> None: |
| box_pivot = box_df.pivot(index="component", columns="depth_m", values="governing_sf") |
| hull_pivot = hull_df.pivot(index="component", columns="depth_m", values="governing_sf") |
| vmax = max(np.nanmax(box_pivot.values), np.nanmax(hull_pivot.values)) |
| vmin = min(np.nanmin(box_pivot.values), np.nanmin(hull_pivot.values)) |
| fig, axes = plt.subplots(2, 1, figsize=(14, 7), sharex=True) |
| for ax, pivot, title in [ |
| (axes[0], box_pivot, "Naive Flat-Wall Box"), |
| (axes[1], hull_pivot, "ISO Frame + Internal Hull"), |
| ]: |
| img = ax.imshow(pivot.values, aspect="auto", cmap="viridis", vmin=vmin, vmax=vmax) |
| ax.set_yticks(range(len(pivot.index))) |
| ax.set_yticklabels(pivot.index) |
| ax.set_xticks(range(len(pivot.columns))) |
| ax.set_xticklabels([f"{int(col)}" for col in pivot.columns], rotation=45) |
| ax.set_title(title) |
| axes[1].set_xlabel("Depth (m)") |
| cbar = fig.colorbar(img, ax=axes.ravel().tolist(), shrink=0.9) |
| cbar.set_label("Governing safety factor") |
| fig.subplots_adjust(left=0.16, right=0.90, top=0.93, bottom=0.12, hspace=0.35) |
| fig.savefig(output_path, dpi=180) |
| plt.close(fig) |
|
|
|
|
| def build_summary( |
| material: Material, |
| box_design: BoxContainerDesign, |
| hull_design: InternalHullDesign, |
| box_df: pd.DataFrame, |
| hull_df: pd.DataFrame, |
| target_depth_m: float, |
| ) -> str: |
| target_pressure = hydrostatic_pressure(target_depth_m) |
| box_min = box_df.groupby("depth_m")["governing_sf"].min() |
| hull_min = hull_df.groupby("depth_m")["governing_sf"].min() |
| box_target = box_df[box_df["depth_m"] == target_depth_m].sort_values("governing_sf").iloc[0] |
| hull_target = hull_df[hull_df["depth_m"] == target_depth_m].sort_values("governing_sf").iloc[0] |
| req_box_wall = required_box_thickness( |
| span_m=box_design.wall_bay_span_m, |
| pressure_pa=target_pressure, |
| material=material, |
| target_sf=1.5, |
| ) |
| req_box_door = required_box_thickness( |
| span_m=box_design.door_clear_span_m, |
| pressure_pa=target_pressure, |
| material=material, |
| target_sf=1.5, |
| ) |
| req_hull_shell = required_cylinder_thickness( |
| radius_m=hull_design.hull_outer_diameter_m / 2.0, |
| pressure_pa=target_pressure, |
| material=material, |
| target_sf=1.5, |
| knockdown=hull_design.shell_buckling_knockdown, |
| ) |
| box_volume = gross_box_volume(box_design) |
| hull_volume = gross_cylinder_volume(hull_design) |
| box_fail_depth = float(box_min[box_min < 1.0].index.min()) if (box_min < 1.0).any() else math.inf |
| hull_fail_depth = float(hull_min[hull_min < 1.0].index.min()) if (hull_min < 1.0).any() else math.inf |
|
|
| return f"""# Subsea 40-Foot Structural Screening Summary |
| |
| ## Model intent |
| |
| This report screens two concepts under hydrostatic external pressure: |
| |
| - `{box_design.name}`: a flat-wall sealed 40-foot box with stiffened panels and a top access lid |
| - `{hull_design.name}`: a 40-foot transport envelope carrying an internal rounded pressure hull |
| |
| The analysis is a structural screening model, not code-certifiable FEA. It is intended to show design ranking and likely first failure modes. |
| |
| ## Assumptions |
| |
| - Material: `{material.name}` |
| - Young's modulus: `{material.youngs_modulus_pa / 1e9:.0f} GPa` |
| - Yield strength: `{material.yield_strength_pa / 1e6:.0f} MPa` |
| - Seawater density: `{RHO_SEAWATER:.0f} kg/m^3` |
| - Gravity: `{G:.2f} m/s^2` |
| - Target comparison depth: `{target_depth_m:.0f} m` (`{target_pressure / 1e5:.2f} bar(g)`) |
| |
| ## Result at target depth |
| |
| ### Flat-wall box |
| |
| - Governing component: `{box_target['component']}` |
| - Governing safety factor: `{box_target['governing_sf']:.2f}` |
| - Governing stress: `{box_target['stress_mpa']:.1f} MPa` |
| |
| ### Internal rounded hull |
| |
| - Governing component: `{hull_target['component']}` |
| - Governing safety factor: `{hull_target['governing_sf']:.2f}` |
| - Governing stress: `{hull_target['stress_mpa']:.1f} MPa` |
| |
| ## Thickness required for SF = 1.5 at target depth |
| |
| - Flat wall bay (`{box_design.wall_bay_span_m:.2f} m` stiffener spacing): `{req_box_wall * 1000:.1f} mm` |
| - Flat cargo door / opening (`{box_design.door_clear_span_m:.2f} m` clear span): `{req_box_door * 1000:.1f} mm` |
| - Rounded cylindrical shell (`{hull_design.hull_outer_diameter_m / 2.0:.2f} m` radius): `{req_hull_shell * 1000:.1f} mm` |
| |
| ## Gross packaging volume |
| |
| - 40-foot box envelope: `{box_volume:.1f} m^3` |
| - Internal rounded hull gross volume: `{hull_volume:.1f} m^3` |
| - Rounded hull / box gross volume ratio: `{hull_volume / box_volume:.2f}` |
| |
| ## Depth where governing SF first drops below 1.0 |
| |
| - Flat-wall box: `{box_fail_depth if math.isfinite(box_fail_depth) else 'not reached in sweep'}` |
| - Internal rounded hull: `{hull_fail_depth if math.isfinite(hull_fail_depth) else 'not reached in sweep'}` |
| |
| ## Interpretation |
| |
| The flat-wall box fails for the expected reason: the large flat panels and especially the large door / lid spans become pressure-loaded plates. The structure very quickly turns into a heavy pressure vessel, and once reinforced enough to survive depth it is no longer behaving like a cheap shipping container. |
| |
| The internal rounded hull works materially better because shell buckling scales more favorably than flat-plate bending for this geometry. The transport frame can still be ISO-like for handling, but the actual pressure boundary should stay rounded. |
| |
| ## What this model proves |
| |
| - A normal box-shaped pressure boundary is structurally unattractive underwater. |
| - A 40-foot transport envelope can still be useful if the actual pressure hull inside it is cylindrical / rounded. |
| - The likely first failure modes are the large flat opening panels on the box concept and shell buckling / hatch thickness on the rounded concept. |
| |
| ## What this model does not prove |
| |
| - Final certifiable wall thickness |
| - Weld detail adequacy |
| - Local stress concentrations at penetrators, supports, or hatch rings |
| - Fatigue, corrosion allowance, or collapse after dent / ovality defects |
| - Thermal, fluid, and electrical integration |
| |
| The next step after this model would be a proper shell / plate FEA and then a welded-detail design review. |
| """ |
|
|
|
|
| def default_material() -> Material: |
| return Material( |
| name="S355 structural steel", |
| youngs_modulus_pa=210e9, |
| poisson_ratio=0.30, |
| yield_strength_pa=355e6, |
| density_kg_m3=7850.0, |
| ) |
|
|
|
|
| def default_box_design() -> BoxContainerDesign: |
| return BoxContainerDesign( |
| name="naive_sealed_flat_box", |
| outer_length_m=12.192, |
| outer_width_m=2.438, |
| outer_height_m=2.591, |
| wall_thickness_m=0.016, |
| roof_thickness_m=0.018, |
| door_thickness_m=0.020, |
| wall_bay_span_m=0.60, |
| roof_bay_span_m=0.60, |
| door_clear_span_m=2.34, |
| access_lid_span_m=1.20, |
| access_lid_thickness_m=0.025, |
| ) |
|
|
|
|
| def default_hull_design() -> InternalHullDesign: |
| return InternalHullDesign( |
| name="iso_frame_internal_pressure_hull", |
| envelope_length_m=12.192, |
| envelope_width_m=2.438, |
| envelope_height_m=2.591, |
| hull_outer_diameter_m=2.20, |
| hull_cyl_length_m=9.40, |
| shell_thickness_m=0.030, |
| endcap_thickness_m=0.035, |
| endcap_radius_m=1.10, |
| hatch_diameter_m=0.80, |
| hatch_thickness_m=0.060, |
| shell_buckling_knockdown=0.20, |
| head_buckling_knockdown=0.50, |
| ) |
|
|
|
|
| def parse_args() -> argparse.Namespace: |
| parser = argparse.ArgumentParser(description="Run subsea 40-foot container structural screening.") |
| parser.add_argument("--max-depth-m", type=float, default=150.0) |
| parser.add_argument("--depth-step-m", type=float, default=5.0) |
| parser.add_argument("--target-depth-m", type=float, default=100.0) |
| parser.add_argument("--wall-thickness-mm", type=float, default=None) |
| parser.add_argument("--roof-thickness-mm", type=float, default=None) |
| parser.add_argument("--door-thickness-mm", type=float, default=None) |
| parser.add_argument("--lid-thickness-mm", type=float, default=None) |
| parser.add_argument("--wall-bay-span-m", type=float, default=None) |
| parser.add_argument("--roof-bay-span-m", type=float, default=None) |
| parser.add_argument("--door-clear-span-m", type=float, default=None) |
| parser.add_argument("--lid-span-m", type=float, default=None) |
| parser.add_argument("--shell-thickness-mm", type=float, default=None) |
| parser.add_argument("--endcap-thickness-mm", type=float, default=None) |
| parser.add_argument("--hatch-thickness-mm", type=float, default=None) |
| parser.add_argument("--hull-diameter-m", type=float, default=None) |
| parser.add_argument("--hull-length-m", type=float, default=None) |
| parser.add_argument("--hatch-diameter-m", type=float, default=None) |
| parser.add_argument("--shell-knockdown", type=float, default=None) |
| parser.add_argument("--head-knockdown", type=float, default=None) |
| parser.add_argument( |
| "--output-dir", |
| type=Path, |
| default=Path("underwater_datacenter_project") / "simulation_outputs", |
| ) |
| return parser.parse_args() |
|
|
|
|
| def main() -> None: |
| args = parse_args() |
| output_dir = args.output_dir |
| output_dir.mkdir(parents=True, exist_ok=True) |
|
|
| material = default_material() |
| box_design = default_box_design() |
| hull_design = default_hull_design() |
|
|
| if args.wall_thickness_mm is not None: |
| box_design = BoxContainerDesign(**{**asdict(box_design), "wall_thickness_m": args.wall_thickness_mm / 1000.0}) |
| if args.roof_thickness_mm is not None: |
| box_design = BoxContainerDesign(**{**asdict(box_design), "roof_thickness_m": args.roof_thickness_mm / 1000.0}) |
| if args.door_thickness_mm is not None: |
| box_design = BoxContainerDesign(**{**asdict(box_design), "door_thickness_m": args.door_thickness_mm / 1000.0}) |
| if args.lid_thickness_mm is not None: |
| box_design = BoxContainerDesign(**{**asdict(box_design), "access_lid_thickness_m": args.lid_thickness_mm / 1000.0}) |
| if args.wall_bay_span_m is not None: |
| box_design = BoxContainerDesign(**{**asdict(box_design), "wall_bay_span_m": args.wall_bay_span_m}) |
| if args.roof_bay_span_m is not None: |
| box_design = BoxContainerDesign(**{**asdict(box_design), "roof_bay_span_m": args.roof_bay_span_m}) |
| if args.door_clear_span_m is not None: |
| box_design = BoxContainerDesign(**{**asdict(box_design), "door_clear_span_m": args.door_clear_span_m}) |
| if args.lid_span_m is not None: |
| box_design = BoxContainerDesign(**{**asdict(box_design), "access_lid_span_m": args.lid_span_m}) |
|
|
| if args.shell_thickness_mm is not None: |
| hull_design = InternalHullDesign(**{**asdict(hull_design), "shell_thickness_m": args.shell_thickness_mm / 1000.0}) |
| if args.endcap_thickness_mm is not None: |
| hull_design = InternalHullDesign(**{**asdict(hull_design), "endcap_thickness_m": args.endcap_thickness_mm / 1000.0}) |
| if args.hatch_thickness_mm is not None: |
| hull_design = InternalHullDesign(**{**asdict(hull_design), "hatch_thickness_m": args.hatch_thickness_mm / 1000.0}) |
| if args.hull_diameter_m is not None: |
| hull_design = InternalHullDesign( |
| **{ |
| **asdict(hull_design), |
| "hull_outer_diameter_m": args.hull_diameter_m, |
| "endcap_radius_m": args.hull_diameter_m / 2.0, |
| } |
| ) |
| if args.hull_length_m is not None: |
| hull_design = InternalHullDesign(**{**asdict(hull_design), "hull_cyl_length_m": args.hull_length_m}) |
| if args.hatch_diameter_m is not None: |
| hull_design = InternalHullDesign(**{**asdict(hull_design), "hatch_diameter_m": args.hatch_diameter_m}) |
| if args.shell_knockdown is not None: |
| hull_design = InternalHullDesign(**{**asdict(hull_design), "shell_buckling_knockdown": args.shell_knockdown}) |
| if args.head_knockdown is not None: |
| hull_design = InternalHullDesign(**{**asdict(hull_design), "head_buckling_knockdown": args.head_knockdown}) |
|
|
| depths = np.arange(5.0, args.max_depth_m + 0.1, args.depth_step_m) |
| box_df, hull_df = run_depth_sweep(depths, material, box_design, hull_design) |
|
|
| box_csv = output_dir / "box_depth_sweep.csv" |
| hull_csv = output_dir / "internal_hull_depth_sweep.csv" |
| box_df.to_csv(box_csv, index=False) |
| hull_df.to_csv(hull_csv, index=False) |
|
|
| sf_plot = output_dir / "safety_factor_vs_depth.png" |
| heatmap_plot = output_dir / "failure_heatmap.png" |
| plot_safety_factor_curves(box_df, hull_df, sf_plot) |
| plot_failure_heatmap(box_df, hull_df, heatmap_plot) |
|
|
| summary_text = build_summary(material, box_design, hull_design, box_df, hull_df, args.target_depth_m) |
| summary_path = output_dir / "simulation_summary.md" |
| summary_path.write_text(summary_text, encoding="utf-8") |
|
|
| metadata = { |
| "material": asdict(material), |
| "box_design": asdict(box_design), |
| "internal_hull_design": asdict(hull_design), |
| "target_depth_m": args.target_depth_m, |
| "max_depth_m": args.max_depth_m, |
| "depth_step_m": args.depth_step_m, |
| } |
| (output_dir / "simulation_metadata.json").write_text(json.dumps(metadata, indent=2), encoding="utf-8") |
|
|
| print(f"Wrote outputs to {output_dir.resolve()}") |
| print(f"Summary: {summary_path.resolve()}") |
| print(f"Curves: {sf_plot.resolve()}") |
| print(f"Heatmap: {heatmap_plot.resolve()}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|