3_num_calculus
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||
Harvard Applied Math 205: Code Examples Unit 3: Numerical Calculus ========================== quadrat.py - Integrates a function using composite trapezoid and Simpson's rules. Outputs the error as a function of the interval length h. diff.py - Constructs a differentiation matrix, and uses it to calculate the derivative of a test function. l-v.py - Demonstrates Python's black box integration routine odeint in the scipy.integrate module. Solves the two-component Lotka–Volterra model for predator–prey interactions. euler.py - Demonstrates the simple first-order forward Euler method for integrating an ordinary differential equation. e_stab.py - Tests the stability of the choice of timestep in the forward Euler method order2.py - Demonstrates three different second-order time-integration schemes: the modified Euler method, the improved Euler method, and Ralston's method. r_extrap.py - Demonstrates applying Richardson extrapolation to the forward Euler method, to achieve a new method of second order. r_extrap2.py - Demonstrates applying Richardson extrapolation twice to the forward Euler method, to achieve a new method of third order. stiff.py - Solves a two-component differential equation that has one stiff mode. It uses an explict scheme and an implicit scheme. The explicit scheme has a very strict timestep restriction, while the implicit scheme is unconditionally stable. stiff2.py - Demonstrates using Python's black-box stiff solver for the same two-component differential equation from stiff.py. ad-bash.py - Solves a differential equation using a second-order Adams-Bashforth multi-step scheme. ode_bvp.py - Solves an ODE boundary value problem by formulating it as a linear system using finite differences. transp.py - Solves the linear advection equation using a first-order scheme with an upwinded one-sided derivative. transp2.py - Solves the linear advection equation where the spatial derivative is calculated using a second-order centered-difference scheme. This scheme is slightly unstable, which becomes apparant after many timesteps have been performed. m_of_lines.py - Demonstrates the method of lines for the linear advection equation, whereby the spatial grid is discretized but the system is time-integrated using a black-box ODE integration routine. heat.py - Solves the heat equation on a periodic unit interval using an explicit finite difference scheme. c-n.py - Solves the heat equation using the Crank-Nicolson method, which is second-order in space and time, and unconditionally stable. poisson.py - Solves the two-dimensional Poisson equation using a linear solve of a finite-difference discretization.