Tuesday, August 06, 2013

Lorenz in Living Color: Part 4 - Visualizing the System

As I mentioned previously, an error in my implementation of the Runge-Kutta algorithm on the Arduino left me convinced that I needed something with higher precision to do the necessary calculations.  This set-back would eventually sideline the project for several months but before I set it aside, I took on the chunk of code that would follow the calculations to find the solution to the Lorenz system, that I was having trouble with.  Given the z, y, and z values that would result from that calculation, I needed be able to determine the red, green, and blue values for all 50 of the LEDs I was going to be using.

This gets to a very fundamental question: once I did get to a place where I had a running list of coordinates of the solution points to the Lorenz system, how was I going to present those in an attractive way?  My first thought was just to use a row of LEDs each one representing a state of the system.  As the Arduino would generate the solution to the system for the next step in time, the new color would be shoved onto the string of LEDs, pushing all the previous solutions down one LED.  The result would look a lot like the animations form previous posts but here's what it looks like when all 50 LEDs are used:


My thoughts were to orient the string of LEDs vertically, maybe four or five feet tall and place them behind a piece of frosted glass or plastic, perhaps with some etching somewhat related to the weather.  I held onto this idea for quite some time before I was confronted with the reality that I had no way to etch a five-foot long piece of glass or plastic nor did I have any specific plans for what that art would be.  And if I was going to be the one to make the art, I suspected I would spend a large amount of time on it and the results would not be that fantastic.  The project would turn into one playing to my weaknesses rather than my strengths.

Lorenz, the man, is the one that coined the term "butterfly effect" to describe how chaotic systems can start out in very similar states but over time diverge drastically.  Interestingly, given the right set of parameters to the Lorenz equations, the shape of the solutions ("the attractor") takes on a vaguely butterfly-like shape.


I started of thinking of ways of trying to use this visual similarity. I still liked the idea of having the LEDs behind frosted glass to diffuse the colors; maybe a butterfly shape could be etched into the frosted glass?  Behind this etched glass I could arrange the LEDs in the shape of the attractor and as the solutions to the system were found, I could light up the LED that corresponded to that place on the X-Z plane with the color that corresponded to the X(red), Y(green), Z (blue) coordinates.  By arranging the string of LEDs in a figure-eight the looping path of the solution to the system would be shown by constantly moving LED with a color based on the the latest solution to the system.

But this would once again require me to create some kind of passible image of a butterfly to be etched. Seeking to avoid this complexity, I decided to switch the two images: I would etch the attractor on the frosted glass and arrange the LEDs in the shape of a butterfly.  I could generate the image of the attractor using Matlab and arranging 50 LEDs in the shape of a butterfly profile seemed something I could manage.

Once this decision was made, the next step was to write the code that would take the latest solution to the Lorenz system, an X, Y, Z coordinate, and define the state of each of the LEDs.

No comments:

Post a Comment