This page is divided into a number of segments that deal with different aspects of the simulator such as installing the software, dependencies needed to use the simulator and simulating sample circuits. Use the links below to access the sections.
The most essential software is Python. Python 3 has been released, but I still use Python 2.7. So
would recommend you to install that. How do you get this? If you are a Linux user, Python usually comes installed. If not use your distribution's package manager to get the 2.7 version of Python. If you are a Windows user, check out this page:
At the top of the page are listed the latest stable versions of Python 2.7 and 3. The link will take you to a download page where you need to choose your distribution.
If you would like an Integrated Development Environment (IDE), I would recommend Eric which I use in Linux. The link is
The next software is one for editing spreadsheets as all the inputs from the user are through spreadsheets saved as Comma Separated Value (.csv) files. On Windows, Microsoft Excel will do. On Linux, I use LibreOffice Calc. You can use any software as long as the software allows you to embed each cell within quotes, separate cells within a row with commas and separate lines with newline characters. Read up a little on .csv files if you want to know how to convert a .xls or similar file to .csv.
The next software you need is a plotting software. There are several but I would recommend Gnuplot. If you are a Linux user, use your distribution package to install it as it is standard GNU software. If you are a Windows user, it gets a bit tricky. You need to first install CygWin. You can find that here:
CygWin is an embedded Linux system within Windows. You can go all the way and install all the packages it comes with if you want to play aroundwith it. But if you just want to use it for this software, all you need is Gnuplot. In the package installer, search for Gnuplot and select it. It may happen that even after installing Gnuplot, you can't view plots because that needs Xserver installed. I would recommend that you install any Graphics based software like Xfig. Just search for Xfig in the package installer, and the dependency will be Xserver. Say yes to all the dependencies and you should be done.
The first step is to create a circuit file. As an example I create a circuit file using LibreOffice Calc. This could also be the process if you are using Microsoft Excel. The figure below is a snapshot of the circuit:
The circuit is pretty simple. A voltage source is feeding two resistors. The voltage across the second resistor is measured by a voltmeter and the current supplied by the source is measured by an ammeter. To save the circuit, choose the file to be save as a .csv file. In this case, we shall name the file doc_example.csv. The next snapshot shows a warning that LibreOffice gives when you want to save it as a .csv file. Microsoft Excel gives a similar warning. Just go ahead and save it.
Now the next step after saying yes to saving it as a .csv file is important. It specifies the field delimiter to be a comma and the text delimiter to be a double quote. Make sure this is the case. The field delimiter is how two adjacent cells in a row are separated in the final text file. For the simulator to be able to read the circuit, the field delimiter has to be a comma. Anything else and it will not work. The text delimiter is what encloses a component. This should be a double quote or a single quote. Do not change this to anything else. The simulator will read a component only if it is within quotes.
As for the newline character that separates rows in the .csv file, an option does not appear above. Both LibreOffice and Excel use the standard \n newline character. The simulator interprets both the \n and \r as newline characters. If you are having trouble, check what newline character you are using and try to change it to one of these.
The next step is to run the circuit simulator. Make sure all the files of the simulator are in the same directory as the circuit doc_example.csv file above. The simulator must be able to find the file and currently it will search only in the present working directory. If you are using Linux and want to run the command from the shell command line, run the following command from a terminal in the directory with these files:
If you are using IDLE in Windows, open the file circuit_solver.py and either press F5 or go to Run menu and choose Run Module.
Now the simulator works in interactive mode. The next set of screenshots will show you the different parameters. Using IDLE in Windows but could be using Linux in command line with just the same results.
If this is an empty project and the circuit file above has just been created, the simulator will create a sample circuit_inputs.csv file. This file contains the parameters of the simulation. The sample is shown below:
Some of the fields are self-explanatory. The first row will take the name of the circuit file which in this case is doc_example.csv. However, the simulator populates this field with sample_ckt.csv. The next field is about the time duration of the simulation - for how long do you want the simulation to run? In this case it is 0.1 seconds but the default is 1s. The time entered is always in seconds, so if you want 2 minutes, enter 120s. The next row is the time step of the simulation. In this case it is 10 microseconds. For more complex power electronic circuits, it is recommended to be 1 microsecond or even less. The next row is about the time step for storing data - how often do you want to store data? The next row is about the name of the output file. The default is ckt_output.dat. The next fields will need explanation.
Row 6 in for control files that the simulation needs. You can enter as many control files as you want. Just make sure they are .py files. Each control file should be in a separate column. If you don't have any, delete all of them but leave the first two columns and the row intact.
Row 7 asks if you wish to split the output file. This is for very large simulations which might generate hundreds of MB or even GB of data. When plotting the waveforms, it is incredibly difficult to plot large amounts of data and some plotting software might just hang. So, in that case use this functionality to split the output file into pieces. Row 8 gives the interval of each part of the output. For example, if it is a 1s simulation, you could split it into files of 0.2s duration. The third column in Row 8 is empty, but this value would be 0.2 in that case.
The screenshot shows the actual inputs for this case.
The next screenshot shows how the simulator prints out the number of nodes, branches and loops. Next, it will ask for the parameters of the circuit components.
The simulator creates another spreadsheet by adding _params.csv to the circuit file. This spreadsheet contains the parameters of the circuit. The simulator reads the components in the circuit and automatically assigns default parameters to the components. These default parameters are written into the file doc_example_params.csv and are available for the user to change. You need to open this file and change the parameters according to your need. The default parameters are in the next snapshot:
You can change all the parameters above. The value you need to change is after the equal to (=) sign in any of the fields. What you should not change are the first three columns. The first column is the type of the component. The second is the name of the component. The third is the cell position of the component. Changing these three will cause the simulator to crash. The three columns are for your reference to know which component exists in which location of the circuit.
In the above example, just two parameters are changed to show you how it is done. The polarity of the voltmeter and the voltage source are changed. You need to save and close the file. Not closing the file may cause the simulator to not be able to read the parameter file and abort.
The simulator then tells you in what sequence the meters are plotted in the output file. The output of a meter is always plotted. In this circuit, there are two meters. Therefore, there are two outputs being plotted. In the circuit output data file, the first column is always the simulation time. The remaining columns are meter outputs or control signals. So the second column is the meter at 1A which is the ammeter and the third column is the meter at 4G which is the voltmeter.
To check the results of the simulation, we use Cygwin. Start Cygwin and change directory to the directory that contains the simulation files. Then start the X server with the command startx. After the X server has started, run the command gnuplot to enter the Gnuplot shell. It looks like this:
As said before the first column is the time, the second is the ammeter output and the third is the voltmeter output. So the command:
$plot "ckt_out.dat" u 1:2 w l
Implies plot the file ckt_out.dat using columns 1 and 2 (where column 1 will be x axis and 2 will be y axis) with line. This is the way I generate my plots. Feel free to read the manual on Gnuplot to see more options.
And to check the voltage:
$plot "ckt_out.dat" u 1:3 w l
And to check the current and voltage together:
$plot "ckt_out.dat" u 1:2 w l, '' u 1:3 w l
In the above command, the empty quote means use the same file for the next line. You can specify the file, but this shortcut will do.
The top right of the graph contains the key to the graph. Since the current is hardly visible, we use the handy command:
$plot "ckt_out.dat" u 1:($2*20) w l, '' u 1:3 w l
Since the current has being magnified by a factor of 20, it is possible to check the phase of the current with respect to the voltage.
This was a fairly simple example to get started. More complex circuits will need more parameters. The examples and case studies provided in the Blog section of the website would make these fairly clear. If in doubt, feel free to contact me.
This section describes how a circuit is designed in this software. As said before, the user interface for this software is spreadsheets saved as Comma Separated Value (.csv) files. To repeat a snapshot of the circuit in the previous section:
By designing a circuit the way shown above, I avoid the use of a graphical interface but at the same time make it reasonably convenient for the user as they can more or less "draw" the circuit in a spreadsheet. The other option would be to provide a netlist describing the connectivity between nodes which is not feasible for larger circuits. The following components are available to the user as of now:
More components may be added as needed. Now that all the components that can be used have been listed, how do you use them? A component as shown in the figure above has two parts - the component type (one of those listed above) and the name of the component separated by an underscore. In the above example, in VoltageSource_V1, the first part is the type which is VoltageSource while the second part is the name which is V1. The underscore is a reserved character, do not use it in anywhere in a circuit description. Everywhere else, like in the control functions, you can use underscore as will be shown later, but never use it in the circuit schematic. The only rule in naming components is that two components of the same type cannot have the same name. Which means there cannot be two VoltageSource components with the name V1. In the above example, VoltageSource and Voltmeter have names V1. That is acceptable. Different component types can have the same name.
Though it is not a component, there is a jump connector. The reason is that sometimes wires will cross each other and it is unavoidable. The way the simulator works, if it sees two or more components in adjacent cells, it forms a physical connection. The way to use a jump connection is shown with this circuit.
The above circuit of a single-phase diode bridge rectifier fed by a voltage source cannot be designed without a jumper. The labels jump1 at cell positions 16E and 11K are jump connections. When the simulator encounters a jump connection, it looks for another jump connection with the same name and continues the branch from that connection. There are a few rules for using jump connections: