PyME Preface

Preface¶

This was heavily inpsired by AeroPython. Where a teacher flipped her Graduate level Aero class and has had great results. I think SciPy is going to change K-12 education in great ways and want to make something for basic ME courses.

The quick jump from Python to 3xx BSME courses.

I will assume the reader has a basic understanding of Python. If you have 13 hours, code academy is a perfect place to start.. The AeroPython project has a very nice intro to Jupyter Notebooks as well.

My TI-89 had a certain set of features, features I have grown accustomed to over a very long career. Features that would make me a nightmare for me to live without. So to self audit my Mechanics of Materials (Purdue ME323) course I decided to do what I did last time.

The way I learned this stuff the first time was by programming it. My TI-89 was the centerpiece of my studying. Redoing junior level engineering in TI-BASIC makes you breakdown the equation into how it actually works. For Design of Experiments class I once half wrote the most basic parts of SAS/R in TI-BASIC so the tests were plug'n'chug.]

Take my word for it that Python is heads and shoulders a more complete language than TI-BASIC however it has a lot of things that basic Python doesn't out of the box.

So as a start, lets bring Python up to (almost) what I did on the TI-89.

TI-89 -> Python¶

1. A good set of units. Units being correct has saved my butt on tests more times than I can count. If you get a units error you likely have the wrong equation. It's also saved my butt in the real world too.

Thankfully someone else has written a pretty good library. Pint is Python package to define, operate and manipulate physical quantities: the product of a numerical value and a unit of measurement. It allows arithmetic operations between them and conversions from and to different units. It is BSD licensed.

[Aside: No engineering student should ever. Ever. Ever learn English units again. For the sake of my sanity and yours, I will avoid them. For the love of all that is sensible we should never crash something into another planet because we screwed up units, let alone English units.

The output from the SM_FORCES application code as required by a MSOP Project Software Interface Specification (SIS) was to be in metric units of Newtonseconds (N-s). Instead, the data was reported in English units of pound-seconds (lbf-s). - Mars Climate Orbiter Mishap Investigation Phase I Report]

2. You need to do matrix algebra. Matrix math with statics & dynamics makes life easy. Thankfully some smart people back in the days of Fortran wrote some: BLAS Since then we've just been adding wrappers to it. It's at the heart of pretty much any engineering program today. For Python that wrapper is NumPy. It is BSD licensed.

3. We need a way to do symbolic math. TI-89 can do symbolic math, write the equations and forget about rearranging/transcription errors. For that there is SymPy. It is BSD licensed.

4. We need a way to display results. For equations Jupyter notebook can handle $\LaTeX$. [If you aren't exactly sure how to draw a symbol there's always Detexify and "How do I _ in LaTeX" on google.]

For graphs there is matplotlib. A python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms.

In [3]:
#1 Units.
import pint
#2 Linear Algebra
import numpy
import sympy
#4 Display.
from IPython.display import Latex # Display latex from Python windows.
import matplotlib                 # Plotting.
%matplotlib inline


It turns out someone else had a similar list and made a shortcut to most of that. %pylab

So for all projects I'll start with what the TI-89 can do and add packages as the courses require:

In [4]:
%pylab inline
import pint  # Units.
import sympy # Symbolic math
from IPython.display import display,Latex # Display latex from Python windows.

Populating the interactive namespace from numpy and matplotlib