Compare Ritz To Galerkin
Compare Ritz To Galerkin
Compare Ritz To Galerkin
method for finding axial deformation of a simple cantilever beam, and on how to
determine if the approximate solution found is an exact solution.
by Nasser M. Abbasi
Student, Engineering Mechanics dept.
University of Wisconsin, Madison
oct 16, 2009
Abstract
Using a simple problem, it is shown that, using a global trial function, the Rayleigh Ritz variational
method and the Galerkin method give the same solution. These solutions are compared to the
exact solution. It is found that one can determine that the exact solution was reached by
increasing the order of the trial function polynomial until the solution returned by Rayleigh Ritz or
Galerkin method no longer changes.
The problem
A cantilever beam is loaded with traction load of q = c x (for some constant c). It is fixed on the left side. We need to
find axial deformation u (x)
L1
2
A E I dx M x - 0 q uHxL x
du 2
where u (x) is the trial function . The trial function needs to satisfy only the essential conditions, which in this problem is given as u (0) = 0, so we start by assuming a trial function uHxL.
u HxL = a0 + a1 x + a2 x2
compare_ritz_to_galerkin.nb
This trial function has 2 degrees of freedom they are called the generalized degrees of freedom. The trial function
could have been selected to have only one degree of freedom i.e. uHxL = a1 x and this would also have worked but 2
degrees of freedom will give more accurate solution.
Start by defining the trial function
Remove@"Global`*"D
u = Sum@ai x^i, 8i, 0, 2<D
a0 + x a1 + x2 a2
Make the trial function satisfy essential boundary condition
sol = First Solve@Hu . x 0L 0, a0 D
8a0 0<
u = u . sol
x a1 + x2 a2
Set up the potential energy functional
P=
1
3
Solve for
1
2
A E Hx uL2 x - c x u x
c L3 a1 +
dP
dai
1
2
A L E a21 -
1
4
c L4 a2 + A L2 E a1 a2 +
2
3
A L3 E a22
eq1 = a1 P 0
-
c L3
3
+ A L E a1 + A L2 E a2 0
eq2 = a2 P 0
-
c L4
4
+ A L2 E a1 +
4
3
A L3 E a2 0
7 c L2
12 A E
, a2 -
cL
4AE
>
compare_ritz_to_galerkin.nb
solutionByRitzMethod = u . %
7 c L2 x
12 A E
c L x2
4AE
In this method, we start with the differential equation itself and integrate it with a test function we call g HxL. The
differential equation for axial deformation with traction load qHxL is A E
d2 u
dx2
AE
d2 u
dx2
+ q g (x) x = 0
We start by assuming a trial function u = a0 + a1 x + a2 x2 . Now due to u H0L = 0 we find that a0 = 0, hence
u = a1 x + a2 x2 Next, we do integration by parts the above integral and obtain
I = Bg HxL AE
du
dx
AE
du
dx
+q
dg (x)
dx
x + q gHxL dx
L
But
Bg HxL AE
du
dx
= g HLL AE
duHLL
dx
- g H0L AE
duH0L
dx
and now since a test function must also satisfy the essential conditions, hence gH0L = 0 and also the trial function
satisfies the natural boundary conditions at x = L which is that there is no load at that point, hence this means
A E Hdu dxL = 0 since this is the load at the end. Hence the integral becomes
I = -
AE
du
dx
+q
dg (x)
dx
x + q gHxL dx = 0
du
hence g1 HxL
dai
du
da1
= x and g2 HxL =
du
da2
= x2 so now
compare_ritz_to_galerkin.nb
eq1 = H- A E x u x g1 + q g1 L x
L
c L3
3
- A L E a1 - A L2 E a2
eq2 = H- A E x u x g2 + q g2 L x
L
c L4
4
- A L2 E a1 -
4
3
A L3 E a2
7 c L2
12 A E
, a2 -
cL
4AE
>
c L x2
4AE
We see that this solution is the same as the one found from the Ritz method
solutionByGalerkinMethod - solutionByRitzMethod
0
Exact solution for the problem
The ODE is
A E u''@xD = -q
With the essential conditions uH0L = 0 and with natural boundary condition A E u'@xD = 0 at x = L. Find exact solution:
Remove@uD
q = c x;
sol = FirstDSolve@8A E u''@xD -q, u@0D 0, A E u'@LD 0<, u@xD, xD;
solutionExact = u@xD . sol;
Collect@solutionExact, xD
c L2 x
2AE
c x3
6AE
compare_ritz_to_galerkin.nb
Compare the above solution to the one found above, we see that the approximate solution is
u=
7 c L2 x
12 A E
c L x2
4AE
c L2 x
2AE
c x3
6AE
FEM
0.15
0.10
0.05
0.2
0.4
0.6
0.8
1.0
How can we improve the FEM solution, can we make it match the exact solution?
Make the trial function a polynomial of higher order. Try
u = a0 + a1 x + a2 x2 + a3 x3
and repeat Ritz method. Instead of making the same steps as above, let us write a function which accepts a trial function uHxL and returns back the solution. Find define the function
findSolutionByRitzMethod @u_, x_D := ModuleB8eqs, coeffVar, P<,
Clear@A, E, c, LD;
coeffVar = Flatten@Normal@CoefficientArrays @u, xDDD;
coeffVar = Select@coeffVar, UnsameQ@, 0D &D;
L1
L
P=
A E HD@u, xDL2 x - c x u x;
0 2
0
eqs = Table@ D@P, coeffVar@@iDD D 0, 8i, 1, Length@coeffVarD<D;
First Solve@eqs, coeffVarD
Now we can call the above function for the trial function shown above to dtermine the values of the ai ' s
Printed by Mathematica for Students
compare_ritz_to_galerkin.nb
trialFunction = a1 x + a2 x2 + a3 x3 ;
solutionByRitzMethodMoreTerms =
findSolutionByRitzMethod@trialFunction, xD
:a1
c L2
2AE
, a2 0, a3 -
c
6AE
>
c x3
-
2AE
6AE
We see now that the FEM solution is the same as the exact solution. We can confirm this by taking the difference
between them
solutionByRitzMethodMoreTerms - solutionExact Simplify
0
What happens if we add more terms to the trial functions? We should expect that the solution would not change. This
is confirmed by the following table generated using the above function
numberOfTrialFunctions = 5;
HtrialFunction = Table@Sum@ai x ^ i, 8i, 1, j<D, 8j, 1, numberOfTrialFunctions <DL TableForm
x a1
x a1 + x2
x a1 + x2
x a1 + x2
x a1 + x2
a2
a2 + x3 a3
a2 + x3 a3 + x4 a4
a2 + x3 a3 + x4 a4 + x5 a5
Now find the solution using each of the above trial functions using Ritz method
tbl = Table@findSolutionByRitzMethod @trialFunction @@iDD, xD, 8i, 1, numberOfTrialFunctions <D;
tbl =
Table@8trialFunction @@iDD, trialFunction @@iDD . tbl@@iDD<, 8i, 1, numberOfTrialFunctions <D;
Grid@8 8"TrialFunction ", "Solution"<, Sequence tbl<, Frame AllD
TrialFunction
Solution
x a1
c L2 x
3AE
x a1 + x2 a2
7 c L2 x
12 A E
c L x2
4AE
x a1 + x2 a2 + x3 a3
c L2 x
2AE
c x3
6AE
x a1 + x2 a2 + x3 a3 + x4 a4
c L2 x
2AE
c x3
6AE
x a1 + x2 a2 + x3 a3 + x4 a4 + x5 a5
c L2 x
2AE
c x3
6AE
We see from the above that as more terms added to the trial function, after the cubic polynomial, the solution no
Printed by Mathematica for Students
longer changes. This implies, at least in this example,
that the exact solution was reached. (Need to find a formal
compare_ritz_to_galerkin.nb
We see from the above that as more terms added to the trial function, after the cubic polynomial, the solution no
longer changes. This implies, at least in this example, that the exact solution was reached. (Need to find a formal
proof of this).