{ "metadata": { "name": "", "signature": "sha256:c334619ad18feb0b04faa57eab495e48215ad6b014d4ab8c09697baee5c35f56" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Multigrid Lecture and Homework Example" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Aron Ahmadia (US Army ERDC) and David Ketcheson (KAUST)" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Teaching Numerical Methods with IPython Notebooks, SciPy 2014" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\"Creative
This example by Aron Ahmadia and David Ketcheson is licensed under a Creative Commons Attribution 4.0 International License. All code examples are also licensed under the [MIT license](http://opensource.org/licenses/MIT)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.core.display import HTML\n", "css_file = './example.css'\n", "HTML(open(css_file, \"r\").read())" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 6, "text": [ "" ] } ], "prompt_number": 6 }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Multigrid\n", "\n", "Multigrid is one of the great algorithms for numerically solving PDEs. It is also one of the few essentially optimal algorithms for solving a linear system of equations, since it computes the solution of an $N\\times N$ system in ${\\mathcal O}(N\\log(N))$ -- or even just ${\\mathcal O}(N)$ -- operations. \n", "\n", "This notebook is meant to accompany a reading of [Section 4.6 of Randall LeVeque's text on finite difference methods](http://0-epubs.siam.org.library.kaust.edu.sa/doi/abs/10.1137/1.9780898717839.ch4). Other good resources are cited there." ] }, { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from matplotlib import animation\n", "from clawpack.visclaw.JSAnimation import IPython_display" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A two-point boundary value problem\n", "Let's use Jacobi's method to solve the one-dimensional boundary value problem \n", "\n", "\\begin{align}\n", "u''(x) & = f(x) & 0