10217

# Finite Element Solution of 1D Poisson Equation with Galerkin Spectral Decomposition

This Demonstration shows the finite element method (FEM) applied to the solution of the 1D Poisson equation. A capacitor with plates at a fixed distance with each plate held at potential and , respectively, is shown on the right. The 1D Poisson equation for the potential is , with the charge density between the plates in the range for simplicity. The solution over the entire domain is subject to the Dirichlet boundary conditions (BCs): and .
In order to assess the validity of the approximate FEM solution, this Demonstration first computes the exact solution of the Poisson partial-differential equation (PDE) and related BCs with the built-in Mathematica command DSolve. The exact solution is plotted as a dashed blue line on the left together with the FEM solution. In a finite-element method, the domain on which the PDE is solved is split into several subdomains (or elements) and a trial solution is hypothesized for each element. Then those solutions are patched together. Finally, the parameters of the trial solution are adjusted to obtain a best fit to the exact solution.
In particular, Galerkin's spectral decomposition is equivalent to a minimization of the integral of the difference between the approximate and exact solutions (it belongs to the class of weighted residual methods). For this 1D problem the subdomain elements are straight lines of equal length. The trial hat functions used in the linear expansion of the solution are linear interpolations between the solution values to be determined at the nodes . The next step is the assembly of the (sparse tridiagonal) stiffness matrix and the load vector with the proper elements accounting for the inclusion of Dirichlet BCs, since it can be demonstrated that these problems reduce to the solution of a linear system of equations , where the solution vector contains the expansion coefficients of the solution, which are the solution values at the nodes. One can notice that the elements in the stiffness matrix are combinations of inverse step sizes and independent of the charge density , whereas the elements in the load vector change for different 's, but the required integrals can be performed analytically or by other methods.
This Demonstration shows how the relative error between FEM and analytical solution decreases as the number of elements increases. The error is computed as .

### DETAILS

The Mathematica program here has been adapted and extended from the Java code LaplaceFEM.java in the following book:
R. H. Landau, M. J. Paez, and C. C. Bordeianu, A Survey of Computational Physics, Princeton: Princeton University Press, 2008.
A standard reference for the basics of the finite-element method applied to electromagnetics is, for instance:
J. Jin, The Finite Element Method in Electromagnetics, 2nd. ed., New York: John Wiley and Sons, 2002.

### PERMANENT CITATION

 Share: Embed Interactive Demonstration New! Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details » Download Demonstration as CDF » Download Author Code »(preview ») Files require Wolfram CDF Player or Mathematica.

#### Related Topics

 RELATED RESOURCES
 The #1 tool for creating Demonstrations and anything technical. Explore anything with the first computational knowledge engine. The web's most extensive mathematics resource. An app for every course—right in the palm of your hand. Read our views on math,science, and technology. The format that makes Demonstrations (and any information) easy to share and interact with. Programs & resources for educators, schools & students. Join the initiative for modernizing math education. Walk through homework problems one step at a time, with hints to help along the way. Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet. Knowledge-based programming for everyone.