Physics-First Instrument Architecture

Why this simulator is structured like a laboratory instrument (not a toy)

Most simulators start with UI and “make the math fit”. This project intentionally does the opposite: we treat the solver as the instrument, and the interface as a thin control surface.

Design Philosophy

Physics first. Rendering second. UI last.

Strict architectural direction:

state → core → physics → metrics → panels → rendering → ui → main

No circular imports.
No hidden coupling.
No solver logic inside UI.

Architecture Flow Diagram

state mutable runtime parameters core τ, R_total, period, duty physics analytic RL / RLC kernels metrics P, Q, S, energy, validation panels formatted measurement output rendering scope · field · helix ui → main event binding + orchestration

Rule: Dependencies may only flow downward. Upstream layers must never import downstream layers.

What “Physics First” means (in practice)

The One-Way Dependency Rule

Every layer is allowed to depend only on layers to its left. Nothing “downstream” may be imported “upstream”. This prevents circular imports and prevents accidental feedback loops.

LayerResponsibilityMay depend on
stateMutable runtime parameters (inputs)
corePure helpers (τ, Rtotal, periods, duty)state
physicsClosed-form kernels (RL/RLC waveforms)state, core
metricsMeasurement math (P/Q/S, energy per period, validation)state, core, physics
panelsFormatting + presentation synthesis (numbers → UI)metrics
renderingCanvas drawing (scope, field, helix)physics (via wave builder), panels (readouts)
uiEvent binding (sliders, toggles, focus mode)state (write), rendering hooks (callbacks only)
mainOrchestration + lifecycle (init + loop)everything (as a coordinator)

Why “No Solver Logic in UI” is critical

If solver logic lives in UI code, then:

Instead, UI is restricted to two safe actions:

Rendering is not allowed to influence results

Rendering is downstream. It consumes already-computed waves/metrics and draws them.

This is why the simulator stays defensible: even if you export a PNG, pause the view, or drop to 15 FPS, the computed values are unchanged — only the presentation changes.

“No Hidden Coupling” (what we actively avoid)

Hidden coupling is when two parts of the app affect each other without an explicit interface. Examples we avoid:

Instead, data flows in one direction: inputs → state → physics/metrics → panels/render → pixels.

Why this matters for a reference-grade tool

A short “instrument contract”

The math must remain correct if the UI is deleted.
The UI must remain functional if the renderer is replaced.
Rendering must never change physics.

Where to go next