|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +# Install dependencies |
| 9 | +make install |
| 10 | + |
| 11 | +# Run tests |
| 12 | +make pytest # standard test suite |
| 13 | +make pytest-slow # slow/marked tests with verbose output |
| 14 | +make coverage # tests with coverage |
| 15 | + |
| 16 | +# Lint and format |
| 17 | +make format # ruff format + isort |
| 18 | +make lint # ruff + pylint |
| 19 | +make ruff-lint # ruff only |
| 20 | +make pylint # pylint only |
| 21 | + |
| 22 | +# Docs |
| 23 | +make build-docs |
| 24 | +``` |
| 25 | + |
| 26 | +**Run a single test file:** |
| 27 | +```bash |
| 28 | +pytest tests/unit/test_environment.py -v |
| 29 | +``` |
| 30 | + |
| 31 | +**Run a single test by name:** |
| 32 | +```bash |
| 33 | +pytest tests/unit/test_environment.py::test_methodname_expectedbehaviour -v |
| 34 | +``` |
| 35 | + |
| 36 | +## Architecture |
| 37 | + |
| 38 | +RocketPy simulates 6-DOF rocket trajectories. The core workflow is linear: |
| 39 | + |
| 40 | +``` |
| 41 | +Environment → Motor → Rocket → Flight |
| 42 | +``` |
| 43 | + |
| 44 | +**`rocketpy/environment/`** — Atmospheric models, weather data fetching (NOAA, Wyoming soundings, GFS forecasts). The `Environment` class (~116KB) is the entry point for atmospheric conditions. |
| 45 | + |
| 46 | +**`rocketpy/motors/`** — `Motor` is the base class. `SolidMotor`, `HybridMotor`, and `LiquidMotor` extend it. `Tank`, `TankGeometry`, and `Fluid` support liquid/hybrid propellant modeling. |
| 47 | + |
| 48 | +**`rocketpy/rocket/`** — `Rocket` aggregates a motor and aerodynamic surfaces. `aero_surface/` contains fins, nose cone, and tail implementations. `Parachute` uses trigger functions for deployment. |
| 49 | + |
| 50 | +**`rocketpy/simulation/`** — `Flight` (~162KB) is the simulation engine, integrating equations of motion with scipy's LSODA solver. `MonteCarlo` orchestrates many `Flight` runs for dispersion analysis. |
| 51 | + |
| 52 | +**`rocketpy/stochastic/`** — Wraps any component (Environment, Rocket, Motor, Flight) with uncertainty distributions for Monte Carlo input generation. |
| 53 | + |
| 54 | +**`rocketpy/mathutils/`** — `Function` class wraps callable data (arrays, lambdas, files) with interpolation and mathematical operations. Heavily used throughout for aerodynamic curves, thrust profiles, etc. |
| 55 | + |
| 56 | +**`rocketpy/plots/` and `rocketpy/prints/`** — Visualization and text output, each mirroring the module structure of the core classes. |
| 57 | + |
| 58 | +**`rocketpy/sensors/`** — Simulated sensors (accelerometer, gyroscope, barometer, GNSS) that can be attached to a `Rocket`. |
| 59 | + |
| 60 | +**`rocketpy/sensitivity/`** — Global sensitivity analysis via `SensitivityModel`. |
| 61 | + |
| 62 | +## Coding Standards |
| 63 | + |
| 64 | +- **Docstrings:** NumPy style with `Parameters`, `Returns`, and `Examples` sections. Always include units for physical quantities (e.g., "in meters", "in radians"). |
| 65 | +- **No type hints in function signatures** — put types in the docstring `Parameters` section instead. |
| 66 | +- **SI units by default** throughout the codebase (meters, kilograms, seconds, radians). |
| 67 | +- **No magic numbers** — name constants with `UPPER_SNAKE_CASE` and comment their physical meaning. |
| 68 | +- **Performance:** Use vectorized numpy operations. Cache expensive computations with `cached_property`. |
| 69 | +- **Test names:** `test_methodname_expectedbehaviour` pattern. Use `pytest.approx` for float comparisons. |
| 70 | +- **Tests follow AAA** (Arrange, Act, Assert) with fixtures from `tests/fixtures/`. |
| 71 | +- **Backward compatibility:** Use deprecation warnings before removing public API features; document changes in CHANGELOG. |
0 commit comments