Main Page

From Python Dynamics
Jump to: navigation, search

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

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:

  1. Sage
  2. The Enthought Distribution (Academic version are free)
  3. Python(x,y)

Specific platform installation instructions follow:

Windows

  1. Download and install the Windows version of the Enthought Python Distribution at Enthought Download Page
  2. 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
  3. Unzip the source code into a directory
  4. Open up a new command prompt (Start Menu -> Run -> type cmd and press enter), and navigate to that directory (e.g. cd C:\Users\PyDyUserPerson\Software\sympy-version)
  5. In the command prompt, enter: python setup.py install
  6. 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

  1. Download and install the Mac OS X version of the Enthought Python Distribution at Enthought Download Page
  2. 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
  3. Open your Downloads folder and double click to downloaded SymPy file to unzip it
  4. Go to Applications -> Utilities -> Terminal to open a new Terminal Window
  5. Navigate to the SymPy directory you just created (e.g. cd ~/Downloads/sympy-version#)
  6. In the terminal window run the following command: python setup.py install.
    • If the above command gave an error, try: sudo python setup.py install This will prompt you for your password
  7. 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:

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

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox