feat: design validator, CSV/JSON export, 1/2A6-2 motor preset#3
Merged
rramboer merged 1 commit intoMay 8, 2026
Merged
Conversation
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.
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three quick-win additions, stacked on top of #2 (the hobby-rocket pivot). Base-branch should be set to
feat/hobby-rocket-pivotafter #2 merges tomain, or the PR can be retargeted tomain.1. Pre-launch design validator
validate_design(rocket, sim_config=None) -> list[DesignWarning]runs heuristic checks on a configuredRocketand returns advisories. The CLI runs it automatically (skip with--no-validate) and returns exit code2if anyerror-level warning fires, so it can gate CI or scripts.Implemented checks:
motor_too_bigwill_not_liftlawn_dartlow_twrlow_apogeetransonicballistic_descentdelay_too_shortdelay_too_long2. CSV / JSON export
SimulationResultgains.to_csv(path),.to_dict(), and.to_json(path). CLI flags--csv FILEand--json FILE. Output formats:time_s, altitude_m, velocity_ms, acceleration_ms2, mass_kg, thrust_n, drag_n, phase.{ "rocket_name", "summary": {...}, "states": [...] }— the summary dict mirrors the publicSimulationResultfields.3.
1/2A6-2motor presetThe Mosquito kit was previously documented as using
1/2A6-2, but the motor was missing fromMOTORSso the kit silently fell back toA8-3via a_KIT_MOTOR_FALLBACKStable. The preset is now present and the fallback plumbing is gone. Mosquito kit'smotoris now1/2A6-2for real.Bonus fix
SimulationResult.deployed_below_groundpreviously 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 whatvalidate_design'slawn_dartcheck needs). One-line addition in the landing branch ofsimulation.py.Test plan
pytest— 114 tests pass (was 96; +18 acrosstest_validation.py,test_export.py, and one extra intest_motors.py)ruff check src tests— cleanruff format --check src tests— cleanmypy src— no issuespython -m build— producesrocket_sim-0.1.0.tar.gzand the wheeltwine check dist/*— both passrocket-sim --kit alpha-iii --motor c6-5 --no-plot --csv out.csv --json out.json— runs validation, prints summary, writes both filesmotor_too_bigerror path and exits non-zero