Welcome to your wiki!
This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: [SamplePage].
The wiki uses Markdown syntax.
Welcome to my project of developing an open source circuit simulator specifically for power electronics applications. Being a power electronics researcher, this project was undertaken with the selfish objective of developing a simulator that would meet my needs. My needs essentially were - being able to simulate large systems maybe with several converters, design controls in a manner similar to what you would code on a hardware controller and generate huge amounts of data for analysis. Moreover, since I always use a regular desktop or laptop and not a high end workstation, another huge objective is that the simulator should not cause the computer to hang as I would also need it for other purposes.
I maintain a blog describing the simulator:
To follow the development in detail, please refer to the blog which is written in a fairly verbose manner. These wiki pages will describe the files uploaded onto the project page and their usage.
A brief description about the way files are uploaded onto the project. There will be two folders - current and archive. The folder "current" will contain the latest files (and also a tar.gz and zip file) while the "archive" will contain the older tar.gz and .zip files. To create a version system so that I and others know which version we are using, we will start with a 0.1.0. This follows the MAJOR.MINOR.PATCH pattern. Essentially, I'll be releasing code every time it works, so the third digit will change everytime. A minor work will be when an element is added. A major revision will be when a library is added. I strongly doubt if I will be able to stick with these rules but better to have them anyway.
Version - 0.1.0
This is the first "sort of" working simulator. The elements coded have been - Voltage sources, Resistors and Inductors. Current measurement can be performed with an ammeter.
The way to use the code is as follows:
1. The program to be executed is circuit_solver.py. You would need Python on your computer. This program will ask you for the circuit layout file.
The circuit layout file is a .csv file that contains the topology of the circuit. An example file is testckt3.csv. All the devices will be depicted by their name (e.g. Resistor) followed by an underscore and a name tag. Example: Resistor_R2 or Inductor_L3. Names are case insensitive. However, wrong spellings will cause an error. Also, leaving a space or adding another character will cause an error. So Voltage_Source will be an error as it should be VoltageSource or voltagesource. The connections between devices can be signified by a "wire".
It is an error to have a broken branch. If there is an open circuit, connect a large resistor. Don't leave it open.
You can use jumpers so that connections can criss-cross or if you want one part of the circuit somewhere else. A jump label essentially consists of the word "jump" followed by the label - example: jump1, jump2, jumpa etc. Every jump label must have one and only one other jump label. A jump essentially allows you to jump from one "branch" to another so therefore, a jump can't be next to a node and the jump has to be last element on the branch.
Error signals are generated wherever possible.
If all goes well, the program will tell you to enter the parameters of the circuit in the file with a "_params" appended to the circuit file. So if testck3.csv is the circuit file, testckt3_params.csv will be the parameter file.
The parameter .csv file has the following layout. Every component has a row. The first column is the type of component - Resistor, Inductor, VoltageSource etc. The second column is the name that you have given that component example- R1, L2 etc. The third column is the cell position of the element so that you can check the physical location of the element in the spreadsheet. After that are the parameters. For resistors and indcutors, if there is only one parameter the next column contains the default value. For voltage source, there are a few columns with peak, frequency, phase and also the direction of positive polarity. Again default values are provided after the "=" signs.
You need to change the values, save it and make sure it saves as a .csv file. Also, make sure that all .csv files have a line feed at the end of every row.
If you later to need to add components, the parameters file will retain the parameters of the old components.
The program will run and give the meter readings in separate columns in a .dat file that you agan have to enter. Use gnuplot or any other plotting software to plot them.
A description of the remaining files:
This file contains all the matrix operations. Though I could have used numpy, I still wanted to have my own class definition so that things will be more in control at a later stage.
This file contains the ODE solver which is the Runge Kutta 4th order method. Besdies, there is also a static matrix equation solver. The matrices are reduces to an upper triangular form in the solvers.
This file contains all the component classes - Resistor, Inductor etc. Also, a dictionary is maintained at the end of the file of all the components found in component_list. So if you add another class, add the class name with the name as it will appear in the spreadsheet.
This is a monster of a file that does a number of tasks. From the circuit layout, it generates a list of nodes, a map of branches between nodes, a list of loops containing all the elements. Take a look at the blog for details on how this progressed.
Version 0.1.1 and Version 0.1.2:
Basically, version 0.1.0 had a very serious bug and that was that if the circuit had stiff elements (with very low L/R ratios or time constants), the solver became unstable. Version 0.1.1 was an attempted solution but the solution didn't work for all cases. Version 0.1.2 is a better solution.
Take a look at the blog for details, however the main points are highlighted here:
Using the system ODE matrices A, B and E (of Edx/dt=Ax+Bu) it is determined if there are any loops that are stiff.
The objective is to isolate every stiff branch to a seperate loop and convert that differential equation to static equation. At this point, this conversion has been done without any log reports. However, the aim is to generate a log report that certain events did result in stiff equations and if those are to be solved, a simulation time step of this order would be necessary.
Not only are row operations performed on the ODE matrices, but these row operations are also made to change the loops. Therefore, a completely new set of loops are the end result.
The immediate next step is to avoid these computations unless absolutely necessary. Therefore, the simulation will become "event driven". Computations will be performed only if a change is detected in the network.
Log in to post a comment.