numerical methods in materials science and engineeringmgoodman/day1.pdfnumerical methods in...

23
Numerical Methods in Materials Science and Engineering Matthew Goodman [email protected] MSE 350 - Python Acedemic Integrity Python Overview Why Python? Homework Bibliography Numerical Methods in Materials Science and Engineering First Day Matthew Goodman [email protected] Materials Science and Engineering University of Arizona August 24, 2009

Upload: truongthien

Post on 24-Apr-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Numerical Methods in Materials Science andEngineering

First Day

Matthew [email protected]

Materials Science and EngineeringUniversity of Arizona

August 24, 2009

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Welcome to MSE 350

I I am not Dr. Erdmann! He is out for the week.

I Watch the NASA launch (http://countdown.ksc.nasa.gov/shuttle/countdown/cdt/)

I Laptop use in class is encouraged! (for programmingrelated . . . )

I There is no assumption of previous programmingexperience . . .

I Prereqs: Vector and Diff-Eq.

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Today

I This presentation:http://u.arizona.edu/~mgoodman/

I Class site:http://www.u.arizona.edu/~erdmann/mse350/

I Plagiarism Videohttp://deanofstudents.arizona.edu/

I Class overview

I HW for Wednesday

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Academic Integrity “video”

Just don’t do it!

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

What is Python?

Python is a general-purpose high-level programminglanguage. Its design philosophy emphasizes code readability.Python claims to “[combine] remarkable power with veryclear syntax”, and its standard library is large andcomprehensive. Its use of indentation as block delimiters isunusual among popular programming languages.[wik, ]

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python?

I Modern

I Modular

I Concise

I Powerful

I Interactive

I Cross Platform

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – Modern

I First Release in 1991!

I Under heavy active development

I Used by a number of giants:

I YouTube, Google, BitTorrent

I Yahoo!, CERN, NASA, OLPC

I Most Linux/Unix

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – ModernFrom xkcd.com[xkc, ]

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – Modern

Wow Development!

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – Modular

Some standard modules:

I os – Dealing with the operating system and files

I wave – Working with sound files

I gzip, tarfile, zipfile – Working with compressed files

I urllib, webbrowser – Retrieving web pages andinteracting with the local web browser

I sqllite, tables, csv – Specialized database and data fileformats.

I email, pidgin – Interface to email and chat clients.

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – Modular

Unique problems in programming are RARE.

I Reinventing the wheel == bad!

I Python modules offer engineered solutions to commontasks.

I This class will focus on several modules well suited toengineering and science related endeavors:

I Numpy – Powerful array operationsI Scipy – Scientific librariesI MatPlotLib – Plotting http:

//matplotlib.sourceforge.net/gallery.htmlI Mayavi – 3d visualization (demo) https://svn.

enthought.com/enthought/wiki/Mayavi/Gallery

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – Modular

Modularity extends even to OTHER PROGRAMMINGLANGUAGES

I SWIG – Generates python interfaces to many languages(Java, C, C++, FORTRAN, Perl . . .)

I Cython – Creates C code out of Python

I PyCUDA – Interface to the NVIDIA CUDA GPUcomputing platform

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – Concise

I Python was designed with readability in mind.

I Code is broken up with white-space

I More on this all later!

print “hello world”lunch options = “spam, eggs, and spam”if “spam” in lunch options: print “Yay spam!”

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – PowerfulAll of the following things could be comfortablyaccomplished in less than 10 lines of code thanks to thewealth of modules available:

I Monitor an industrial process and send an email in caseof disruption.

I Connect to a remote database and perform a complexquery and display/save the results.

I Take the symbolic integral of a complex function.

I Visualize a 2d or 3d data set with interactive display

I Download a large number of files from a website on aautomatic schedule.

I Load an image, perform several filters and save it as adifferent format.

I Write an alarm clock with user specified wait time andmusic ramping.

I Make a chat-robot that harasses your friends.

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – Interactive

Demo time!

I Interactive help

I Interactive programming

I Interactive HPC

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Why Python? – Cross Platform

I Supports all major operating systemsI LinuxI Windows (95, XP, Vista, 7?)I Mac OSX

I Portable code!

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

HW1: Get Python

Downloading and Installing the following is your homeworkfor the next class:

I python – the Python interpreter

I ipython – the interactive Python interpreter

I A text editor – 100+ options here . . .

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

HW1: Continued . . .

Also, we will need the following modules:

I numpy

I scipy

I matplotlib

I tables

I mayavi

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

HW1: Made Easy

You could track down all these individual installs and files,but it is much easier to download a bulk distribution thatincludes all of these tools:

I The Enthought Python Distribution (EPD) found athttp://www.enthought.com/. (all platforms)

I python(x,y) the “full” distribution found athttp://www.pythonxy.com/. (ia-64 not supported?)

I From the Linux apt repositories (ask me for a packagelist) (Debian/Ubuntu)

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Completing HW1

The final three steps:

1. Download the python script found here(http://www.u.arizona.edu/~mgoodman/)

2. Run it

3. Send a screen shot of everything working well to me [email protected]

4. Please include your full name, and a“secret-name/moniker” under which grades will beposted (if you don’t choose one, I will and you probablywont like it)

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Working Configuration

This is good:

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Lastly . . .

I If you have any trouble . . .

I Please also begin reading the first three sections of thepython tutorial found at:

I http://docs.python.org/tutorial/

I We will have covered all of that material by the end ofWednesday if all goes well.

NumericalMethods in

Materials Scienceand Engineering

MatthewGoodman

[email protected]

MSE 350 - Python

Acedemic Integrity

Python Overview

Why Python?

Homework

Bibliography

Bibliography I

Wikipedia, the free encyclopedia.http://www.wikipedia.org.

Xkcd, a webcomic of romance, sarcasm, math, andlanguage.http://www.xkcd.com.