Section6.41D and 2D Steady State PDEs (Elliptic PDEs)
Consider a 1-dimensional rod that is infinitely thin and has unit length. For the sake of simplicity assume the following:
the specific heat of the rod is exactly 1 for the entire length of the rod,
the temperature of the left end is held fixed at \(u(0) = 1\),
the temperature of the right end is held fixed at \(u(1) = 0\), and
the temperature has reached a steady state.
(assume that the temperatures are reference temperatures instead of absolute temperatures).
Since there are no external sources of heat we model the steady-state heat profile with Laplace's equation <<Unresolved xref, reference "eqn_laplace"; check spelling or use "provisional" attribute>>. Write this equation in terms of 1-dimensional spatial derivatives and solve for the temperature profile by hand.
Devise a way to approximate the temperature profile from the previous problem numerically. Recall that we already know how to build numerical second derivatives. Your method will eventually involve solving a system of linear equations.
Now we will solve the steady state temperature profile problem assuming that there is an external source of heat. This means that we need to solve the 1D Poisson equation <<Unresolved xref, reference "eqn_poisson"; check spelling or use "provisional" attribute>>. Take \(f(x) = 5\sin(2 \pi x)\), \(u(0) = 2\) and \(u(1) = 0.5\). \begin{equation*} \text{ Solve: } u_{xx} = -5\sin(2\pi x) \text{ on } x \in (0,1) \text{ with } u(0)=2 \text{ and } u(1) = 0.5 \end{equation*}
First do so by discretizing the domain with very few points so we can write the system of equations by hand. Write your code with the number of points as a parameter so you can later change it to several hundred points.
Generalize the previous problem with a MATLAB function that solves the 1D Poisson boundary valued equation: \begin{equation*} \text{ Solve: } u_{xx} = - f(x) \text{ on } x \in (x_0,x_n) \text{ with } u(x_0) = \alpha \text{ and } u(x_n) = \beta. \end{equation*}
function [x,u] = Poisson1D(f, xmin, xmax, num_interior_pts, BCleft, BCright)
Test your code with a known function \(f(x)\).
Note: when we are using fixed values for the boundary conditions these are called “Dirichlet boundary conditions.”
The previous problems only account for Dirichlet boundary conditions (fixed boundary conditions). We would now like to modify our Poisson solution to allow for a Neumann condition: where we know the derivative of \(u\) at one of the boundaries. The statement of the problem is as follows: \begin{equation*} \text{ Solve: } u_{xx} = - f(x) \text{ on } x \in (x_0,x_n) \text{ with } \frac{du}{dx}\Big|_{x_0} = \alpha \text{ and } u(x_n) = \beta. \end{equation*}
Write a function to solve this problem:
function [x,u] = Poisson1D_Neumann(f, xmin, xmax, num_interior_pts, NBC, DBC)
Write a MATLAB script to solve the Neumann problem with \(f(x) = 2e^{-0.1x}\), \(u'(0)=0\), and \(u(1)=0\).
Now let's ramp up our discussion of the Poisson equation to two spatial dimensions. Consider the domain \(\Omega=(0,1)\times (0,1)\) with Dirichlet boundary conditions. With the help of your instructor, write code to solve the 2D Dirichlet problem \begin{equation*} \text{ Solve: } \nabla \cdot \nabla u = - f(x) \text{ in } x \in \Omega \text{ with } f(x,y) = 20\text{ exp } \left( -\frac{(x-0.5)^2 + (y-0.5)^2}{0.05} \right) \end{equation*} subject to the boundary conditions: \begin{align*} u(x,1) \amp = \sin(2\pi x)\\ u(x,0) \amp = \sin(2\pi x)\\ u(0,y) \amp = 0\\ u(1,y) \amp = 0 \end{align*}