Garlerkin FiniteElementmethod PDF
Garlerkin FiniteElementmethod PDF
̃ ̃
function BVP_Galerkin2(a,b,c,t1,t2,x1,x2,ne) ( ) ( ) ( ) ( )
Download m-file
̃
http://www.mathworks.com/matlabcentral/fileexchange/40153-galerkins- Changing the variable to by substituting for and and
method-over--ne--elements-for-solving-2nd-order-homogeneous--c-c-bvp ( )
changing the integration domain by using the relation: ,
we obtain:
Galerkin’s method was used over elements in the entire domain
, - to numerically solve the following boundary value problem
(BVP). ( )
∫ [ ]2 3
∫ ( )[ ]2 3
(Eq. 1)
( ) , ( ) ( )
∫ ( ), ( ) ( )- 2 3
A general element, say element which has two nodes, say, ̃ ̃
( ) ( ) ( ) ( )
and such that is first considered. In order to apply Galerkin
method to one element at a time, a local coordinate such that
at node and at Node is introduced. The relation between
and for element is then: ( ). The approximate This equation can be written in matrix form as:
solution within the element e is given by: ̃( ) ( ) ( ),
where and are the interpolation functions and can be
expressed as a function of the variable as follow: ∫ [ ]2 3
( )
( ) . / ( ) { }
( )
∫ { }[ ]2 3
( ) ( ) ( )
( ) ( )
∫ { } , ( ) ( )- 2 3
Using the chain rule of differentiation, the derivatives of are: ( )
( ) ( ) ( ) ( )
( )
̃ ̃
Note that the terms ( ) and ( ) were not converted because
the boundary conditions do not use the approximation scheme. The
( )
above equation can be written in a matrix form as:
̃ ̃
∫ 4 ̃5 ( ) ( ) ( )
( )
0 1 ∫ [ ]
( ) ( )
̃ ̃ [ ]
∫ ( ) ∫ ( ) ∫ ̃ ( )
d2x/dt2 m/s 2
20
This equation is derived for each element
where is the number of elements. The right hand side of these 10
equations contain terms that are derivatives at the nodes ( ) and
0
( ) which are not generally known, however the second equation
for the element ( ) can be added to the first equation of element -10
( ) to eliminate the derivative term. Continuing this process for 1 2 3 4 5 6 7 8 9 10
Time (sec)
successive elements and the equations for the elements
1.2
will reduce to number of equations which is equal to the
Error of approximation
number of nodes. The equations to be solved take the following 1
form where is the global stiffness matrix. 0.8
Error (%)
0.6
( ) ( ) ( ) ( )
0.4
( ) ( ) ( )
0.2
[ ] 0
{ }
( ) -0.2
1 2 3 4 5 6 7 8 9 10
Time (s)
Figure 1. Solution to the differential equation in example
% Solution: We have:
-2 % a=1; b=2; c=3;
% t1=1; t2=10;
-3 % x1=2; x2=0;
Approximate x(t) % Using ne=64 elements,
-4 % >>BVP_Galerkin2(1,2,3,1,10,2,0,64)
Exact x(t)
%++++++++++++++++++++++++++++++++++++++++++++++++++++++
-5
1 2 3 4 5 6 7 8 9 10 +++++++++++++++++++
Time (sec) % Sep.26 to Dec26, 2010. Ramin
5
Shamshiri
% [email protected]
% Doctoral student at the University of
0 Florida
%++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++
dx/dt (m/s)
-5
%=============================Program
-10 Begin================================
function BVP_Galerkin2(a,b,c,t1,t2,x1,x2,ne) % Declare
-15 Approximate dx(t)
function
Exact dx(t) %% Begin Approximate solution via Galerkin method over
-20 each individual element
1 2 3 4 5 6 7 8 9 10
Time (sec)
% Define element length
le = (t2-t1)/ne;
% Define t matrix: t=t1:t2
t_GM=t1:le:t2;
t_GM=t_GM';
C=inv([exp(r1*t1) exp(r2*t1);exp(r1*t2)
% Display the solvable stiffness matrix exp(r2*t2)])*([x1;x2]);
disp('The solvable stiffness matrix is') C1=C(1);
K_strike=k; C2=C(2);
for j=1:ne+1
error_GM(j)=((C1*exp(r1*t_GM(j))+C2*t_GM(j)*exp(r2*t_GM
(j)))-
(x_GM(j)))/(C1*exp(r1*t_GM(j))+C2*t_GM(j)*exp(r2*t_GM(j
)));
end
C=inv([exp(r1*t1) exp(r2*t1);exp(r1*t2)
exp(r2*t2)])*([x1;x2]);
C1=C(1);
C2=C(2);
for j=1:ne+1
error_GM(j)=((C1*exp(r1*t_GM(j))+C2*exp(r2*t_GM(j)))-
(x_GM(j)))/(C1*exp(r1*t_GM(j))+C2*exp(r2*t_GM(j)));
end
end