Skip to content

Commit

Permalink
Merge branch 'master' into relax_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth committed Dec 1, 2015
2 parents 6739143 + 05c85f4 commit 7a6ca09
Show file tree
Hide file tree
Showing 59 changed files with 105,111 additions and 132,528 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.ipynb_checkpoints/
*.pyc
.ipynb_checkpoints
.pyc
.env
36 changes: 35 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
Instructional Material

All instructional material is made available under the Creative
Commons Attribution license. You are free:

* to Share---to copy, distribute and transmit the work
* to Remix---to adapt the work

Under the following conditions:

* Attribution---You must attribute the work using "Copyright (c)
Barbagroup" (but not in any way that suggests that we
endorse you or your use of the work). Where practical, you must
also include a hyperlink to https://github.com/numerical-mooc/numerical-mooc.

With the understanding that:

* Waiver---Any of the above conditions can be waived if you get
permission from the copyright holder.
* Other Rights---In no way are any of the following rights
affected by the license:
* Your fair dealing or fair use rights;
* The author's moral rights;
* Rights other persons may have either in the work itself or in
how the work is used, such as publicity or privacy rights. *
* Notice---For any reuse or distribution, you must make clear to
others the license terms of this work. The best way to do this is
with a link to http://creativecommons.org/licenses/by/3.0/.

For the full legal text of this license, please see:
http://creativecommons.org/licenses/by/3.0/legalcode

Software

The MIT License (MIT)

Copyright (c) 2014 Barba group
Expand All @@ -18,4 +52,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
#Practical Numerical Methods with Python

A multi-campus, connected course (plus MOOC) on numerical methods for differential equations in science and engineering. Collaboratively developed by:
This project started in 2014 as a multi-campus, connected course (plus MOOC) on numerical methods for science and engineering.

