Saturday, May 26, 2018

YouTube playlists and lecture series on using the simulator

I reorganized my YouTube channel into playlists:

So now there is a playlist for every topic rather than just a collection of videos. I am trying to break the videos up into pieces as it is easier to record them and also upload them on YouTube. A playlist ensures everything is in order inside a topic.

Recording videos has been a learning experience. I am gradually getting the hang of using recording and editing software. I use Kazam in Linux to record the screen while programming or going through slides. I use Kdenlive to edit the videos. Initially the videos needed only a clipping of the last extra seconds. Now I need to boost up the volume as I find the volume is quite low. Also as simulations will get longer, it will be needed to pause the video often and that means cut out parts that are just pauses.

The first major lecture series is one on how to use the circuit simulator web app version. How to install the circuit simulator is a separate playlist:

This playlist contains videos on how to install Python Power Electronics in Windows and Linux.

The lecture series on how to use the simulator should be watched after you have installed a version of the circuit simulator on your system.

The circuit chosen is a single-phase diode bridge rectifier with a dc capacitor at the output. The load consists of a constant resistor load and a switched resistor load. The first part of the lecture series describes the simulator without using any control functions. The latter part of the simulator describes how to write control functions. The main emphasis here is on the special variables that can be defined with control functions and how they are to be used.

As time goes on more detailed simulation results will be described in the videos. For now the above tutorial is to get you started with Python Power Electronics so that you can use it for your own projects. The video lecture references two short papers that are available on my website:

And of course for details on the simulator and how control functions are processed or the user interface is handled, check out my book:

The book contains entire chapters on user interface, control functions and an entire example on how to simulate a reactive power compensator for a three-phase distribution system.

Making videos is fun and I will continue making them. I feel that videos engage people much more than documents or even slide shows. Stay tuned for more videos on the YouTube channel:

For continuous news and updates, follow my Facebook page:

Wednesday, May 2, 2018

Releasing the command line version compatible with Python 3

So finally I started with migration to Python 3. Find the download link:

It wasn't too tough a migration. Mainly the print statement have become functions. So a lot of editing of these statements. Another change which I can't quite understand the necessity of was that raw_input function to get inputs from the user has been removed and an input function is available instead. A more subtle change and this is something which can cause errors to crop up much later is the nature of division.

In Python 2, dividing an integer by an integer yields an integer. So 5/2 will produce 2. In most languages it is the same. To produce exact division, you would have to write 5/2.0 or 5/(2*1.0) etc. Basically one of the operands must be a float. But in Python 3, 5/2 will produce 2.5. To produce an integer result, this would have to be an integer division 5//2.

I many of my loops I use integer division to iterate up to the mid-point of an array. I changed in a couple of places the regular division to integer division or else the for-loop throws an error because the index cannot be a float. But errors are expected later as there a number of such for loops which act on special conditions and it would take a vast number of different circuits before all these loops are discovered and changed.

The next step is to migrate the Django based web app to Python 3. Until then feel free to download and check out the CLI above with Python 3 with your circuits. And please do report errors so that I can fix bugs.

Friday, April 20, 2018

Virtual environments and HOW-TO videos

The first major issue that most people have with a new software is being able to install and execute it. To make this process easier, I make two video lectures on how to install Python Power Electronics in Windows and Linux. I am a Linux user but a vast majority of engineers will be Windows users.

In Windows, I used Anaconda Python which is an entire Python ecosystem. You can download and install it for free on your computer. After which you can create an environment. The advantage of creating an environment is to be able to create a separate isolated container for a particular application. This is particularly when you use your computer for work or study with a different version of Python and do not want an experimental software from messing up your work system. Inside this environment install Django and MatPlotLib which are dependencies for Python Power Electronics besides  Python. The entire video is here:

In Linux, I use virtualenv to create a similar Python virtual environment. Inside this environment, I use pip to install Django and MatPlotLib. The entire video can be found here:

Now that these lectures describe how to install Python Power Electronics in Windows and Linux, the next part will be on how to simulate a circuit with it. There are three aspects to this. First is the basic circuit simulation. How would you simulate a circuit without any control. Just the circuit, the parameters of the components and how to run it and check the results. This video describes that:

The next video will describe how to detect and fix bugs in a simulation. There are a few common mistakes that are made quite often and can be fixed fairly easily. The more complex errors are those that occur due to control problems and these are a bit tough to decode. Control problems will be deferred to a later video lecture along with describing how control can be included in a simulation.

Friday, April 13, 2018

The road ahead in 2018

There has been a lot of changes this year and also the past year. Moved to Germany last year in May 2017 and came back in March 2018. Now that I have published a book with Springer, I would like to keep publishing and would not like my first book to be my last. And with this, I need to set some goals particularly for this year.

To begin with, I plan to create video lectures on my YouTube channel fairly regularly. The link to the channel is:

Feel free to subscribe and check out what will be uploaded there. I find that creating a video lecture helps to put together my thoughts for more elaborate reports and tutorials.

My plan is to create mini books in different topics in power electronics, bringing together similar topics or breaking a large topic into smaller sub-topics. Each book will be introduced with a series of video lectures and accompanied by a simulation package. I am planning the first mini-book on simulating many of the known topologies of dc-dc converters.

The theme of these books will be description from fundamental concepts with the minimal amount of mathematical analysis. The reason for doing so is to make power electronics learning accessible to working people who have limited time and energy after their day jobs.

And of course, if you would like to read all about the circuit simulator, feel free to check out my book on circuit simulation:

Most of the updates to the project will be on my Facebook page:

So feel free to like and follow the page for regular updates.

Sunday, January 28, 2018

Book published with Springer International

