Skip to Content

PHY460S 1460S Lorenz Map Assignment

Python Package

To complete the computational laboratory on the Lorenz Map, you will need the python module, available here:

It uses several python libraries: numpy and scipy for the numerical computations, and matplotlib for plotting. These are standard and are installed on the Physics undergraduate computers. They should also be easily downloadable from the web if you would like to install them on your own computer; they are all open source and available for free.

Note that in order to see a three dimensional plot of the Lorenz attractor, you will require mplot3d, a toolkit that comes with matplotlibversions 0.99 and later. You will still be able to run the rest of the code (and do the assignment) with earlier versions of matplotlib.

This wiki will help you get started with Python. Of particular interest may be the section on Installing Python. It will also get you started on running python scripts and modules with IDLE. As of this writing, the University of Toronto Physics Python Distribution does not include a recent enough version of matplotlib to see the 3d plot. If you install this file, or use the undergraduate computers, you will still be able to do all the problems on the assignment. If you would like to see a 3d plot of solutions to the Lorenz equation (and the Lorenz Attractor in all its glory), you may want to install the most recent version of Python(x,y) on your own computer directly (follow the links in the Wiki page above).

Running defines a python module named lorenz; it can be imported into your own scripts, or into an interactive session of python, from which you can access the functions it defines.

Once you have downloaded and installed Python and, open it through IDLE as in the wiki tutorial above. A brief message should appear and you can get started.

The lorenz module should be straightforward to use; if you have any programming experience at all, all you are required to do is import the module and run some of the methods it defines, changing some of the parameters. You will not need to go through all of the tutorials on the wiki.

Use of the methods are documented through a standard feature of python called doc strings. You can read them just by looking at the code in a text editor, or calling help(...) where '...' is the name of any of the methods defined in after you have imported the module into an interactive python session.

The internal workings of the code are also documented, so if you are interested in how it works you can take a look.

lorenz.m to

This python package is intended to provide the same functionality as the previous Mathematica package, lorenz.m. All the methods you need to use are prefixed by plot_. Computer resources being somewhat more plentiful than they were in 1999 when the Mathematica package was written, there is no longer any reason to precomputing the trajectories. Instead, the default parameters in the python module are set up to be the same as were used to generate the precomputed trajectories. When the assignment asks you to look at a preloaded trajectory with for a given r, you can instead simply call any of the plot functions with that r and no other parameters specified.

The only other change is that there is no animation of a trajectory; instead if you have matplotlib v0.99 or later, you can call plot_3d to get a three dimensional plot of a trajectory which you can rotate yourself.

The site content is Copyright 2009 Department of Physics, University of Toronto.