Skip to content

Commit e501bc6

Browse files
committed
Refactor and enhance vector impulse simulation
- Introduced `simulate_vector_impulse.py` to encapsulate the vectorized translation impulse engine simulation. - Implemented JAX support with fallbacks to NumPy for performance optimization. - Added classes for 3D vectors and impulse profiles, along with methods for trajectory planning and energy computation. - Created a multi-segment trajectory planning function to handle complex maneuvers. - Developed visualization functions for trajectory analysis, including 3D plots and energy timelines. - Deprecated the standalone JAX acceleration test script, replacing it with a pytest-based demo that runs conditionally based on JAX availability. - Added pytest fixtures for trajectory planning and mission results to streamline testing. - Updated V&V tests to import from the new simulation module structure.
1 parent ff809bc commit e501bc6

15 files changed

Lines changed: 647 additions & 1110 deletions

UQ-TODO.ndjson

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121
{"title":"Stability Mode Sensitivity","description":"Perturb background profiles and recompute dominant growth rates in WarpBubble3DStabilityAnalyzer; report distribution of max growth.","type":"analysis","severity":55,"category":"stability","impact":"High sensitivity indicates need for profile constraints or damping mechanisms"}
2222
{"title":"Metamaterial-Plasma Coupling Validation","description":"Validate 10⁴× enhancement with small toroidal rings","type":"validation","severity":70,"category":"cross_system_coupling","impact":"Could affect energy reduction accuracy"}
2323
{"title":"Battery Cost-Complexity Tradeoff","description":"Analyze battery vs. fusion for 25 MW in small spacecraft","type":"theoretical","severity":65,"category":"system_integration","impact":"Could increase costs if battery scaling is inefficient"}
24+
{"title":"Define abort criteria for ramp overshoot","description":"Quantify safe abort thresholds for power ramp overshoot and quench conditions; tie to safety checklist.","type":"safety","severity":60,"category":"safety","impact":"Prevents thermal/electrical overstress during transients"}
25+
{"title":"Thermal cooldown margin validation","description":"Model cooldown time and margin after full-power mission; ensure compliance with thermal limits.","type":"analysis","severity":55,"category":"thermal","impact":"Undersized cooling could force increased dwell or mission delays"}
26+
{"title":"Fix geometry and mission timeline","description":"Lock geometry and mission timeline consistent with constraints; propagate to tests and docs.","type":"process","severity":40,"category":"documentation","impact":"Prevents drift between models and mission plan"}
2427
{"title":"Ring Field Synchronization","description":"Ensure 1-meter rings synchronize fields for stable 5-meter bubble","type":"theoretical","severity":55,"category":"temporal_coupling","impact":"Could destabilize warp bubble if unsynchronized"}

