https://github.com/abdulrhman-dev/circuit-simulator
A simple circuit solver that solves DC circuits that contain independent sources and resistors.
https://github.com/abdulrhman-dev/circuit-simulator
circuit-simulator circuit-solver circuits cpp dc graphics mna raylib
Last synced: 10 months ago
JSON representation
A simple circuit solver that solves DC circuits that contain independent sources and resistors.
- Host: GitHub
- URL: https://github.com/abdulrhman-dev/circuit-simulator
- Owner: abdulrhman-dev
- Created: 2024-11-08T06:38:39.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-09T16:22:40.000Z (about 1 year ago)
- Last Synced: 2025-01-24T12:46:08.536Z (12 months ago)
- Topics: circuit-simulator, circuit-solver, circuits, cpp, dc, graphics, mna, raylib
- Language: C++
- Homepage:
- Size: 3.62 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Circuit Simulator

A circuit simulator that provides an intuitive platform for designing, modifying, and solving simple DC circuits.
## Features
- ✅ **Interactive Circuit Design:** Create circuit elements like resistors, voltage sources, current sources, wires, and ground on a user-friendly grid interface.
- ✅ **Efficient Value Input:** Update circuit element values directly with support for metric prefixes (e.g., k, M, µ) for precision.
- ✅ **Seamless Input Navigation:** Quickly switch between circuit elements to modify values.
- ✅ **Multiple Circuits:** Design and solve multiple circuits simultaneously within a single canvas.
- ✅ **Easy Circuit Solving:** Solve the circuit and hover over nodes and elements to view detailed information like voltage and current values.
- ✅ **Error Detection:** Automatically identifies and alerts you to invalid circuit configurations.
- ✅ **Camera Control and Zoom:** Adjust the view and zoom level to easily navigate and manage large circuits.
- ✅ **Undo/Redo Actions:** Effortlessly correct mistakes with undo functionality.
## User Guide
### 1. Creating a Circuit Element
- **Start Drawing**: Click on any grid intersection to begin creating a circuit element. The element will extend from the clicked intersection to the mouse cursor position.
- **Cancel Creation**: Right-click or press `Ctrl + Z` to cancel the creation.
- **Complete Element**: Click on another grid intersection to finalize the circuit element.
- **Switch Elements**: Press the first character of a circuit element to switch to its drawing mode:
- `R`: Resistor
- `V`: Voltage Source
- `C`: Current Source
- `W`: Wire
- `G`: Ground
---
### 2. Modifying Circuit Element Values
- **Single Element Input**:
- Left-click on the element to enter input mode.
- Type the desired value and press `Enter` (metrix prefixes can be added at the end).
- Supported metric prefixes include:
- `p`: $`10^{-12}`$
- `n`: $`10^{-9}`$
- `µ`: $`10^{-6}`$ (write `u` instead of µ)
- `m`: $`10^{-3}`$
- `k`: $`10^3`$
- `M`: $`10^6`$
- `G`: $`10^9`$
- **Multiple Elements Input**:
- Press `Tab` to navigate to the next element.
- Press `Shift + Tab` to navigate to the previous element.
- Input mode exits when:
- `Enter` is pressed.
- `Shift + Tab` is pressed on the first element.
- `Tab` is pressed on the last element.
---
### 3. Solving the Circuit
- **Solve Command**: Press `Ctrl + Enter` to solve the circuit (multiple circuits can be solved in one canvas).
- **View Results**:
- Hover over nodes to see nodal voltages.
- Hover over elements to view voltage differences and currents.
- **Error Handling**: Invalid circuits will display an error message.
---
### 4. Extra Features
- **Camera Controls**:
- Move the view: Hold `Right Click` and drag the mouse.
- Zoom in/out: Use the mouse wheel or press `Ctrl + =` / `Ctrl + -`.
- **Undo Actions**: Press `Ctrl + Z` to undo the last action.
---
### 5. Shortcuts Summary
| **Action** | **Shortcut** |
|-------------------------------|------------------------|
| Draw Resistor | `R` |
| Draw Voltage Source | `V` |
| Draw Current Source | `C` |
| Draw Wire | `W` |
| Draw Ground | `G` |
| Cancel Element Creation | `Right Click` |
| Enter Input Mode | `Left Click on Element` |
| Enter Input Mode for First Element | `Tab` |
| Navigate to Next Element | `Tab` |
| Navigate to Previous Element | `Shift + Tab` |
| Solve Circuit | `Ctrl + Enter` |
| Move Camera | `Right Click + Drag` |
| Zoom In/Out | `Mouse Wheel` / `Ctrl + =` / `Ctrl + -` |
| Undo Last Action | `Ctrl + Z` |
---
## Project Setup
### Steps
**1. Install Raylib on your system:**
One of the easiest ways to install Raylib is using `vcpkg`
Follow this video for instructions: [here](https://youtu.be/UiZGTIYld1M?si=jz9CSbnuvEvrdDks)
**2. Clone the repository:**

**3. You’re done!:**
Run the project via `Ctrl + F5`.