├── .gitignore ├── README.md ├── lecture_notes ├── lecture_1.pdf ├── lecture_10.pdf ├── lecture_11.pdf ├── lecture_12.pdf ├── lecture_13.pdf ├── lecture_14.pdf ├── lecture_15.pdf ├── lecture_16.pdf ├── lecture_17.pdf ├── lecture_18.pdf ├── lecture_19.pdf ├── lecture_2.pdf ├── lecture_21.pdf ├── lecture_22.pdf ├── lecture_23.pdf ├── lecture_3.pdf ├── lecture_4.pdf ├── lecture_5.pdf ├── lecture_6.pdf ├── lecture_7.pdf ├── lecture_8.pdf └── lecture_9.pdf ├── midterm └── midterm_soln.pdf ├── problem_sets ├── hw1.ipynb ├── hw1.pdf ├── hw1_soln.ipynb ├── hw1_soln.pdf ├── hw2.pdf ├── hw2_soln.pdf ├── hw3.pdf ├── hw3_soln.ipynb ├── hw3_soln.pdf ├── hw4.ipynb └── hw4.pdf └── supp_material ├── fd_stability.ipynb ├── linear_algebra_with_functions.pdf ├── poissonFD.ipynb └── practice_midterm.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | problem_sets/.ipynb_checkpoints/pset1-checkpoint.ipynb 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 18.303: Linear Partial Differential Equations: Analysis and Numerics 2 | 3 | This is the main repository of course materials for 18.303 at MIT, taught by Dr. Andrew Horning, in Fall 2023. The syllabus is attached in the README below. Lecture notes, problem sets, exams, and supplementary materials will be posted in the repo directory. 4 | 5 | > **Course description** 6 | > 7 | > _Provides students with the basic analytical and computational tools of linear partial differential equations (PDEs) for practical applications in science engineering, including heat/diffusion, wave, and Poisson equations. Analytics emphasize the viewpoint of linear algebra and the analogy with finite matrix problems. Studies operator adjoints and eigenproblems, series solutions, Green's functions, and separation of variables. Numerics focus on finite-difference and finite-element techniques to reduce PDEs to matrix problems, including stability and convergence analysis and implicit/explicit timestepping. Some programming required for homework and final project._ 8 | > 9 | > Prerequisite: linear algebra ([18.06](http://web.mit.edu/18.06), 18.700, or equivalent). 10 | 11 | ## Syllabus 12 | 13 | **Lectures**: MW 11:00 am - 12:30 pm in Room 2-142. 14 | 15 | **Office Hours:** 4pm on Tuesday and Wednesday in Room 2-238C. 16 | 17 | **Grading**: 50% homework, 15% mid-term (November 8), 35% final project 18 | (due the last day of class). Problem sets are due in class on the due date. Missed 19 | midterms require a letter from Student Support Services or Student Disabilities 20 | Services to justify accommodations. Justifiable reasons for absence include sports, 21 | professional obligations, or illness. In the event of a justified absence, a make-up assignment will be provided. 22 | 23 | **Collaboration policy**: Set aside time to work on each problem independently before 24 | discussing it with classmates. Always write up the solution on 25 | your own and acknowledge your collaborators. 26 | 27 | **Books**: [Introduction to Partial Differential Equations](https://www-users.cse.umn.edu/~olver/pde.html) by Olver. 28 | 29 | **Final project**: Instead of a final exam, study a PDE and/or numerical 30 | solver not covered in class, and write a 5-10 page academic-style paper that 31 | includes: 32 | 33 | > *Review*: why is this PDE/method important, what is its history, and what are 34 | the important publications and references? (A comprehensive bibliography is 35 | expected: not just the sources you happened to consult, but a complete set of 36 | sources you would recommend that a reader consult to learn a fuller picture 37 | > 38 | > *Analysis*: what are the important general analytical properties? e.g. 39 | conservation laws, algebraic structure, nature of solutions (oscillatory, 40 | decaying, etc.). Analytical solution of a simple problem. 41 | > 42 | > *Numerics*: what numerical method do you use, and what are its convergence 43 | properties (and stability, for timestepping)? Implement the method (e.g. in 44 | Julia) and demonstrate results for some test problems. Validate your solution 45 | (show that it converges in some known case). 46 | 47 | You must submit a one-page proposal of your intended final-project topic (November 17), 48 | summarizing what you intend to do. Potential projects will be suggested as the course progresses. 49 | 50 | ## Assignments 51 | 52 | - [Homework 1](https://github.com/mitmath/18303/blob/master/problem_sets/hw1.pdf) is due at 10pm on Friday, September 22 ([Solutions](https://github.com/mitmath/18303/blob/master/problem_sets/hw1_soln.pdf)). 53 | - [Homework 2](https://github.com/mitmath/18303/blob/master/problem_sets/hw2.pdf) is due at 10pm on Friday, October 6 ([Solutions](https://github.com/mitmath/18303/blob/master/problem_sets/hw2_soln.pdf)). 54 | - [Homework 3](https://github.com/mitmath/18303/blob/master/problem_sets/hw3.pdf) is due at 10pm on Friday, October 27 ([Solutions](https://github.com/mitmath/18303/blob/master/problem_sets/hw3_soln.pdf)). 55 | - [Homework 4](https://github.com/mitmath/18303/blob/master/problem_sets/hw4.pdf) is due at 10pm on Friday, December 8. 56 | 57 | ## Tentative Schedule 58 | 59 | - Why study *linear* PDEs? 60 | - The "linear algebra" of taking derivatives 61 | - Optional: **Julia Tutorial** 62 | - Poisson's equation: diagonalizing a linear operator 63 | - Numerical approximation: global or local? 64 | - The heat equation: operator exponentials 65 | - Numerical approximations of operator exponentials 66 | - Convergence, stability, and conditioning 67 | - Wave equations: analysis and numerics 68 | - Higher dimensional PDEs and systems of PDEs 69 | - Generalized boundary conditions and well-posedness 70 | - Green's function and singular integral equations 71 | - Weak form and Galerkin's method 72 | - Finite Element Methods 73 | 74 | ## Lecture Summaries 75 | 76 | ### Lecture 1 77 | 78 | - What are linear partial differential equations (PDEs) and why should we solve them? 79 | - Example: the transport equation and its characteristic curves. 80 | 81 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_1.pdf) | Olver, Chapter 1 82 | 83 | ### Lecture 2 84 | 85 | - First-order linear PDEs. 86 | - Reduction to an ODE system: the method of characteristics. 87 | - Computation on a grid: finite differences. 88 | 89 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_2.pdf) | Olver, Chapter 2.1-2.2 90 | 91 | ### Lecture 3 92 | 93 | - Finite differences: approximation errors. 94 | - Time-stepping and spatial discretizations. 95 | - A linear algebraic roadmap for linear PDEs. 96 | 97 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_3.pdf) | Olver, Chapter 5.1 98 | 99 | ### Lecture 4 100 | 101 | - Function spaces and bases. 102 | - The nullspace of a differential operator. 103 | - Boundary conditions and invertibility. 104 | - Inner products, norms, and integrability. 105 | 106 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_4.pdf) | [Linear Algebra with Functions](https://github.com/mitmath/18303/blob/master/supp_material/linear_algebra_with_functions.pdf) 107 | 108 | 109 | ### Lecture 5 110 | 111 | - Diagonalizing differential operators. 112 | - Fourier's basis and its properties. 113 | - Poisson's equation: separation of variables. 114 | 115 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_5.pdf) | Olver, Chapter 3.2 116 | 117 | ### Lecture 6 118 | 119 | - Poisson's equation with homogeneous boundary conditions. 120 | - Enforcing homogeneous boundary conditions through a basis. 121 | - Enforcing inhomogeneous boundary conditions via nullspace. 122 | 123 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_6.pdf) | Olver, Chapter 4.3 124 | 125 | ### Lecture 7 126 | 127 | - Diagonalization in separable domains. 128 | - Laplace's equation in a disk. 129 | - Poisson's formula for the disk. 130 | 131 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_7.pdf) | Olver, Chapter 4.3 132 | 133 | ### Lecture 8 134 | 135 | - Maximum and minimum principles. 136 | - Finite differences in 2 dimensions. 137 | 138 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_8.pdf) | Olver, Chapter 4.3 | [poissonFD.ipynb](https://github.com/mitmath/18303/blob/master/supp_material/poissonFD.ipynb) 139 | 140 | ### Lecture 9 141 | 142 | - Kronecker products and the "vec" identity. 143 | - Finite difference discretizations on separable domains. 144 | - Fourier spectral discretizations on periodic domains. 145 | 146 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_9.pdf) 147 | 148 | ### Lecture 10 149 | 150 | - The heat equation and its derivation. 151 | - Boundary conditions and their physics. 152 | - Fourier series solution and the operator exponential. 153 | 154 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_10.pdf) | Olver, Chapter 4.1 155 | 156 | ### Lecture 11 157 | 158 | - Operator exponential for the heat equation. 159 | - Smoothness, asymptotics, and equilibrium solutions. 160 | - Homogeneous vs inhomogeneous boundary conditions. 161 | 162 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_11.pdf) | Olver, Chapter 4.1 163 | 164 | ### Lecture 12 165 | 166 | - Heat flow in a rod with temperature fixed at endpoints. 167 | - Heat flow in a disk with temperature prescribed on boundary. 168 | - Dirichlet eigenfunctions of the Laplacian in a disk. 169 | 170 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_12.pdf) | Olver, Chapter 4.1 171 | 172 | ### Lecture 13 173 | 174 | - Operator exponentials of self-adjoint operators. 175 | - Growth, decay, and conservation via eigenvalues. 176 | - Examples: transport (revisited) and a (quantum) particle-in-a-box. 177 | 178 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_13.pdf) 179 | 180 | ### Lecture 14 181 | 182 | - The wave equation on a periodic domain. 183 | - Operator 'exponential' for the wave equation. 184 | - Characteristics and causality for solutions. 185 | 186 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_14.pdf) | Olver, Chapter 4.2 187 | 188 | ### Lecture 15 189 | 190 | - Extracting d'Alembert's solution from the characteristics. 191 | - Causal domains and data. 192 | - Examples: traveling waves, standing waves, and a Gaussian velocity impulse. 193 | 194 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_15.pdf) | Olver, Chapter 2.4 195 | 196 | ### Lecture 16 197 | 198 | - Waves and reflections on bounded domains. 199 | - Dirichlet boundary conditions. 200 | - Neumann boundary conditions. 201 | 202 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_16.pdf) | Olver, Chapter 4.2 203 | 204 | ### Lecture 17 205 | 206 | - Finite-difference schemes for time-dependent PDE. 207 | - Forward Euler approximation of the heat equation. 208 | - Stability analysis for time-stepping schemes. 209 | 210 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_17.pdf) | Olver, Chapter 5.2 211 | 212 | ### Lecture 18 213 | 214 | - Explicit and implicit time-stepping schemes. 215 | - Stability analysis for transport equations. 216 | - Numerical diffusion. 217 | 218 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_18.pdf) | [Stable FD Notebook](https://github.com/mitmath/18303/blob/master/supp_material/fd_stability.ipynb) | Olver, Chapter 5.3 219 | 220 | ### Lecture 19 221 | 222 | - Roots of numerical diffusion. 223 | - Limitations of eigenvalue analysis (e.g., transport with a boundary). 224 | - Characteristics and the CFL condition. 225 | 226 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_19.pdf) | [Stable FD Notebook](https://github.com/mitmath/18303/blob/master/supp_material/fd_stability.ipynb) | Olver, Chapter 5.3 227 | 228 | ### Lecture 20 229 | 230 | - Finite difference approximations for the wave equation. 231 | - CFL condition for the wave equation. 232 | - Numerical approximations of the operator exponential. 233 | 234 | [Stable FD Notebook](https://github.com/mitmath/18303/blob/master/supp_material/fd_stability.ipynb) | Olver, Chapter 5.4 235 | 236 | ### Lecture 21 237 | 238 | - The "inverse" of a differential operator. 239 | - Dirac's delta function and Green's functions. 240 | - Green's function for the second derivative operator. 241 | 242 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_21.pdf) | Olver, Chapter 6.1 243 | 244 | ### Lecture 22 245 | 246 | - Physical interpretations of Green's functions. 247 | - Symmetry of Green's function for self-adjoint operator. 248 | - The delta function as a "distribution." 249 | 250 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_22.pdf) | Olver, Chapter 6.2 251 | 252 | ### Lecture 23 253 | 254 | - Distributions and their calculus. 255 | - Properties of the Green's function. 256 | - The Green's function for the Helmholtz operator. 257 | 258 | [Notes](https://github.com/mitmath/18303/blob/master/lecture_notes/lecture_23.pdf) | Olver, Chapter 6.2 259 | 260 | -------------------------------------------------------------------------------- /lecture_notes/lecture_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_1.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_10.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_11.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_12.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_12.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_13.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_13.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_14.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_14.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_15.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_15.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_16.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_16.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_17.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_17.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_18.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_18.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_19.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_19.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_2.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_21.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_21.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_22.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_22.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_23.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_23.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_3.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_4.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_5.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_6.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_7.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_8.pdf -------------------------------------------------------------------------------- /lecture_notes/lecture_9.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/lecture_notes/lecture_9.pdf -------------------------------------------------------------------------------- /midterm/midterm_soln.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/midterm/midterm_soln.pdf -------------------------------------------------------------------------------- /problem_sets/hw1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/problem_sets/hw1.pdf -------------------------------------------------------------------------------- /problem_sets/hw1_soln.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/problem_sets/hw1_soln.pdf -------------------------------------------------------------------------------- /problem_sets/hw2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/problem_sets/hw2.pdf -------------------------------------------------------------------------------- /problem_sets/hw2_soln.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/problem_sets/hw2_soln.pdf -------------------------------------------------------------------------------- /problem_sets/hw3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/problem_sets/hw3.pdf -------------------------------------------------------------------------------- /problem_sets/hw3_soln.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/problem_sets/hw3_soln.pdf -------------------------------------------------------------------------------- /problem_sets/hw4.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# 18.303 Homework 4 Solutions\n", 9 | "\n", 10 | "This notebook accompanies homework 4 on finite-difference schemes for time-dependent PDEs. Execute the following code to import some useful linear algebra and plotting utilities used below." 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "using LinearAlgebra\n", 20 | "using SparseArrays\n", 21 | "using Plots" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "### Transport Equation\n", 29 | "\n", 30 | "Build your second-order accurate finite-difference matrices for the spatial derivatives in your second-order transport scheme below. (**Hint:** you'll need approximations for both first and second derivatives.)\n", 31 | "\n", 32 | "Note that scaling factors like $1/(2\\Delta x)$ and $1/(\\Delta x)^2$ are incorporated into the stability factor $\\sigma$ in the time-stepping code below, so your difference matrices should just have simple integer entries." 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "metadata": {}, 39 | "outputs": [], 40 | "source": [ 41 | "## build differentiation matrix approximation d/dx\n", 42 | "function fdiff1(n)\n", 43 | " # your code goes here\n", 44 | " return D\n", 45 | "end\n", 46 | "\n", 47 | "# check your code with a 12 x 12 difference matrix\n", 48 | "fdiff1(12)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "## build differentiation matrix approximation d^2/dx^2\n", 58 | "function fdiff2(n)\n", 59 | " # your code goes here\n", 60 | " return D\n", 61 | "end\n", 62 | "\n", 63 | "# check your code with a 12 x 12 difference matrix\n", 64 | "fdiff2(12)" 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": {}, 70 | "source": [ 71 | "Fill in the time_step function below to implement your second-order time stepping scheme and simulate transport with the provided bimodal initial condition." 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "metadata": {}, 78 | "outputs": [], 79 | "source": [ 80 | "# computational grid = periodic interval [0, 1)\n", 81 | "n = 100\n", 82 | "Δx = 2/n\n", 83 | "xgrid = LinRange(-1,1-Δx,n)\n", 84 | "\n", 85 | "# second-order spatial discretizations\n", 86 | "D1 = fdiff1(n) # first partial derivative with respect to spatial variable\n", 87 | "D2 = fdiff2(n) # second partial derivative with respect to spatial variable\n", 88 | "c = 0.1 # wave speed\n", 89 | "\n", 90 | "# time stepping (step forward in time with time-step h_t using Forward Euler)\n", 91 | "Δt = 0.2 # time step\n", 92 | "σ = c * Δt / (Δx) # critical parameter for stability\n", 93 | "function time_step(D1, D2, u1, σ)\n", 94 | " # your time stepping scheme goes here\n", 95 | "end\n", 96 | "\n", 97 | "# initial condition\n", 98 | "u1 = 2*exp.(-10*cos.(pi*xgrid).^2)\n", 99 | "\n", 100 | "# time stepping gif\n", 101 | "anim = Animation()\n", 102 | "m = 200 # number of steps in time \n", 103 | "for k ∈ 1:m # animate solution\n", 104 | " plot(xgrid, u1, linecolor = :blue, legend = false)\n", 105 | " ylims!(0.0,6)\n", 106 | " u1 = time_step(D1, D2, u1, σ)\n", 107 | " frame(anim)\n", 108 | "end\n", 109 | "display(σ) # print out value of sigma to compare with 0.5 stability criterion\n", 110 | "gif(anim) # play movie of solution\n" 111 | ] 112 | }, 113 | { 114 | "cell_type": "markdown", 115 | "metadata": {}, 116 | "source": [ 117 | "### 2D Wave equation" 118 | ] 119 | }, 120 | { 121 | "cell_type": "markdown", 122 | "metadata": {}, 123 | "source": [ 124 | "Build your second-order accurate finite-difference matrix for the Laplacian on an $n\\times n$ computational grid on the unit square, $[-1,1]\\times[-1,1]$. Your code should produce an $n^2\\times n^2$ matrix that takes in an $n^2\\times 1$ vector of function values on the grid as input and produces an $n^2\\times 1$ vector of values of the approximate Laplacian of that function on the grid." 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": null, 130 | "metadata": {}, 131 | "outputs": [], 132 | "source": [ 133 | "## build n^2 x n^2 finite difference approximation of the Laplacian\n", 134 | "function fdiff2D(n)\n", 135 | " # your code goes here\n", 136 | " return D2\n", 137 | "end\n", 138 | "\n", 139 | "# Test out a 16 x 16 sample\n", 140 | "fdiff2D(10)" 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "Fill in the time_step function to implement your second-order time-stepping scheme for the wave equation on the unit square. Don't forget to fill in a second-order approximation to $u_1$ to get your scheme off to a good start." 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": null, 153 | "metadata": {}, 154 | "outputs": [], 155 | "source": [ 156 | "# computational grid = interval (0, 1)\n", 157 | "n = 50\n", 158 | "Δx = 2/n\n", 159 | "xgrid = LinRange(-1+Δx,1-Δx,n)\n", 160 | "\n", 161 | "# spatial discretization\n", 162 | "D = fdiff2D(n) # Laplacian with respect to spatial variables on 2D grid (vec'd)\n", 163 | "c = 1 # wave speed\n", 164 | "\n", 165 | "# time stepping (step forward in time with time-step h_t using Forward Euler)\n", 166 | "Δt = 0.02 # time step\n", 167 | "σ = c * Δt / Δx # critical parameter for stability\n", 168 | "function time_step(D,u0,ht)\n", 169 | " u2 = # your time-stepping scheme goes here! Check the 1D wave example in fd_stability.ipynb to compare implementation syntax/notation\n", 170 | " return [u2 u0[:,1]]\n", 171 | "end\n", 172 | "\n", 173 | "# initial condition (initial velocity = 0 for this example)\n", 174 | "g = 2*exp.(-15*xgrid.^2) # x component of initial condition\n", 175 | "u0 = vec(g*transpose(g)) # initial condition (symmetric Gaussian bump) on 2D grid (vec'd)\n", 176 | "u1 = # your second order approximation to u1 = u(x,t1) on 2D grid (vec'd) goes here\n", 177 | "\n", 178 | "# time stepping gif\n", 179 | "anim = Animation()\n", 180 | "m = 200 # number of steps in time \n", 181 | "for k ∈ 1:m # animate solution\n", 182 | " surface(xgrid, xgrid, reshape(u1[:,1],n,n), zlimits=(-2,2), legend = false)\n", 183 | " u1 = time_step(D,u1,Δt)\n", 184 | " frame(anim)\n", 185 | "end\n", 186 | "display(σ) # print out value of sigma to compare with 0.5 stability criterion\n", 187 | "gif(anim) # play movie of solution\n" 188 | ] 189 | } 190 | ], 191 | "metadata": { 192 | "@webio": { 193 | "lastCommId": null, 194 | "lastKernelId": null 195 | }, 196 | "kernelspec": { 197 | "display_name": "Julia 1.6.3", 198 | "language": "julia", 199 | "name": "julia-1.6" 200 | }, 201 | "language_info": { 202 | "file_extension": ".jl", 203 | "mimetype": "application/julia", 204 | "name": "julia", 205 | "version": "1.6.3" 206 | } 207 | }, 208 | "nbformat": 4, 209 | "nbformat_minor": 1 210 | } 211 | -------------------------------------------------------------------------------- /problem_sets/hw4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/problem_sets/hw4.pdf -------------------------------------------------------------------------------- /supp_material/linear_algebra_with_functions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/supp_material/linear_algebra_with_functions.pdf -------------------------------------------------------------------------------- /supp_material/practice_midterm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/18303/c599fb9d562609fd0d12afa80b4847b31cd755a3/supp_material/practice_midterm.pdf --------------------------------------------------------------------------------