# Phase Angle Fixer — AI / Agent Summary This file helps AI assistants and tools understand the repo quickly (project “DNA”). ## What this repo is - **Single-file web app** (`index.html`): HTML + CSS + JavaScript, no build step, no backend. - **Purpose:** Check and fix three-phase power meter **phase angles** (Va, Ia, Vb, Ib, Vc, Ic). It suggests wiring fixes, phase rotation (ABC vs ACB), CT/PT polarity, meter settings (CT/PT ratio, phase correction), and shows phasor + time-domain plots. - **Users:** People who commission or troubleshoot power meters and need to verify/correct phase angles and phase sequence. ## Tech stack - Vanilla JS (no frameworks). - No package manager; fonts loaded from Google Fonts (DM Sans, JetBrains Mono). - All logic and UI in one file: `index.html`. ## Key concepts in code - **Angle convention:** Angles in degrees; normalized to (−180°, 180°] (NASPI-style). Difference = subtract then wrap. - **Phase sequence:** ABC (positive) = Vb−Va ≈ −120°, Vc−Va ≈ +120°. ACB (negative) = opposite; also “B and C swapped” pattern. - **V–I angle:** φ = I − V (phasor difference). pf = cos(φ). Used for power factor, polarity (≈ ±180° → reversed CT), and unity-PF meter correction. - **Meter setup:** Optional CT ratio, PT ratio, nominal voltage, CT type (standard / Rogowski / residual). Multiplier = (CT ratio) × (PT ratio). These are used in fix suggestions when present. ## File roles | File | Role | |------------|------| | `index.html` | Entire app: inputs, analysis, charts (radial + sinusoidal), fix list, ref notes. | | `README.md` | Human-facing overview, run instructions, references, structure. | | `AGENTS.md` | This file; for AI/agents. | | `.gitignore` | Ignore OS/editor/temp files. | | `LICENSE` | MIT. | ## How to run Open `index.html` in a browser (file:// or any static server). No install. ## Where to change things - **UI copy / labels:** In `index.html`, in the `` card sections and in JS strings (e.g. `suggestion`, `msg`). - **Phase logic:** In `index.html`, inside `analyze()`: `rotationOk`, `near()`, swap detection, voltage balance, CT polarity, unity-PF fixes. - **Meter setup / multiplier:** `getMeterSetup()` and the block that writes `meterMultiplierWrap` and `rctNote`. - **Charts:** `drawRadialChart(norm)` and `drawLineChart(norm)`; both use `CHART_ITEMS` and normalized angles. - **References / links:** In ref notes and formula blocks in `index.html`; also listed in README. ## References the app cites NASPI TR-006, electronics-tutorials.ws phasors, learnabout-electronics phase/phasors, NJIT ECE 449 Lab 3 (phase sequence), EEP (phase sequence CW/CCW), Electrical Ampere (phase angle). All URLs are in the app and in README.