VnV-TODO-RESOLVED.ndjson

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{"category":"V&V","task":"Backreaction analyzer timeout path","priority":"Done","source_file":"src/warp_engine/backreaction.py","source_file_lines":"1:200","source_snippet":"analyze_backreaction_coupling(..., timeout_s)","python_snippet":"from warp_engine.backreaction import analyze_backreaction_coupling as f; assert callable(f)","status":"resolved","date":"2025-08-10"}
22
{"category":"V&V","task":"Ultimate B-Spline import and objective smoke","priority":"Done","source_file":"src/optimization/ultimate_bspline_optimizer.py","source_file_lines":"1:420","source_snippet":"objective_function_core","python_snippet":"from ultimate_bspline_optimizer import UltimateBSplineOptimizer as U; U().objective_function(U().initialize_parameters())","status":"resolved","date":"2025-08-10"}
33
{"category":"V&V","task":"Natário build_metric divergence-free shift","priority":"Done","source_file":"src/supraluminal_prototype/warp_generator.py","source_file_lines":"1:120","source_snippet":"build_metric, expansion_scalar","python_snippet":"from src.supraluminal_prototype.warp_generator import GridSpec, build_metric, expansion_scalar; m=build_metric({'grid':GridSpec()}); th=expansion_scalar(m); import numpy as np; assert float(np.mean(np.abs(th)))<5e-3","status":"resolved","date":"2025-08-09"}
4-
{"category":"V&V","task":"Vector impulse energy scales ~ v_max^2","priority":"Done","source_file":"simulate_vector_impulse.py","source_file_lines":"1:260","source_snippet":"compute_vector_energy_integral","python_snippet":"from simulate_vector_impulse import Vector3D, VectorImpulseProfile, WarpBubbleVector, simulate_vector_impulse_maneuver; base=VectorImpulseProfile(target_displacement=Vector3D(10,0,0), v_max=1e-5, n_steps=200); import numpy as np; import numpy as _np; warp=WarpBubbleVector(shape_params=_np.array([1.0,2.0,0.5])); E1=simulate_vector_impulse_maneuver(base, warp, enable_progress=False)['total_energy']; base.v_max=2e-5; E2=simulate_vector_impulse_maneuver(base, warp, enable_progress=False)['total_energy']; assert E2>E1 and 3.3<E2/(E1+1e-30)<4.7","status":"resolved","date":"2025-08-09"}
4+
{"category":"V&V","task":"Vector impulse energy scales ~ v_max^2","priority":"Done","source_file":"src/simulation/simulate_vector_impulse.py","source_file_lines":"1:260","source_snippet":"compute_vector_energy_integral","python_snippet":"from src.simulation.simulate_vector_impulse import Vector3D, VectorImpulseProfile, WarpBubbleVector, simulate_vector_impulse_maneuver; base=VectorImpulseProfile(target_displacement=Vector3D(10,0,0), v_max=1e-5, n_steps=200); import numpy as np; import numpy as _np; warp=WarpBubbleVector(shape_params=_np.array([1.0,2.0,0.5])); E1=simulate_vector_impulse_maneuver(base, warp, enable_progress=False)['total_energy']; base.v_max=2e-5; E2=simulate_vector_impulse_maneuver(base, warp, enable_progress=False)['total_energy']; assert E2>E1 and 3.3<E2/(E1+1e-30)<4.7","status":"resolved","date":"2025-08-09"}
55
{"category":"V&V","task":"Trajectory accuracy improves with n_steps","priority":"Done","source_file":"integrated_impulse_control.py","source_file_lines":"300:380","source_snippet":"execute_impulse_mission (vector path)","python_snippet":"from simulate_vector_impulse import Vector3D, VectorImpulseProfile, WarpBubbleVector, simulate_vector_impulse_maneuver; import numpy as _np; target=Vector3D(100,0,0); warp=WarpBubbleVector(shape_params=_np.array([1.0,2.0,0.5])); c=VectorImpulseProfile(target_displacement=target,v_max=5e-5,t_up=5,t_hold=10,t_down=5,n_steps=100); f=VectorImpulseProfile(target_displacement=target,v_max=5e-5,t_up=5,t_hold=10,t_down=5,n_steps=400); rc=simulate_vector_impulse_maneuver(c, warp, enable_progress=False); rf=simulate_vector_impulse_maneuver(f, warp, enable_progress=False); assert rf['trajectory_error']<=rc['trajectory_error']*1.05","status":"resolved","date":"2025-08-09"}
66
{"category":"V&V","task":"Vector impulse energy scales ~ v_max^2","priority":"Done","note":"Implemented in tests/test_vnv_vector_impulse.py"}
7+
{"category":"V&V","task":"Validate plasma_density bounds and units","priority":"High","source_file":"src/supraluminal_prototype/warp_generator.py","source_snippet":"def plasma_density","python_snippet":"import numpy as np\nfrom src.supraluminal_prototype.warp_generator import plasma_density, GridSpec\nres = plasma_density({'grid': GridSpec(), 'n0': 3e20})\nn = res['n']\nassert float(n.min()) >= 0 and np.isfinite(n).all()\n# units: n0 is in m^-3; ensure scaling preserves peak within ~1%\nassert np.isclose(float(n.max()), 3e20, rtol=1e-2)","status":"resolved","date":"2025-08-10"}
8+
{"category":"V&V","task":"Bench field_synthesis against simplified analytic target","priority":"Medium","source_file":"src/supraluminal_prototype/warp_generator.py","source_snippet":"def field_synthesis","python_snippet":"import numpy as np\nfrom src.supraluminal_prototype.warp_generator import GridSpec, field_synthesis, target_soliton_envelope, compute_envelope_error\ngrid = GridSpec()\n# Use target_soliton_envelope as simplified analytic target\nanalytic = target_soliton_envelope({'grid': grid, 'r0': 0.0, 'sigma': 0.5*grid.extent})['envelope']\n# Synthesize with uniform ring amplitudes and reasonable sigma\nsyn = field_synthesis([1,1,1,1], {'grid': grid, 'sigma': 0.2*grid.extent})['envelope']\nerr = compute_envelope_error(syn, analytic, norm='l2')\n# Expect bounded error on coarse grid; tighten later with fitters\nassert 0.0 <= err <= 0.6","status":"resolved","date":"2025-08-10"}
9+
{"category":"V&V","task":"V&V: coil ramp linearity and hysteresis","priority":"Medium","source_file":"src/supraluminal_prototype/hardware.py","source_snippet":"class CoilDriver","python_snippet":"from src.supraluminal_prototype.hardware import CoilDriver\ndrv = CoilDriver(max_current=5000.0, hysteresis=0.0)\nvals = [drv.command(i/30.0) for i in range(31)]\n# Near-linear increments\nincs = [vals[i]-vals[i-1] for i in range(1,31)]\nassert max(abs(incs[i]-incs[0]) for i in range(1,len(incs))) < 1e-3*drv.max_current","status":"resolved","date":"2025-08-10"}
710
{"category":"V&V","task":"Trajectory accuracy improves with n_steps","priority":"Done","note":"Implemented in tests/test_vnv_vector_impulse.py"}

