Projects

Python is an amazing and versatile language to transform any idea into working code. Be it testing algorithms for interesting games and thought experiments, visualizing data, creating a graphical user interface (GUI), or creating a simple database management system, Python is my go-to tool. These are a few short projects I worked on with this wonderful language.

MG-Lite

This was partly an exercise in testing the multigrid algorithm in a simple one-dimensional system. However, it was mainly written in an attempt to create GUIs for applications. The multigrid solver is an important component of the finite-difference solver, SARAS. This project helped test the restriction and prolongation operations of the multigrid V-Cycle. It also provided great insight into designing a simple and intuitive GUI for the code.

I used PyQt5 to create its main and console windows. Python's versatile matplotlib generates the plots as the solver concludes. Being a lightweight multigrid solver, the application is called MG-Lite, and is available on my GitHub page.

Image
Image

Low-Dimensional Models

When one looks at the spectrum of a turbulent flow field by taking its Fourier transform, it is readily seen that the energy of the flow is distributed across many wavenumbers, or modes. However, when the flow is laminar, or poised at the incipient stages of instability, certain Fourier modes are more dominant, i.e., they contain most of the energy. By studying the evolution of these dominant modes, it is possible to predict the growth and decay of instabilities in the flow.

Using a versatile Fourier basis named Craya-Herring basis (taught by Prof. M. K. Verma in his course Physics of Turbulence at IIT-K), one can quickly derive the governing equations of a handful of modes. Here, the evolution of certain velocity and temperature modes are shown for rotating Rayleigh-Bénard convection.

3D Vision with Python

Our eyes perceive the world in 3D using the visual input from both the eyes. The small difference in points of view from the two eyes is used by the brain to place objects at different distances. Thus, using two images of the same object taken from two slightly different points of view, one can mimic this effect. This is the principle behind stereoscopy.

In this image, there are two 3D views of a circularly polarized wave, each taken from two slightly different angles. This is done by adjusting the azimuthal angle of the view in Python's matplotlib. This was subsequently animated by continuously rotating the camera around the wave. When this animation is played on a 3D monitor with accompanying 3D glasses, it produces a convincing illusion of depth.

Image
Image

Conway's Game

Conway's Game of Life is a captivating numerical experiment to observe the evolution of cellular automata. We start with an \(m \times n\) grid of cells, some of which are alive, while the rest are dead. Using a set of 3 simple rules, one can numerically step through each generation of the cells.

  1. Any live cell with 2 or 3 live neighbours will stay alive
  2. Any dead cell with 3 live neighbours will become alive
  3. All other cells will die or remain dead

I use the FuncAnimation() function from the animation class of Python's matplotlib module to see the growth and decline of cells, starting from a given initial configuration. One of the intermediate configurations during one such experiment is shown here. All yellow cells are alive, while the purple ones are dead. It is hard to predict how the cells will evolve - sometimes they die off en masse, other times they cycle through states endlessly in a loop.

Project Euler

Project Euler is a brilliant collection of some truly challenging programming problems. Each problem tackles an interesting math problem (usually from number theory or geometry). For instance, Problem 144 tracks a beam of light as it reflects multiple times through an elliptical mirrored cavity (a white cell). The reflections of the laser beam form a beautiful pattern (shown here) which reminds me of the Eye of Sauron from the Lord of the Rings. Another interesting problem is Problem 96, which requires one to write a program to solve Su-Doku puzzles.

I usually use Python to solve these problems. Currently I am on Level 4, having solved 110 problems so far. I maintain the solutions on GitHub again, but as a private repository ;)

Image