Tuesday, July 16, 2013

Next step

Been a while since I updated this blog. I have been incredibly busy with my day job and so not much progress since the last update. I haven't given up on this project. I'll be back soon once my main project goes into autopilot.

The diode model is not complete yet. There is no special function for the diode to freewheel. So that would be the next step.

I will be giving a lightening talk (5 minutes only) in Pycon Canada to be held in Toronto next month. So if any of you are planning to attend, do send me an email.

Wednesday, June 19, 2013

Version 0.2.1 released

Released the next version of the simulator with diode model:
http://sourceforge.net/projects/pythonpowerelec/

As always, for questions or comments, please send me an email at pythonpowerelectronics@gmail.com

Tuesday, June 18, 2013

Diode model - loops and manipulations

For any circuit, the number of independent loops is Branches-Nodes+1. The loop finder function returns excess loops for all circuits except maybe the simplest circuits. Initially, I had removed the excess loops and assumed they were linear combinations of the previous loops. But when the circuit has a ladder structure, it may so happen that some of the essential loops appear right at the end and get thrown out.

This is what I found when I was trying to figure out why the three-phase diode bridge rectifier was not working. The only way to ensure that essential loops are not deleted is to let all of them be to begin with. With row operations, some loops will be eliminated. As and how loops are eliminated, they should be completely deleted and the system should be reduced.

So, first the loop finder function (click on "View Raw" below the code box to see the code in a new window):



The difference is in the terminating condition:
if loop_iter:
As long as loop_iter is searching, let it search. So let it add as many valid loops as possible.
The number of excess loops can be pretty huge (x6).

Next comes the main circuit_solver.py. In this, another matrix has been conceived called the system_loop_map. This is to indicate which branches are stiff so as to eliminate stiff branches from as many loops as possible. The code for this has been put together in one block (click on "View Raw" below the code box to see the code in a new window):



So essentially, for every loop there is minimal information about every branch in the circuit - if it exists and if it does, is the branch stiff.



So essentially, I use system_loops_map to make the system upper triangular as far as stiff branches are concerned. The next block I am not sure if it is needed. Whether it is necessary to make sure a stiff loop is connected to the input. I'll test it and try to get rid of it. For some reason, it looks like an ugly code block.

The last part of to reduce the size of the system by getting rid of redundant loops (click on "View Raw" below the code box to see the code in a new window):


Diode model - part I

Where do I begin? Massive number of changes. So first, the diode class (clink on "View Raw" below the code box to see the code in a new window):


Similar to many of the others. In the parameter specification, the user needs to enter the voltage level of the diode and the polarity in terms of where the cathode is.

The diode resistance changes with the status whether "ON" or "OFF". The diode is ON when it is forward biased beyond a certain threshold voltage. It turns "OFF" when current becomes negative. The ON resistance, forward bias threshold voltage and the ON drop voltage can be made user defined parameters.

Thursday, May 23, 2013

Testing the circuit solver

Now that a basic control interface is ready, I can begin with the power electronics library. Main focus would be on the diode and IGBT (or simply an ideal switch). With these, the intent would be to start rigorously testing the circuit solver. Something which I put off before because I wanted to get to the power electronics library ASAP.

A basic problem has arisen particularly in the solving of stiff equations. A single phase diode bridge rectifier threw this error up. It it in the way the loops are rewritten whenever a diode turns on and off.

Found out the problem this afternoon and will figure it out tomorrow.

Wednesday, May 22, 2013

Version 0.2.0 released

Releasing version 0.2.0 with controlled voltage source as library element.
http://sourceforge.net/projects/pythonpowerelec/

Just realized while moving version 0.1.5 to the archives that the zip archive was empty. Added another zip file in the archives. In case of doubts, email to pythonpowerelectronics@gmail.com.


Controlled Voltage Source

Think I got a basic code working for a controlled voltage source. To begin with here is the code for the class (click on "view raw" below the code box to see the code in a new window):


The only difference between a normal voltage source is that it has two lists control_tag and control_values. The control tag is the name of the control input and the corresponding index in the other list is its value. These are lists because there can be multiple control inputs to any controllable device.

Next in the main program "circuit_solver.py". The first stage is to get the names of the control codes from the user. Then generate "descriptor" files for each of these control codes. Check if they exist. If they don't create blank templates (check the previous blog entry). This is the code (click on "view raw" below the code box to see it in a new window):


The next step is to take in the descriptor parameters. These will be used to update the dictionaries for the inputs, outputs, staticvariables and time events. Here is the code (click on "view raw" below the code box to see it in a new window):


The next step was a bit tricky. The idea is to write all these different control codes into one main program called __control.py and import this file. Each control code will be written as a function.

So basically, define the function, assign the input to variables, assign the static variables to local variables, assign the time events to local variables. And then finally embed the control code. Then assign the local variables to outputs, reassign local variables to static variables and time events as applicable to take these back to the main program.

Here is the code (click on "view raw" below the code box to see it in a new window):


Anyway, a basic circuit with a controlled voltage source works. So I'll just release this as the next minor version.