-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_advanced_physics.py
More file actions
78 lines (66 loc) · 2.32 KB
/
Copy pathtest_advanced_physics.py
File metadata and controls
78 lines (66 loc) · 2.32 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
69
70
71
72
73
74
75
76
77
78
import requests
import time
payload = {
"mission_name": "Test Advanced Physics",
"mission_target": "Jupiter Transfer",
"initial_orbit": "JUPITER",
"spacecraft_mass": 200.0,
"sail_area": 1200.0,
"reflectivity": 0.92,
"sail_type": "flat_plate",
"hybrid_mode": True,
"ion_thrust_newtons": 0.5,
"ion_isp_seconds": 3000.0,
"fuel_mass_kg": 50.0,
"simulation_duration_days": 100.0,
"time_step_seconds": 1000.0,
"use_solar_cycle": True,
"use_cme": False,
"use_atmospheric_drag": False,
"enable_gravity_assists": True,
"spacecraft_charge": 0.05,
"solver_type": "RK4_SYMPLECTIC"
}
print("Submitting mission...")
res = requests.post("http://127.0.0.1:8000/mission/create", json=payload)
if not res.ok:
print("Failed to create mission:", res.text)
exit(1)
data = res.json()
mission_id = data["mission_id"]
print(f"Mission {mission_id} created. Running...")
res = requests.post(f"http://127.0.0.1:8000/mission/run/{mission_id}")
if not res.ok:
print("Failed to run mission:", res.text)
exit(1)
print("Polling for completion...")
while True:
status_res = requests.get(f"http://127.0.0.1:8000/mission/{mission_id}/status")
if status_res.json()["status"] == "COMPLETED":
break
elif status_res.json()["status"] == "FAILED":
print("Mission failed!")
exit(1)
time.sleep(0.5)
print("Mission completed. Fetching results...")
res = requests.get(f"http://127.0.0.1:8000/mission/{mission_id}/results")
results = res.json()
traj = results["trajectory"]
print(f"Trajectory Length: {len(traj)} steps")
if len(traj) > 0:
first_step = traj[0]
last_step = traj[-1]
# Check diagnostics
last_diags = last_step.get("diagnostics", {})
a_lorentz = last_diags.get("a_lorentz_ms2")
a_third = last_diags.get("a_third_body_ms2")
print(f"Initial Mass: {first_step['mass']} kg")
print(f"Final Mass: {last_step['mass']} kg")
if a_lorentz is not None:
print(f"Lorentz Acceleration detected: {a_lorentz:.2e} m/s^2")
else:
print("WARNING: Lorentz Acceleration entirely missing.")
if a_third is not None:
print(f"Gravity Assist (Third-Body) Acceleration detected: {a_third:.2e} m/s^2")
else:
print("WARNING: Third-Body Acceleration missing from orbital mechanics output.")