Skip to content

feat: add Kirchhoff's Circuit Laws simulation - #389

Merged
mattqdev merged 2 commits into
physicshub:mainfrom
niyexdroid:feat/kirchhoff-circuit-laws
Sep 26, 2026
Merged

mattqdev merged 2 commits into
physicshub:mainfrom
niyexdroid:feat/kirchhoff-circuit-laws

Conversation

@niyexdroid

@niyexdroid niyexdroid commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

📘 Pull Request Template – PhysicsHub

🔍 Description

Adds a new Kirchhoff's Circuit Laws simulation built on the engine.

Build and solve DC circuits: single loop, series, parallel and a two-loop network with two cells. Charge flow is animated, a voltmeter and an ammeter can be dragged onto the circuit, and the readout shows Kirchhoff's current and voltage laws balancing to zero in real time.

Files:

  • simulations/KirchhoffCircuit.jsx — the simulation
  • app/(core)/data/configs/KirchhoffCircuit.js — inputs and sim-info readout
  • app/(core)/data/chapters.js — catalogue entry (upperSecondary, also lowerSecondary, extended)
  • app/(core)/data/simulationOverviews.js — page overview
  • app/(core)/data/articles/kirchhoffs-circuit-laws-explained.js + articles/index.js — companion article
  • public/thumbnails/kirchhoff-circuit.webp — catalogue thumbnail
  • routes.js, public/sitemap.xml — regenerated for the two new pages

✅ Checklist

  • Verified that the project builds and runs locally (npm run dev)
  • Ensured no ESLint or TypeScript warnings/errors remain (eslint + prettier --check pass on the changed files)
  • Updated documentation, comments, or in-code explanations where needed
  • Verified responsiveness across devices (desktop 1280, tablet 768, mobile 375 — no horizontal overflow)
  • Followed the CONTRIBUTING.md guidelines

🎨 Visual Changes (if UI-related)

Clip of the simulation to follow in a comment.


📂 Type of Change

  • ✨ New feature (non-breaking change that adds functionality)

🧩 Additional Notes for Reviewers

No engine changes — the simulation only uses the existing createSimulation API.

Tested in a headless browser against next dev:

  • All four circuits: readouts match hand calculation (series 0.889 A, parallel 6.545 A, single loop 2.667 A, two-loop node A 6.49 V), every KCL/KVL row balances, power delivered = power dissipated.
  • Changing R₁ live re-solves the network (two-loop node A 6.49 V → 5.22 V at R₁ = 10 Ω).
  • Dragging the voltmeter probe snaps it to the nearest node and updates the reading.
  • No new console errors. The <circle> attribute cx: Expected length, "undefined" error also appears on untouched pages (e.g. /simulations/SimplePendulum), so it predates this PR.

🤖 Generated with Claude Code

Interactive DC circuit simulation (single loop, series, parallel, two-loop network) with draggable voltmeter and ammeter, plus its config, catalogue entry, overview, companion article, thumbnail and regenerated sitemap/routes.
@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown

@niyexdroid is attempting to deploy a commit to the PhysicsHub's projects Team on Vercel.

A member of the Team first needs to authorize it.

@mattqdev

Copy link
Copy Markdown
Collaborator

hey @niyexdroid thank you for this simulation! Can you please send a video that shows how that works? Like a video demo where you try the sim

thank you!

@mattqdev

Copy link
Copy Markdown
Collaborator

@niyexdroid hey are you still working at this?

@niyexdroid

Copy link
Copy Markdown
Contributor Author

@niyexdroid hey are you still working at this?

Sorry, just the video left to do, i haven't been close to my pc. i will do it tomorrow by 2pm GWT

@mattqdev

Copy link
Copy Markdown
Collaborator

alright no problem

@niyexdroid

Copy link
Copy Markdown
Contributor Author

sorry it took this long i was trying to add a text to the video. The video is 18.3 MB, it too long to add here, so i did a google drive link:
https://drive.google.com/file/d/1sizKSplm8DILSQq24hk9frJih6rdWHBH/view?usp=sharing

@niyexdroid

Copy link
Copy Markdown
Contributor Author

alright no problem

Its done now you can check my previous comment and the video link is there

@mattqdev

Copy link
Copy Markdown
Collaborator

Thank you so much for this simulation (and the video)!
If you want to publish it somewhere or share it somewhere would be awesome!
Hope to see you again in contributions here!

@mattqdev
mattqdev merged commit 5b1f2d3 into physicshub:main Sep 26, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants