Related: 01_core_philosophy.md | 02_component_protocol.md | 05_execution_model.md
The architecture strictly separates memory management (Provision) from physics initialization (Stage) and temporal evolution (Step). This ensures high performance for Monte Carlo loops by eliminating redundant memory allocation.
Every component behaves identically to the Simulator host:
1. Lifecycle Flow Diagram
┌─────────────────────────────────────────────────────────────────────────────┐
│ APPLICATION START │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ PROVISION (once) │
│ • Allocate memory, state vectors │
│ • Register outputs on Backplane │
│ • Load parameters from config │
│ • Parse static assets (tables, meshes) │
│ • Generate Data Dictionary │
└─────────────────────────────────────────────────────────────────────────────┘
│
┌─────────────────┴─────────────────┐
│ FOR EACH RUN/EPISODE │
▼ │
┌─────────────────────────────────────────────────────────────────────────────┐
│ STAGE (per run) │
│ • Zero state derivatives, set t=0 │
│ • Apply initial conditions from RunConfig │
│ • Wire inputs (resolve signal pointers) │
│ • Run trim/equilibrium solver if needed │
│ • Build execution order (topological sort) │
└─────────────────────────────────────────────────────────────────────────────┘
│
┌─────────────────┴─────────────────┐
│ SIMULATION LOOP │
▼ │
┌─────────────────────────────────────────────────────────────────────────────┐
│ STEP (per Δt) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ PreStep() │ ─► │ Step() │ ─► │ PostStep() │ │
│ │ (optional) │ │ (all comps) │ │ (optional) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ Integrator │ X_new = X + dt * f(X_dot) │
│ └──────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
│ (end of run)
▼
┌─────────────────────────────────────┐
│ Return to STAGE for next run │
│ (Monte Carlo, parameter sweep) │
└─────────────────────────────────────┘
│
│ (application exit)
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ SHUTDOWN │
│ • Flush recording buffers │
│ • Close file handles │
│ • Release resources │
└─────────────────────────────────────────────────────────────────────────────┘
2. Phase I: Provision (Setup)
Goal: Heavy lifting. Allocate memory, compile compute graphs, parse immutable assets (URDFs, Meshes). Frequency: Called once when the application launches.
- Action: Allocate large state vectors and signal buffers.
- Action: Register public outputs in the Backplane.
- Action: Declare parameter structs.
- Action: Load static reference tables (atmosphere, gravity).
3. Phase II: Stage (The Merged Reset/Trim)
Goal: Prepare the mathematical state for $t=0$. This merges "Reset" (hard values) and "Trim" (solved values) into a single pipeline. Frequency: Called at the start of every new episode/run.
The Stage(RunConfig) function acts as a solver pipeline:
- Zeroing: Wipe state derivatives ($