Inspiration
RLC circuits usually get taught twice, as two unrelated subjects: once in a physics class as a differential equation that "rings and settles," and once in a linear algebra class as an abstract system with eigenvalues. I wanted to build something for my Computer Science IA that showed both are literally the same object — that the damping you see in a scope trace and the eigenvalues sitting in a 2×2 matrix are two views of one truth. Circuit Lab is that idea made interactive: move a slider, and watch the physics and the math update in lockstep, in real time.
What it does
Circuit Lab simulates a series R-L-C circuit and lets you flip between two modes:
- DC step response (transient) — flip the switch and watch capacitor voltage and loop current evolve exactly as governed by the circuit's differential equation.
- AC steady state — drive the circuit with a sine wave and watch current and voltage settle into a steady phase relationship, governed by complex impedance instead.
Every trace, eigenvalue, matrix entry, and phasor on the page is computed live from whatever $R$, $L$, $C$, and $f$ you currently have set — nothing is precomputed or looked up from a table. The app includes:
- A live SVG schematic that redraws itself as you move the sliders
- A canvas-rendered oscilloscope showing $v_C(t)$ and $i(t)$
- A phase-plane panel that shows the eigenvalues $\lambda_1, \lambda_2$ in DC mode, or a full rotating phasor diagram ($V, I, V_R, V_L, V_C$) in AC mode
- A live Bode plot of $|Z(f)|$ and $\angle Z(f)$ with a marker tracking resonance
- A system matrix panel showing the literal state matrix $A$ with real numbers plugged in, next to the damping ratio $\zeta$ and quality factor $Q$
- Jarvis, an AI tutor scoped entirely to whatever circuit is currently on screen
How I built it
The simulator itself is a single HTML file — vanilla HTML5, CSS3, and JavaScript, with zero build step, zero framework, and zero bundler. All the math (eigenvalue decomposition for the DC transient, complex impedance for AC steady state) is solved live in the browser on every slider movement, rendered with the Canvas API for the scope/phase-plane/Bode plots and inline SVG for the schematic.
Jarvis is a separate Python/Flask backend that calls Groq's API (openai/gpt-oss-120b) rather than a custom-trained model. What makes it feel like a specialized circuit tutor instead of a generic chatbot is three layers wrapped around that general-purpose LLM:
- A fixed system prompt that scopes it entirely to RLC circuits
- Live context grounding — every message sends Jarvis the exact current circuit state (mode, $R/L/C/f$, regime, eigenvalues, matrix $A$, $Q$) as structured JSON
- A two-layer safety pipeline: input screening blocks prompt injection or off-topic requests before they reach the model, and output validation clamps anything Jarvis proposes to change on the live circuit to physically valid ranges before it ever touches the UI
Replies stream token-by-token, and any LaTeX-ish math Jarvis writes is converted client-side into real symbols and superscript/subscript text, with no external math renderer.
Challenges I ran into
The safety pipeline was the hardest part conceptually: letting an LLM propose changes to a live, stateful interface is risky if you trust it blindly, so I built input screening and output validation that clamps or drops anything malformed before it can push the circuit into an invalid state — a pattern I adapted from a safety layer in a sister project of mine.
Deployment turned into its own unexpected challenge. Since the frontend is a static file but Jarvis needs a real running backend, I had to work through the split carefully: a hardcoded localhost:5001 reference that worked fine on my machine silently broke the AI tutor for anyone else visiting the live site, static hosts like GitHub Pages can't hide API keys at all, and free-tier backend hosting comes with a real cold-start tradeoff I had to design around (and eventually solve with a keep-alive ping) rather than ignore.
Accomplishments that I'm proud of
I'm proud that the core simulator needs zero backend to work at all — opening a single HTML file gives you real, live-computed linear algebra and circuit physics, no server required. I'm also proud of the phasor diagram actually visually reconstructing Kirchhoff's voltage law ($V_R + V_L + V_C$ summing back to $V$) rather than just labeling arrows, and of Jarvis's safety pipeline actually holding up — it can suggest a live demonstration on the circuit without ever being able to corrupt it.
What I learned
Building this deepened my own intuition for how damping ratio and eigenvalues aren't separate facts to memorize — they're the same $\alpha$ vs $\omega_0$ comparison viewed two ways. On the engineering side, I learned a lot about the practical gap between "an LLM that works when I run it locally" and "an LLM feature that works for a stranger on the internet" — environment variables, CORS, and the real tradeoffs of free-tier hosting weren't things I'd had to reason about carefully before.
What's next for Circuit Lab
- Parallel RLC and multi-loop circuit topologies, not just series
- Exportable/shareable circuit configurations via a URL
- Jarvis-generated practice questions and quizzes grounded in the current circuit
- A dedicated always-on backend instead of a free-tier one, so Jarvis responds instantly every time
Log in or sign up for Devpost to join the conversation.