VnV-TODO.ndjson

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
{"category":"Docs/Process","task":"Traceability: link roadmap items to tests","priority":"High","source_file":"docs/roadmap.ndjson","source_snippet":"associated_tasks","python_snippet":"# Scriptable check: for each associated_tasks title, ensure a matching line exists in VnV-TODO.ndjson/UQ-TODO.ndjson/tests"}
77
{"category":"Docs/Process","task":"Finalize requirements spec v1.0","priority":"High","source_file":"docs/requirements.md","source_snippet":"Mission requirements","python_snippet":"# Placeholder: validate document completeness checklist; assert all MUST-level items present"}
88
{"category":"Safety","task":"Safety checklist v0.9","priority":"High","source_file":"docs/safety_checklist.md","source_snippet":"Safe ramp abort and quench procedures","python_snippet":"# Placeholder: validate presence of abort criteria, watchdogs, thermal margins"}
9-
{"category":"V&V","task":"V&V: coil ramp linearity and hysteresis","priority":"Medium","source_file":"src/supraluminal_prototype/hardware.py","source_snippet":"class CoilDriver","python_snippet":"from src.supraluminal_prototype.hardware import CoilDriver\ndrv = CoilDriver(max_current=5000.0, hysteresis=0.0)\nvals = [drv.command(i/30.0) for i in range(31)]\n# Near-linear increments\nincs = [vals[i]-vals[i-1] for i in range(1,31)]\nassert max(abs(incs[i]-incs[0]) for i in range(1,len(incs))) < 1e-3*drv.max_current"}
109
{"category":"V&V","task":"V&V: power draw vs. model across ramp","priority":"High","source_file":"src/supraluminal_prototype/power.py","source_snippet":"def compute_smearing_energy","python_snippet":"# Placeholder: integrate measured P(t) and compare to model E within tolerance; assert abs(E_meas-E_model)/E_model < 0.1"}
1110
{"category":"Design","task":"Power electronics block diagram v1","priority":"Medium","source_file":"docs/power_electronics_block.md","source_snippet":"DC bus, ring drivers, protections","python_snippet":"# Placeholder artifact existence check"}
1211
{"task":"Instantiate MetricBackreactionEvolution with default parameters","priority":"High","source_file":"evolve_3plus1D_with_backreaction.py","source_file_lines":"1:20","source_snippet":"class MetricBackreactionEvolution","python_snippet":"from evolve_3plus1D_with_backreaction import MetricBackreactionEvolution; mbe = MetricBackreactionEvolution(); assert hasattr(mbe, 'laplacian_3d') and callable(mbe.laplacian_3d)"}
@@ -29,5 +28,3 @@
2928
{"task":"Verify build_metric for Natário metric with 1-meter rings","priority":"High","source_file":"src/supraluminal_prototype/warp_generator.py","source_file_lines":"50:65","source_snippet":"def build_metric(self, params): ...","python_snippet":"import numpy as np\nfrom supraluminal_prototype.warp_generator import WarpFieldGenerator\nxs = np.linspace(-1,1,16)\ngen = WarpFieldGenerator(grid=(xs, xs, xs), dx=xs[1]-xs[0])\nG = gen.build_metric({'r_eff':1e-10,'v':3e8})\nassert G.shape == (4,4,16,16,16)\nr2 = sum(xi**2 for xi in np.meshgrid(xs,xs,xs,indexing='ij'))\nassert np.allclose(G[0,0], np.exp(-r2))"}
3029
{"task":"Test plasma_density and field_propagation for 5-meter bubble","priority":"Medium","source_file":"src/supraluminal_prototype/warp_generator.py","source_file_lines":"70:85","source_snippet":"def plasma_density(self, T): ... def field_propagation(self, F): ...","python_snippet":"import numpy as np\nfrom supraluminal_prototype.warp_generator import WarpFieldGenerator\nxs = np.linspace(-1,1,16)\ngen = WarpFieldGenerator(grid=(xs, xs, xs), dx=xs[1]-xs[0])\nT = gen.build_metric({'r_eff':1e-10,'v':3e8})\nrho = gen.plasma_density(T)\nF = gen.field_propagation(T)\nassert np.allclose(rho, 3e20)\nassert F.shape == (3,16,16,16)"}
3130
{"category":"V&V","task":"Integration test for battery power delivery","priority":"High","source_file":"src/supraluminal_prototype/power_system.py","source_file_lines":"90:100","source_snippet":"def deliver_power(self, P): ...","python_snippet":"import numpy as np\nfrom supraluminal_prototype.power_system import PowerSystem\nP = PowerSystem(capacity=2.56e10)\nP_out = P.deliver_power(2.5e8)\nassert P_out >= 2.5e8\nassert P.capacity_remaining() >= 0"}
32-
{"category":"V&V","task":"Validate plasma_density bounds and units","priority":"High","source_file":"src/supraluminal_prototype/warp_generator.py","source_snippet":"def plasma_density","python_snippet":"import numpy as np\nfrom src.supraluminal_prototype.warp_generator import plasma_density, GridSpec\nres = plasma_density({'grid': GridSpec(), 'n0': 3e20})\nn = res['n']\nassert float(n.min()) >= 0 and np.isfinite(n).all()\n# units: n0 is in m^-3; ensure scaling preserves peak within ~1%\nassert np.isclose(float(n.max()), 3e20, rtol=1e-2)"}
33-
{"category":"V&V","task":"Bench field_synthesis against simplified analytic target","priority":"Medium","source_file":"src/supraluminal_prototype/warp_generator.py","source_snippet":"def field_synthesis","python_snippet":"import numpy as np\nfrom src.supraluminal_prototype.warp_generator import GridSpec, field_synthesis, target_soliton_envelope, compute_envelope_error\ngrid = GridSpec()\n# Use target_soliton_envelope as simplified analytic target\nanalytic = target_soliton_envelope({'grid': grid, 'r0': 0.0, 'sigma': 0.5*grid.extent})['envelope']\n# Synthesize with uniform ring amplitudes and reasonable sigma\nsyn = field_synthesis([1,1,1,1], {'grid': grid, 'sigma': 0.2*grid.extent})['envelope']\nerr = compute_envelope_error(syn, analytic, norm='l2')\n# Expect bounded error on coarse grid; tighten later with fitters\nassert 0.0 <= err <= 0.6"}

