# How to use FEM to solve a PDE

I come from a Computer Science background and I've been around searching for a concise tutorial that tells me how Finite Element Method is used to solve a certain partial differential equation. Unfortunately I was depressed with the large number of advanced studies and papers that assumed prior knowledge.

Is it possible to understand the entire process of implementing FEM easily?

-
It might be expeditious for you to say a bit more about the "certain partial differential equation" you want to solve. The FEM is fairly simply applied to elliptic linear PDE's in a modest number of dimensions, but if your case is not of this form, then it's probably best to explain that now. BTW a "Computer Science background" suggests you are familiar with discrete mathematics and linear algebra in particular. If that is not the case, also worth some clarificiation. –  hardmath Nov 30 '11 at 16:13
Thank you. Well, the equation I want to solve is the [dynamic version of Euler-Bernoulli beam equation](en.wikipedia.org/wiki/Euler-Bernoulli_beam_equation#Dynamic beam equation) which is $\cfrac{\partial^2 }{\partial x^2}\left(EI\cfrac{\partial^2 w}{\partial x^2}\right) = - \mu\cfrac{\partial^2 w}{\partial t^2} + q(x)$. (sorry for the long reply due to problems in my country) –  al-Amjad Tawfiq Isstaif Jan 3 '12 at 10:41
Just glancing at it, this doesn't seem to be of elliptic type, though it is a linear PDE. I'm assuming constants $E,I,\mu$ are positive. You should also have some boundary/initial conditions specified. If it is of hyperbolic type (as I suspect), then you may still be able to give a FEM approximation, though typically one might apply a finite element approach in the "space" variable and a finite difference stepping approach in the "time" dimension. –  hardmath Jan 3 '12 at 16:09

After a lot of search, I found this excellent crash course:

A Finite Element Crash Course

-

here is the solution to your problem Euler-bernoulli cantilever beam deflection equation Solution by using finite difference method

D4y/dx4 =- p/ EI In the finite difference method, the derivatives can be approximated by the following expressions : dy/dx|i ~ (yi+1 - yi )/ 2(Δx) d2y/dx2|i ~ (yi+1 - 2yi + yi-1)/( Δx)2 d3y/dx3|i ~ (yi+2 - 2yi+1 +2 yi-1 - yi-2)/ 2(Δx)3 d4y/dx4|i ~ (yi+2 - 4yi+1 +6 yi - 4 yi-1 + yi-2)/ (Δx)4

Where i is the node sequence. xi = i/(n-1) where n = number of nodes Applying the boundary conditions: y(x=0) =0 , gives y0 = 0. dy(x=0)/dx = 0, dy/dx|x=0 ~ (yi+1 - yi )/ 2(Δx) ; gives y1 = y-1 d2y(x=L)/dx2 = 0, d3y(x=L)/dx3 = 0, at end node

Solution: for n=7, at node 0, dy/dx|0 = 0 at node 1 d4y/dx4|1 ~ (y1+2 - 4y1+1 +6 y1 - 4 y1-1 + y1-2)/ (Δx)4 ~ (y3 - 4y2 +6 y1 - 4 y0 + y-1)/ (Δx)4 ~ (y3 - 4y2 +7 y1)/ (Δx)4 at node 2 d4y/dx4|2 ~ (y2+2 - 4y2+1 +6 y2 - 4 y2-1 + y2-2)/ (Δx)4 ~ (y4 - 4y3 +6 y2 - 4 y1 + y0)/ (Δx)4 ~ (y4 - 4y3 +6 y2 - 4 y1 )/ (Δx)4 at node 3 d4y/dx4|3 ~ (y3+2 - 4y3+1 + 6 y3 - 4 y3-1 + y3-2)/ (Δx)4 ~ (y5 - 4y4 +6 y3 - 4 y2 + y1)/ (Δx)4 at node 4 d4y/dx4|4 ~ (y4+2 - 4y4+1 + 6 y4 - 4 y4-1 + y4-2)/ (Δx)4 ~ (y6 - 4y5 + 6 y4 - 4 y3 + y2)/ (Δx)4 at node 5 d4y/dx4|5 ~ (y5+2 - 4y5+1 + 6 y5 - 4 y5-1 + y5-2)/ (Δx)4 ~ (y7 - 4y6 + 6 y5 - 4 y4 + y3)/ (Δx)4 From the Boundary conditions: d2y/dx2|i@x=L ~ (yi+1 - 2yi + yi-1)/( Δx)2 ~(yi+1 - 2yi + yi-1) = 0 ~(y7 - 2y6 + y5) = 0 ≡ y7 = 2y6 - y5

d4y/dx4|5 ~ (2y6 - y5 - 4y6 + 6 y5 - 4 y4 + y3)/ (Δx)4 ~ (– 2y6 + 5 y5 - 4 y4 + y3)/ (Δx)4

at node 6 d4y/dx4|6 ~ (y6+2 - 4y6+1 + 6 y6 - 4 y6-1 + y6-2)/ (Δx)4 ~ (y8 - 4y7 + 6 y6 - 4 y5 + y4)/ (Δx)4

Use boundary conditions at end note (x=L) d3y/dx3|i@x=L ~ (yi+2 - 2yi+1 +2 yi-1 - yi-2)/ 2(Δx)3 ~ (y6+2 - 2y6+1 +2 y6-1 - y6-2)/ 2(Δx)3 ~ (y8 - 2y7 +2 y5 - y4)/ 2(Δx)3 = 0 ≡ y8 - 2y7 = -2 y5 + y4

d4y/dx4|6 ~ (y8 - 2y7 - 2y7 + 6 y6 - 4 y5 + y4)/ (Δx)4
~ (-2 y5 + y4 - 2y7 +6 y6 - 4 y5 + y4)/ (Δx)4 ~ ( - 2y7 + 6 y6 - 6 y5 + 2 y4)/ (Δx)4 y7 = 2y6 - y5 d4y/dx4|6 ~ ( - 2(2y6 - y5 ) + 6 y6 - 6 y5 + 2 y4)/ (Δx)4 ~( ( - 4y6 + 2 y5 ) + 6 y6 - 6 y5 + 2 y4)/ (Δx)4 ~ ( 2 y6 - 4 y5 + 2 y4)/ (Δx)4

Arrange equations :

Solving the above linear equations gives the values of yi which is the deflection of the beam at each node. yi = 1.0e-4
y0 y1 y2 y3 y4 y5 y6 0 -0.479 -1.623 -3.193 -5.002 -6.918 -8.860

increase number of nodes for more accurate solution No of nodes RMS % 7 5.79 21 0.97 51 0.24 101 0.08

with my complements .... sumaia sumaia@onetel.com

-