Skip to content

Commit 1803fad

Browse files
noreplyclaude
andcommitted
Add __main__ demos to power.py and thermal.py
Now runnable: python -m orbital_compute.power (battery + aging demo) and python -m orbital_compute.thermal (orbit thermal cycling demo). 7 more core modules still need __main__ blocks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c3c92b9 commit 1803fad

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

orbital_compute/power.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,35 @@ def predict_eol(self, cycles_per_day: float, avg_dod: float = 30.0,
195195

196196
cycles_to_eol = remaining_fade / fade_per_cycle
197197
return cycles_to_eol / cycles_per_day
198+
199+
200+
if __name__ == "__main__":
201+
print("=" * 60)
202+
print(" POWER SUBSYSTEM DEMO")
203+
print("=" * 60)
204+
205+
# Simulate 3 orbits
206+
pm = PowerModel(PowerConfig(solar_panel_watts=2000, battery_capacity_wh=5000))
207+
print(f"\n Solar: {pm.config.solar_panel_watts}W, Battery: {pm.config.battery_capacity_wh}Wh")
208+
print(f"\n Simulating 3 LEO orbits (95 min each)...")
209+
for orbit in range(3):
210+
# Sunlit phase (60 min)
211+
for _ in range(60):
212+
s = pm.step(60, in_eclipse=False, compute_load_w=500)
213+
sun_batt = s.battery_pct
214+
# Eclipse phase (35 min)
215+
for _ in range(35):
216+
s = pm.step(60, in_eclipse=True, compute_load_w=500)
217+
ecl_batt = s.battery_pct
218+
print(f" Orbit {orbit+1}: sunlit→{sun_batt:.0%} eclipse→{ecl_batt:.0%} "
219+
f"solar={s.solar_output_w:.0f}W load={s.load_w:.0f}W")
220+
221+
# Battery aging
222+
print(f"\n Battery Aging (5 years, 15 cycles/day, 30% DoD):")
223+
ba = BatteryAgingModel(initial_capacity_wh=5000)
224+
for year in range(1, 6):
225+
for _ in range(365 * 15):
226+
ba.cycle(dod_pct=30, c_rate=0.5, temp_c=28)
227+
ba.calendar_age(8760)
228+
print(f" Year {year}: SoH={ba.soh_pct:.1f}% capacity={ba.capacity_wh:.0f}Wh")
229+
print(f"\n{'=' * 60}")

orbital_compute/thermal.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,22 @@ def max_sustainable_heat_w(self, target_temp_c: float = 70.0) -> float:
104104
q_solar = c.solar_absorptivity * 1361.0 * c.radiator_area_m2 * 0.25
105105
q_earth = c.earth_ir_w_m2 * c.radiator_area_m2 * 0.5
106106
return max(0.0, q_rad - q_solar - q_earth)
107+
108+
109+
if __name__ == "__main__":
110+
print("=" * 60)
111+
print(" THERMAL SUBSYSTEM DEMO")
112+
print("=" * 60)
113+
tm = ThermalModel(ThermalConfig(radiator_area_m2=4.0), initial_temp_c=20.0)
114+
print(f"\n Radiator: {tm.config.radiator_area_m2} m², Start: 20°C")
115+
print(f" Max sustainable heat: {tm.max_sustainable_heat_w(70):.0f}W at 70°C")
116+
print(f"\n Simulating sunlit orbit with 500W GPU heat...")
117+
for minute in range(95):
118+
eclipse = minute >= 60
119+
s = tm.step(60, 500 if not eclipse else 100, eclipse)
120+
if minute % 10 == 0:
121+
phase = "ECLIPSE" if eclipse else "SUNLIT"
122+
print(f" t={minute:3d}min {phase:7s} temp={s.temp_c:5.1f}°C "
123+
f"heat={s.heat_generated_w:.0f}W rad={s.heat_radiated_w:.0f}W "
124+
f"throttle={s.throttle_pct:.0%}")
125+
print(f"\n{'=' * 60}")

0 commit comments

Comments
 (0)