22.520 Numerical Methods for PDEs : Video 11: 1D Finite Difference Mappings Theory and Matlab February 15, 2015 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 1 Theory / 15
Idea So far, we ve only considered square and simple 1-D unit domains. What is domain is something other than a square/rectangle/unit line? What if finite difference is not aligned with x and y directions? What if the nodes are along a curved line? So far, the nodes have been equally spaced. What about refining locally to get better answers? How to we setup finite differences with varying node refinement? 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 2 Theory / 15
Idea Define a mapping, T, between a computational and physical domain. Can be mathematical or numerical (computational physical) Transform governing equation from the physical computational. Solve the PDE on the computational domain Map the computational results to the physical domain. 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 3 Theory / 15
Let s use the 1-D string example: Let s define the physical and computational domains Computational: Define computational domain: ξ = (0, 1). Define the physical space as follows: The real string is 4 units long. The real string is refined at sides. x(ξ) = 2cos(πξ) 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 4 Theory / 15
We d like to solve: 2 u(x(ξ)) = 2 u x 2 = f on the computational domain rather than physical domain. To do this, we need to recognize that: u(x) = u(x(ξ)) Goal: what is the equivalent equation to solve on the computational domain. ie. What equation can we solve in ξ domain and get the answer? 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 5 Theory / 15
Let s start by expressing ( ) x in the computational domain. The goal is to find the derivatives w.r.t. ξ rather than x. This way, we can perform finite differences w.r.t. ξ. Taking the first derivative: Similarly, we can write: ( ) x = ( ) dξ ξ dx ( ) ξ = ( ) dx x dξ 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 6 Theory / 15
So, the first derivative is: (u) x = (u) dξ ξ dx Now, let s try the second derivative: ( ) 2 u (u) x 2 = x = x ( ) (u) x dξ ξ dx = f Substituting in the first derivative result from above: 2 u x 2 = dξ ( u dx ξ ξ dξ ) = f dx 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 7 Theory / 15
Now, we need to apply the chain rule: 2 u x 2 = dξ ( u dx ξ ξ Continuing by simplification: Continuing: 2 u x 2 = ( ) dξ 2 dx ξ ) dξ dx + dξ u dx ξ ( ) u + dξ u ξ dx ξ 2 u x 2 = 1 2 u ) 2 ξ 2 1 ( dx dξ ( dx dξ ξ ( ) dξ = f dx ( ) 1 = f ξ dx dξ ) 3 2 x ξ 2 u ξ = f 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 8 Theory / 15
Using J to represent the Jacobian of the mapping, J = dx dξ, the equation is : 2 u x 2 = 1 2 u J 2 ξ 2 1 2 x u J 3 ξ 2 ξ = f The result is an equivalent equation in the computational domain as that which must be satisfied in the physical domain. The components in blue are those corresponding to the geometry. Those in red correspond to the derivative of the solution in the computational domain. 22.520 Numerical Methods for PDEs : Video 11: 1D FiniteFebruary Difference 15, Mappings 2015 9 Theory / 15
To implement the equation in a finite difference solution method in the computational domain: 2 u x 2 = 1 J 2 2 u ξ 2 1 J 3 2 x ξ 2 u ξ = f Substitute the second order, central difference equations for the first and second derivatives: ( 2 ) u x 2 = 1 ( ) ui 1 2u i + u i+1 J 2 ξ 2 1 2 ( ) x ui+1 u i 1 J 3 ξ 2 = f i 2 x Now, all that s left is to construct the matrices. 22.520 Numerical Methods for PDEs : Video 11: 1D Finite February Difference 15, Mappings 2015 10 Theory / 15
Let s generalize for a given row i of the matrix: ( 2 ) u x 2 = 1 ( ) ui 1 2u i + u i+1 J 2 ξ 2 1 2 ( ) x ui+1 u i 1 J 3 ξ 2 = f i = 1 2 x The A-Matrix entries are: ( ) 1 1 A(row i, column i ) = 2 J 2 ξ 2 ( ) 1 1 A(row i, column i + 1) = 1 J 2 ξ 2 1 J 3 2 x ( ) 1 1 A(row i, column i 1) = 1 J 2 ξ 2 + 1 J 3 2 x ξ 2 f (row i ) = 1 ( 1 ξ 2 ) 2 ξ ) ( 1 2 ξ 22.520 Numerical Methods for PDEs : Video 11: 1D Finite February Difference 15, Mappings 2015 11 Theory / 15
For our example: 2 u(x(ξ)) = f x = 2cos(πξ) The mapping coefficients can be analytically computed: dx dξ = 2π sin(πξ) d 2 x dξ 2 = 2π 2 cos(πξ) Alternatively, if we only had the points in the physical domain (ie. not provided with an analytical mapping), we could simply use finite difference formulae to calculate the derivatives, e.g.: dx dξ = x i+1 x i 1 2 ξ 22.520 Numerical Methods for PDEs : Video 11: 1D Finite February Difference 15, Mappings 2015 12 Theory / 15
1-D string example solution (computational vs. physical): 22.520 Numerical Methods for PDEs : Video 11: 1D Finite February Difference 15, Mappings 2015 13 Theory / 15
Let s check our infinity-norm convergence (max error) : The convergence is second order (i.e., the solution converges as expected) 22.520 Numerical Methods for PDEs : Video 11: 1D Finite February Difference 15, Mappings 2015 14 Theory / 15
What have we learned? We can transform an equation from a tricky physical domain to a simpler reference computational domain. We need to develop a new governing equation for the computational domain that represents the physical domain equation but on a uniform grid/spacing. Once we have the mapping & new equation, the solution to the finite difference problem is identical to what was done before. The mapping can be computed numerically or analytically (depending on complexity). 22.520 Numerical Methods for PDEs : Video 11: 1D Finite February Difference 15, Mappings 2015 15 Theory / 15