conftest.py

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,10 @@
11
#!/usr/bin/env python3
22
"""
3-
Shared pytest fixtures for integration tests.
4-
"""
5-
import asyncio
6-
import os
7-
from pathlib import Path
8-
import pytest
9-
10-
from integrated_impulse_control import (
11-
IntegratedImpulseController, MissionWaypoint, ImpulseEngineConfig
12-
)
13-
from simulate_vector_impulse import Vector3D
14-
from simulate_rotation import Quaternion
15-
16-
17-
# Skip heavy script-style module and any site-packages tests during collection
18-
def pytest_ignore_collect(collection_path: Path, config):
19-
try:
20-
name = os.path.basename(str(collection_path))
21-
if name in {"test_ultimate_bspline.py", "test_lqg_bounds_focused.py", "test_pipeline.py", "test_solver_debug.py"}:
22-
return True
23-
p = str(collection_path)
24-
if "/site-packages/" in p or p.endswith("internal_test_util/test_harnesses.py"):
25-
return True
26-
except Exception:
27-
return False
28-
return False
29-
30-
31-
@pytest.fixture(scope="function")
32-
def trajectory_plan():
33-
"""Provide a minimal, feasible trajectory plan for mission execution tests."""
34-
config = ImpulseEngineConfig(
35-
max_velocity=1e-4,
36-
max_angular_velocity=0.1,
37-
energy_budget=1e12,
38-
)
39-
controller = IntegratedImpulseController(config)
3+
Root-level pytest configuration is intentionally empty.
404
41-
waypoints = [
42-
MissionWaypoint(
43-
position=Vector3D(0.0, 0.0, 0.0),
44-
orientation=Quaternion(1.0, 0.0, 0.0, 0.0),
45-
dwell_time=1.0,
46-
),
47-
MissionWaypoint(
48-
position=Vector3D(100.0, 0.0, 0.0),
49-
orientation=Quaternion.from_euler(0.0, 0.0, 0.0),
50-
dwell_time=1.0,
51-
approach_speed=5e-5,
52-
),
53-
]
54-
55-
plan = controller.plan_impulse_trajectory(waypoints, optimize_energy=True)
56-
return plan
57-
58-
59-
@pytest.fixture(scope="function")
60-
def mission_results(trajectory_plan):
61-
"""Execute a short mission to generate results for reporting tests."""
62-
config = ImpulseEngineConfig(
63-
max_velocity=1e-4,
64-
max_angular_velocity=0.1,
65-
energy_budget=1e12,
66-
)
67-
controller = IntegratedImpulseController(config)
68-
69-
async def run():
70-
return await controller.execute_impulse_mission(trajectory_plan, enable_feedback=False)
5+
Notes:
6+
- Actual fixtures and collection filters live in tests/conftest.py.
7+
- Keeping this file minimal prevents import-time side effects from legacy imports.
8+
"""
719

72-
return asyncio.run(run())
10+
# Do not define hooks or fixtures here; tests/ scope owns pytest config.

docs/progress_log-completed.ndjson

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@
3636
{"event":"Add JAX vs NumPy benchmark summary to docs using jax_acceleration test","status":"completed","refs":["test_jax_acceleration.py","docs/technical-documentation.md"]}
3737
{"event":"CI workflow added to run tests on GitHub Actions","status":"completed","refs":[".github/workflows/ci.yml","requirements-test.txt"]}
3838
{"event":"README updated with pytest filters and focused run guidance","status":"completed","refs":["README.md","pytest.ini","conftest.py"]}
39-
{"event":"Added V&V tests: vector energy ~ v_max^2 and trajectory accuracy improves with n_steps","status":"completed","refs":["tests/test_vnv_vector_impulse.py","simulate_vector_impulse.py"]}
39+
{"event":"Added V&V tests: vector energy ~ v_max^2 and trajectory accuracy improves with n_steps","status":"completed","refs":["tests/test_vnv_vector_impulse.py","simulate_vector_impulse.py"]}
40+
{"event":"Laser coherence injection-locking plan draft","status":"completed","refs":["docs/roadmap.ndjson:Rings, Coils, Lasers, Plasma Integration","docs/technical-documentation.md:Coherence Control Plan (draft)"]}
41+
{"event":"CI hygiene: tests-only discovery and optional JAX demo skip","status":"completed","refs":["pytest.ini:testpaths","tests/test_jax_acceleration.py"]}

0 commit comments

Comments
 (0)