File size: 30,642 Bytes
bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 4964eeb bfdace6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | #!/usr/bin/env python3
"""
OCEI v2.4.0 Reference Physics, Astrodynamics & Economics Kernel
OrbitCompute.ai // Spatial Compute Holdings (MIT License)
Zenodo Concept DOI: 10.5281/zenodo.24181719
1:1 deterministic parity with the live Cloudflare Edge Production Worker:
- Coupled J2 Dawn-Dusk SSO solstice eclipse envelope (89d/yr @ 650 km, 96.05% annual mean)
- Downlink-bound & 5-yr attrition coupling into token output, USD/MTok, payback & dispatch (NEU-3)
- Stefan-Boltzmann two-sided radiative transfer with Earth IR/albedo & Silicon Tj throttling
- Continuous SEU / Van Allen belt / 25-MW Young-Daly fault-domain checkpointing
- Tri-Track sensitivity (target / conservative / current_2026) & dual Brownfield/Greenfield parity
- Historical NOAA event replay verification (Halloween 2003 29,500 pfu, Gannon 2024 207 pfu)
"""
from __future__ import annotations
import json
import math
import sys
from decimal import Decimal, ROUND_HALF_UP
from typing import Any, Dict, Optional
SCHEMA_VERSION = "2.4.0"
CONCEPT_DOI = "10.5281/zenodo.24181719"
def js_round(val: float, dec: int = 2) -> float:
"""Deterministic half-up rounding matching JavaScript Number.toFixed()."""
q = Decimal("1") if dec == 0 else Decimal("0." + "0" * (dec - 1) + "1")
return float(Decimal(str(val)).quantize(q, rounding=ROUND_HALF_UP))
HARDWARE_PROFILES: Dict[str, Dict[str, Any]] = {
"rubin_nvl72": {
"id": "rubin_nvl72",
"name": "NVIDIA Vera Rubin NVL72 (227 kW Nominal / 250 kW Starmind Class)",
"node_kw": 250.0,
"nominal_rack_kw": 227.0,
"gpus_per_node": 72,
"pflops_fp4_per_node": 3600.0,
"native_precision": "FP4_SPARSE (50 PFLOPS/GPU; 25 PFLOPS dense)",
"tokens_sec_per_mw": 420000.0,
"capex_usd_per_kw": 24500.0,
"rad_shield_factor": 1.00,
"tj_knee_c": 78.0,
},
"starmind_ai1": {
"id": "starmind_ai1",
"name": "SpaceX Starmind AI1 Satellite (175 kW Avg / 250 kW Peak, 75 kW/t Raw, 160 m2 Rad)",
"node_kw": 175.0,
"nominal_rack_kw": 175.0,
"peak_kw": 250.0,
"radiator_area_m2_nominal": 160.0,
"gpus_per_node": 72,
"pflops_fp4_per_node": 2800.0,
"native_precision": "FP4_SPARSE (Vera Rubin / Terafab gen-1)",
"tokens_sec_per_mw": 420000.0,
"capex_usd_per_kw": 23500.0,
"rad_shield_factor": 0.96,
"tj_knee_c": 80.0,
},
"trillium_tpu_v6e": {
"id": "trillium_tpu_v6e",
"name": "Google Trillium TPU v6e Pod (125 kW Suncatcher Class — 918 TF BF16 / 1,836 TOPS INT8)",
"node_kw": 125.0,
"nominal_rack_kw": 125.0,
"gpus_per_node": 64,
"pflops_fp4_per_node": 117.5,
"native_precision": "INT8_1836_TOPS / BF16_918_TFLOPS per chip (no native FP4)",
"tokens_sec_per_mw": 195000.0,
"capex_usd_per_kw": 19800.0,
"rad_shield_factor": 0.88,
"tj_knee_c": 78.0,
},
"blackwell_b200": {
"id": "blackwell_b200",
"name": "NVIDIA Blackwell GB200 NVL72 Module (120 kW Starcloud-2 Class)",
"node_kw": 120.0,
"nominal_rack_kw": 120.0,
"gpus_per_node": 72,
"pflops_fp4_per_node": 1440.0,
"native_precision": "FP4_SPARSE (20 PFLOPS/GPU; 10 PFLOPS dense)",
"tokens_sec_per_mw": 350000.0,
"capex_usd_per_kw": 22000.0,
"rad_shield_factor": 1.08,
"tj_knee_c": 78.0,
},
"terafab_370k": {
"id": "terafab_370k",
"name": "Custom High-Tj Vacuum Silicon (250 kW Terafab 370K Class)",
"node_kw": 250.0,
"nominal_rack_kw": 250.0,
"gpus_per_node": 72,
"pflops_fp4_per_node": 4200.0,
"native_precision": "FP4_SPARSE (High-Tj 95C vacuum-hardened)",
"tokens_sec_per_mw": 465000.0,
"capex_usd_per_kw": 21000.0,
"rad_shield_factor": 0.78,
"tj_knee_c": 95.0,
},
}
LAUNCH_VEHICLES: Dict[str, Dict[str, Any]] = {
"starship_v3": {"id": "starship_v3", "label": "Starship V3 (125t Reference / 100t Sensitivity @ 25M USD)", "payload_tons": 125.0, "cost_musd": 25.0},
"starship_v4": {"id": "starship_v4", "label": "Starship V4 Block 4 (200t @ 10M USD amortized)", "payload_tons": 200.0, "cost_musd": 10.0},
"new_glenn_9x4": {"id": "new_glenn_9x4", "label": "Blue Origin New Glenn 9x4 (70t @ 35M USD)", "payload_tons": 70.0, "cost_musd": 35.0},
}
REALISM_MODES: Dict[str, Dict[str, Any]] = {
"target": {
"id": "target",
"label": "Canonical Reusable-Scale Reference (~15.5 kg/kW MMOD; +16.3% margin over SpaceX AI1 13.3 kg/kW)",
"mass_mult": 1.00,
"bus_cost_musd_per_ton": 0.28,
"lv_payload_mult": 1.00,
"lv_cost_mult": 1.00,
"rad_eol_margin": 1.00,
},
"conservative": {
"id": "conservative",
"label": "Sensitivity Bound: Traditional Aerospace / Turyshev Envelope (~38 kg/kW, 1,200 USD/kg bus, 100t V3 @ 40M USD, +25% EOL rad)",
"mass_mult": 2.45,
"bus_cost_musd_per_ton": 1.20,
"lv_payload_mult": 0.80,
"lv_cost_mult": 1.60,
"rad_eol_margin": 1.25,
},
"current_2026": {
"id": "current_2026",
"label": "Sensitivity Bound: Pre-Starship 2026 Empirical Baseline (~42 kg/kW, 3,500 USD/kg bus, ~2,667 USD/kg F9-class)",
"mass_mult": 2.70,
"bus_cost_musd_per_ton": 3.50,
"lv_payload_mult": 0.18,
"lv_cost_mult": 2.40,
"rad_eol_margin": 1.30,
},
}
STORM_PROFILES: Dict[str, Dict[str, Any]] = {
"g0_quiet": {
"id": "g0_quiet",
"label": "G0 Quiet Solar Minimum (Kp 1.00, 0.15 pfu)",
"kp": 1.00, "proton_pfu": 0.15, "bz_nt": 1.50, "bt_nt": 4.0, "xray_wm2": 2.0e-7, "flare": "B2.0", "f107": 140.0, "wind_kms": 350.0,
},
"g3_storm": {
"id": "g3_storm",
"label": "G3 Strong Geomagnetic / S2 Proton Storm (Kp 7.00, 120 pfu)",
"kp": 7.00, "proton_pfu": 120.0, "bz_nt": -14.0, "bt_nt": 18.0, "xray_wm2": 5.0e-5, "flare": "M5.0", "f107": 195.0, "wind_kms": 680.0,
},
"g5_extreme": {
"id": "g5_extreme",
"label": "G5 Extreme Carrington Superstorm (Kp 9.00, 2,500 pfu)",
"kp": 9.00, "proton_pfu": 2500.0, "bz_nt": -35.0, "bt_nt": 45.0, "xray_wm2": 1.0e-3, "flare": "X10.0", "f107": 265.0, "wind_kms": 980.0,
},
"halloween_2003": {
"id": "2003-10-29-HALLOWEEN-SUPERSTORM",
"label": "Halloween Solar Superstorm (Oct 29, 2003 — X17.2 / G5 / S4)",
"date_utc": "2003-10-29T06:15:00Z",
"kp": 9.0, "proton_pfu": 29500.0, "bz_nt": -27.0, "bt_nt": 45.0, "xray_wm2": 1.7e-3, "flare": "X17.2", "f107": 275.0, "wind_kms": 1850.0,
},
"gannon_2024": {
"id": "2024-05-10-GANNON-G5-STORM",
"label": "May 2024 Gannon G5 Geomagnetic Superstorm (AR3664 — X5.8 / G5 / S2)",
"date_utc": "2024-05-10T17:45:00Z",
"kp": 9.0, "proton_pfu": 207.0, "bz_nt": -32.0, "bt_nt": 74.0, "xray_wm2": 5.8e-4, "flare": "X5.8", "f107": 225.0, "wind_kms": 950.0,
},
"solar_min_2019": {
"id": "2019-12-15-DEEP-SOLAR-MINIMUM",
"label": "Cycle 24/25 Deep Solar Minimum Baseline (Dec 15, 2019 — G0 / S0)",
"date_utc": "2019-12-15T00:00:00Z",
"kp": 0.67, "proton_pfu": 0.12, "bz_nt": 1.2, "bt_nt": 3.5, "xray_wm2": 1.0e-8, "flare": "A1.0", "f107": 70.0, "wind_kms": 310.0,
},
}
def survival_factor(rate_pct: float) -> float:
r = rate_pct / 100.0
if r <= 0.0:
return 1.0
return (1.0 - ((1.0 - r) ** 5)) / (5.0 * r)
def compute_annual_sso_eclipse_envelope(
altitude_km: float,
effective_cluster_kw: float,
orbital_usd_per_mtok: float,
mmod_mass_tons: float,
effective_payload_tons: float,
launches_required: int,
mass_mult: float = 1.0,
) -> Dict[str, Any]:
"""Exact J2 circular Dawn-Dusk SSO (LTAN 06:00/18:00) annual solstice eclipse geometry."""
if altitude_km > 1600.0:
return {"applicable": False, "note": "Altitude above LEO sun-synchronous regime (>1,600 km)."}
r_earth = 6371000.0
r_eq = 6378137.0
mu_earth = 3.986004418e14
j2 = 1.08262668e-3
omega_sun = (2.0 * math.pi) / (365.2422 * 86400.0)
obliq_deg = 23.439
h_m = altitude_km * 1000.0
a_sso = r_eq + h_m
n_sso = math.sqrt(mu_earth / (a_sso ** 3))
cos_i = -omega_sun / (1.5 * n_sso * j2 * ((r_eq / a_sso) ** 2))
if abs(cos_i) >= 1.0:
return {"applicable": False, "note": "Non-SSO altitude."}
i_deg = math.degrees(math.acos(cos_i))
beta_min = js_round(180.0 - i_deg - obliq_deg, 2)
beta_crit = js_round(math.degrees(math.asin(r_earth / (r_earth + h_m))), 2)
t_orb_min = (2.0 * math.pi * math.sqrt(((r_earth + h_m) ** 3) / mu_earth)) / 60.0
ecl_days = 0
total_ecl_frac = 0.0
max_ecl_min = 0.0
for d in range(365):
delta_sun = obliq_deg * math.sin((2.0 * math.pi * d) / 365.2422)
b_day = 90.0 - abs(delta_sun + (i_deg - 90.0))
if b_day < beta_crit:
ecl_days += 1
arg_d = math.sqrt(h_m * h_m + 2.0 * r_earth * h_m) / ((r_earth + h_m) * math.cos(math.radians(b_day)))
f_ecl = (1.0 / math.pi) * math.acos(min(1.0, max(-1.0, arg_d)))
total_ecl_frac += f_ecl
ecl_m = f_ecl * t_orb_min
if ecl_m > max_ecl_min:
max_ecl_min = ecl_m
ann_sunlit = js_round((1.0 - total_ecl_frac / 365.0) * 100.0, 2)
worst_sunlit = js_round((1.0 - max_ecl_min / t_orb_min) * 100.0, 2)
pg_mtok = js_round(orbital_usd_per_mtok / max(0.5, ann_sunlit / 100.0), 4)
pg_delta = js_round(((100.0 / max(50.0, ann_sunlit)) - 1.0) * 100.0, 2)
extra_batt_t = js_round((effective_cluster_kw * 1000.0 * (max_ecl_min / 60.0)) / (0.80 * 0.95 * 280.0 * 1000.0), 1)
extra_mmod_t = js_round(extra_batt_t * 1.18 * mass_mult, 1)
extra_flights = math.ceil((mmod_mass_tons + extra_mmod_t) / effective_payload_tons) - launches_required
return {
"applicable": True,
"ltan_reference": "06:00/18:00 Dawn-Dusk SSO (J2 circular)",
"sso_inclination_deg": js_round(i_deg, 2),
"solstice_min_beta_deg": beta_min,
"critical_eclipse_beta_deg": beta_crit,
"solstice_eclipse_days_per_year": ecl_days,
"max_solstice_eclipse_min": js_round(max_ecl_min, 2),
"worst_day_sunlit_pct": worst_sunlit,
"annual_mean_sunlit_pct": ann_sunlit,
"mitigation_strategy_recommended": "SEASONAL_SOLSTICE_POWER_GATING" if ecl_days > 0 else "YEAR_ROUND_SUNLIT_NO_ECLIPSE",
"seasonal_power_gating_usd_per_mtok": pg_mtok,
"seasonal_power_gating_cost_delta_pct": pg_delta,
"worst_day_full_battery_extra_tons": extra_batt_t,
"worst_day_full_battery_extra_mmod_tons": extra_mmod_t,
"worst_day_full_battery_extra_flights": extra_flights,
"year_round_zero_eclipse_sso_min_alt_km": 1400,
}
def evaluate_ocei_kernel(
power_mw: float = 100.0,
altitude_km: float = 650.0,
beta_deg: float = 75.0,
loop_temp_c: float = 80.0,
distance_km: float = 10000.0,
hw: str = "rubin_nvl72",
launch_vehicle: str = "starship_v3",
realism_mode: str = "target",
storm_mode: str = "g0_quiet",
grid_price_usd_mwh: float = 115.0,
earth_capex_factor: float = 1.0,
annual_attrition_pct: float = 0.0,
comm_intensity_bits_per_flop: float = 1e-8,
custom_storm: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]:
"""Deterministic OCEI v2.4.0 physics, astrodynamics, TCO & underwriting kernel."""
power_mw = js_round(max(1.0, min(100000.0, float(power_mw))), 2)
altitude_km = js_round(max(300.0, min(35786.0, float(altitude_km))), 1)
beta_deg = js_round(max(0.0, min(90.0, float(beta_deg))), 1)
loop_temp_c = js_round(max(40.0, min(120.0, float(loop_temp_c))), 1)
distance_km = js_round(max(100.0, min(20000.0, float(distance_km))), 1)
grid_price_usd_mwh = js_round(max(-200.0, min(5000.0, float(grid_price_usd_mwh))), 2)
earth_capex_factor = js_round(max(0.4, min(1.5, float(earth_capex_factor))), 2)
annual_attrition_pct = js_round(max(0.0, min(20.0, float(annual_attrition_pct))), 2)
comm_intensity = max(1e-11, min(1e-3, float(comm_intensity_bits_per_flop)))
hw_p = HARDWARE_PROFILES.get(hw, HARDWARE_PROFILES["rubin_nvl72"])
lv_p = LAUNCH_VEHICLES.get(launch_vehicle, LAUNCH_VEHICLES["starship_v3"])
rm_p = REALISM_MODES.get(realism_mode.lower(), REALISM_MODES["target"])
st = custom_storm if custom_storm is not None else STORM_PROFILES.get(storm_mode, STORM_PROFILES["g0_quiet"])
nodes_count = math.ceil((power_mw * 1000.0) / hw_p["node_kw"])
eff_kw = nodes_count * hw_p["node_kw"]
eff_mw = eff_kw / 1000.0
total_acc = nodes_count * hw_p["gpus_per_node"]
# A. Orbital Beta-Angle Eclipse Integral & Battery Mass
r_earth = 6371000.0
mu_earth = 3.986004418e14
h_m = altitude_km * 1000.0
beta_rad = math.radians(beta_deg)
t_orb_s = 2.0 * math.pi * math.sqrt(((r_earth + h_m) ** 3) / mu_earth)
beta_crit_rad = math.asin(r_earth / (r_earth + h_m))
beta_crit_deg = js_round(math.degrees(beta_crit_rad), 2)
t_ecl_s = 0.0
if abs(beta_rad) < beta_crit_rad:
arg = math.sqrt(h_m * h_m + 2.0 * r_earth * h_m) / ((r_earth + h_m) * math.cos(beta_rad))
t_ecl_s = (t_orb_s / math.pi) * math.acos(min(1.0, max(-1.0, arg)))
sunlit_frac = max(0.55, 1.0 - t_ecl_s / t_orb_s)
ecl_min = js_round(t_ecl_s / 60.0, 2)
ecl_batt_t = (eff_kw * 1000.0 * (t_ecl_s / 3600.0)) / (0.80 * 0.95 * 280.0 * 1000.0)
total_batt_t = js_round(ecl_batt_t + eff_mw * 0.45, 2)
# B. Stefan-Boltzmann Radiative Cooling + Physical TSI F10.7 Coupling (0.008 W/m2/sfu)
sigma = 5.670374419e-8
f_earth = (r_earth / (r_earth + h_m)) ** 2
i_am0 = 1361.0 + (st["f107"] - 150.0) * 0.008
q_earth = f_earth * (0.92 * 237.0 + 0.15 * 0.30 * i_am0 * max(0.15, math.cos(beta_rad)))
t_loop_k = loop_temp_c + 273.15
q_emit = 2.0 * 0.92 * sigma * 0.85 * ((t_loop_k ** 4) - (2.725 ** 4))
q_net = js_round(max(180.0, q_emit - q_earth), 1)
rad_area_m2 = int(js_round(((eff_kw * 1000.0 * 0.94) / q_net) * rm_p["rad_eol_margin"], 0))
tj_knee = hw_p["tj_knee_c"]
tj_factor = 1.0 if loop_temp_c <= tj_knee else max(0.75, 1.0 - (((loop_temp_c - tj_knee) / 42.0) ** 1.65) * 0.22)
orb_pue = js_round(1.016 + (0.006 if loop_temp_c < 70.0 else 0.002), 3)
terr_pue = 1.32
# C. AM0 Solar Array + Van Allen Radiation Belt Envelope + 5-Yr TID
cell_temp_c = js_round(92.0 * sunlit_frac - 15.0 * (1.0 - sunlit_frac), 1)
temp_der = 1.0 - 0.002 * max(0.0, cell_temp_c - 25.0)
if 800.0 < altitude_km <= 6000.0:
va_mult = 1.0 + 17.0 * math.exp(-(((altitude_km - 3200.0) / 1400.0) ** 2))
elif 6000.0 < altitude_km <= 25000.0:
va_mult = 2.5 + 8.0 * math.exp(-(((altitude_km - 18000.0) / 6000.0) ** 2))
elif altitude_km > 25000.0:
va_mult = 6.5
else:
va_mult = 1.0
tid_deg = min(0.15, (0.018 + math.log10(max(1.0, st["proton_pfu"])) * 0.003) * (va_mult ** 0.35))
tid_fac_5yr = (1.0 - ((1.0 - tid_deg) ** 5)) / (5.0 * tid_deg)
eff_pv = js_round(0.32 * temp_der * tid_fac_5yr, 4)
sol_yield = js_round(i_am0 * eff_pv * sunlit_frac, 1)
sol_area_m2 = int(js_round((eff_kw * 1000.0 * orb_pue) / sol_yield, 0))
# D. Continuous SEU Rate, SAA/Van Allen & 25-MW Fault-Domain Young-Daly
dom_gpus = min(total_acc, 7200)
per_gpu_dbe_hr = 1.05e-5 * math.exp(0.32 * st["kp"]) * (1.0 + 0.42 * (max(0.05, st["proton_pfu"]) ** 0.38)) * hw_p["rad_shield_factor"] * va_mult
dom_dbe_hr = max(0.001, dom_gpus * per_gpu_dbe_hr)
dom_mtbf_min = js_round((1.0 / dom_dbe_hr) * 60.0, 2)
delta_ckpt = 0.42
tau_opt_min = js_round(math.sqrt(2.0 * delta_ckpt * dom_mtbf_min), 2)
ecc_ovh = js_round(min(18.0, 1.05 + 0.22 * st["kp"] + 0.55 * math.log10(max(1.0, st["proton_pfu"])) + 1.8 * math.log10(va_mult)), 2)
ckpt_ovh = js_round(min(35.0, (delta_ckpt / tau_opt_min) * 100.0), 2)
net_avail = js_round(max(42.0, (100.0 - ecc_ovh - ckpt_ovh * 0.42) * tj_factor), 2)
l1_lead_min = js_round(1500000.0 / (max(250.0, st["wind_kms"]) * 60.0), 1)
storm_trigger = (st["bz_nt"] <= -8.0) or (st["kp"] >= 5.0) or (st["proton_pfu"] >= 10.0)
# E. Mass-Coupled Sizing (+18% MMOD + FCC 5-Yr De-Orbit + Altitude Delta-V)
dry_bus_t = eff_kw / 135.0
rad_t = (rad_area_m2 * 2.1) / 1000.0
sol_t = (sol_area_m2 * 1.1) / 1000.0
deorb_t = js_round((dry_bus_t + rad_t + sol_t) * 0.045, 1)
mmod_t = js_round((dry_bus_t + rad_t + sol_t + total_batt_t + deorb_t) * 1.18 * rm_p["mass_mult"], 1)
dv_fac = 1.0 if altitude_km <= 800.0 else max(0.22, 1.0 / (1.0 + 0.00018 * (altitude_km - 800.0)))
eff_payload_t = js_round(lv_p["payload_tons"] * rm_p["lv_payload_mult"] * dv_fac, 2)
eff_launch_musd = js_round(lv_p["cost_musd"] * rm_p["lv_cost_mult"], 2)
flights = math.ceil(mmod_t / eff_payload_t)
hw_capex = (eff_kw * hw_p["capex_usd_per_kw"]) / 1e6
launch_capex = js_round(flights * eff_launch_musd, 2)
bus_capex = js_round(mmod_t * rm_p["bus_cost_musd_per_ton"], 2)
orb_ops = js_round(eff_mw * 1.15, 2)
orb_tco = js_round(hw_capex + launch_capex + bus_capex + orb_ops, 2)
earth_civil = js_round(eff_mw * 18.2 * earth_capex_factor, 2)
earth_capex = js_round(hw_capex + earth_civil, 2)
five_yr_mwh = eff_mw * terr_pue * 43800.0
earth_energy = js_round((five_yr_mwh * grid_price_usd_mwh) / 1e6, 2)
earth_ops = js_round(eff_mw * 2.65 * 5.0, 2)
earth_tco = js_round(earth_capex + earth_energy + earth_ops, 2)
net_savings = js_round(earth_tco - orb_tco, 2)
# F. Optical OISL Vacuum Speed of Light, OGS Downlink & Roofline (before TCO for NEU-3)
peak_ef = js_round(((nodes_count * hw_p["pflops_fp4_per_node"]) / 1000.0) * tj_factor, 2)
c_vac = 299792.458
v_fib = c_vac / 1.4682
lat_fib = js_round(((distance_km * 1.24) / v_fib) * 1000.0, 2)
lat_orb = js_round(((distance_km * 1.12 + 2.0 * altitude_km) / c_vac) * 1000.0, 2)
ogs_tbps = js_round(max(0.8, (eff_mw / 100.0) * 3.2 * 0.994), 2)
flops_per_watt = (peak_ef * 1e18) / (eff_mw * 1e6)
gamma_b_j = js_round(comm_intensity * flops_per_watt, 1)
req_dl_tbps = js_round((gamma_b_j * 0.05 * eff_mw * 1e6) / 1e12, 3)
ogs_util_pct = js_round((req_dl_tbps / ogs_tbps) * 100.0, 1)
dl_bound = req_dl_tbps > ogs_tbps
dl_factor = max(0.005, ogs_tbps / max(0.001, req_dl_tbps)) if dl_bound else 1.0
vb_feasible = comm_intensity <= 1.6e-5
# Coupled Attrition & Downlink Token Economics (NEU-3)
surv = survival_factor(annual_attrition_pct)
orb_eff_ratio = (net_avail / 100.0) * surv * dl_factor
earth_eff_ratio = 0.991
sust_tok_s = max(1, int(js_round(eff_mw * hw_p["tokens_sec_per_mw"] * orb_eff_ratio, 0)))
orb_mtok_total = (sust_tok_s * 86400.0 * 365.0 * 5.0) / 1e6
orb_usd_mtok = js_round((orb_tco * 1e6) / orb_mtok_total, 4)
orb_wacc_mtok = js_round(orb_usd_mtok * 1.14, 4)
earth_mtok_total = (eff_mw * hw_p["tokens_sec_per_mw"] * earth_eff_ratio * 86400.0 * 365.0 * 5.0) / 1e6
earth_usd_mtok = js_round((earth_tco * 1e6) / earth_mtok_total, 4)
# K2 Dual Breakeven & Dispatch Invariance
cool_delta = eff_mw * 1.42 * 5.0
be_grid = js_round(((launch_capex + bus_capex + orb_ops - cool_delta) * 1e6) / five_yr_mwh, 2)
avail_scale = earth_eff_ratio / max(0.005, orb_eff_ratio)
bf_tok_be = js_round(((orb_tco * avail_scale - hw_capex - cool_delta) * 1e6) / five_yr_mwh, 2)
gf_tco_be = js_round(((orb_tco * avail_scale - hw_capex - earth_civil - earth_ops) * 1e6) / five_yr_mwh, 2)
earth_bf_tco = js_round(hw_capex + earth_energy + cool_delta, 2)
earth_bf_mtok = js_round((earth_bf_tco * 1e6) / earth_mtok_total, 4)
tok_red_pct = js_round((1.0 - orb_usd_mtok / earth_usd_mtok) * 100.0, 1)
lo_gate = min(be_grid, bf_tok_be)
hi_gate = max(be_grid, bf_tok_be)
if dl_bound:
dispatch_sig = "TERRESTRIAL_PRIMARY"
directive = "MIGRATE_TO_TERRESTRIAL_DOWNLINK_BOUND"
else:
dispatch_sig = "TERRESTRIAL_PRIMARY" if grid_price_usd_mwh < lo_gate else ("ORBIT_PRIMARY" if grid_price_usd_mwh > hi_gate else "HYBRID_SPLIT")
if storm_trigger:
directive = "TRIGGER_PRE_EMPTIVE_CHECKPOINT_AND_HYBRID_SPLIT"
elif dispatch_sig == "TERRESTRIAL_PRIMARY":
directive = "MIGRATE_BATCH_TO_TERRESTRIAL_SPOT"
elif dispatch_sig == "HYBRID_SPLIT":
directive = "HYBRID_LOAD_BALANCE_ORBIT_EARTH"
else:
directive = "ROUTE_TO_ORBIT_DAWN_DUSK_SSO"
gf_verdict = "ORBIT_GREENFIELD_ADVANTAGE" if ((not dl_bound) and (orb_usd_mtok < earth_usd_mtok)) else "EARTH_GREENFIELD_ADVANTAGE"
# G. OCEI 4-Pillar Score
f107_bonus = 0.0 if st["kp"] >= 5.0 else (i_am0 - 1361.0) * 0.35
p1 = js_round(max(140.0, min(250.0, (246.0 + f107_bonus) * sunlit_frac * (eff_pv / 0.281))), 1)
p2 = js_round(max(160.0, min(250.0, 244.0 * ((q_net / 1055.0) ** 0.16) * tj_factor)), 1)
bz_pen = abs(st["bz_nt"]) * 0.65 if st["bz_nt"] < 0.0 else 0.0
va_pen = 18.0 * math.log10(va_mult)
p3 = js_round(max(70.0, min(248.0, 240.0 - st["kp"] * 3.4 - math.log10(max(1.0, st["proton_pfu"])) * 21.0 - bz_pen - va_pen)), 1)
jit_pen = (st["kp"] - 5.0) * 2.8 if st["kp"] >= 6.0 else 0.0
lat_pen = 0.0 if altitude_km <= 800.0 else min(95.0, ((altitude_km / c_vac) * 1000.0 - 4.0) * 0.72)
dl_pen = min(35.0, (ogs_util_pct - 100.0) * 0.15) if dl_bound else 0.0
p4 = js_round(max(110.0, min(250.0, 247.0 - ckpt_ovh * 0.35 - jit_pen - lat_pen - dl_pen)), 1)
cliff = 1.0 if net_avail >= 88.0 else max(0.72, 1.0 - (88.0 - net_avail) * 0.018)
spot_score = js_round((p1 + p2 + p3 + p4) * cliff, 1)
struct_score = js_round(246.0 * sunlit_frac + p2 + max(70.0, 234.5 - va_pen) + max(110.0, 246.5 - lat_pen), 1)
earth_p1 = js_round(max(55.0, min(210.0, 105.0 + (115.0 - grid_price_usd_mwh) * 0.65)), 1)
earth_score = js_round(earth_p1 + 95.0 + 248.0 + 82.0, 1)
# I. Credit Underwriting & Annual SSO Eclipse Envelope
orb_tco_w = js_round(orb_tco / eff_mw, 2)
eff_rev_w_yr = 50.0 * surv * dl_factor
payback_gross = js_round(orb_tco_w / max(0.5, eff_rev_w_yr), 2)
payback_net = js_round(orb_tco_w / max(0.5, eff_rev_w_yr * 0.72), 2)
sso_env = compute_annual_sso_eclipse_envelope(
altitude_km, eff_kw, orb_usd_mtok, mmod_t, eff_payload_t, flights, rm_p["mass_mult"]
)
return {
"schema_version": SCHEMA_VERSION,
"ocei_standard": {
"ocei_spot_realtime_score": spot_score,
"ocei_structural_5yr_score": struct_score,
"terrestrial_tier4_grid_score": earth_score,
"net_orbital_spread_pts": js_round(spot_score - earth_score, 1),
"breakeven_grid_usd_mwh": be_grid,
"brownfield_token_parity_usd_mwh": bf_tok_be,
"greenfield_tco_breakeven_usd_mwh": gf_tco_be,
"arbitrage_dispatch_signal": dispatch_sig,
"greenfield_capex_verdict": gf_verdict,
"dispatch_directive": directive,
"pillars_250": {"p1": p1, "p2": p2, "p3": p3, "p4": p4},
},
"space_weather_and_young_daly_checkpointing": {
"kp_index": st["kp"],
"proton_pfu": st["proton_pfu"],
"l1_shockwave_lead_time_min": l1_lead_min,
"fault_domain_seu_mtbf_minutes": dom_mtbf_min,
"young_daly_optimal_checkpoint_interval_min": tau_opt_min,
"hbm_ecc_scrubbing_overhead_pct": ecc_ovh,
"net_effective_compute_availability_pct": net_avail,
"pre_emptive_checkpoint_trigger": storm_trigger,
},
"thermodynamic_radiative_cooling": {
"earth_view_factor": js_round(f_earth, 4),
"absorbed_earth_ir_albedo_w_m2": js_round(q_earth, 1),
"effective_net_heat_rejection_w_m2": q_net,
"required_deployable_radiator_area_m2": rad_area_m2,
"silicon_tj_thermal_throttle_factor": js_round(tj_factor, 4),
},
"orbital_mechanics_and_launch_mass": {
"sunlit_duty_cycle_pct": js_round(sunlit_frac * 100.0, 2),
"eclipse_duration_min_per_orbit": ecl_min,
"annual_sso_eclipse_envelope": sso_env,
"five_year_mean_pv_efficiency_pct": js_round(eff_pv * 100.0, 2),
"required_solar_array_area_m2": sol_area_m2,
"eclipse_and_holdup_battery_mass_tons": total_batt_t,
"fcc_deorbit_propellant_reserve_tons": deorb_t,
"mmod_shielded_total_constellation_mass_tons": mmod_t,
"deployed_mass_kg_per_it_kw": js_round((mmod_t * 1000.0) / eff_kw, 2),
"launches_required": flights,
},
"optical_oisl_laser_network": {
"long_haul_terrestrial_fiber_latency_ms": lat_fib,
"long_haul_orbital_oisl_latency_ms": lat_orb,
"effective_ogs_ground_downlink_tbps": ogs_tbps,
"turyshev_gamma_bits_per_joule": gamma_b_j,
"required_downlink_tbps_cached": req_dl_tbps,
"ogs_downlink_utilization_pct": ogs_util_pct,
"downlink_bound": dl_bound,
"downlink_throughput_cap_factor": js_round(dl_factor, 4),
"tightly_coupled_training_feasible": vb_feasible,
},
"token_economics_and_5yr_tco": {
"cluster_peak_exaflops_fp4": peak_ef,
"sustained_frontier_tokens_per_sec": sust_tok_s,
"orbital_cost_per_1m_tokens_usd": orb_usd_mtok,
"wacc_adjusted_orbital_lcoc_usd_mtok": orb_wacc_mtok,
"terrestrial_cost_per_1m_tokens_usd": earth_usd_mtok,
"terrestrial_brownfield_usd_per_1m_tokens": earth_bf_mtok,
"token_production_cost_reduction_pct": tok_red_pct,
"orbital_5yr_total_tco_musd": orb_tco,
"terrestrial_5yr_total_tco_musd": earth_tco,
"five_year_net_tco_savings_in_orbit_musd": net_savings,
},
"credit_underwriting_and_covenants": {
"orbital_5yr_tco_usd_per_watt": orb_tco_w,
"implied_orbital_payback_years": payback_gross,
"implied_net_cashflow_payback_years_72pct_ebitda": payback_net,
},
}
def verify_golden_masters() -> bool:
"""Offline regression suite verifying 1:1 parity with the live Cloudflare Worker."""
gm1 = evaluate_ocei_kernel(storm_mode="g0_quiet")
assert gm1["ocei_standard"]["ocei_spot_realtime_score"] == 965.2
assert gm1["ocei_standard"]["ocei_structural_5yr_score"] == 975.3
assert gm1["orbital_mechanics_and_launch_mass"]["deployed_mass_kg_per_it_kw"] == 15.51
assert gm1["orbital_mechanics_and_launch_mass"]["launches_required"] == 13
assert gm1["token_economics_and_5yr_tco"]["orbital_cost_per_1m_tokens_usd"] == 0.5137
assert gm1["ocei_standard"]["breakeven_grid_usd_mwh"] == 28.42
gm2 = evaluate_ocei_kernel(altitude_km=575, beta_deg=66.6, hw="starmind_ai1", storm_mode="g0_quiet")
assert gm2["ocei_standard"]["ocei_spot_realtime_score"] == 965.2
assert gm2["token_economics_and_5yr_tco"]["orbital_cost_per_1m_tokens_usd"] == 0.4975
assert gm2["orbital_mechanics_and_launch_mass"]["annual_sso_eclipse_envelope"]["solstice_eclipse_days_per_year"] == 97
assert gm2["orbital_mechanics_and_launch_mass"]["annual_sso_eclipse_envelope"]["annual_mean_sunlit_pct"] == 95.31
gm3 = evaluate_ocei_kernel(storm_mode="g3_storm")
assert gm3["ocei_standard"]["ocei_spot_realtime_score"] == 880.9
gm4 = evaluate_ocei_kernel(storm_mode="g5_extreme")
assert gm4["ocei_standard"]["ocei_spot_realtime_score"] == 795.4
gm5 = evaluate_ocei_kernel(realism_mode="conservative", storm_mode="g0_quiet")
assert gm5["orbital_mechanics_and_launch_mass"]["deployed_mass_kg_per_it_kw"] == 39.26
assert gm5["ocei_standard"]["greenfield_capex_verdict"] == "EARTH_GREENFIELD_ADVANTAGE"
gm6 = evaluate_ocei_kernel(realism_mode="current_2026", storm_mode="g0_quiet")
assert gm6["orbital_mechanics_and_launch_mass"]["deployed_mass_kg_per_it_kw"] == 43.54
assert gm6["token_economics_and_5yr_tco"]["orbital_cost_per_1m_tokens_usd"] == 4.5503
gannon = evaluate_ocei_kernel(storm_mode="gannon_2024")
assert gannon["ocei_standard"]["ocei_spot_realtime_score"] == 850.0
assert gannon["space_weather_and_young_daly_checkpointing"]["net_effective_compute_availability_pct"] == 89.67
assert gannon["token_economics_and_5yr_tco"]["orbital_cost_per_1m_tokens_usd"] == 0.56
env650 = gm1["orbital_mechanics_and_launch_mass"]["annual_sso_eclipse_envelope"]
assert env650["solstice_eclipse_days_per_year"] == 89
assert env650["max_solstice_eclipse_min"] == 19.68
assert env650["annual_mean_sunlit_pct"] == 96.05
assert env650["worst_day_full_battery_extra_tons"] == 154.1
dl_test = evaluate_ocei_kernel(comm_intensity_bits_per_flop=2e-6, storm_mode="g0_quiet")
assert dl_test["optical_oisl_laser_network"]["downlink_bound"] is True
assert dl_test["ocei_standard"]["arbitrage_dispatch_signal"] == "TERRESTRIAL_PRIMARY"
assert dl_test["ocei_standard"]["dispatch_directive"] == "MIGRATE_TO_TERRESTRIAL_DOWNLINK_BOUND"
assert dl_test["token_economics_and_5yr_tco"]["orbital_cost_per_1m_tokens_usd"] > 20.0
att_test = evaluate_ocei_kernel(annual_attrition_pct=9.0, storm_mode="g0_quiet")
assert att_test["credit_underwriting_and_covenants"]["implied_orbital_payback_years"] == 0.8
assert att_test["credit_underwriting_and_covenants"]["implied_net_cashflow_payback_years_72pct_ebitda"] == 1.11
halloween = evaluate_ocei_kernel(storm_mode="halloween_2003")
assert halloween["ocei_standard"]["ocei_spot_realtime_score"] == 697.1
assert halloween["space_weather_and_young_daly_checkpointing"]["net_effective_compute_availability_pct"] == 80.93
assert halloween["token_economics_and_5yr_tco"]["orbital_cost_per_1m_tokens_usd"] == 0.6208
assert halloween["ocei_standard"]["breakeven_grid_usd_mwh"] == 28.91
return True
_round = js_round
SENSITIVITY_TRACKS = REALISM_MODES
run_golden_master_suite = verify_golden_masters
if __name__ == "__main__":
verify_golden_masters()
print(json.dumps({
"status": "OK",
"schema_version": SCHEMA_VERSION,
"verified_vectors": [
"GM-1_G0_TARGET", "GM-2_FCC_575_AI1", "GM-3_G3_STORM", "GM-4_G5_CARRINGTON",
"GM-5_CONSERVATIVE", "GM-6_CURRENT_2026", "G6_GANNON_207PFU",
"HALLOWEEN_2003_29500PFU", "A1_A2_J2_SOLSTICE_89D",
"NEU3_DOWNLINK_BOUND", "NEU3_ATTRITION_PAYBACK"
],
}, indent=2))
|