Skip to content

feat: design validator, CSV/JSON export, 1/2A6-2 motor preset#3

Merged
rramboer merged 1 commit into
feat/hobby-rocket-pivotfrom
feat/quickwins-csv-validate-motor
May 8, 2026
Merged

feat: design validator, CSV/JSON export, 1/2A6-2 motor preset#3
rramboer merged 1 commit into
feat/hobby-rocket-pivotfrom
feat/quickwins-csv-validate-motor

Conversation

@rramboer

@rramboer rramboer commented May 8, 2026

Copy link
Copy Markdown
Owner

Summary

Three quick-win additions, stacked on top of #2 (the hobby-rocket pivot). Base-branch should be set to feat/hobby-rocket-pivot after #2 merges to main, or the PR can be retargeted to main.

1. Pre-launch design validator

validate_design(rocket, sim_config=None) -> list[DesignWarning] runs heuristic checks on a configured Rocket and returns advisories. The CLI runs it automatically (skip with --no-validate) and returns exit code 2 if any error-level warning fires, so it can gate CI or scripts.

Implemented checks:

Code Severity Trigger
motor_too_big error Motor diameter exceeds airframe diameter
will_not_lift error Peak thrust-to-weight ratio < 1 (rocket can't lift off)
lawn_dart error Ground impact before recovery deploys
low_twr warning Peak TWR between 1 and 5 (marginal launch-rod departure)
low_apogee warning Predicted apogee < 30 m (underpowered)
transonic warning Predicted max velocity > 343 m/s (airframe stress)
ballistic_descent warning No recovery system configured
delay_too_short info Ejection fires more than 2 s before apogee (chute may shred)
delay_too_long info Ejection fires more than 2 s after apogee (rocket descends hard)

2. CSV / JSON export

SimulationResult gains .to_csv(path), .to_dict(), and .to_json(path). CLI flags --csv FILE and --json FILE. Output formats:

  • CSV: one row per simulation step, columns time_s, altitude_m, velocity_ms, acceleration_ms2, mass_kg, thrust_n, drag_n, phase.
  • JSON: { "rocket_name", "summary": {...}, "states": [...] } — the summary dict mirrors the public SimulationResult fields.

3. 1/2A6-2 motor preset

The Mosquito kit was previously documented as using 1/2A6-2, but the motor was missing from MOTORS so the kit silently fell back to A8-3 via a _KIT_MOTOR_FALLBACKS table. The preset is now present and the fallback plumbing is gone. Mosquito kit's motor is now 1/2A6-2 for real.

Bonus fix

SimulationResult.deployed_below_ground previously only fired when the ejection charge tried to deploy below ground level. It now also fires when the rocket lands before recovery ever deploys (which is what validate_design's lawn_dart check needs). One-line addition in the landing branch of simulation.py.

Test plan

  • pytest — 114 tests pass (was 96; +18 across test_validation.py, test_export.py, and one extra in test_motors.py)
  • ruff check src tests — clean
  • ruff format --check src tests — clean
  • mypy src — no issues
  • python -m build — produces rocket_sim-0.1.0.tar.gz and the wheel
  • twine check dist/* — both pass
  • CLI smoke: rocket-sim --kit alpha-iii --motor c6-5 --no-plot --csv out.csv --json out.json — runs validation, prints summary, writes both files
  • CLI smoke: a custom rocket with motor diameter > airframe diameter triggers the motor_too_big error path and exits non-zero
  • CI green on this PR

Three small but high-value additions, stacking on the hobby-rocket pivot
(PR #2):

1. Pre-launch design validator (validate_design, DesignWarning,
   format_warnings). Heuristic checks for marginal thrust-to-weight,
   underpowered configurations, transonic flight without reinforced
   airframe, motor too big for the airframe, ballistic descent, and
   "lawn dart" timing. Wired into the CLI by default; --no-validate
   disables it. CLI returns exit code 2 if any error-level warning fires
   so it's usable in CI / scripts.

2. CSV and JSON export on SimulationResult (.to_csv, .to_dict, .to_json).
   CLI flags --csv FILE / --json FILE. Unlocks downstream notebook /
   spreadsheet workflows without forcing users to reach into the states
   list themselves.

3. 1/2A6-2 motor preset added to MOTORS, with the Mosquito kit now
   pointing at it directly. Removes the previous silent fallback that
   substituted A8-3 when 1/2A6-2 was requested — that fallback is gone,
   along with the _resolve_motor / _KIT_MOTOR_FALLBACKS plumbing.

Also fixes a missed case in the simulator: the lawn-dart flag
(SimulationResult.deployed_below_ground) was only set when the recovery
charge fired below ground, not when the rocket landed before recovery
ever deployed. Now set in both cases.

Tests: +18 (114 total). All ruff + mypy + pytest + build + twine clean.
README and CHANGELOG updated with new flags, exports, and motor row.
@rramboer rramboer merged commit b383d3c into feat/hobby-rocket-pivot May 8, 2026
@rramboer

rramboer commented May 8, 2026

Copy link
Copy Markdown
Owner Author

Closing in favor of folding these commits into #2 — solo-project, no need for a stacked PR. The validator + CSV/JSON + 1/2A6-2 commit (b383d3c) is now part of #2 alongside the pivot commit.

@rramboer rramboer deleted the feat/quickwins-csv-validate-motor branch May 8, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant