Main Page
Contents |
Introduction
Python Dynamics (PyDy) is a collection of open source software that gives you the ability to derive both non-linear and linear symbolic equations of motion for systems in classical mechanics and then analyze the systems with linear analysis, simulation, and visualization tools. The core of the suite is a package in the SymPy distribution called mechanics which is held under the physics sub package (sympy.physics.mechanics). It provides a framework for deriving the equations of motion of complex mutli-body systems. Other popular tools such as SciPy, Gnu Scientific Library, OpenGL, and Visual Python provide the means for numerical analyses and visualization of the resulting equations of motion.
History
PyDy was started by Luke Peterson as a Google Summer of Code project in 2009. He developed the original methods for deriving symbolic equations of motion within the SymPy framework. Two years later, Gilbert Gede was awarded a second GoSC grant to build on Luke's work and restructure the code base for integration into sympy. The software was introduced to the UC Davis multibody dynamics course at the beginning of 2012, to replace the aging Autolev.
Features
- The core of PyDy is written in a full featured object oriented programming language, Python, which is one of the most easy to learn and read. Python has a large support community and is one of the most popular languages today. You can access hundreds and hundreds of libraries for database connectivity, scientific tools, http connections, etc. PyDy leverages the open source ethos, so that we focus on the dynamics part and while others more versed in scientific programming and visualization provide those components.
- SymPy is a computer algebra system (CAS) library which offers many more symbolic manipulations than to numerical dynamics centric packages. It is comparable in features to Maple, Mathematica and MathCAD.
- PyDy utilizes a large collection of anaylsis, plotting and visualization pacakges. You can work in your preferred language and package suite.
- PyDy has a strong community, as do most open source projects. Leverage the collective knowlegde of PyDy, SymPy, and Python users worldwide.
- PyDy can leverage multiple methods of generating equations of motion from Newton-Euler to Kane.
- All of the code is Open Source, licensed under the BSD license. This means you can read it to gain a better understanding, and modify it. PyDy and SymPy welcome contributions from other users and developers.
- PyDy is free as in beer. It leverages the open source development model so that the software is available at no cost to users, whether academic, commercial or the general public.
- Detailed documentation, tutorials and examples, where much is user contributed.
- PyDy offers comparable features to commercial symbolic dynamics software such as AutoSim, Autolev, and MotionGenesis which all also primarily leverage Kane's approach.
Installation
To work on dynamics problems in Python, the first thing that you need to do is install Python, then SymPy which includes the sympy.physics.mechanics pacakge for symbolic derivation of equations of motion. SymPy Documentation
Simple Installation
If you've never installed or worked with Python before, it is easiest to install a distribution. Three of the most popular distributions that include a large assortment of science and mathematics tools are:
- Sage
- The Enthought Distribution (Academic version are free)
- Python(x,y)
Specific platform installation instructions follow:
Windows
- Download and install the Windows version of the Enthought Python Distribution at Enthought Download Page
- Download the most recent version of SymPy from Sympy Source Page using the "zip" button, or by following the following link Lastest Sympy Source Code
- Unzip the source code into a directory
- Open up a new command prompt (Start Menu -> Run -> type
cmdand press enter), and navigate to that directory (e.g.cd C:\Users\PyDyUserPerson\Software\sympy-version) - In the command prompt, enter: python setup.py install
- Done!
Debian GNU/Linux (Ubuntu)
Download or clone the most recent version of SymPy from Sympy Source Page using the "zip" button, or by following the following link Lastest Sympy Source Code.
Open a terminal. Go to the directory where the SymPy files were un-zipped. Type:
sudo python setup.py install
sudo gives permission to install system wide, python is the main python interpreter, setup.py is the SymPy install file, and install is the flag for setup.py to install.
Mac
- Download and install the Mac OS X version of the Enthought Python Distribution at Enthought Download Page
- Download the most recent version of SymPy from Sympy Source Page using the "zip" button, or by following the following link Lastest Sympy Source Code
- Open your Downloads folder and double click to downloaded SymPy file to unzip it
- Go to Applications -> Utilities -> Terminal to open a new Terminal Window
- Navigate to the SymPy directory you just created (e.g.
cd ~/Downloads/sympy-version#) - In the terminal window run the following command:
python setup.py install.- If the above command gave an error, try:
sudo python setup.py installThis will prompt you for your password
- If the above command gave an error, try:
- Done!
Advanced Installation
If you are well versed at Python package installation and version control, then you can install the latest SymPy code using Git. You can also install all of the various other packages with your system's package manager, downloading from [1], or downloading individual binaries. Most of the packages in PyDy can be found in Linux and Mac package managers. Refer to your system for details about installing packages. If you want to install each package yourself here is a list of some of the software used in the examples that you will be potentially useful:
- Advanced Interpreter: IPython
- Integrated Development Environments: IDLE
- Integration: SciPy, GSL, Matlab/Octave
- 2D Plotting: Matplotlib, GNU Plot, Matlab/Octave
- 3D Visualization: Visual Python, OpenGL, VTK
Getting Started
PyDy uses tools written in the Python programming language, so it is best to get familiar with Python. There are many tutorials and even free books available online. The next step is to get familiar with SymPy as it is the symbolic toolset which is used to derive the equations of motion.
Starting with PyDy
The Beginner's Tutorial is a great place to start for absolute beginners.
The first thing to do is to open the Python interpreter. If you have IDLE installed, start IDLE. From here you can experiment with a short list of commands. From IDLE, you can also click "New Window" to open up an empty .py file to start your script in.
One of the most important features in Python (and SymPy by extension) is the ability to call help(function) on any function to get a description of its behavior. Use this functionality for reminders on how to use commands, or view the complete documentation, listed below.
SymPy/Physics/Mechanics
The sympy.physics.mechanics documentation has the information you need to get started with the commands for deriving equations of motion. It provides background to the commands, as well as usage of them you will use: here.
SymPy
Documentation for SymPy can be found at [2]. To get familiar with basic SymPy commands follow the tutorial. SymPy works like most other symbolic mathematics software.
Python
Good places to start for Python introduction are the official Python tutorial and the free book Dive Into Python. Internet searches for "python" and "tutorial" will bring up many valuable results. There are also great books for purchase that teach the language too.
Examples
There are a few examples in the sympy.physics.mechanics documentation but many more can be found on this website. Feel free to contribute examples by forking our Git repository on Github and adding an example and creating a new page with a detailed tutorial.
Generic Language Templates
Equations of Motion
Start to Finish Examples
Resources
- Python Tutorial: SymPy is written in Python and it is a good idea to get familiar with the language to some degree. The official Python tutorial is a good place to start.
- PyDy examples repository: All of the examples from this website are stored in this repository.
- Sympy source repository: The latest development version of SymPy can be downloaded here.
- SymPy documentation: The documentation for the latest SymPy release.
- SymPy Discussion List
- PyDy Discussion List
- SymPy Bug Tracker Report issues, bugs and feature requests for SymPy here.