I am happy to make a couple of announcements. The first is that my book on the circuit simulator has been published with Springer International and can be found on their website:

The second is that I have launched a video lecture series on power electronics with my circuit simulator. For this I have started a You Tube channel:

Saturday, August 12, 2017

Migration to Python 3 and virtualenv

So far Python Power Electronics has been built on Python2. I have Python 2.7.9 on computer and most of the other versions of Python I have used are quite similar i.e Python 2.7.x. Python 2 is now legacy and support will be disabled from 2020. Though that is a couple of years away, I figured I should start migrating since Python 3 is now well established and almost every OS ships with Python 3 by default and it may be soon when installing Python 2 may actually become an issue.

To start this migration, I don't want to do a system wide installation of Python 3 as it will break all my projects. So I am starting with virtualenv. To begin with, I am installing Python 3.5.4 into a separate folder.

In my Linux system, the system wide packages are installed in /usr. So I am installing Python 3.5.4 in home:
In the above user is the name of the user that you are logged in as. For that matter, you could install this in any other folder of your choice. I would strongly suggest that you install Python 3.5.4 in a user writable directory and not in a root directory.

So, download Python 3.5.4 from the Python website:

So let us suppose, this is downloaded to:
Extract the zip file to:
Change into this directory. In this directory you will find the entire source.

There will be some dependency issues - something is missing etc. I had a problem with libssl-dev being missing. I installed it using apt-get on my Debian system.

Anyway, first compile the source:
/home/user/Python-3.5.4/ $ ./confiure --prefix=/home/user/python_3_5_4

The prefix states that Python should be installed in a special folder and not in /usr/local/ which is the default.
If you get any errors and you might, Google each error and check which package is needed. Quite often it may say a package is missing when it is installed. What might actually missing is the development package. For example libssl may be installed, but libssl-dev may be missing. But that may cause it to exit with an error.

After that run the command:
/home/user/Python-3.5.4/ $ make

And if no errors:
/home/user/Python-3.5.4/ $  make install

The last command will create within /home/user/python_3_5_4 separate bin/, lib/ etc directories where Python will be installed.

Now, if you check:
python -V
You should get Python 2.7.x.

But if you run:
/home/user/python_3_5_4/bin/python3 -V
You should get Python 3.5.4.

So this means Python 3.5.4 has been installed in a separate directory. Now to begin using it.

Create a directory in home or anywhere else which will be the separate environment for Python 3.5.4. For example,

Change into this directory. Now you need virtualenv installed. I didn't have it so I used apt-get again to install virtualenv.

Run the command:
/home/user/python_3_5_4_virtual $ virtualenv -p /home/user/python_3_5_4/bin/python3 python3_install

What this will do it create a virtual environment but will use this Python 3.5.4 installed in an isolated directory to create an install environment in the directory called python3_install. So python3_install will contain all software related to Python - django, matplotlib, numpy, scipy etc.

Once this is done, activate it:
/home/user/python_3_5_4_virtual $ source python3_install/bin/activate

Now a special session will start. If within this session, you run:
(python3_install) /home/user/python_3_5_4_virtual $ python -V
You will get Python 3.5.4. The (python3_install) in bracket means you are in a virtual environment.

If you exit this environment by running:
(python3_install) /home/user/python_3_5_4_virtual $ deactivate

You exit. Which means:
/home/user/python_3_5_4_virtual $ python -V
Gives Python 2.7.9. Notice that (python3_install) has disappeared meaning you have exited the virtual environment.

So, to perform the migration, I will enter this virtual environment, install dependencies with Python 3.5.4 as the base. I will check the operation of the simulator bit by bit.

Wednesday, July 26, 2017

Tutorial on PV panel simulation

I released a tutorial on how to simulate a PV panel.

This is the first step towards simulating the interaction of renewable energy systems with the grid and also on how to build smart grids and microgrids with renewable energy. In the past I have simulated converters for interfacing PV to the grid and I have usually assumed the PV panel as a dc source. As I was focused on the control of the power converter, assuming the PV panel as a dc source, was not a problem. But if I need to simulate how PV can be used in any system, I need a more accurate model of a PV panel. In the least, I need to be able to replicate the V-I characteristics of the PV panel. It would be a good addition if I could also model how the output of the PV panel is affected by radiation, temperature etc.

The problem is that a lot of the papers that deal with PV are pretty heavy into solid state physics. The widely popular current-source with anti-parallel diode equivalent circuit for a PV panel is usually used. However, where most of the papers defer is how to generate the constants that the current generated and drawn by the diode are expressed with respect to. The only data available from a PV panel specification are of limited use when it comes to solving these equations. In order to be able to completely express the equations, constants have to be determined by solving non-linear equations.

My objective was to generate a PV model that was reasonably accurate and also understandable to a power electronics engineer without an in-depth understanding of device physics. And I found that several approximations were possible to determine many of the constants that appeared in the equations.

The most important assumptions were around the two extreme operating points - open-circuit and short-circuit. At short-circuit, the entire photo current generated flows into the short. The short-circuit current at a reference temperature is provided in the datasheet. Therefore, the photo current can be equated to the short-circuit current. Conversely, at open-circuit, the entire photo current flows into the anti-parallel diode. Therefore, the diode current is now equal to the photo-current which at the reference temperature is equal to the short-circuit current. The concept is that the value of the photo current generated depends only on the temperature and solar radiation. At short-circuit, this current flows into the short while at open-circuit, it flows into the diode.

The remaining calculations are merely procedure. Finally, the PV current that has been calculated is modeled as a voltage behind a resistance. A capacitance is connected across the PV terminals to stabilize the voltage.

Check out the report in the tutorial link for more information.