├── lessons
├── figures
│ ├── squarewave.png
│ ├── FD-stencil_LF.png
│ └── FD-stencil_FTCS.png
└── Conservative.vs.Nonconservative.Forms.ipynb
├── .gitignore
├── styles
└── custom.css
└── README.md
/lessons/figures/squarewave.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/barbagroup/PASI2013/master/lessons/figures/squarewave.png
--------------------------------------------------------------------------------
/lessons/figures/FD-stencil_LF.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/barbagroup/PASI2013/master/lessons/figures/FD-stencil_LF.png
--------------------------------------------------------------------------------
/lessons/figures/FD-stencil_FTCS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/barbagroup/PASI2013/master/lessons/figures/FD-stencil_FTCS.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | lessons/.ipynb_checkpoints/01_Burgers.equation-checkpoint.ipynb
3 |
4 | lessons/.ipynb_checkpoints/02_Sod.Shock.Tube-checkpoint.ipynb
5 |
--------------------------------------------------------------------------------
/styles/custom.css:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
69 |
84 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #PASI 2013 Lessons, in Python
2 | ##"The science of understanding tsunamis, storm surges and tidal phenomena"
3 | ###Valparaiso, Chile (Jan. 2013)
4 | ####with funding from NSF and DOE under the PASI program, and additional support from ONR Global, Santiago.
5 |
6 | These lessons were prepared during Fall 2013, inspired by some of the lecture notes from the mini-courses at the PASI (Jan. 2013) and background material from Prof. Barba's CFD course. They present foundations to understanding mathematical models such as waves and shallow-water phenomena.
7 |
8 | The institute was led by [Prof. Lorena A. Barba](http://lorenabarba.com/) and the instructors were:
9 |
10 | - [Cheryl Ann Blain](http://www.bu.edu/pasi-tsunami/people/cheryl-ann-blain/), Oceanography Division, Naval Research Laboratory
11 | - [Donna Calhoun](http://www.bu.edu/pasi-tsunami/people/donna-calhoun/), Department of Mathematics, Boise State University
12 | - [Changsheng Chen](http://www.bu.edu/pasi-tsunami/people/changsheng-chen/), Department of Fisheries Oceanography, School for Marine Science and Technology, University of Massachusetts-Dartmouth
13 | - [David George](http://www.bu.edu/pasi-tsunami/people/david-george/), U.S. Geological Survey
14 | - [Philip Liu](http://www.bu.edu/pasi-tsunami/people/philip-liu/), School of Civil and Environment Engineering, Cornell University
15 | - [Patrick Lynett](http://www.bu.edu/pasi-tsunami/people/patrick-lynett/), Department of Civil Engineering, University of Southern California
16 | - [Ridgway Scott](http://www.bu.edu/pasi-tsunami/people/l-ridgway-scott/), Departments of Computer Science and Mathematics, University of Chicago
17 | - [Tim Warburton](http://www.bu.edu/pasi-tsunami/people/tim-warburton/), Computational and Applied Mathematics, Rice University
18 |
19 | You can find brief biographies of the instructors on the [People](http://www.bu.edu/pasi-tsunami/people/) page of the institute.
20 |
21 | [Materials](http://www.bu.edu/pasi-tsunami/materials/) from the institute include lecture notes (presentation slides), and several videos recorded as screencasts during lecture.
22 |
23 | ###Notebooks
24 |
25 | * [Exploring schemes with Burgers' equation](http://nbviewer.ipython.org/github/barbagroup/PASI2013/blob/master/lessons/01_Burgers.equation.ipynb)
26 |
27 | * [Sod's Shock Tube](http://nbviewer.ipython.org/github/barbagroup/PASI2013/blob/master/lessons/02_Sod.Shock.Tube.ipynb)
28 |
29 | * [Shallow Water Equations in 1D with Python and NumPy](http://nbviewer.ipython.org/github/barbagroup/PASI2013/blob/master/lessons/03_Shallow.Water.1D.Python.ipynb)
30 |
31 | * [Intro to solving SWE with PyClaw in 1d](http://nbviewer.ipython.org/github/barbagroup/PASI2013/blob/master/lessons/04_Shallow.Water.1D.ipynb)
32 |
33 | * [Solving SWE with PyClaw in 2d](http://nbviewer.ipython.org/github/barbagroup/PASI2013/blob/master/lessons/05_Shallow.Water.2D.ipynb)
34 |
35 | * [Conservative and Non-conservative Forms](http://nbviewer.ipython.org/github/barbagroup/PASI2013/blob/master/lessons/Conservative.vs.Nonconservative.Forms.ipynb)
36 |
--------------------------------------------------------------------------------
/lessons/Conservative.vs.Nonconservative.Forms.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "metadata": {
3 | "name": "",
4 | "signature": "sha256:9b5f82ca1223bd3ff6e4cd752768cd46790ed77a97ab9689c6274fd8bd0c40a2"
5 | },
6 | "nbformat": 3,
7 | "nbformat_minor": 0,
8 | "worksheets": [
9 | {
10 | "cells": [
11 | {
12 | "cell_type": "markdown",
13 | "metadata": {},
14 | "source": [
15 | "#Conservative and Non-conservative Forms"
16 | ]
17 | },
18 | {
19 | "cell_type": "markdown",
20 | "metadata": {},
21 | "source": [
22 | "Consider the conservative derivative:\n",
23 | "\n",
24 | "$$\\frac{\\partial \\rho u}{\\partial x}$$\n",
25 | "\n",
26 | "When we discretize this with a backward difference, it yields:\n",
27 | "\n",
28 | "$$\\frac{\\partial \\rho u}{\\partial x} \\approx \\frac{\\rho u_i - \\rho u_{i-1}}{\\Delta x}$$\n",
29 | "\n",
30 | "If we instead start with the non-conservative derivative (apply the product rule), we have:\n",
31 | "\n",
32 | "$$\\rho \\frac{\\partial u}{\\partial x} + u \\frac{\\partial \\rho}{\\partial x}$$\n",
33 | "\n",
34 | "But now, applying the same backward difference scheme yields\n",
35 | "\n",
36 | "$$\\rho \\frac{\\partial u}{\\partial x} + u \\frac{\\partial \\rho}{\\partial x} \\approx \\rho_i \\frac{u_i - u_{i-1}}{\\Delta x} + u_i \\frac{\\rho_i - \\rho_{i-1}}{\\Delta x}$$\n",
37 | "\n",
38 | " "
39 | ]
40 | },
41 | {
42 | "cell_type": "markdown",
43 | "metadata": {},
44 | "source": [
45 | "The first big takeaway here is that the numerical approximations are different for the conservative and non-conservative forms, despite the fact that the original equations are mathematically equivalent. \n",
46 | "\n",
47 | "#####What makes it conservative or non-conservative?\n",
48 | "\n",
49 | "If a derivative is conservative, when you expand it out into a series, all of the terms except for those on the boundary should cancel with each other. \n",
50 | "\n",
51 | "Take our conservative derivative, expanded between $i=0$ and $i=3$:\n",
52 | "\n",
53 | "$$\\frac{(\\rho u)_1 - (\\rho u)_0}{\\Delta x} + \\frac{(\\rho u)_2 - (\\rho u)_1}{\\Delta x} + \\frac{(\\rho u)_3 - (\\rho u)_2}{\\Delta x}$$\n",
54 | "\n",
55 | "Hopefully you can see that if we add up all of the terms in that expansion, we'll be left with only those terms at the boundary of our expansion. \n"
56 | ]
57 | },
58 | {
59 | "cell_type": "markdown",
60 | "metadata": {},
61 | "source": [
62 | "Let's try the same thing with the non-conservative form:\n",
63 | "\n",
64 | "$$\\rho_1 \\frac{u_1 - u_0}{\\Delta x} + u_1 \\frac{\\rho_1 - \\rho_0}{\\Delta x} + \\rho_2 \\frac{u_2-u_1}{\\Delta x} + u_2 \\frac{\\rho_2 - \\rho_1}{\\Delta x} + \\rho_3 \\frac{u_3-u_2}{\\Delta x} + u_3 \\frac{\\rho_3 - \\rho_2}{\\Delta x}$$\n",
65 | "\n",
66 | "Ack. Now nothing cancels out at all. In fact, for each additional grid point that we add to this series, the expansion will get longer and longer. \n",
67 | "\n",
68 | "#####So which is better?\n",
69 | "\n",
70 | "Non-conservative forms will generally work fine if the solution is expected to be smooth, i.e. without shocks. \n",
71 | "\n",
72 | "If there is the potential for shocks or any kind of sharp change, you need to use the conservative form."
73 | ]
74 | },
75 | {
76 | "cell_type": "markdown",
77 | "metadata": {},
78 | "source": [
79 | "#####Works consulted\n",
80 | "\n",
81 | "\"Conservation Vs Non-conservation Forms of Conservation Equations.\" Fluid Dynamics. N.p., n.d. Web. 17 July 2014. .\n",
82 | "\n",
83 | "LeVeque, Randall J. \"Chapter 12.\" Numerical Methods for Conservation Laws. Basel: Birkha\u0308user Verlag, 1992. N. pag. Print."
84 | ]
85 | },
86 | {
87 | "cell_type": "raw",
88 | "metadata": {},
89 | "source": [
90 | "Please ignore the cell below, it just loads a stylesheet for rendering the notebook."
91 | ]
92 | },
93 | {
94 | "cell_type": "code",
95 | "collapsed": false,
96 | "input": [
97 | "from IPython.core.display import HTML\n",
98 | "def css_styling():\n",
99 | " styles = open(\"../styles/custom.css\", \"r\").read()\n",
100 | " return HTML(styles)\n",
101 | "css_styling()"
102 | ],
103 | "language": "python",
104 | "metadata": {},
105 | "outputs": [
106 | {
107 | "html": [
108 | "\n",
109 | "\n",
110 | "\n",
111 | "\n",
176 | "\n"
191 | ],
192 | "metadata": {},
193 | "output_type": "pyout",
194 | "prompt_number": 1,
195 | "text": [
196 | ""
197 | ]
198 | }
199 | ],
200 | "prompt_number": 1
201 | }
202 | ],
203 | "metadata": {}
204 | }
205 | ]
206 | }
--------------------------------------------------------------------------------