This dynamical systems machine allows for on-the-fly switching between any number of user-specified systems. Users may also switch between a fixed perspective or the perspective of one of the particles. Dyn.py can be extended with more dynamical systems by even a novice programmer.
The goal of dyn.py is a simple platform for others to study dynamical systems. The program, or dynamical system machine, requires little or no programming experience to extend with any dynamical system that the user chooses. The user can use some ddextra functionality to tune their systems in real time. can then manipulate the system to see it from different angles and how it develops over time.
To transform a dynamical system defined by a system of differential equations to a format dyn.py can understand use the Gauss-Sidel method. Essentially, you take the differential equation and compute delta (x,y,z) from the last step to this step. Step size can also be tuned to give good results. Please view the documentation for details on how to add a new dynamical system to dyn.py.
Dyn.py uses szg's distributed scene graph (DSG) framework to draw objects in the cube. My DSG has several important nodes: t is the root of the scene graph; stars is attached to t and holds the individual star points; n is attached to to t and n's transform represents joystick input; w is attached to n and it's transform represents where the dynamical system starts in the cube; m is attached to w and it's transform represents rotations of the system by the user. N, m, w are separate transforms in my scenegraph for convenience. All of the remaining transforms are attached to m, so n, m, w could really be a single transformation, but it is nice to think of and update the different components as separate transforms.
I use a simple randomized selection to draw the stars in dyn.py. I wanted the stars to lie on some boundary sphere surrounding the dynamical system. To pick random points on this sphere, it is easier to think of it in terms of spherical coordinates: theta, the angle along the equator; phi, the angle from the equator to the north or south pole; and r, the radius. To determine theta and phi, I pick a random fraction, frac, between 0 and 1. Theta = 2*pi*frac and phi = (frac - .49)*pi. Note, you *must* use different "fracs" for theta and phi, otherwise, there will exist a function that maps theta to phi, or in other words, your stars will be in a straight line. To vary the stars appearance, I proportionately make some stars 1 pixel, 2 pixels, and 3 pixels big.
My method for changing between dynamical systems relies heavily on principles of functional programming. In python, functions are treated as first class variables. In other words, functions can be assigned to a variable, passed as a parameter to other functions, and even operated on by so called higher order functions (i.e. map, fold_left, filter, etc). [For more information about functional programming, I suggest reading the paper Why Functional Programming Matters by John Hughes] In dyn.py, each system of equations is associated with four variables: I have a variable that holds the x, the y, and the z equations and a variable to hold the step value, h. Each equation variable points to an anonymous function or a function without a name. You cannot call these functions unless you hold the variable. When a particle updates it's position, it references these xeq, yeq, zeq and h variables. Thus, the particle does not know which equation it is using at all. So, I play a trick on the particle and have xeq, yeq, zeq, and h point to a new system when I wish to change systems. The particle updates itself then by the new set of rules. To make switching easier, I place the systems into a circular queue for each variable. So, to update to the next system, I say for example xeq = xeqs(i+1). Thus, I can add as many systems as I like to my circular queues without needing to tell the program how many I have added.
These are the more difficult and interesting parts of my program. Feel free to browse and edit the source or read the user documentation for more information. I can be contacted at lambdakai AT google's e-mail system.
Note these screenshots are around ~300k each
Picture of Lorenz system from inside
Switching from Rossler to Lorenz
Lorenz seen from particle's perspective