This project is part of a series of "mini-projects" within the ELEC2300 module at the University of Southampton. The original objective was to create a command-line RC circuit simulator in C++ using object-oriented programming (OOP) principles. However, I got a little carried away and expanded it into a more general circuit simulator capable of performing DC nodal analysis and transient analysis of basic RC, RL and RLC circuits.
The simulator is built on a modular architecture, allowing for easy addition of new component types and analysis methods. The user interface is designed to be intuitive and efficient, providing a good balance between functionality and usability.
Circuits are described using netlist-style text files, which the simulator parses to construct the circuit from individual component objects. From there, the user can select an analysis through an interactive command-line interface. ANSI escape codes are used throughout the CLI to provide colour, formatting and clearer feedback without requiring a graphical interface.
The transient-analysis system automatically identifies supported RC, RL and RLC circuits and selects the appropriate numerical solver. First-order circuits are solved using a first-order ODE solver, while RLC circuits use a second-order solver to handle the coupled capacitor-voltage and inductor-current states. The calculated response is then displayed using a terminal-based plotting system.
I also implemented a simple bang-bang controller as an extension to the RC simulation. This creates a feedback loop in which the simulated supply switches between its minimum and maximum output depending on whether the capacitor voltage is above or below a chosen target.
I deliberately designed the project around separate, reusable C++ classes rather than building all of the functionality directly into the CLI. Components, circuits, netlist parsing, numerical solvers, plotting, analysis and control are kept separate, making the project easier to maintain and providing a foundation for supporting more complex circuits and analysis methods in the future.