-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_local.py
More file actions
68 lines (58 loc) · 2.34 KB
/
Copy pathtest_local.py
File metadata and controls
68 lines (58 loc) · 2.34 KB
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
import traceback
import sys
# Add project root so we can import modules
import pathlib
sys.path.insert(0, str(pathlib.Path(__file__).parent))
from api.server import SimulationConfigJSON, mission_manager
payload = {
"mission_name": "Test Local Thermal",
"mission_target": "Mercury Orbit Tests",
"initial_orbit": "MERCURY",
"spacecraft_mass": 200.0,
"sail_area": 1200.0,
"reflectivity": 0.92,
"sail_type": "flat_plate",
"hybrid_mode": False,
"ion_thrust_newtons": 0.0,
"ion_isp_seconds": 3000.0,
"fuel_mass_kg": 0.0,
"simulation_duration_days": 2.0,
"time_step_seconds": 100.0,
"use_solar_cycle": True,
"use_cme": False,
"use_atmospheric_drag": False,
"enable_gravity_assists": False,
"spacecraft_charge": 0.0,
"solver_type": "RK4_SYMPLECTIC"
}
try:
config = SimulationConfigJSON(**payload)
mission = mission_manager._build_mission_obj(config)
print("Running local mission SYNCHRONOUSLY...")
mission.run()
print("Mission completed successfully!")
traj = mission.get_trajectory()
print(f"Generated {len(traj)} data points.")
if len(traj) > 0:
last_step = traj[-1]
diags = getattr(last_step, 'diagnostics', None) or last_step.get("diagnostics", {}) if isinstance(last_step, dict) else last_step.diagnostics
print("Final Diagnostics Data:")
for k, v in diags.items():
print(f" {k}: {v}")
degs = [s.get("degradation_factor", 1.0) for s in traj]
print(f"\nDegs sample: {degs[:5]} ... {degs[-5:]}")
final_deg = last_step.get("degradation_factor", 1.0)
print(f"\nFinal Degradation Factor: {final_deg}")
temp = diags.get('sail_physics__T_equilibrium_K', 0.0)
print(f"Final Membrane Temp: {temp:.2f} K")
# Verify the degradation rate worked
degradation = final_deg
if temp > 350.0 and degradation < 1.0:
print("SUCCESS: High temperatures detected and optical degradation multiplier properly decayed.")
elif temp <= 350.0:
print("WARNING: Spacecraft did not get hot enough to degrade. Temp:", temp)
else:
print("ERROR: Spacecraft got hot but degradation_factor did not decay:", degradation)
except Exception as e:
print("Mission failed with trace:")
traceback.print_exc()