In Fall 2015, the second run of the connected courses, we have these instructors participating:
- [Lorena A. Barba](http://lorenabarba.com), George Washington University, USA
- Ian Hawke, Southampton University, UK
- Carlos Jerez, Pontificia Universidad Catolica de Chile
- [Ian Hawke](http://www.southampton.ac.uk/maths/about/staff/ih3.page), Southampton University, UK
- [Bernard Knaepen](http://depphys.ulb.ac.be/bknaepen/), Université Libre de Bruxelles, Belgium

**Note:** David Ketcheson, from King Abdullah University of Science and Technology (KAUST), Saudi Arabia was going to be our fourth partner, but unfortunately the local course at KAUST got cancelled due to low enrollment.

[**"Practical Numerical Methods with Python"**](http://openedx.seas.gwu.edu/courses/GW/MAE6286/2014_fall/about) is an open, online course hosted on an independent installation of the [Open edX](http://code.edx.org) software platform for MOOCs.
The MOOC (massive open online course) is ran by Prof. Barba at the George Washington University, while each instructor is running a local course, for credit at their institution. You can register for the MOOC at any time in the [GW Online Open edX](http://openedx.seas.gwu.edu/) platform to experience the complete course (including quizzes, examples and discussion board).
The MOOC (massive open online course) was run in 2014 for the first time by Prof. Barba at the George Washington University. At the same time, two other participating instructors ran a local course, for credit at their institution.

###Update for 2015

The synchronous course at the George Washington University will run again, starting September 1st, 2015. In addition, there will be a **new site for numericalmooc!**

- [Bernard Knaepen](http://depphys.ulb.ac.be/bknaepen/), Physics Department, Université Libre de Bruxelles

Prof. Knaepen will be teaching his numerical methods class at ULB, adopting the numericalmooc materials and creating new content.

### The MOOC

You can register for the MOOC at any time in the [GW Online Open edX](http://openedx.seas.gwu.edu/) platform to experience the complete course (including quizzes, examples and discussion board).

All content is open —really open, i.e., you can use, share, mod, remix— and most is available outside the course platform also (on GitHub and YouTube).

####Find the list of IPython Notebooks, with links to nbviewer, in the [Wiki](https://github.com/numerical-mooc/numerical-mooc/wiki).

##List of Course Modules
##Course Modules

1. [**The phugoid model of glider flight.**](https://github.com/numerical-mooc/numerical-mooc/tree/master/lessons/01_phugoid)
Described by a set of two nonlinear ordinary differential equations, the phugoid model motivates numerical time integration methods, and we build it up starting from one simple equation, so that the unit can include 3 or 4 lessons on initial value problems. This includes: a) Euler's method, 2nd-order RK, and leapfrog; b) consistency, convergence testing; c) stability
Expand All @@ -28,8 +41,11 @@ Starting with an overview of the concept of conservation laws, this module uses
This module deals with solutions to parabolic PDEs, exemplified by the diffusion (heat) equation. Starting with the 1D heat equation, we learn the details of implementing boundary conditions and are introduced to implicit schemes for the first time. Another first in this module is the solution of a two-dimensional problem. The 2D heat equation is solved with both explicit and implict schemes, each time taking special care with boundary conditions. The final lesson builds solutions with a Crank-Nicolson scheme.
5. **Relax and hold steady: elliptic problems.**
Laplace and Poisson equations (steps 9 and 10 of “CFD Python”), explained as systems relaxing under the influence of the boundary conditions and the Laplace operator; introducing the idea of pseudo-time and iterative methods. Linear solvers for PDEs : Jacobi’s method, slow convergence of low-frequency modes (matrix analysis of Jacobi), Jacobi as a smoother, Multigrid.
6. **Boundaries take over: the boundary element method (BEM).**
6. **Perform like a pro: making your codes run faster**
Getting performance out of your numerical Python codes with just-in-time compilation, targeting GPUs with Numba and PyCUDA.

Planned module (not yet started):
- **Boundaries take over: the boundary element method (BEM).**
Weak and boundary integral formulation of elliptic partial differential equations; the free space Green's function. Boundary discretization: basis functions; collocation and Galerkin systems. The BEM stiffness matrix: dense versus sparse; matrix conditioning. Solving the BEM system: singular and near-singular integrals; Gauss quadrature integration.
7. **Tsunami: Shallow-water equation with finite volume method.**
1D first … 2D problem with HPC solution (Python parallel or CUDA Python) -- *optional*.


104 changes: 104 additions & 0 deletions lessons/00_getting_started/00_01_Intro_to_the_command_line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#Intro to the command line

Welcome! The command can be one of the most powerful ways to interact with a variety of computer systems, but it can also be a little confusing at first glance. This mini-crash-course should help familiarize you with the basics of command line usage and navigation.


##Who am I?

Time to get started! You likely know your username since you've just logged in, but sometimes you may have multiple accounts with slight variations on a username.

First, please open up a terminal using the menu in the upper-left corner (on Red Hat) and selecting

> Applications -> System Tools -> Terminal
You can always ask the terminal who you are by entering

```Bash
whoami
```

and hitting \<Enter\>. (From now on, after typing in a command, just hit \<Enter\> unless we tell you otherwise.)

![whoami](./images/1.whoami.gif)

##Where am I?

We know who we are, time to find out *where* we are. You can always find out what folder you're in by using the "print working directory" command, or `pwd`. Try it out!

```Bash
pwd
```

![pwd](./images/2.pwd.gif)

We're in our home directory. This is the base directory for a regular user in Linux. In the SEAS labs, the home directory is always `/home/seas/<username>`. If you're using your own Linux machine, the home directory is probably `/home/<username>`. If you're on a Mac, the home directory is `/Users/<username>` (they like to be different).

##What's in here?

We know who we are and where we are, now it's time to figure out what's in here. We use the "list" command, `ls`, to view any files or directories that are in the current folder.

```Bash
ls
```

![ls](./images/3.ls.gif)

The items you see above in the gif are all folders. They're the usual folders created by default in Red Hat Linux. Your home folder is actually the same folder as your Titan network drive on Windows, so you may have other files and folders in your home directory.

##How do I go there?

To navigate to a new folder, we use the change directory command, `cd`, followed by the name of the folder. While you *can* type out the full folder name, it's usually nicer to use what's called Tab-completion.

Let's change to the `Pictures` directory. Type `cd Pi` and then hit the TAB key to complete the directory name. Then hit \<Enter\>

Now you're in the `Pictures` directory. It's probably empty, but you can check with `ls`.

To go back to your home directory, type `cd ..`

The `..` is a command-line shortcut to move "up" one folder in a directory tree. Try `cd`-ing into a few other folders and then returning back to your home directory to get the hang of moving around.

![cd](./images/4.cd.gif)

###Multiple tab-completions

If there are multiple possible completions for a partial directory name, you can ask the terminal to display them by hitting TAB twice. Try entering

```Bash
cd Do
```

and then hit TAB twice to see the list of matching directories. Then you can add a `c` and Tab-complete `Documents`.

![cdtabtab](./images/5.cdtabtab.gif)

##Quick config step

Now that we have a handle on basic terminal navigation, we are going to make a few tweaks to this setup to make it friendlier.
Copy the two lines below by selecting them and hitting Ctrl+c and then paste them into the terminal using Ctrl+Shift+v and hit \<Enter\>. **Note** that Ctrl+v doesn't work, you need to add Shift.

```Bash
echo "export PATH=/opt/anaconda/bin:\$PATH" >> .bashrc
echo "export PS1=\"\u \w \"" >> .bashrc
```

(If you are following along and aren't at GW, don't copy the first line, that only applies to the GW Linux labs)

Now, to activate the options we just selected, type the following line in the terminal and hit \<Enter\>

```Bash
source .bashrc
```

It should look a little something like this:

![image](./images/6.bashrc.gif)

##Fire up a jupyter notebook!

It's time to get started! If you're at GW then everything is already installed, just run

```Bash
jupyter notebook
```

in a terminal and it will launch a notebook server in your browser. If you *aren't* at GW, then see the next module in Getting Started on installing Python and Jupyter.
41 changes: 41 additions & 0 deletions lessons/00_getting_started/00_02_Installing_Jupyter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#Jupyter Install

This guide is to help you get Jupyter notebooks up and running on your personal computer.

##1. Install Anaconda

There are several ways to install Python and Jupyter and all of the required libraries to complete this course. You are welcome to try out any of them, but we **strongly** suggest using the Anaconda Python Distribution. It is up-to-date (unlike the versions of Python that may already exist on your Linux or OSX machine) and it also comes with `conda`. We'll get to `conda` a little later, but believe us, it's awesome and you want to have it.

###Download the installer

First download the Anaconda installer. Visit http://continuum.io/downloads to download the appropriate installer for your operating system.

**You must first click the link that says "I Want Python 3.4*"** to select the correct installer.

![anaconda](./images/anaconda.download.gif)


###Run the installer

Follow the appropriate instructions for your operating system listed on the [Anaconda Install Page](http://docs.continuum.io/anaconda/install). For Linux users, make sure to answer "yes" when the installer asks about editing your `PATH`.

![addtopath](./images/addtopath.gif)

Also note that on both Linux and OSX, you have to close the current terminal window and re-open it before the Anaconda installation will be available.

##2. Install Jupyter and other libraries

Once Anaconda is installed, you can then use the included `conda` package to install all of the necessary packages for the course. Open a terminal and run

```Bash
conda install jupyter numpy scipy sympy matplotlib
```

##3. Test your installation
Once `conda` is finished you should be ready to go! Open a terminal and run

```Bash
jupyter notebook
```

to launch a notebook server.
107 changes: 107 additions & 0 deletions lessons/00_getting_started/00_03_Intro_to_Jupyter_notebook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Intro to Jupyter notebooks

## What is the Jupyter Notebook?
We'll work extensively with [Jupyter Notebooks](https://jupyter-notebook.readthedocs.org/en/latest/notebook.html) (formerly IPython Notebooks) in this course. They are media-rich documents that combine text with markown formatting, typeset mathematics with MathJax, and executable Python statements.

The best way to understand the notebooks is to try them out, so let's get started!

## Launching the notebook server

To launch the notebook server, first open up a terminal and then enter

```Bash
jupyter notebook
```

This will start the notebook server. It *should* automatically open the main page of the notebook server in your default browser, but if it doesn't, simply open the browser of your choice and enter

```
http://localhost:8888/tree
```

in the address bar.

This will bring up a simple file-browser that will show the contents of the directory where you've launched the terminal from. Click on the `New Notebook` button and then select **Python 3** at the bottom to create your first notebook.

![newnotebook](./images/newnotebook.gif)

##Executing a code cell

Below the toolbars, you'll see a single code cell, prepended with `In [ ]:`. This cell can contain an arbitrarily long code segment, but we'll start with a simple one liner. In that lone code cell, type

```Python
x = 5
```

and then hit *Shift+Enter*. If you just hit Enter you'll find that it will simply add another line to the current cell. So remember, **to execute a cell**, it's **Shift+Enter**.

So what happened? We've assigned the label x to the number 5. And also you should see that the label of that cell will now read `In[1]:` because that's the first statement we've executed in this Python kernel. You'll also notice that the notebook has created a new cell, since we already used the only existing cell.

In this new cell, let's try to print out the value we assigned to x, so enter


```Python
print(x)
```

and then hit **Shift+Enter**. And there's the output we expect! The cell gets labeled `In[2]:` and the output of that command is printed immediately below the cell.

The whole procedure should look something like this:

![runandprint](./images/runandprint.gif)

##The Kernel
Don't worry too much about what the "kernel" is, but the main point to remember here is that we can assign a variable in one cell but still access it in a separate cell. The cells are ways for *us* to divide up our thoughts and our code, but everything is connected underneath.

##Overwriting variables

Since each cell is interacting with the same Python instance, if we give `x` a new value and then enter `print(x)` we'll get that new value. That's pretty straight forward —but what if we then delete the cell where we gave `x` a new value?

Let's take a look!

![overwrite](./images/overwrite.gif)

Even though we deleted the cell where we assigned `x = 7`, the assignment is still valid. In fact, the assignment will remain valid until we explicitly execute a cell that sets x equal to a new value, or until we completely restart this Jupyter Notebook instance.

##Markdown
Markdown is a *writing format* that makes it easy to type well-formatted text that is rendered into properly formatted XHTML. It's seriously awesome. Cells in Jupyter notebooks can be used for many things: to run Python, to embed media, or to write text in Markdown. This allows us to write notes about what we're doing, what the code is doing, what we're *trying* to do, whatever we like! These notes can be for ourselves, to document our work, or to share with others.

To create a Markdown cell in a notebook, click on an empty cell, then click on the Dropdown list (by default, it will say "Code") and select "Markdown"—as shown below.

Markdown is also (sort of) code, so after you type some text, you will also hit *Shift+Enter* to execute the cell and render the Markdown text. Try it out! Just type out a sentence or two in a markdown cell, then hit *Shift+Enter* to render the text.

![render](./images/rendermarkdown.gif)

##Markdown Math

Markdown can do more than just render simple text, it can also render LaTeX-style equations using **MathJax**!

* For inline math, wrap LaTeX inside single `$` signs
`$...$`
* For single-line rendering, wrap LaTeX inside double `$$` signs
`$$...$$`

![mathjax](./images/mathjax.gif)

**Note:**

Be aware that math typesetting is handled by MathJax and not by LaTeX. While the vast majority of MathJax syntax is identical to LaTeX, there are a few small differences (especially when it comes to matrix commands). So if you find something doesn't typeset the way you expect, Google around to make sure you're using the correct command.

##More Markdown Syntax
There are several references to learn Markdown tricks, but we especially like the summary by [John Gruber](http://daringfireball.net/projects/markdown/syntax). A few features that we find particularly useful are listed below.

For italics, wrap text in single `*`: `*this will be italic*`
For bold, wrap text in double `**`: `**this will be bold**`
For a bulleted list, start the line with an `*`, then type a space followed by the bullet item
```
* list item
* another list item
* and another
```

##Moving Cells Around
You'll often find that you want to add or delete cells, or just move them around. To move a cell, just click on it to select it, then use the Up- and Down-arrows in the toolbar to change the position of the cell.

![movecells](./images/movingcells.gif)

To add a cell, you can click the + button in the toolbar. Once you're comfortable with the notebook layout, you can also click on Help -> Keyboard Shortcuts to find out various shortcuts for adding, deleting and managing cell position and type.
Loading

0 comments on commit 7a6ca09

Please sign in to comment.