# MEMORY

This file is the durable handoff for AI agents working in this repository. Keep it short, factual, and current. If it ever drifts from the source docs or code, update this file to match the real source of truth.

## File Roles

- `MEMORY.md` stores durable project context: guardrails, sourced facts, assumptions, decisions, code status, and verification notes.
- `TODO.md` stores the active execution queue and the current critical path.
- `CHANGELOG.md` stores dated repository-level change history.
- Do not turn `TODO.md` into a second memory file, `MEMORY.md` into a running checklist, or `CHANGELOG.md` into a design document.

## Guardrails

- Treat `/docs` and direct instructor clarifications as authoritative for assignment requirements and parameter values.
- Do not invent missile or target thrust, mass, drag, or geometry tables. Transcribe them from the source packet and note what was extracted.
- Preserve SI units unless a document explicitly states otherwise.
- Keep [`code/Interceptor_3DOF.m`](./code/Interceptor_3DOF.m) as the primary entry point unless there is an intentional repo-wide refactor.
- When implementing the atmosphere helper, include the stratosphere branch for altitude `> 11 km`.
- Do not describe the model as runnable until all `XX` placeholders are replaced and `getRho.m` exists.
- Record every meaningful assumption, extracted constant, unresolved issue, and verification result here.
- Keep `TODO.md` aligned with the current critical path, but keep durable context and decisions in this file.
- Keep dated repo history in `CHANGELOG.md`, not in this file.
- Use exact dates in status notes.
- Do not store secrets, tokens, or personal data in this file.

## Current Snapshot

- Date: `2026-03-28`
- Project: MATLAB 3DOF interceptor-versus-target engagement assignment for AERO 3220 Spring 2026.
- Source docs reviewed:
  - `docs/AERO 3220 3DOF Information Spring 26.pdf`
  - `docs/Atmosphere Model SI Units.pdf`
  - `docs/Addendum to Atomosphere Model Feb 26.pdf`
  - `docs/Missile and Target Data for 3DOF Spring 26.pdf`
- Instructor clarification documented on `2026-03-28`:
  - The atmosphere model must be written and integrated into the simulation.
  - The atmosphere implementation must include the stratosphere model for altitude `> 11 km`.
  - The code will not run until the missing `XX` values are replaced with real numbers.
- Stratosphere model confirmed from `docs/Addendum to Atomosphere Model Feb 26.pdf`:
  - For `z > 11000 m`, use `T = T0 + lapserate*(11000 - z0)`, so temperature is constant above `11 km`.
  - Compute `P11k = P0*(T/T0)^(-g/(lapserate*R))`.
  - Compute `P = P11k*exp(-g*(z - 11000)/(R*T))`.
  - Then compute `rho = P/(R*T)` and `acousticSpeed = sqrt(gamma*R*T)`.
- Active implementation assumptions:
  - `Maz = 0 deg` is currently assumed in `code/Interceptor_3DOF.m` to preserve the coplanar `y = 0` engagement geometry until a source document says otherwise.
  - The target and missile thrust, mass, and drag arrays were manually transcribed from the image-based plots in `docs/Missile and Target Data for 3DOF Spring 26.pdf` on `2026-03-28`.
- Assignment baseline confirmed from the handout:
  - Velocity pursuit guidance gain = `0.5`
  - Blind range = `2 m`
  - Acquisition range = `5000 m`
  - Lateral acceleration limit = `40 g`
  - Velocity-pursuit guidance start delay = `0.5 s` after missile launch
  - Terminal proportional-navigation gain = `4`
  - Commit time = `50 s`
  - Missile initial elevation angle = `40 deg`
- Required plots confirmed:
  - Target/missile vertical-plane trajectories
  - Target speed versus time
  - Missile speed versus time
  - Missile Mach number versus time
  - Missile acceleration magnitude versus time since missile launch

## Code Status

- [`code/Interceptor_3DOF.m`](./code/Interceptor_3DOF.m) drives the integration loop, plotting, and CSV export.
- [`code/getRho.m`](./code/getRho.m) now exists and implements both the lower-atmosphere model and the addendum-defined stratosphere branch for `z > 11 km`.
- [`code/Interceptor_3DOF.m`](./code/Interceptor_3DOF.m) and [`code/getGuidance.m`](./code/getGuidance.m) now contain the known scalar assignment constants.
- [`code/T3dxdt.m`](./code/T3dxdt.m) and [`code/M3dxdt.m`](./code/M3dxdt.m) now contain manually transcribed target/missile reference areas, thrust curves, mass curves, and drag tables.
- [`code/getGuidance.m`](./code/getGuidance.m) now normalizes input shapes to column vectors so `M3dxdt` can call it without row/column mismatch failures.
- Octave now evaluates `getRho.m`, `T3dxdt.m`, and `M3dxdt.m` successfully, and the full script begins integrating without placeholder errors.
- End-to-end validation is still incomplete because the current nested `ode45` loop runs very slowly in Octave and was not observed through final plot/CSV generation within the available runtime.
- [`code/getMD.m`](./code/getMD.m) exists and computes miss distance at the point of closest approach.

## Next Actions

1. Complete an end-to-end Octave validation run and confirm that the required plots and CSV files are produced.
2. Investigate the runtime cost of the nested `ode45` loop in [`code/Interceptor_3DOF.m`](./code/Interceptor_3DOF.m) if full validation remains too slow.
3. Confirm whether the temporary `Maz = 0 deg` assumption should remain.
4. Decide whether the manually transcribed target/missile curves need a second pass for tighter fidelity.

## Update Protocol For Agents

After any meaningful change, update:

- `Current Snapshot` if assumptions, sourced values, or operating context changed.
- `Code Status` if files were added, edited, or made runnable.
- `Next Actions` only if the durable sequencing changed in a meaningful way.
- `TODO.md` if the active work queue or current critical path changed.
- `CHANGELOG.md` with a short dated note for repo-level changes.
