Finite Differences for 1D Problems
Finite Difference Method (FDM) is the most basic numerical method to solve partial differential equations. This worksheet shows you how to solve a Poisson equation -u'' = f in 1D with Dirichlet and Neumann boundary conditions, and how to solve a time-dependent problem du/dt - ddu/dxx = f.
The following active input text box contains the main code. You need to click on it to see an "Evaluate" link appear at its bottom. Click on this link to have the code sent to our computer and interpreted. Then you can evaluate/modify/evaluate the examples in the other text boxes in the same way. Have fun and let us know at femhub@googlegroups.com with any problems or questions.
The Code:
|
|
Case 1
Equation -u'' = f with Dirichlet boundary conditions (solution values prescribed) at both interval endpoints.
|
Case 2
Equation -u'' = f with a Dirichlet boundary condition (solution value) on the left and Neumann boundary condition (solution derivative) on the right.
|
Case 3 Equation -u'' = f with a Dirichlet boundary condition (solution value) on the left and Newton boundary condition (combination of solution value and derivative) on the right.
|
Case 4 Time-dependent equation du/dt - ddu/dxx = f(x,t) with Dirichlet boundary conditions, discretized in time using implicit Euler method.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|