เป็น ∂ มาให้ แล้วต้องการ u
Numerical method for solving Partial Differential Equations (PDE)
Notations
ut=∂t∂u - partial derivative with respect to time
uxy=∂y∂(∂x∂u) - second-order mixed partial derivative (x first แล้วค่อย y)
Analogy: Think of ut as measuring how fast something changes over time, and uxy as measuring how the rate of change in the x direction varies as you move in the y direction.
Important PDEs in Practical Applications
Heat Equation
ut=uxx
Describes heat diffusion in one spatial dimension
Models how temperature spreads through a material over time
Wave Equation
utt=uxx
Describes wave propagation in one spatial dimension
Models vibrations, sound waves, or string oscillations
Laplace Equation
uxx+uyy=0
Describes steady-state phenomena in two spatial dimensions
Models equilibrium temperature distribution, electric potential, etc.
Important Note: Many second-order linear PDEs can be transformed into one of the above three equations (plus terms of lower order).
The Heat Equation (Detailed)
General Form
The heat equation in one space dimension: ut=cuxx,0≤x≤L,t≥0
where c is a positive constant.
t คือเวลานะ, x คือ position
Initial Condition
u(0,x)=f(x),0≤x≤L
Specifies the initial temperature distribution at time t=0
Boundary Conditions
u(t,0)=α,u(t,L)=β,t≥0
Specifies the temperature at both ends of the domain for all time
The initial temperature distribution is given by f(x)
Analogy: Imagine a metal rod where you heat one end and cool the other. The heat equation tells you how the temperature at each point along the rod changes over time, eventually reaching a steady state.
Initial-Boundary Value Problem for PDE in One Space Dimension
Problem Domain Visualization
Horizontal axis (x): Space from 0 to L
Vertical axis (t): Time from 0 upward
Bottom edge: Initial values (at t=0)
Left edge: Boundary values at x=0
Right edge: Boundary values at x=L
Interior region: Problem domain where solution must be found
Analogy: Think of this as a rectangular plot where the bottom row shows the starting condition, and the left and right columns show what's happening at the boundaries. You need to fill in all the interior points.
The Wave Equation (Detailed)
General Form
The wave equation in one space dimension: utt=cuxx,0≤x≤L,t≥0
where c is a positive constant.
Initial Conditions
u(0,x)=f(x),ut(0,x)=g(x),0≤x≤L
f(x): initial position/profile
g(x): initial velocity
Boundary Conditions
u(t,0)=α,u(t,L)=β,t≥0
Physical Example
Models vibrations of a violin string of length L
Initial profile given by f(x)
Initial velocity given by g(x)
Ends are anchored (fixed) by the boundary conditions
Analogy: Picture a guitar string. f(x) is how you pull it initially, and g(x) is how fast different parts are moving when you release it. The wave equation predicts how the string will vibrate over time.
The Laplace Equation
Method ในการ solve
We don’t have time (t) anymore, but we have 2D space (x,y)
General Form
The Laplace equation in two space dimensions: uxx+uyy=0
Boundary conditions can be defined in many different ways
Often used for steady-state problems (no time dependence)
Analogy: Think of a rubber membrane stretched over a frame. The Laplace equation describes the equilibrium shape of the membrane, where it's not moving anymore.
Time-Dependent Problems
Definition
Time-dependent PDEs: PDEs that have derivatives with respect to t and come with initial conditions
Examples: Heat equation, Wave equation
Not time-dependent: Laplace equation (no t derivative, no initial conditions)
Introduce spatial mesh points: xi=iΔx for i=0,…,n+1
Where Δx=n+11
Replace uxx with finite difference approximation: uxx(t,xi)≈(Δx)2u(t,xi+1)−2u(t,xi)+u(t,xi−1)
for i=1,…,n
Resulting system of ODEs: yi′(t)=(Δx)2c(yi+1(t)−2yi(t)+yi−1(t))
for i=1,…,n
where yi(t)≈u(t,xi)
Boundary conditions: y0(t)=yn+1(t)=0 for all t
Initial conditions: yi(0)=f(xi) for i=1,…,n
Result: This is an initial value problem for a system of coupled first-order ODEs (RK ก็ได้)
Method of Lines
Use an ODE solver to solve the initial value problem for this system
This approach is known as the method of lines
The resulting ODEs are usually very stiff → choose an appropriate ODE method (e.g., implicit methods)
Analogy: Instead of tracking temperature at every point along the rod (infinite points), we only track it at a finite number of points. The PDE becomes a system of ODEs, one equation for each point showing how its temperature changes based on its neighbors.
Example 1: Method of Lines
Problem Setup
ut=2uxx,0≤x≤1,t≥0
Initial condition: u(0,x)=41−(x−21)2,0≤x≤1
Boundary conditions: u(t,0)=0,u(t,1)=0,t≥0
Using n=3 interior spatial mesh points.
Solution Steps
Calculate Δx: Δx=3+11=41
Mesh points:
x0=0, x1=1/4, x2=1/2, x3=3/4, x4=1
Calculate coefficient: (Δx)2c=(1/4)22=32
System of ODEs: y1′(t)=32(y2(t)−2y1(t)+y0(t))=32(y2(t)−2y1(t)) y2′(t)=32(y3(t)−2y2(t)+y1(t)) y3′(t)=32(y4(t)−2y3(t)+y2(t))=32(−2y3(t)+y2(t))
This is a recurrence relation that can be used iteratively.
Initial and Boundary Conditions
Initial conditions: ui0=f(xi) for i=1,…,n
Boundary conditions: u0k=α and un+1k=β for all k
Analogy: Imagine a grid where each point represents temperature at a specific location and time. Starting from the initial temperature distribution (bottom row), you calculate the temperature at each point in the next time step based on its current value and its neighbors' values.
Example 2: Fully Discrete Method
Problem Setup
Same heat equation as Example 1:
ut=2uxx,0≤x≤1,t≥0
Initial condition: u(0,x)=41−(x−21)2,0≤x≤1
Boundary conditions: u(t,0)=0,u(t,1)=0,t≥0
Using n=3 interior spatial mesh points and Δt=0.25.
Continue for subsequent time steps using the same formula...
Warning: Notice the negative values appearing! This suggests the method may be unstable with these parameters. This is a common issue with explicit methods for PDEs.
Properties of the Fully Discrete Method
Accuracy
Local truncation error: O(Δt)+O((Δx)2)
First-order accurate in time
Second-order accurate in space
Scheme Type
This time-stepping scheme is explicit
We have a direct formula for obtaining the next point
No need to solve any equations at each time step
Stability Concerns
Explicit methods for parabolic PDEs (like heat equation) often have stability restrictions
Typically require Δt≤C(Δx)2 for some constant C
If this condition is violated, the solution may become unstable (oscillate wildly or blow up)
Analogy: An explicit method is like a recipe where you can compute each step directly. An implicit method (not shown here) would require solving a system of equations at each time step, like solving a puzzle, but it's often more stable.
Summary
Key Concepts
PDEs vs ODEs: PDEs involve multiple independent variables (space + time), while ODEs involve only one (usually time)
Three Important PDEs:
Heat equation: diffusion processes
Wave equation: oscillatory phenomena
Laplace equation: steady-state problems
Numerical Approaches:
Semidiscrete: Discretize space, keep time continuous → system of ODEs
Fully discrete: Discretize both space and time → algebraic equations
Method of Lines: Convert PDE to ODE system, then use ODE solvers
Explicit vs Implicit:
Explicit: Direct computation, but may have stability restrictions
Implicit: Requires solving equations, but often more stable
Accuracy: Track truncation errors in both space and time separately
Centered Difference for Second Derivative: uxx(t,xi)≈(Δx)2u(t,xi+1)−2u(t,xi)+u(t,xi−1)
Stencil Diagrams
Page 22: Stencil showing the computational pattern for the explicit finite difference scheme for the heat equation.
Shows three time levels: k−1, k, and k+1
Shows three spatial points: i−1, i, and i+1
The point at (k+1,i) depends on three points from time level k
Analogy: Think of a stencil as a template showing which neighboring points you need to calculate the next value. Like a cookie cutter pattern - it shows exactly which ingredients (neighboring values) go into making the next cookie (next value).
Analogy: The wave equation is like tracking the motion of a vibrating string. You need to know both where the string is initially (f(x)) and how fast it's moving (g(x)). To start the numerical scheme, you use the initial velocity to estimate where the string will be after the first tiny time step.
Page 26: Stencil showing the computational pattern for the explicit finite difference scheme for the wave equation.
Shows three time levels: k−1, k, and k+1
Shows three spatial points: i−1, i, and i+1
The point at (k+1,i) depends on five points: three from level k and two from level k−1
Example 3: Wave Equation with Fully Discrete Method
Problem Setup
utt=5uxx,0≤x≤1,t≥0
Initial conditions: u(0,x)=1−x,ut(0,x)=x2,0≤x≤1
Boundary conditions: u(t,0)=1,u(t,1)=0,t≥0
Using n=4 interior spatial mesh points and Δt=0.1.
Note: The calculation seems to have an error in the PDF. It should be: c(ΔxΔt)2=5(1/50.1)2=5(0.20.1)2=5(0.5)2=1.25
Interior points:
u12=2u11−u10+(1.25)(u21−2u11+u01) =2(0.804)−54+(1.25)(0.616−2(0.804)+1)=0.818 u22=2u21−u20+(1.25)(u31−2u21+u11) =2(0.616)−53+(1.25)(0.436−2(0.616)+0.804)=0.642 u32=2u31−u30+(1.25)(u41−2u31+u21) =2(0.436)−52+(1.25)(0.264−2(0.436)+0.616)=0.482 u_4^2 = 2u_4^1 - u_4^0 + (1.25)(u_5^1 - 2u_4^1 + u_3^1)$$$$= 2(0.264) - \frac{1}{5} + (1.25)(0 - 2(0.264) + 0.436) = 0.213
8. Continue for subsequent time steps using the same formula.
Comparison: Semidiscrete vs Fully Discrete Methods
Semidiscrete Methods
Even in semidiscrete methods, the time variable is ultimately discretized anyway by the ODE solver
The difference: we let the (possibly sophisticated) ODE solver choose appropriate step sizes that maintain stability and achieve desired accuracy
The solver may even change step sizes as needed (adaptive time stepping)
Fully Discrete Methods
The user must choose time step sizes explicitly
More direct control but requires more knowledge of stability constraints
Can be simpler to implement for basic problems
Connection to ODE Methods
Important observation: The fully discrete method for the heat equation is exactly Euler's method applied to equation (1) (the semidiscrete system of ODEs for the heat equation).
Stability Analysis for Heat Equation
Stability Condition for Explicit Scheme
By stability analysis, the explicit finite difference scheme for the heat equation requires:
Δt≤2c(Δx)2
for the scheme to be stable.
Analogy: This stability condition is like a speed limit. If you try to take too large a time step (go too fast) relative to your spatial grid spacing, the numerical solution will become unstable and blow up - like a car losing control at high speed on a bumpy road.
Important notes:
As Δx decreases (finer spatial mesh), Δt must decrease even faster (quadratically)
This can make explicit methods computationally expensive for fine grids
This motivates the use of implicit methods
Implicit Methods for the Heat Equation
Backward Euler Method
Applying the backward Euler method to equation (1) yields the implicit finite difference scheme:
uik+1=uik+c(Δx)2Δt(ui+1k+1−2uik+1+ui−1k+1)
for i=1,…,n.
Properties:
Unconditionally stable (no restriction on Δt)
Still only first-order accurate in time
Requires solving a linear system at each time step
Page 35: Stencil showing the backward Euler method applied to the heat equation.
Shows points at time levels k and k+1
The point at (k+1,i) depends on three points from level k+1 (horizontal line)
Implicit nature: need to solve for all points at level k+1 simultaneously
Crank-Nicolson Method
Applying the implicit trapezoid method to equation (1) yields the Crank-Nicolson method:
Requires solving a linear system at each time step
Computational Efficiency
For both backward Euler and Crank-Nicolson methods for the heat equation in one space dimension:
The linear system to be solved at each step is tridiagonal
Tridiagonal systems can be solved very efficiently in O(n) time
Therefore, these implicit methods are practical despite requiring system solves
Analogy: The Crank-Nicolson method is like averaging your estimate of tomorrow's temperature using both today's data and tomorrow's data. It's more accurate because it "looks both backward and forward" in time, unlike explicit methods that only look backward.
Page 37: Stencil showing the Crank-Nicolson method.
Shows points at time levels k−1, k, and k+1
The point at (k+1,i) depends on six points: three from level k+1 and three from level k
Symmetric pattern reflecting the averaging nature of the method
Time-Independent Problems
Key Differences from Time-Dependent Problems
Similar to ODE BVPs, the solution to time-independent PDEs depends on all of the boundary conditions
The approximate solution must be computed everywhere simultaneously
Cannot use step-by-step marching as in time-dependent PDEs
Results in solving a large system of equations
Analogy: Time-independent problems are like solving a jigsaw puzzle where every piece affects every other piece. You can't just build from left to right - you need to consider all the boundary constraints and fit everything together at once.
Finite Difference Methods for Time-Independent Problems
Main Idea
Define a discrete mesh of points within the problem domain
Replace the derivatives in the PDE by finite difference approximations
Solve the resulting system of equations for the approximate solutions at all mesh points simultaneously
A Finite Difference Method for the Laplace Equation
Problem Setup
Consider the Laplace equation on the unit square:
uxx+uyy=0,0≤x≤1,0≤y≤1
Page 40: Diagram showing the unit square with boundary conditions.
Top boundary (y=1): u=1
Left boundary (x=0): u=0
Right boundary (x=1): u=0
Bottom boundary (y=0): u=0
Mesh Definition
Page 41: Diagram showing the discrete mesh with interior and boundary points.
Interior grid points: (xi,yj)=(ih,jh),i,j=1,…,n
where n=2 and h=n+11=31.
Finite Difference Approximation
Let ui,j be an approximation to the true solution u(xi,yj).
Boundary values: ui,j where either i or j is 0 or n+1.
Replace second derivatives with second-order centered differences:
Analogy: This equation says that at equilibrium (steady state), the value at each interior point is the average of its four neighbors (up, down, left, right). Like a stretched rubber membrane - each point settles at the average height of its neighbors.
System of Equations
Writing out the four equations explicitly (for n=2, we have 4 interior points):