diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2025-09-18 16:41:51 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2025-09-18 16:41:51 -0600 |
| commit | ab2b98a153216af10fa71f909a346bcc83533551 (patch) | |
| tree | 7a3800e69333d7d0d528e22e453f02dd53bc2990 /tutorials/module_3 | |
| parent | b7e71424dfde2ad56c4d8baaa2350e64a0f085a7 (diff) | |
Added PDE tutorial
Diffstat (limited to 'tutorials/module_3')
| -rw-r--r-- | tutorials/module_3/2_roots_optimization.md | 2 | ||||
| -rw-r--r-- | tutorials/module_3/5_ode.md | 28 | ||||
| -rw-r--r-- | tutorials/module_3/6_pde.md | 92 | ||||
| -rw-r--r-- | tutorials/module_3/control_volume_approach.png | bin | 0 -> 30804 bytes |
4 files changed, 117 insertions, 5 deletions
diff --git a/tutorials/module_3/2_roots_optimization.md b/tutorials/module_3/2_roots_optimization.md index 5023636..ee8f8c6 100644 --- a/tutorials/module_3/2_roots_optimization.md +++ b/tutorials/module_3/2_roots_optimization.md @@ -1,4 +1,4 @@ - # Root Finding Methods +# Root Finding Methods By now you've learned the quadratic formula to find the roots of a second degree polynomial. $$ diff --git a/tutorials/module_3/5_ode.md b/tutorials/module_3/5_ode.md index acb0cff..b5d5e99 100644 --- a/tutorials/module_3/5_ode.md +++ b/tutorials/module_3/5_ode.md @@ -17,7 +17,13 @@ where $f(t,y)$ describes the rate of change of $y$ with respect to time $t$. # Explicit Methods ## Euler's Method - +<img + style="display: block; + margin-left: auto; + margin-right: auto; + width: 50%;" + src="fw_eulers.png" + alt="Forward Eulers"> Eulers method or more specifically Forwards Eulers method is one of the simplest methods for solving ODE's. The idea of the Forward Euler method is to approximate the solution curve by taking small time steps, each step moving forward along the tangent given by the slope $f(t,y)$. At each step, the method updates the solution using the formula $$ y_{n+1} = y_n + h f(t_n, y_n) @@ -59,7 +65,14 @@ plt.show() Although Forward Euler’s method is easy to implement and provides insight into how numerical integration works, it is not very accurate for larger step sizes and can become unstable for certain types of problems, especially stiff ODEs. Its accuracy is **first-order**, meaning the local error per step scales with $h^2$, and the global error across an interval scales with $h$. Because of this, Forward Euler is often used as a starting point for understanding numerical ODE solvers and as a baseline for comparing more advanced methods like Heun’s method or Runge–Kutta. ## Heun's Method - +<img + style="display: block; + margin-left: auto; + margin-right: auto; + width: 40%;" + src="https://upload.wikimedia.org/wikipedia/commons/c/ce/Karl_Heun.jpg" + alt="Karl Heun"> + Heun’s method introduced by German Mathematician Karl Heun is a refinement of the Forward Euler method. Like Euler’s method, it starts from the initial value problem $$ \frac{dy}{dt} = f(t, y), \quad y(t_0) = y_0 @@ -69,8 +82,13 @@ $$ y_{n+1} = y_n + \frac{h}{2}\big[f(t_n, y_n) + f(t_{n+1}, y_n + h f(t_n, y_n))\big] $$ This averaging of slopes makes the method **second-order accurate**, which means its global error decreases proportionally to $h^2$ rather than just $h$, as in Forward Euler. - - +<img + style="display: block; + margin-left: auto; + margin-right: auto; + width: 50%;" + src="heuns_method.png" + alt="Heun's Method"> In practice, Heun’s method provides a significant improvement in accuracy without adding much computational cost. It still only requires evaluating the function $f(t,y)$ twice per step, making it more efficient than higher-order methods like Runge–Kutta while being more stable and reliable than Forward Euler. ## Classical Runge-Kutta Also known as the **classical fourth-order Runge–Kutta (RK4)** method. It takes four slope evaluations per step: one at the beginning, two at intermediate points, and one at the end of the step. These slopes are then combined in a weighted average to update the solution. RK4 is accurate to **fourth order**, meaning the global error scales as $h^4$, which is far more accurate than Euler or Heun for the same step size. In practice, this makes RK4 the “workhorse” of many ODE solvers where stability and accuracy are needed but the system is not excessively stiff. @@ -78,7 +96,9 @@ Also known as the **classical fourth-order Runge–Kutta (RK4)** method. It take **SciPy’s `solve_ivp`**, build on this idea with adaptive Runge–Kutta methods. For example, `RK45` is an adaptive solver that pairs a 4th-order method with a 5th-order method, comparing the two at each step to estimate the error. Based on this estimate, the solver adjusts the step size automatically: smaller steps in regions where the solution changes quickly, and larger steps where the solution is smooth. This makes `RK45` both efficient and robust, giving you the accuracy benefits of Runge–Kutta methods while also taking away the burden of manually choosing an appropriate step size. ## Problem 1: Exponential decay + ## Problem 2: The Predator-Pray Model + ## Problem 3: Swinging Pendulum diff --git a/tutorials/module_3/6_pde.md b/tutorials/module_3/6_pde.md index 8b13789..332852e 100644 --- a/tutorials/module_3/6_pde.md +++ b/tutorials/module_3/6_pde.md @@ -1 +1,93 @@ +# Partial Differential Equation + +## Finite Difference +### Elliptic Equations +- Used for steady-state, boundary value problems + + +Description of how the Laplace equations works +$$ +\frac{\partial^2T}{\partial x^2}+\frac{\partial^2T}{\partial y^2}=0 +$$ + +Finite-different solutions +- Laplacian Difference equation +$$ +\frac{\partial^2T}{\partial x^2}= \frac{T_{i+1,j}-2T_{i,j}+T_{i-1,j}}{\Delta x^2} +$$ +and +$$ +\frac{\partial^2T}{\partial y^2}= \frac{T_{i+1,j}-2T_{i,j}+T_{i-1,j}}{\Delta y^2} +$$ + +Boundary Conditions + + +Control-Volume approach +<img + style="display: block; + margin-left: auto; + margin-right: auto; + width: 50%;" + src="control_volume_approach.png" + alt="Two Different perspsectives for developing approximate solutions of PDE: (a) finite-difference or node and (b) control-volume based"> +Computer Algorithms + +### Parabolic Equations +- Used for unstead-state, initial + boundary conditions problems +For parabolic PDE equations we also consider the change in time as well as space. + +Heat-conduction equation +Explanation of heat equation +$$ +k\frac{\partial^2T}{\partial x^2}=\frac{\partial T}{\partial t} +$$ + +Explicit methods + +Simple Implicit methods +Crank-Nicolson +ADI + + +### Hyperbolic Equations +MacCormack Method + + +## Finite-Element Method +General Approach +### One-dimensional analysis + +### Two-dimensional Analysis + + + + + + + + + + + + + + + + + +# Problem 1: Finite-Element Solution of a Series of Springs + +Problem 32.4 from Numerical Methods for Engineers 7th Edition Steven C. Chapra and Raymond P. Canale + +A series of interconnected strings are connected to a fixed wall where the other is subject to a constant force F. Using the step-by-step procedure from above, dertermine the displacement of the springs. + + + + + + +## Problem 2: Finite + +Solve the non-dimensional transient heat conduction equation in two dimensions, which represents the transient temperature distribution in an insulated plate diff --git a/tutorials/module_3/control_volume_approach.png b/tutorials/module_3/control_volume_approach.png Binary files differnew file mode 100644 index 0000000..caa3478 --- /dev/null +++ b/tutorials/module_3/control_volume_approach.png |
