More Strange Attractors

As I mentioned toward the end of my post on the Python/GTK+ implementation of the Lorenz attractor, I ultimately wanted to add some of the other strange attractors to my program in order to make it a bit more interesting. So I did just that. It also gave me a good excuse to learn a bit more about how to use and layout widgets in a GTK+ application.

In addition to the Lorenz attractor, the program now will generate the Rössler Attractor and a plot of the behavior of Chua’s Circuit. The Rössler Attractor is another well-known system in the world of chaos theory, which you can learn more about by following the above link. Since I’m only plotting a 2D section of each attractor, I have to decide which view to display. In the case of the Rössler, I thought that the X-Y view was better than the X-Z view.

More interesting to me is the simulation of Chua’s Circuit, as this is based on an actual analog circuit you can build. The circuit is a chaotic oscillator that consists of the usual L-C elements (and a resistor plus limiting diodes) along with a nonlinear negative resistance circuit element. The negative resistance element is usually implemented with an active device such as an op-amp, although it has been reported that a memristor can also serve this function. The simulation is a system of three ordinary differential equations, much like the Lorenz or Rössler systems, but with a function in the first ODE to represent the behavior of the nonlinear negative resistance element. You can see in the code listing below that this was easy to implement in Python with a lambda function. It’s cool to see the pattern drawn on a display, but I think it would be much better to have an actual circuit render it on an analog oscilloscope. One day, I hope to do that, but in the mean time, enjoy these videos of the behavior of such a circuit.

As far as my additions to the Python code, I created a GTK DrawingArea for each attractor, then added them to a Stack, which allows them to be switched with the StackSwitcher widget at the bottom of the screen. For clarity, I also added a legend to each DrawingArea to display which axes are being rendered for each attractor, as the Rössler has a different view from the other two. This code is a bit longer than the initial iteration, but much of it is similar, since the calculation and plotting of each system is nearly the same (yes, I could have factored the code quite a bit, but this is just for fun). Another fun time with code was had!

Leave a Reply