SlideShare a Scribd company logo
Title:
CEE 235B Final Project
Revision:
A
ii
Revision A
CEE 235B ADVANCED FINITE ELEMENT
ANALYSIS OF STRUCTURES
Author: John Wick
UCLA MASTERS in ENGINEERING
Field of Study: Mechanics of Structures
Title:
CEE 235B Final Project
Revision:
A
iii
TABLE OF CONTENTS
ACRONYMS...............................................................................................................................v
1 ABSTRACT.....................................................................................................................1
2 INTRODUCTION.............................................................................................................1
3 METHODS ......................................................................................................................2
4 RESULTS .....................................................................................................................11
5 DISCUSSION................................................................................................................16
6 SUMMARY & CONCLUSIONS .....................................................................................22
7 REFERENCES..............................................................................................................23
APPENDIX A. MATLAB CODE..............................................................................................A-1
Title:
CEE 235B Final Project
Revision:
A
iv
LIST OF FIGURES
Figure 1. Elastic Bar Impacting rigid wall @ Velocity V_0...........................................................1
Figure 2. Matched method rationale............................................................................................8
Figure 3. Approximate solution of Displacement vs Time..........................................................11
Figure 4. Approximate Solution of Stress vs Time.....................................................................12
Figure 5. Exact Solution of Displacement vs Time ....................................................................13
Figure 6. Exact Solution of Stress vs time.................................................................................13
Figure 7. Comparison of displacement approximations to exact solution...................................14
Figure 8. Comparison of stress approximations to exact solution..............................................15
Figure 9. Effect of element size on approximation.....................................................................15
Figure 10. Effect of time step size on approximation .................................................................16
Figure 11. Unstable finite element model results.......................................................................19
Figure 12. Damping of high frequency oscillations in approximate solution...............................20
Figure 13. L2 Error norm of Displacement.................................................................................21
Figure 14. H1 Error Norm of Stress...........................................................................................21
LIST OF EQUATIONS
Equation 1. 3D Wave equation....................................................................................................2
Equation 2. Strong form of the boundary value problem..............................................................2
Equation 3. Constitutive Law......................................................................................................2
Equation 4. Strain Displacement Relationship.............................................................................2
Equation 5. Stress Strain Relationship in 1D...............................................................................3
Equation 6. Strain Displacement Relationship in 1D ...................................................................3
Equation 7. Strong form of 1D elastic bar BVP............................................................................3
Equation 8. Weak form of 1D elastic bar BVP.............................................................................4
Equation 9. Galerkin formulation of 1D elastic bar BVP...............................................................4
Equation 10. Finite element approximation of trial and weight functions in space and time.........5
Equation 11. Mass and Stiffness matrices...................................................................................5
Equation 12. Element Mass and Stiffness matrices.....................................................................5
Equation 13. Semi-Discrete equation of 1D elastic bar BVP........................................................6
Equation 14. Full discrete equation of 1D elastic bar BVP...........................................................6
Equation 15. Newmark Time integration method.........................................................................7
Equation 16. Ratio of temporal and spatial integration frequency to exact frequency..................8
Equation 17. Stability analysis of Newmark Time Integration ......................................................9
Equation 18. Critical Time step for central difference method......................................................9
Equation 19. L2 error norm .......................................................................................................10
Equation 20. H1 error norm.......................................................................................................10
Equation 21. Rate of Convergence ...........................................................................................10
Title:
CEE 235B Final Project
Revision:
A
v
ACRONYMS
Acronym Description
1D 1 dimensional
2D 2 dimensional
3D 3 dimensional
BVP Boundary Value Problem
Det Determinant
DOF Degree of Freedom
E*I Stiffness (E = Elastic Modulus; I=rotational inertia)
Eq Equation
Hz Hertz
K Stiffness
L Length
NEN Number of Element Nodes
ODE Ordinary Differential Equation
PDE Partial Differential Equation
RMS Root Mean Square
Wn Natural Frequency
Title:
CEE 235B Final Project
Revision:
A
1
1 ABSTRACT
The objective of this paper is to study the numerical characteristics of explicit and implicit time
integration methods and their stability and accuracy.
2 INTRODUCTION
This paper will guide the reader through the procedure of solving for displacement and stress
histories at various locations along a finite length elastic bar that impacts into a rigid wall with an
initial velocity V_0 as shown in figure 1 below.
Figure 1. Elastic Bar Impacting rigid wall @ Velocity V_0
The bar is made of a linear elastic material with constant material properties throughout its
length. The bar will be divided up into a linear finite element model consisting of 2-node
elements. Two methods will be described and developed to solve for the displacement and
stress histories during the impact event:
1. The implicit time integration method will utilize the central difference method with a
lumped mass
2. The explicit time integration method will utilize the average acceleration method with
consistent mass.
The methods section below will provide details in how the two different methods are developed
and utilized to calculate the history plots.
Due to the nature of a finite element analysis, it’s an approximation of a true solution. The error
of the approximation is an important factor in understanding how accurate a model is to the true
solution. The accuracy and stability of both methods will be discussed as they relate to the true
solution. Additional discussion will include how element size and time step size affect the
accuracy and stability of the numerical approximation.
Title:
CEE 235B Final Project
Revision:
A
2
3 METHODS
This section will describe the process by which the governing 3 dimensional differential equation
is manipulated until a solution of displacement and stress at various locations along the length
of the bar is reached. The calculations of error between the approximate and exact solution will
also be described in this section.
Equation 1 below is the 3 dimensional wave equation that governs the bar’s response.
Equation 1. 3D Wave equation
Below are the boundary conditions and initial conditions that, coupled with equation 1, make up
the strong form of this boundary value problem.
Equation 2. Strong form of the boundary value problem
In order to reduce this to a 1 dimensional problem, the following relationships are substituted
into the strong form presented above.
Equation 3. Constitutive Law
Equation 4. Strain Displacement Relationship
When i=j=k=1, the constitutive law and strain displacement operations are reduced to the
following 1D equations
Title:
CEE 235B Final Project
Revision:
A
3
Equation 5. Stress Strain Relationship in 1D
Equation 6. Strain Displacement Relationship in 1D
Utilizing equations 5 and 6, the strong form of the 1D elastic bar problem is show below
Equation 7. Strong form of 1D elastic bar BVP
In order to arrive at the semi and fully discrete equation from where the accelerations and
displacement are calculated and iterated, modify the strong form must be modified into the weak
form by multiplying it by an arbitrary weight function, wi and integrating over the entire space
and time domain.
Title:
CEE 235B Final Project
Revision:
A
4
Equation 8. Weak form of 1D elastic bar BVP
After integrating by parts the second derivative of u with respect to x, the weak form integral
simplifies into 2 terms shown in equation 9 below. The Galerkin formulation of elastodynamics
below introduces the function Uh(x,t), the trial function, which is the approximation of the true
solution U(x,t).
Equation 9. Galerkin formulation of 1D elastic bar BVP
The formulation for uh(x,t) and wh(x,t) are shown below in eq 10 where NEN is the number of
element nodes. The 1D elastic BVP requires the use of 2 node elements and therefore each
element has an N1 and N2 shape function. The 2 node elements used classify Uh as a first
order approximation of the solution. It is first order because the shape functions, N1 and N2 for
each element, are linear functions.
Title:
CEE 235B Final Project
Revision:
A
5
Equation 10. Finite element approximation of trial and weight functions in space and time
Utilizing the finite element approximations stated in equation 10, the two terms from the galerkin
formulation in equation 9 above are shown to be the mass (M) and stiffness (K) matrices as
shown below where x double dot is acceleration and x is displacement.
Equation 11. Mass and Stiffness matrices
Utilizing 2 node elements, the individual element mass and stiffness matrices are shown below.
The problem requires the calculation of two different types of mass matrices, a lumped mass
and consistent mass. The lumped mass is a diagonal matrix and the consistent mass matrix is
not. The definition of each is shown below:
Equation 12. Element Mass and Stiffness matrices
Equation 11 and the strong form above lead to the semi discrete equation
Title:
CEE 235B Final Project
Revision:
A
6
Equation 13. Semi-Discrete equation of 1D elastic bar BVP
Where a(t) is the acceleration at time t and d(t) is the displacement at time t. The spatial
component of the finite element approximation is taken care of in the stiffness matrix K. The full
discrete equation is achieved and shown below in equation 14.
Equation 14. Full discrete equation of 1D elastic bar BVP
The dn, vn and an are the approximations of the true or exact values: d(tn), v(tn) and a(tn). From
the discrete equation, the Newmark method of time integration is utilized to calculate the
approximations of the displacement, velocity and acceleration at each node over a specified
time period. The stress as functions of space and time is calculated using the stress strain
relationship from equation 5 above while strain is the derivative of displacement with respect to
x. The Newmark time integration method is summarized below for both implicit and explicit
solutions, the explicit solution is when β = 0 where n+1 is the time step after the nth
time step
Title:
CEE 235B Final Project
Revision:
A
7
Equation 15. Newmark Time integration method
The implicit and explicit methods are both developed via the Newmark method however it’s
important to explain the significance of each. The explicit method calculates a state of the
system at a later time from the state of the system at the current time and the implicit method
takes a weighted average of the current and predicted future state of a system. The explicit
method requires generally smaller and greater number of time steps to approximate the true
solution in order to minimize the error while the implicit method requires extra computations and
matrix inversions. The error associated with both methods of approximation will be discussed
further in the discussion section of this paper.
To begin the cascade of time iterations, begin at time t=0 and calculated a0. D0 and v0 are
known, to calculate a0 the time t=0 discrete equation is set up, subtract the Kd0 term and
multiply it by the inverse of the mass matrix. Utilizing the equations in equation 15 above, begin
calculating d(tn+1), v(tn+1) and a(tn+1) until the end of the simulation has been reached.
The rationale for grouping the central difference method with the consistent mass and the
average acceleration with the lumped mass matrix is to minimize error. The theory of matched
methods suggests that transient integrators and mass matrices shall be matched so that the
induced period errors from the integration method and mass matrix chosen tend to cancel. The
trapezoidal rule of temporal integration tends to increase the simulation time periods and the
converse is true of the central difference method. Similarly, the lumped mass matrix has a
tendency to increase the simulation time period and the opposite is true of the consistent mass
matrix. This is proven via the exact solution of the scalar version of the semi discrete equation of
the 1D elastic bar BVP. The solution is seen below:
Title:
CEE 235B Final Project
Revision:
A
8
Equation 16. Ratio of temporal and spatial integration frequency to exact frequency
Where ∆t is the time step of the temporal integration, β = Newmark coefficient, h is element
length, ω is the exact frequency response and is the frequency produced by time integration
in conjunction with the element spatial discretization. The equation 16 above is graphically
summarized in the two figures below that represent the rationale for the matching method
chosen.
Figure 2. Matched method rationale
The figure on the left represents the frequency ratio (ideal is 1) with curve 1 representing the
consistent mass and curve 2 is the lumped mass. The figure on the right shows the ratio of the
time step to simulation period vs algorithmic damping ratio.
The match up of the central difference method and the lumped mass matrix is a unique case in
which the period errors from the spatial discrete system and the particular integrator are
canceled perfectly and the exact solution is achieved. With β =r=0 and the time step = h/c, =
ω and this property is called superconvergence.
Stability of the Newmark integration method for the 1D elastic rod BVP is summarized below
where β and γ are the Newmark integration constants.
cc
Title:
CEE 235B Final Project
Revision:
A
9
Equation 17. Stability analysis of Newmark Time Integration
The ω is the square root of the maximum eigenvalue of the K and M matrix. Ultimately, for 1 D
wave equation, the critical time step for conditionally stable time integration methods (central
difference method utilizing the consistent mass) is the time it takes for the wave to travel
through one element. The critical time step is reduced to the equation below:
Equation 18. Critical Time step for central difference method
Where h is the length of each element and ρ is the material density. If any time step above the
critical time step is employed for a conditionally stable approximation, the model will not
converge and the approximation error goes to infinity. More details on convergence and the
derivation of the stability conditions are in the discussion section including an example of a
displacement approximation that does not converge. It’s important to note that because of the
physical significance of the critical time step, reducing the time step while holding the mesh
length fixed can only worsen the results and for this investigation, unless otherwise specified,
the critical time step will be used.
Title:
CEE 235B Final Project
Revision:
A
10
The accuracy of the approximations will be shown a number of different ways. The accuracy of
both the displacement and stress approximations from the average acceleration and consistent
mass method will be calculated using the L2 and H1 error norms, respectively. For different time
steps and element sizes visual representations of the error will be provided to demonstrate the
trends. Below are the equations used to calculate the L2 and H1 error norms:
Equation 19. L2 error norm
Equation 20. H1 error norm
Again, u is the exact solution and uh
is the approximate solution and thus the difference
between the approximate and exact solutions over the length of the bar is of interest. It’s
necessary to calculate an error norm at individual time steps and averaging them over the
length of the rod, so at any discrete time step the difference between the two solutions is of
interest.
A log-log plot of element size versus error norm will be provided to quantify the accuracy of the
finite element approximations and the convergence. The slope of the log-log line is the rate of
convergence, α, for the respective approximation model from the equation below
Equation 21. Rate of Convergence
Where h is the element length and c is a constant.
The discussion section will explain how the equations presented in this section demonstrate
how element size and time step size affect both stability and accuracy of the finite element
approximate solution.
Title:
CEE 235B Final Project
Revision:
A
11
4 RESULTS
Before displaying the results, the notations in the plot legends L, L/4, L/2 etc represents
positions along the bar. L/2 represents the mid point, L represents the end of the rod impacting
the wall and 0 represents the free end of the bar.
The figures 3 and 4 below are the plots of displacement and stress, at various points along the
bar, over the simulation time period utilizing the consistent mass and average acceleration time
integration.
Figure 3. Approximate solution of Displacement vs Time
Title:
CEE 235B Final Project
Revision:
A
12
Figure 4. Approximate Solution of Stress vs Time
The bar was divided up into twenty 2 node elements of the same length. The legend indicates
which line corresponds to the various locations along the bar. An important note, the stress is
calculated on each element whereas the displacements are calculated at each node.
Figures 5 and 6 below are the plots of the exact displacement and stress over the simulation
time period utilizing the lumped mass and central difference time integration. Super
convergence is defined as when a finite element approximation yields the exact solution as the
lumped mass and central difference method does.
Title:
CEE 235B Final Project
Revision:
A
13
Figure 5. Exact Solution of Displacement vs Time
Figure 6. Exact Solution of Stress vs time
Title:
CEE 235B Final Project
Revision:
A
14
Identical to the approximate solution, the bar was divided up into twenty 2 node elements of the
same length. The legend indicates which line corresponds to the various locations along the
bar. An important note, the stress is calculated on each element whereas the displacements are
calculated at each node.
The figure below superimposes the real solution and approximate solutions of displacement at 2
different points along the bar for a visual comparison.
Figure 7. Comparison of displacement approximations to exact solution
The figure below superimposes the real solution and approximate solutions of stress at 2
different points along the bar for a visual comparison.
Title:
CEE 235B Final Project
Revision:
A
15
Figure 8. Comparison of stress approximations to exact solution
The graph below shows how the finite element approximate gets closer to the exact solution as
element size is increased. The graph below displays the exact displacement at the midpoint
(Length/2) of the bar with the approximate values utilizing 20 and 100 element discretizations.
Figure 9. Effect of element size on approximation
The approximations are the result of the implicit method of integration and the consistent mass
matrix and the exact solutions are a result of the lumped mass and central difference method.
Title:
CEE 235B Final Project
Revision:
A
16
The approximate solutions are compared to the exact solutions of the same element size for
reasons covered in the discussion section.
The graph below shows how the error of the approximate solution is improved with smaller time
steps.
Figure 10. Effect of time step size on approximation
Each curve is representative at the stress at the midpoint of the bar (L/2) utilizing a 100 element
discretization, the different time steps used for the approximate solutions are indicated in the
legend where h is element length
A more detailed discussion on the results presented, including but not limited to the accuracy of
the approximations and stability of the models will be discussed in the next section.
5 DISCUSSION
The approximate solutions of displacement in figure 3 are reasonable shapes when considering
what physically happens to the bar during impact into a rigid wall. In figure 3, the displacement
at the wall end (x=L), stays zero, consistent with the boundary conditions, and the displacement
has a peak at the free end (x=0) halfway through the time simulation. This makes sense
because the free end continues to displace until the wave induced by the impact of the opposite
end of the bar and the wall reaches the free end and sends the first node back to its nominal
position. Applying the wave explanation to the other nodes, the graph indicates that the nodes
Title:
CEE 235B Final Project
Revision:
A
17
closer to the wall end encounter the wave from impact sooner because it has less distance to
travel which makes sense.
The approximate solutions of the stresses in figure 4 exhibits the overall behavior one would
expect from a physical interpretation however there are some areas on the curves that do not
correlate to the physical reaction. Stress is equal to strain times the elastic modulus, a constant
in this case, and the stress remains zero for elements until they change length. Again, the
boundary condition, at L, the stress remains zero however for an element at the free end, the
element doesn’t crunch until the wave has time to propagate through the bar. Once the bar
returns to its nominal position that same element returns to its original length and the stress
goes back to zero as seen on the graph. The overshoot on the max stresses at various points
along the bar and at the end of the simulation when the bar returns to its nominal length the
stress crosses the x-axis similar to an over damped response are not representative of the
model. In this simulation no damping is assumed and thus these overshoots are clearly errors in
the approximation.
The exact solutions in figures 5 and 6, as stated above, are the results from the lumped mass
and central difference integration method. From the methods section this is the result of
superconvergence. The graphs are identical to the expected response of the bar. The
assumptions made and boundary conditions imposed, the problem reduces to a series of linear
elastic springs (represented by the elements) in which they compress and then release back to
their nominal state. The exact solution shows that the stress reaches the same exact maximum
value (-1) for all elements because they all compress to the same length eventually and then
return to their nominal length (constant material properties) e.g. stress goes back to zero.
As a reminder, for the purposes of this paper the lumped mass with central difference temporal
integration method will be referred to as the exact solution and the consistent mass with the
average acceleration method as the approximate solution.
The comparisons of displacement and stress to the exact solution at various points are included
simply to show on the same graphs, how the different methods’ results look while superimposed
upon each other. Later in this section, the accuracy of the model with respect to time step length
and element size will be discussed.
Stability of a finite element model is best described as the ability of the model to converge and
produce reasonable results. The reason this is important because stability depends on the time
step size and element dimension selected, if too large a time step is used or the elements are
too large, the resolution will be to coarse and the correct response will not be captured. Similar
to the Nyquist theorem for data sampling rates, the theorem states that a signal must be
sampled at a minimum of 2x the frequency at which the signal being measured is oscillating. If
the temperature profile of an engine block of a drag racing car is of interest and the temperature
is recorded every 5 minutes, the resolution of the curve will not provide the detail of interest. In 5
Title:
CEE 235B Final Project
Revision:
A
18
minutes the car will go from idle to maximum temperature and then the engine will then cool off
presumable back to the idle temperature and the data will be of no value. If the rotor
temperature of a steady state generator was of interest, recording the temperature ever 5
minutes could be appropriate as the temperature will not vary much over a 5 minute period.
Conversely, it would be a waste of time and data storage to measure the generator rotor
temperature every half second frequency during stead operation however the every half second
would be reasonable for obtaining a temperature profile of a drag car engine during a race. The
finite element models are the same way, small elements or short time steps between each data
point may not be necessary however too large of elements or too large a time step might not
give a reasonable response. Finite element models that utilize extremely small time steps and
element sizes are costly and time consuming and in some cases necessary but in other cases
not accurate and thus the appropriate time steps and element sizes must be chosen for the
specific model.
With the superconvergent condition, it’s important to note that the accuracy of the lumped mass
and central difference method is not improved with varying element size or smaller time steps.
Theoretically the accuracy of the values of stress and displacement at each node are
independent of element size however with minute numerical calculations propagated through
the time integration, different element sizes produce fractionally small displacement and stress
magnitudes. This is why figure 9 utilizes two different element sizes for comparison to the
approximation method. For reasons stated in the methods section, the critical time step is the
only time step that produces the exact results at each node and that is why the effect of the time
step was not studied for the lumped mass and central difference approximation method.
The stability of the superconvergent condition is however affected by the time step chosen. The
dependence on time step size for both methods is derived from the eigenvalue problem of the
semi-discrete equation presented in the methods section. From the modal equation the
amplification matrix, the ratio of a time step value to the previous time step value, requires
conditions that prevent the amplification matrix becoming larger and larger at later time steps.
The spectral radius is defined as the maximum eigenvalue of the amplification matrix and it
must meet two conditions, the maximum value of the spectral radii must be less than or equal to
1 (less than 1 if eigenvalues are not distinct) and the eigenvalues of the amplification matrix of
multiplicity greater than one are strictly less than one in modulus. A violation of these two
conditions produces rapid or slow divergent instabilities as seen in the figure below. The figure
below is an example of the same 20 element approximation however the time step is too large
for the model to converge.
Form the methods section and equation 17, the central difference method was stable for all time
steps below the critical time step and the average acceleration method with consistent mass
was stable for any time step chosen.
Title:
CEE 235B Final Project
Revision:
A
19
Figure 11. Unstable finite element model results
The only difference between figure 11 and figure 5, the exact displacement, is that the time step
used was 1.2 times the critical time step which lead to an unstable solution.
Figure xx in the methods sections summarizes the stability conditions for the specific problem of
the 1D elastic bar. From that figure one can see that the critical time step is the element length
divided by the speed of sound in the given material. This makes physical sense, as discussed
before this is the time it takes for the wave to propagate through one element. As evidenced by
figure 11 above, if this time step is 1.2 times the critical time step, very small increase, the
proper response cannot be captured. Additionally, it becomes clear that the time step is
dependent on element size as well.
The implicit time integration method, average acceleration, with a consistent mass matrix is
stable for any time step chosen. This is because from equation 17 in the methods section, with
beta = ¼ and gamma = ½, the critical sampling frequency is zero. Although any time step can
be chosen, it’s important to note that the error of the approximation is directly related to the time
step squared. The model will converge for any time step however the accuracy is directly
proportional to time step squared so it’s important to know how accurate the approximations
must be for a given application. Figure 10 from the results points to the same conclusion. The
figure shows a 100 element discretization using the average acceleration and consistent mass
matrix with smaller and smaller multiple time steps of the critical time step, h/c, and visually the
conclusion can be drawn that the smallest time step h/4c is the closest to the exact solution
using a 100 element discretization.
Outside the scope of this study, the high frequency oscillations seen in the approximate
solutions in figure 12 can be eliminated using the consistent mass matrix coupled with different
beta and gamma values. For gamma values above ½ there is a beta value, [(gamma + ½)^2]/4,
that optimizes the damping of the higher frequency oscillations. The figure below shows
Title:
CEE 235B Final Project
Revision:
A
20
compares the exact solution to the non damped approximation and the optimally damped
approximation with gamma = 0.6 and beta = 0.3025 (black dotted line).
Figure 12. Damping of high frequency oscillations in approximate solution
For the case of the 1D elastic bar, the exact solution is provide via the superconvergent
condition and thus the error for the approximated displacements and stresses can be calculated
from the average acceleration method versus element size. From figure 9 in the results, it’s
clear that time step being equal, the smaller the element size the better the approximation.
Now that a visual presentation of the error in finite element approximation has been provided,
the error norms of displacement and stress are quantified via the equations 19 and 20
presented at the end of the methods section. The L2 error norm calculated for displacement
error is graphed versus different element lengths below. The plot is a log-log plot where the
natural log of the element dimension and the error norm are displayed.
Title:
CEE 235B Final Project
Revision:
A
21
Figure 13. L2 Error norm of Displacement
T2 represent a specific time step, the error norm was calculated on a single time step for
various numbers of elements. The slope of the graph, 2, is equal to the rate of convergence and
of the displacement error which is in line with the theoretical value assuming the exact solution
is infinitely continuous e.g. a sinusoidal function. Most importantly, the trend is clear that the
error is reduced with a smaller element size e.g. finer mesh.
Similar for the error on stress, the figure below is the H1 error norm calculated for models with
different element sizes.
Figure 14. H1 Error Norm of Stress
T2 represent a specific time step, the error norm was calculated on a single time step for
various numbers of elements. The slope of the graph, 1, is equal to the rate of convergence and
of the stress error which is in line with the theoretical value assuming the exact solution is
infinitely continuous e.g. a sinusoidal function. Again, the trend is clear that the error is reduced
with a smaller element size.
Title:
CEE 235B Final Project
Revision:
A
22
6 SUMMARY & CONCLUSIONS
The two methods analyzed of approximating the response of the elastic bar problem provide
both exact and reasonable responses when the parameters chosen are best understood. The
average acceleration method utilized with the consistent mass provided a reasonable
approximation regardless of the time step chosen and was better approximated with smaller
time steps and smaller element sizes. The central difference method coupled with the lumped
mass provided the exact solution at each node only for time steps equal to the critical time step.
Theoretically the element size, for the central difference and lumped mass method should not
have affected the results at a given node however due to minute computational errors
compounded through the time integrations, the element size did change the magnitude of the
displacements and stresses by fractions of percentage points.
For practical purposes and not discussed in detail, the understanding of the limitations of a finite
element model are extremely important when taking into consideration time and cost
constraints. As evidenced by the results of this investigation, one approximation provided better
results with smaller time steps and element sizes e.g. more expensive and timely however the
other approximation distanced itself further from the exact solution with smaller time steps and
similarly no accuracy was gained with smaller element sizes.
Title:
CEE 235B Final Project
Revision:
A
23
7 REFERENCES
1) Hughes, J. R., The Finite Element Method: Linear Static and Dynamic Finite Element
Analysis, Dover Publications, Inc, Mineola, New York.
Title:
CEE 235B Final Project
Revision:
A
A-1
APPENDIX A.
MATLAB CODE
%CEE 235B Final Project
%John Wick
% clear all; close all; clc
%number of elements
n=10;
%Initial Conditions at all nodes @ time t=0
%initial Velocity = 1
%initial Displacement = 0
%initial Acceleration = 0
%known Material Properties/Constants (dimensionless)
E=100; %Bar Elastic Modulus
L=10; %Bar Length
A=1; %Bar Cross Sectional Area
rho=0.01; %Bar Density
c=sqrt(E/rho); %Bar Material Speed of Sound
L_e=L/n; %length of element
%number of degrees of freedom
ndof=2; %1 dimensional problem, 2 nodes
%stiffness matrix for 2 node element 1D elasticity (slide 58)
K = zeros(n+1,n+1);
for i=1:n
K(i,i)=2*E*n/L;
K(i,i+1)=-E*n/L;
K(i+1,i)=-E*n/L;
K(i+1,i+1)=2*E*n/L;
end
%eliminate the last column and row -- last node displacement = 0
K(1,1)=E*(n/L);
K(n+1,n+1)=E*(n/L);
K(n+1,:)=[];
K(:,n+1)=[];
% display('Global stiffness matrix,');K
%Construct global consistent mass matrix
M_c = zeros(n+1,n+1);
for ii=1:n
M_c(ii,ii)=(2/3);
Title:
CEE 235B Final Project
Revision:
A
A-2
M_c(ii,ii+1)=1/6;
M_c(ii+1,ii)=1/6;
end
M_c(1,1)=1/3;
M_c(n+1,n+1)=1/3;
M_c=M_c*(rho*L_e);
%Lumped Mass Matrix for 2 node elements 1D elasticity
M_l = zeros(n+1,n+1);
% for j=1:n
% M_l(j,j)=M_c(j,j);
% end
% M_l(n+1,n+1)=M_c(n+1,n+1);
M_c_sum=sum(M_c,2);
%place M_c_sum elements into diagonals of M_l for ROW SUM Lumped Mass
for u=1:n+1;
M_l(u,u)=M_c_sum(u,1);
end
%Choose lumped mass or consistent mass
M=M_c;
%Define Beta and Gamma based on Mass Matrix Chosen Above
if M==M_c
B=1/4;
gamma=1/2;
%Simulation Time Constants
D_t=(2*L_e)/(c); %Critical time step for trapezoidal rule with
consistent mass (unconditionally stable)
T_total=0.2; %duration of the whole simulation
t=T_total/D_t; %total number of time steps
else if M==M_l
B=0;
gamma=1/2;
%Simulation Time Constants
D_t=L_e/c; %Critical time step for central difference with lumped mass
(critical time step slide 59)
T_total=0.2; %duration of the whole simulation
t=T_total/D_t; %total number of time steps
end
end
%eliminate the last column and row -- last node displacement = 0 (EBCs)
M(n+1,:)=[];
M(:,n+1)=[];
% display('Global Mass matrix,');M
%Initial displacement Vector -- eliminate the last node displacement because
its 0
Title:
CEE 235B Final Project
Revision:
A
A-3
d_initial=zeros(n,1);
%Initial velocity Vector -- eliminate the last node velocity because its 0
v_initial=zeros(n,1);
for y=1:n
v_initial(y,1)=v_initial(y)+1;
end
%Call displacement, velocity and acceleration matrices -- Pre Allocation
displacement=zeros(t+1,n+1);
velocity=zeros(t+1,n+1);
acceleration=zeros(t+1,n+1);
%Initial acceleration vector @ t=0
a=M-K*d_initial;
%Place iniital time steps into Displacement, Velocity & Acceleration matrices
d=d_initial;
v=v_initial;
displacement(1,1:n)=d_initial;
velocity(1,1:n)=v_initial;
acceleration(1,1:n)=a;
for k=1:t
%predictors
d_p=d+D_t*v+0.5*((1-2*B)*((D_t)^2)*a);
v_p=v+((1-gamma)*(D_t)*a);
% M star and F star
M_s=M+(B*((D_t)^2)*K);
F_s=-K*d_p;
%acceleration vector a_n+1
a=M_sF_s;
%Correctors
d=d_p+(B*(D_t^2)*a);
v=v_p+(gamma*(D_t)*a);
%assembly of looped displacement, velocity and acceleration matrices
displacement(k+1,1:n)=d;
velocity(k+1,1:n)=v;
acceleration(k+1,1:n)=a;
end
%Assembly of the Stress matrix
stress=zeros(t,n+1);
for r=1:t
Title:
CEE 235B Final Project
Revision:
A
A-4
for rr=1:n
stress(r,rr)=(E*(displacement(r,rr+1)-displacement(r,rr)))/L_e;
end
end
dx=zeros(t,n+1);
for r=1:t
for rr=1:n
dx(r,rr)=((displacement(r,rr+1)-displacement(r,rr)))/L_e;
end
end
%Exact solution
M=M_l;
M(n+1,:)=[];
M(:,n+1)=[];
B=0;
gamma=1/2;
%Simulation Time Constants
D_t=L_e/(c); %Critical time step for central difference with lumped
mass (critical time step slide 59)
T_total=0.2; %duration of the whole simulation
t=T_total/D_t; %total number of time steps
%Call displacement, velocity and acceleration matrices -- Pre Allocation
displacement_exact=zeros(t+1,n+1);
velocity_exact=zeros(t+1,n+1);
acceleration_exact=zeros(t+1,n+1);
%Initial acceleration vector @ t=0
a=M-K*d_initial;
%Place iniital time steps into Displacement, Velocity & Acceleration matrices
d=d_initial;
v=v_initial;
displacement_exact(1,1:n)=d_initial;
velocity_exact(1,1:n)=v_initial;
acceleration_exact(1,1:n)=a;
for kk=1:t
%predictors
d_p=d+D_t*v+0.5*((1-2*B)*((D_t)^2)*a);
v_p=v+((1-gamma)*(D_t)*a);
% M star and F star
M_s=M+(B*((D_t)^2)*K);
F_s=-K*d_p;
%acceleration vector a_n+1
a=M_sF_s;
Title:
CEE 235B Final Project
Revision:
A
A-5
%Correctors
d=d_p+(B*(D_t^2)*a);
v=v_p+(gamma*(D_t)*a);
%assembly of looped displacement, velocity and acceleration matrices
displacement_exact(kk+1,1:n)=d;
velocity_exact(kk+1,1:n)=v;
acceleration_exact(kk+1,1:n)=a;
end
% figure(2);
% plot(displacement_exact)
% format longG
% g=max(displacement_exact(:,n/2))
%Assembly of the Stress matrix
stress_exact=zeros(t,n+1);
for r=1:t
for rr=1:n
stress_exact(r,rr)=(E*(displacement_exact(r,rr+1)-
displacement_exact(r,rr)))/L_e;
end
end
dx_exact=zeros(t,n+1);
for r=1:t
for rr=1:n
dx_exact(r,rr)=(displacement_exact(r,rr+1)-displacement_exact(r,rr))/L_e;
end
end
%error
%subtract each displacement and square it (U - Uh)^2
error=zeros(t+1,n+1);
for y=1:t+1
for yy=1:n+1
error(y,yy)=(displacement_exact(y,yy)-displacement(y,yy))^2;
end
end
%integrate the curve at each displacement (trapezoid rule) and make an error
vector that has
%an error at each time step
E_0=zeros(t,1);
error_pre_sum=zeros(t+1,n+1);
Title:
CEE 235B Final Project
Revision:
A
A-6
for o=1:t
for oo=1:n
error_pre_sum(o,oo)=(error(o,oo)+error(o,oo+1))*(n/(L*2));
end
end
%need to sum the row elements of each row and place them in E_0 giving you
%error norm at each time step
for mm=1:t
E_0(mm,1)=sqrt(sum(error_pre_sum(mm,1:n)));
end
% figure(3);
% plot(E_0)
%error of derivative ie stress!
%subtract each displacement and square it (U - Uh)^2
error_dx=zeros(t,n+1);
for y=1:t
for yy=1:n+1
error_dx(y,yy)=((dx_exact(y,yy)-dx(y,yy))^2);
end
end
%integrate the curve at each displacement (trapezoid rule) and make an error
vector that has
%an error at each time step
E_0_dx=zeros(t,1);
error_dx_pre_sum=zeros(t+1,n+1);
for o=1:t
for oo=1:n
error_dx_pre_sum(o,oo)=(error_dx(o,oo)+error_dx(o,oo+1))*(n/(L*2));
end
end
% need to sum the row elements of each row and place them in E_0 giving you
% error norm at each time step
for mm=1:t
E_0_dx(mm,1)=sqrt(sum(error_dx_pre_sum(mm,1:n)));
end
% figure(4);
% plot(stress)
CEE 235B Final Project_John_Wick

More Related Content

What's hot

Lecture 1 (Introduction to Structural Analysis II)
Lecture  1 (Introduction to Structural Analysis II)Lecture  1 (Introduction to Structural Analysis II)
Lecture 1 (Introduction to Structural Analysis II)
Iqbal Hafeez
 
the moment distribution method
the moment distribution methodthe moment distribution method
the moment distribution method
Er Patel
 
Flexibility Energy Method in structural analysis
Flexibility Energy Method in structural analysisFlexibility Energy Method in structural analysis
Flexibility Energy Method in structural analysis
Mahdi Damghani
 
Three moment theorem
Three moment theoremThree moment theorem
Three moment theorem
Dr. Santhosh Malkapur
 
Math cad vm-001 stress-strain transformations
Math cad   vm-001 stress-strain transformationsMath cad   vm-001 stress-strain transformations
Math cad vm-001 stress-strain transformations
Julio Banks
 
Ch04 position analysis
Ch04 position analysisCh04 position analysis
Ch04 position analysis
Geletu Basha
 
Moment Distribution Method
Moment Distribution MethodMoment Distribution Method
Moment Distribution Method
Bhavik A Shah
 
Mba admission in india
Mba admission in indiaMba admission in india
Mba admission in india
Edhole.com
 
Chapter 3. velocity analysis (IC,GRAPHICAL AND RELATIVE VELOCITY METHOD)
Chapter 3. velocity analysis (IC,GRAPHICAL AND RELATIVE VELOCITY METHOD)Chapter 3. velocity analysis (IC,GRAPHICAL AND RELATIVE VELOCITY METHOD)
Chapter 3. velocity analysis (IC,GRAPHICAL AND RELATIVE VELOCITY METHOD)
kidanemariam tesera
 
Ch03
Ch03Ch03
Binder1
Binder1Binder1
Determinate structures
 Determinate structures Determinate structures
Determinate structuresTarun Gehlot
 
flexibility method
flexibility methodflexibility method
flexibility method
Upendra Pandey
 
Em notes
Em notesEm notes
IIT JEEPhysics Paper I
IIT JEEPhysics Paper IIIT JEEPhysics Paper I
IIT JEEPhysics Paper I
guestac78ef4
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncr
Edhole.com
 
Equilibrium 3
Equilibrium 3Equilibrium 3
Equilibrium 3
DrAhmedAlRubaie
 

What's hot (20)

Lecture 1 (Introduction to Structural Analysis II)
Lecture  1 (Introduction to Structural Analysis II)Lecture  1 (Introduction to Structural Analysis II)
Lecture 1 (Introduction to Structural Analysis II)
 
aaaa
aaaaaaaa
aaaa
 
M6l36
M6l36M6l36
M6l36
 
the moment distribution method
the moment distribution methodthe moment distribution method
the moment distribution method
 
Flexibility Energy Method in structural analysis
Flexibility Energy Method in structural analysisFlexibility Energy Method in structural analysis
Flexibility Energy Method in structural analysis
 
Three moment theorem
Three moment theoremThree moment theorem
Three moment theorem
 
Math cad vm-001 stress-strain transformations
Math cad   vm-001 stress-strain transformationsMath cad   vm-001 stress-strain transformations
Math cad vm-001 stress-strain transformations
 
Ch04 position analysis
Ch04 position analysisCh04 position analysis
Ch04 position analysis
 
Moment Distribution Method
Moment Distribution MethodMoment Distribution Method
Moment Distribution Method
 
Mba admission in india
Mba admission in indiaMba admission in india
Mba admission in india
 
Chapter 3. velocity analysis (IC,GRAPHICAL AND RELATIVE VELOCITY METHOD)
Chapter 3. velocity analysis (IC,GRAPHICAL AND RELATIVE VELOCITY METHOD)Chapter 3. velocity analysis (IC,GRAPHICAL AND RELATIVE VELOCITY METHOD)
Chapter 3. velocity analysis (IC,GRAPHICAL AND RELATIVE VELOCITY METHOD)
 
Ch03
Ch03Ch03
Ch03
 
Binder1
Binder1Binder1
Binder1
 
Determinate structures
 Determinate structures Determinate structures
Determinate structures
 
flexibility method
flexibility methodflexibility method
flexibility method
 
Em notes
Em notesEm notes
Em notes
 
Wang1998
Wang1998Wang1998
Wang1998
 
IIT JEEPhysics Paper I
IIT JEEPhysics Paper IIIT JEEPhysics Paper I
IIT JEEPhysics Paper I
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncr
 
Equilibrium 3
Equilibrium 3Equilibrium 3
Equilibrium 3
 

Viewers also liked

Trabajo de-informatica
Trabajo de-informaticaTrabajo de-informatica
Trabajo de-informatica
FAUSTO MATEO HARO HARO
 
Shahrokh Haydari portfolio
Shahrokh Haydari portfolioShahrokh Haydari portfolio
Shahrokh Haydari portfolioshahrokh haydari
 
Film location photos
Film location photosFilm location photos
Film location photos
lilywallis17
 
Doctor who
Doctor whoDoctor who
Doctor who
katiesnook121
 
Amostra Comunicação - Construção Civil
Amostra Comunicação - Construção CivilAmostra Comunicação - Construção Civil
Amostra Comunicação - Construção Civil
Antônio Henrique Alves de Oliveira
 
Constructivism theory (narrated)
Constructivism theory (narrated)Constructivism theory (narrated)
Constructivism theory (narrated)
Thulani Bhuti Skosana
 
Architecture 3
Architecture 3Architecture 3
Architecture 3
marc sauvez
 
Valentina Hernandez!
Valentina Hernandez!Valentina Hernandez!
Valentina Hernandez!
valentina hernandez sandoval
 
Robbie Ames- Presentation for InsideOut Development. March 2016
Robbie Ames- Presentation for InsideOut Development. March 2016 Robbie Ames- Presentation for InsideOut Development. March 2016
Robbie Ames- Presentation for InsideOut Development. March 2016
amesgolf
 
Inplant ppt
Inplant pptInplant ppt
Inplant ppt
Shriram Hegde
 
Atencion al cliente lisbeth
Atencion al cliente lisbethAtencion al cliente lisbeth
Atencion al cliente lisbeth
Lisbeth2402
 
Mixing desks
Mixing desksMixing desks
Mixing desks
lilywallis17
 
інформаційні моделі11кл
інформаційні моделі11клінформаційні моделі11кл
інформаційні моделі11кл
Людмила Шульга
 
الشدة
الشدة الشدة
الشدة
ahmed elsaid
 
Chloes first festival look
Chloes first festival lookChloes first festival look
Chloes first festival look
lilywallis17
 
métodos de investigación
métodos de investigación métodos de investigación
métodos de investigación
fatimaduque
 
Día de la canción criolla
Día de la canción criollaDía de la canción criolla
Día de la canción criolla
fatimaarriola18
 

Viewers also liked (20)

Trabajo de-informatica
Trabajo de-informaticaTrabajo de-informatica
Trabajo de-informatica
 
Shahrokh Haydari portfolio
Shahrokh Haydari portfolioShahrokh Haydari portfolio
Shahrokh Haydari portfolio
 
Film location photos
Film location photosFilm location photos
Film location photos
 
Doctor who
Doctor whoDoctor who
Doctor who
 
Amostra Comunicação - Construção Civil
Amostra Comunicação - Construção CivilAmostra Comunicação - Construção Civil
Amostra Comunicação - Construção Civil
 
Constructivism theory (narrated)
Constructivism theory (narrated)Constructivism theory (narrated)
Constructivism theory (narrated)
 
za
zaza
za
 
Architecture 3
Architecture 3Architecture 3
Architecture 3
 
Valentina Hernandez!
Valentina Hernandez!Valentina Hernandez!
Valentina Hernandez!
 
AZMET-Company Profile
AZMET-Company ProfileAZMET-Company Profile
AZMET-Company Profile
 
Robbie Ames- Presentation for InsideOut Development. March 2016
Robbie Ames- Presentation for InsideOut Development. March 2016 Robbie Ames- Presentation for InsideOut Development. March 2016
Robbie Ames- Presentation for InsideOut Development. March 2016
 
Inplant ppt
Inplant pptInplant ppt
Inplant ppt
 
Atencion al cliente lisbeth
Atencion al cliente lisbethAtencion al cliente lisbeth
Atencion al cliente lisbeth
 
La tecnologia
La tecnologiaLa tecnologia
La tecnologia
 
Mixing desks
Mixing desksMixing desks
Mixing desks
 
інформаційні моделі11кл
інформаційні моделі11клінформаційні моделі11кл
інформаційні моделі11кл
 
الشدة
الشدة الشدة
الشدة
 
Chloes first festival look
Chloes first festival lookChloes first festival look
Chloes first festival look
 
métodos de investigación
métodos de investigación métodos de investigación
métodos de investigación
 
Día de la canción criolla
Día de la canción criollaDía de la canción criolla
Día de la canción criolla
 

Similar to CEE 235B Final Project_John_Wick

lecture notes fluid mechanics.pdf
lecture notes fluid mechanics.pdflecture notes fluid mechanics.pdf
lecture notes fluid mechanics.pdf
Laggo Anelka
 
lecture notes fluid mechanics.pdf
lecture notes fluid mechanics.pdflecture notes fluid mechanics.pdf
lecture notes fluid mechanics.pdf
Tsegaye Getachew
 
Engn4625 e brick1_2014_ circuitanalysismaths
Engn4625 e brick1_2014_ circuitanalysismathsEngn4625 e brick1_2014_ circuitanalysismaths
Engn4625 e brick1_2014_ circuitanalysismaths
sskara
 
Nonlinear Simulation of Rotor-Bearing System Dynamics
Nonlinear Simulation of Rotor-Bearing System DynamicsNonlinear Simulation of Rotor-Bearing System Dynamics
Nonlinear Simulation of Rotor-Bearing System DynamicsFrederik Budde
 
Quantm mechanics book
Quantm mechanics bookQuantm mechanics book
Quantm mechanics book
ish khan
 
morten_bakkedal_dissertation_final
morten_bakkedal_dissertation_finalmorten_bakkedal_dissertation_final
morten_bakkedal_dissertation_finalMorten Bakkedal
 
Buckling and Postbuckling Loads Characteristics of All Edges Clamped Thin Rec...
Buckling and Postbuckling Loads Characteristics of All Edges Clamped Thin Rec...Buckling and Postbuckling Loads Characteristics of All Edges Clamped Thin Rec...
Buckling and Postbuckling Loads Characteristics of All Edges Clamped Thin Rec...
theijes
 
TR-CIS-0420-09 BobZigon
TR-CIS-0420-09 BobZigonTR-CIS-0420-09 BobZigon
TR-CIS-0420-09 BobZigonBob Zigon
 
ME75-2014-myan076-report
ME75-2014-myan076-reportME75-2014-myan076-report
ME75-2014-myan076-reportMicky Yang
 
Transport Properties of Graphene Doped with Adatoms
Transport Properties of Graphene Doped with AdatomsTransport Properties of Graphene Doped with Adatoms
Transport Properties of Graphene Doped with Adatoms
James McMurray
 
Staircases_in_Fluid_Dynamics_JacobGreenhalgh
Staircases_in_Fluid_Dynamics_JacobGreenhalghStaircases_in_Fluid_Dynamics_JacobGreenhalgh
Staircases_in_Fluid_Dynamics_JacobGreenhalghJacob Greenhalgh
 
Raffaele Salvucci s111179 Thesis
Raffaele Salvucci s111179 ThesisRaffaele Salvucci s111179 Thesis
Raffaele Salvucci s111179 Thesisraffaele00
 

Similar to CEE 235B Final Project_John_Wick (20)

thesis
thesisthesis
thesis
 
thermal_physics
thermal_physicsthermal_physics
thermal_physics
 
lecture notes fluid mechanics.pdf
lecture notes fluid mechanics.pdflecture notes fluid mechanics.pdf
lecture notes fluid mechanics.pdf
 
lecture notes fluid mechanics.pdf
lecture notes fluid mechanics.pdflecture notes fluid mechanics.pdf
lecture notes fluid mechanics.pdf
 
Engn4625 e brick1_2014_ circuitanalysismaths
Engn4625 e brick1_2014_ circuitanalysismathsEngn4625 e brick1_2014_ circuitanalysismaths
Engn4625 e brick1_2014_ circuitanalysismaths
 
Nonlinear Simulation of Rotor-Bearing System Dynamics
Nonlinear Simulation of Rotor-Bearing System DynamicsNonlinear Simulation of Rotor-Bearing System Dynamics
Nonlinear Simulation of Rotor-Bearing System Dynamics
 
Master Thesis
Master Thesis Master Thesis
Master Thesis
 
Quantm mechanics book
Quantm mechanics bookQuantm mechanics book
Quantm mechanics book
 
morten_bakkedal_dissertation_final
morten_bakkedal_dissertation_finalmorten_bakkedal_dissertation_final
morten_bakkedal_dissertation_final
 
Buckling and Postbuckling Loads Characteristics of All Edges Clamped Thin Rec...
Buckling and Postbuckling Loads Characteristics of All Edges Clamped Thin Rec...Buckling and Postbuckling Loads Characteristics of All Edges Clamped Thin Rec...
Buckling and Postbuckling Loads Characteristics of All Edges Clamped Thin Rec...
 
CADances-thesis
CADances-thesisCADances-thesis
CADances-thesis
 
TR-CIS-0420-09 BobZigon
TR-CIS-0420-09 BobZigonTR-CIS-0420-09 BobZigon
TR-CIS-0420-09 BobZigon
 
ME75-2014-myan076-report
ME75-2014-myan076-reportME75-2014-myan076-report
ME75-2014-myan076-report
 
Report #6
Report #6Report #6
Report #6
 
Transport Properties of Graphene Doped with Adatoms
Transport Properties of Graphene Doped with AdatomsTransport Properties of Graphene Doped with Adatoms
Transport Properties of Graphene Doped with Adatoms
 
Staircases_in_Fluid_Dynamics_JacobGreenhalgh
Staircases_in_Fluid_Dynamics_JacobGreenhalghStaircases_in_Fluid_Dynamics_JacobGreenhalgh
Staircases_in_Fluid_Dynamics_JacobGreenhalgh
 
Hoifodt
HoifodtHoifodt
Hoifodt
 
print
printprint
print
 
Raffaele Salvucci s111179 Thesis
Raffaele Salvucci s111179 ThesisRaffaele Salvucci s111179 Thesis
Raffaele Salvucci s111179 Thesis
 
Master Thesis
Master ThesisMaster Thesis
Master Thesis
 

CEE 235B Final Project_John_Wick

  • 1. Title: CEE 235B Final Project Revision: A ii Revision A CEE 235B ADVANCED FINITE ELEMENT ANALYSIS OF STRUCTURES Author: John Wick UCLA MASTERS in ENGINEERING Field of Study: Mechanics of Structures
  • 2. Title: CEE 235B Final Project Revision: A iii TABLE OF CONTENTS ACRONYMS...............................................................................................................................v 1 ABSTRACT.....................................................................................................................1 2 INTRODUCTION.............................................................................................................1 3 METHODS ......................................................................................................................2 4 RESULTS .....................................................................................................................11 5 DISCUSSION................................................................................................................16 6 SUMMARY & CONCLUSIONS .....................................................................................22 7 REFERENCES..............................................................................................................23 APPENDIX A. MATLAB CODE..............................................................................................A-1
  • 3. Title: CEE 235B Final Project Revision: A iv LIST OF FIGURES Figure 1. Elastic Bar Impacting rigid wall @ Velocity V_0...........................................................1 Figure 2. Matched method rationale............................................................................................8 Figure 3. Approximate solution of Displacement vs Time..........................................................11 Figure 4. Approximate Solution of Stress vs Time.....................................................................12 Figure 5. Exact Solution of Displacement vs Time ....................................................................13 Figure 6. Exact Solution of Stress vs time.................................................................................13 Figure 7. Comparison of displacement approximations to exact solution...................................14 Figure 8. Comparison of stress approximations to exact solution..............................................15 Figure 9. Effect of element size on approximation.....................................................................15 Figure 10. Effect of time step size on approximation .................................................................16 Figure 11. Unstable finite element model results.......................................................................19 Figure 12. Damping of high frequency oscillations in approximate solution...............................20 Figure 13. L2 Error norm of Displacement.................................................................................21 Figure 14. H1 Error Norm of Stress...........................................................................................21 LIST OF EQUATIONS Equation 1. 3D Wave equation....................................................................................................2 Equation 2. Strong form of the boundary value problem..............................................................2 Equation 3. Constitutive Law......................................................................................................2 Equation 4. Strain Displacement Relationship.............................................................................2 Equation 5. Stress Strain Relationship in 1D...............................................................................3 Equation 6. Strain Displacement Relationship in 1D ...................................................................3 Equation 7. Strong form of 1D elastic bar BVP............................................................................3 Equation 8. Weak form of 1D elastic bar BVP.............................................................................4 Equation 9. Galerkin formulation of 1D elastic bar BVP...............................................................4 Equation 10. Finite element approximation of trial and weight functions in space and time.........5 Equation 11. Mass and Stiffness matrices...................................................................................5 Equation 12. Element Mass and Stiffness matrices.....................................................................5 Equation 13. Semi-Discrete equation of 1D elastic bar BVP........................................................6 Equation 14. Full discrete equation of 1D elastic bar BVP...........................................................6 Equation 15. Newmark Time integration method.........................................................................7 Equation 16. Ratio of temporal and spatial integration frequency to exact frequency..................8 Equation 17. Stability analysis of Newmark Time Integration ......................................................9 Equation 18. Critical Time step for central difference method......................................................9 Equation 19. L2 error norm .......................................................................................................10 Equation 20. H1 error norm.......................................................................................................10 Equation 21. Rate of Convergence ...........................................................................................10
  • 4. Title: CEE 235B Final Project Revision: A v ACRONYMS Acronym Description 1D 1 dimensional 2D 2 dimensional 3D 3 dimensional BVP Boundary Value Problem Det Determinant DOF Degree of Freedom E*I Stiffness (E = Elastic Modulus; I=rotational inertia) Eq Equation Hz Hertz K Stiffness L Length NEN Number of Element Nodes ODE Ordinary Differential Equation PDE Partial Differential Equation RMS Root Mean Square Wn Natural Frequency
  • 5. Title: CEE 235B Final Project Revision: A 1 1 ABSTRACT The objective of this paper is to study the numerical characteristics of explicit and implicit time integration methods and their stability and accuracy. 2 INTRODUCTION This paper will guide the reader through the procedure of solving for displacement and stress histories at various locations along a finite length elastic bar that impacts into a rigid wall with an initial velocity V_0 as shown in figure 1 below. Figure 1. Elastic Bar Impacting rigid wall @ Velocity V_0 The bar is made of a linear elastic material with constant material properties throughout its length. The bar will be divided up into a linear finite element model consisting of 2-node elements. Two methods will be described and developed to solve for the displacement and stress histories during the impact event: 1. The implicit time integration method will utilize the central difference method with a lumped mass 2. The explicit time integration method will utilize the average acceleration method with consistent mass. The methods section below will provide details in how the two different methods are developed and utilized to calculate the history plots. Due to the nature of a finite element analysis, it’s an approximation of a true solution. The error of the approximation is an important factor in understanding how accurate a model is to the true solution. The accuracy and stability of both methods will be discussed as they relate to the true solution. Additional discussion will include how element size and time step size affect the accuracy and stability of the numerical approximation.
  • 6. Title: CEE 235B Final Project Revision: A 2 3 METHODS This section will describe the process by which the governing 3 dimensional differential equation is manipulated until a solution of displacement and stress at various locations along the length of the bar is reached. The calculations of error between the approximate and exact solution will also be described in this section. Equation 1 below is the 3 dimensional wave equation that governs the bar’s response. Equation 1. 3D Wave equation Below are the boundary conditions and initial conditions that, coupled with equation 1, make up the strong form of this boundary value problem. Equation 2. Strong form of the boundary value problem In order to reduce this to a 1 dimensional problem, the following relationships are substituted into the strong form presented above. Equation 3. Constitutive Law Equation 4. Strain Displacement Relationship When i=j=k=1, the constitutive law and strain displacement operations are reduced to the following 1D equations
  • 7. Title: CEE 235B Final Project Revision: A 3 Equation 5. Stress Strain Relationship in 1D Equation 6. Strain Displacement Relationship in 1D Utilizing equations 5 and 6, the strong form of the 1D elastic bar problem is show below Equation 7. Strong form of 1D elastic bar BVP In order to arrive at the semi and fully discrete equation from where the accelerations and displacement are calculated and iterated, modify the strong form must be modified into the weak form by multiplying it by an arbitrary weight function, wi and integrating over the entire space and time domain.
  • 8. Title: CEE 235B Final Project Revision: A 4 Equation 8. Weak form of 1D elastic bar BVP After integrating by parts the second derivative of u with respect to x, the weak form integral simplifies into 2 terms shown in equation 9 below. The Galerkin formulation of elastodynamics below introduces the function Uh(x,t), the trial function, which is the approximation of the true solution U(x,t). Equation 9. Galerkin formulation of 1D elastic bar BVP The formulation for uh(x,t) and wh(x,t) are shown below in eq 10 where NEN is the number of element nodes. The 1D elastic BVP requires the use of 2 node elements and therefore each element has an N1 and N2 shape function. The 2 node elements used classify Uh as a first order approximation of the solution. It is first order because the shape functions, N1 and N2 for each element, are linear functions.
  • 9. Title: CEE 235B Final Project Revision: A 5 Equation 10. Finite element approximation of trial and weight functions in space and time Utilizing the finite element approximations stated in equation 10, the two terms from the galerkin formulation in equation 9 above are shown to be the mass (M) and stiffness (K) matrices as shown below where x double dot is acceleration and x is displacement. Equation 11. Mass and Stiffness matrices Utilizing 2 node elements, the individual element mass and stiffness matrices are shown below. The problem requires the calculation of two different types of mass matrices, a lumped mass and consistent mass. The lumped mass is a diagonal matrix and the consistent mass matrix is not. The definition of each is shown below: Equation 12. Element Mass and Stiffness matrices Equation 11 and the strong form above lead to the semi discrete equation
  • 10. Title: CEE 235B Final Project Revision: A 6 Equation 13. Semi-Discrete equation of 1D elastic bar BVP Where a(t) is the acceleration at time t and d(t) is the displacement at time t. The spatial component of the finite element approximation is taken care of in the stiffness matrix K. The full discrete equation is achieved and shown below in equation 14. Equation 14. Full discrete equation of 1D elastic bar BVP The dn, vn and an are the approximations of the true or exact values: d(tn), v(tn) and a(tn). From the discrete equation, the Newmark method of time integration is utilized to calculate the approximations of the displacement, velocity and acceleration at each node over a specified time period. The stress as functions of space and time is calculated using the stress strain relationship from equation 5 above while strain is the derivative of displacement with respect to x. The Newmark time integration method is summarized below for both implicit and explicit solutions, the explicit solution is when β = 0 where n+1 is the time step after the nth time step
  • 11. Title: CEE 235B Final Project Revision: A 7 Equation 15. Newmark Time integration method The implicit and explicit methods are both developed via the Newmark method however it’s important to explain the significance of each. The explicit method calculates a state of the system at a later time from the state of the system at the current time and the implicit method takes a weighted average of the current and predicted future state of a system. The explicit method requires generally smaller and greater number of time steps to approximate the true solution in order to minimize the error while the implicit method requires extra computations and matrix inversions. The error associated with both methods of approximation will be discussed further in the discussion section of this paper. To begin the cascade of time iterations, begin at time t=0 and calculated a0. D0 and v0 are known, to calculate a0 the time t=0 discrete equation is set up, subtract the Kd0 term and multiply it by the inverse of the mass matrix. Utilizing the equations in equation 15 above, begin calculating d(tn+1), v(tn+1) and a(tn+1) until the end of the simulation has been reached. The rationale for grouping the central difference method with the consistent mass and the average acceleration with the lumped mass matrix is to minimize error. The theory of matched methods suggests that transient integrators and mass matrices shall be matched so that the induced period errors from the integration method and mass matrix chosen tend to cancel. The trapezoidal rule of temporal integration tends to increase the simulation time periods and the converse is true of the central difference method. Similarly, the lumped mass matrix has a tendency to increase the simulation time period and the opposite is true of the consistent mass matrix. This is proven via the exact solution of the scalar version of the semi discrete equation of the 1D elastic bar BVP. The solution is seen below:
  • 12. Title: CEE 235B Final Project Revision: A 8 Equation 16. Ratio of temporal and spatial integration frequency to exact frequency Where ∆t is the time step of the temporal integration, β = Newmark coefficient, h is element length, ω is the exact frequency response and is the frequency produced by time integration in conjunction with the element spatial discretization. The equation 16 above is graphically summarized in the two figures below that represent the rationale for the matching method chosen. Figure 2. Matched method rationale The figure on the left represents the frequency ratio (ideal is 1) with curve 1 representing the consistent mass and curve 2 is the lumped mass. The figure on the right shows the ratio of the time step to simulation period vs algorithmic damping ratio. The match up of the central difference method and the lumped mass matrix is a unique case in which the period errors from the spatial discrete system and the particular integrator are canceled perfectly and the exact solution is achieved. With β =r=0 and the time step = h/c, = ω and this property is called superconvergence. Stability of the Newmark integration method for the 1D elastic rod BVP is summarized below where β and γ are the Newmark integration constants. cc
  • 13. Title: CEE 235B Final Project Revision: A 9 Equation 17. Stability analysis of Newmark Time Integration The ω is the square root of the maximum eigenvalue of the K and M matrix. Ultimately, for 1 D wave equation, the critical time step for conditionally stable time integration methods (central difference method utilizing the consistent mass) is the time it takes for the wave to travel through one element. The critical time step is reduced to the equation below: Equation 18. Critical Time step for central difference method Where h is the length of each element and ρ is the material density. If any time step above the critical time step is employed for a conditionally stable approximation, the model will not converge and the approximation error goes to infinity. More details on convergence and the derivation of the stability conditions are in the discussion section including an example of a displacement approximation that does not converge. It’s important to note that because of the physical significance of the critical time step, reducing the time step while holding the mesh length fixed can only worsen the results and for this investigation, unless otherwise specified, the critical time step will be used.
  • 14. Title: CEE 235B Final Project Revision: A 10 The accuracy of the approximations will be shown a number of different ways. The accuracy of both the displacement and stress approximations from the average acceleration and consistent mass method will be calculated using the L2 and H1 error norms, respectively. For different time steps and element sizes visual representations of the error will be provided to demonstrate the trends. Below are the equations used to calculate the L2 and H1 error norms: Equation 19. L2 error norm Equation 20. H1 error norm Again, u is the exact solution and uh is the approximate solution and thus the difference between the approximate and exact solutions over the length of the bar is of interest. It’s necessary to calculate an error norm at individual time steps and averaging them over the length of the rod, so at any discrete time step the difference between the two solutions is of interest. A log-log plot of element size versus error norm will be provided to quantify the accuracy of the finite element approximations and the convergence. The slope of the log-log line is the rate of convergence, α, for the respective approximation model from the equation below Equation 21. Rate of Convergence Where h is the element length and c is a constant. The discussion section will explain how the equations presented in this section demonstrate how element size and time step size affect both stability and accuracy of the finite element approximate solution.
  • 15. Title: CEE 235B Final Project Revision: A 11 4 RESULTS Before displaying the results, the notations in the plot legends L, L/4, L/2 etc represents positions along the bar. L/2 represents the mid point, L represents the end of the rod impacting the wall and 0 represents the free end of the bar. The figures 3 and 4 below are the plots of displacement and stress, at various points along the bar, over the simulation time period utilizing the consistent mass and average acceleration time integration. Figure 3. Approximate solution of Displacement vs Time
  • 16. Title: CEE 235B Final Project Revision: A 12 Figure 4. Approximate Solution of Stress vs Time The bar was divided up into twenty 2 node elements of the same length. The legend indicates which line corresponds to the various locations along the bar. An important note, the stress is calculated on each element whereas the displacements are calculated at each node. Figures 5 and 6 below are the plots of the exact displacement and stress over the simulation time period utilizing the lumped mass and central difference time integration. Super convergence is defined as when a finite element approximation yields the exact solution as the lumped mass and central difference method does.
  • 17. Title: CEE 235B Final Project Revision: A 13 Figure 5. Exact Solution of Displacement vs Time Figure 6. Exact Solution of Stress vs time
  • 18. Title: CEE 235B Final Project Revision: A 14 Identical to the approximate solution, the bar was divided up into twenty 2 node elements of the same length. The legend indicates which line corresponds to the various locations along the bar. An important note, the stress is calculated on each element whereas the displacements are calculated at each node. The figure below superimposes the real solution and approximate solutions of displacement at 2 different points along the bar for a visual comparison. Figure 7. Comparison of displacement approximations to exact solution The figure below superimposes the real solution and approximate solutions of stress at 2 different points along the bar for a visual comparison.
  • 19. Title: CEE 235B Final Project Revision: A 15 Figure 8. Comparison of stress approximations to exact solution The graph below shows how the finite element approximate gets closer to the exact solution as element size is increased. The graph below displays the exact displacement at the midpoint (Length/2) of the bar with the approximate values utilizing 20 and 100 element discretizations. Figure 9. Effect of element size on approximation The approximations are the result of the implicit method of integration and the consistent mass matrix and the exact solutions are a result of the lumped mass and central difference method.
  • 20. Title: CEE 235B Final Project Revision: A 16 The approximate solutions are compared to the exact solutions of the same element size for reasons covered in the discussion section. The graph below shows how the error of the approximate solution is improved with smaller time steps. Figure 10. Effect of time step size on approximation Each curve is representative at the stress at the midpoint of the bar (L/2) utilizing a 100 element discretization, the different time steps used for the approximate solutions are indicated in the legend where h is element length A more detailed discussion on the results presented, including but not limited to the accuracy of the approximations and stability of the models will be discussed in the next section. 5 DISCUSSION The approximate solutions of displacement in figure 3 are reasonable shapes when considering what physically happens to the bar during impact into a rigid wall. In figure 3, the displacement at the wall end (x=L), stays zero, consistent with the boundary conditions, and the displacement has a peak at the free end (x=0) halfway through the time simulation. This makes sense because the free end continues to displace until the wave induced by the impact of the opposite end of the bar and the wall reaches the free end and sends the first node back to its nominal position. Applying the wave explanation to the other nodes, the graph indicates that the nodes
  • 21. Title: CEE 235B Final Project Revision: A 17 closer to the wall end encounter the wave from impact sooner because it has less distance to travel which makes sense. The approximate solutions of the stresses in figure 4 exhibits the overall behavior one would expect from a physical interpretation however there are some areas on the curves that do not correlate to the physical reaction. Stress is equal to strain times the elastic modulus, a constant in this case, and the stress remains zero for elements until they change length. Again, the boundary condition, at L, the stress remains zero however for an element at the free end, the element doesn’t crunch until the wave has time to propagate through the bar. Once the bar returns to its nominal position that same element returns to its original length and the stress goes back to zero as seen on the graph. The overshoot on the max stresses at various points along the bar and at the end of the simulation when the bar returns to its nominal length the stress crosses the x-axis similar to an over damped response are not representative of the model. In this simulation no damping is assumed and thus these overshoots are clearly errors in the approximation. The exact solutions in figures 5 and 6, as stated above, are the results from the lumped mass and central difference integration method. From the methods section this is the result of superconvergence. The graphs are identical to the expected response of the bar. The assumptions made and boundary conditions imposed, the problem reduces to a series of linear elastic springs (represented by the elements) in which they compress and then release back to their nominal state. The exact solution shows that the stress reaches the same exact maximum value (-1) for all elements because they all compress to the same length eventually and then return to their nominal length (constant material properties) e.g. stress goes back to zero. As a reminder, for the purposes of this paper the lumped mass with central difference temporal integration method will be referred to as the exact solution and the consistent mass with the average acceleration method as the approximate solution. The comparisons of displacement and stress to the exact solution at various points are included simply to show on the same graphs, how the different methods’ results look while superimposed upon each other. Later in this section, the accuracy of the model with respect to time step length and element size will be discussed. Stability of a finite element model is best described as the ability of the model to converge and produce reasonable results. The reason this is important because stability depends on the time step size and element dimension selected, if too large a time step is used or the elements are too large, the resolution will be to coarse and the correct response will not be captured. Similar to the Nyquist theorem for data sampling rates, the theorem states that a signal must be sampled at a minimum of 2x the frequency at which the signal being measured is oscillating. If the temperature profile of an engine block of a drag racing car is of interest and the temperature is recorded every 5 minutes, the resolution of the curve will not provide the detail of interest. In 5
  • 22. Title: CEE 235B Final Project Revision: A 18 minutes the car will go from idle to maximum temperature and then the engine will then cool off presumable back to the idle temperature and the data will be of no value. If the rotor temperature of a steady state generator was of interest, recording the temperature ever 5 minutes could be appropriate as the temperature will not vary much over a 5 minute period. Conversely, it would be a waste of time and data storage to measure the generator rotor temperature every half second frequency during stead operation however the every half second would be reasonable for obtaining a temperature profile of a drag car engine during a race. The finite element models are the same way, small elements or short time steps between each data point may not be necessary however too large of elements or too large a time step might not give a reasonable response. Finite element models that utilize extremely small time steps and element sizes are costly and time consuming and in some cases necessary but in other cases not accurate and thus the appropriate time steps and element sizes must be chosen for the specific model. With the superconvergent condition, it’s important to note that the accuracy of the lumped mass and central difference method is not improved with varying element size or smaller time steps. Theoretically the accuracy of the values of stress and displacement at each node are independent of element size however with minute numerical calculations propagated through the time integration, different element sizes produce fractionally small displacement and stress magnitudes. This is why figure 9 utilizes two different element sizes for comparison to the approximation method. For reasons stated in the methods section, the critical time step is the only time step that produces the exact results at each node and that is why the effect of the time step was not studied for the lumped mass and central difference approximation method. The stability of the superconvergent condition is however affected by the time step chosen. The dependence on time step size for both methods is derived from the eigenvalue problem of the semi-discrete equation presented in the methods section. From the modal equation the amplification matrix, the ratio of a time step value to the previous time step value, requires conditions that prevent the amplification matrix becoming larger and larger at later time steps. The spectral radius is defined as the maximum eigenvalue of the amplification matrix and it must meet two conditions, the maximum value of the spectral radii must be less than or equal to 1 (less than 1 if eigenvalues are not distinct) and the eigenvalues of the amplification matrix of multiplicity greater than one are strictly less than one in modulus. A violation of these two conditions produces rapid or slow divergent instabilities as seen in the figure below. The figure below is an example of the same 20 element approximation however the time step is too large for the model to converge. Form the methods section and equation 17, the central difference method was stable for all time steps below the critical time step and the average acceleration method with consistent mass was stable for any time step chosen.
  • 23. Title: CEE 235B Final Project Revision: A 19 Figure 11. Unstable finite element model results The only difference between figure 11 and figure 5, the exact displacement, is that the time step used was 1.2 times the critical time step which lead to an unstable solution. Figure xx in the methods sections summarizes the stability conditions for the specific problem of the 1D elastic bar. From that figure one can see that the critical time step is the element length divided by the speed of sound in the given material. This makes physical sense, as discussed before this is the time it takes for the wave to propagate through one element. As evidenced by figure 11 above, if this time step is 1.2 times the critical time step, very small increase, the proper response cannot be captured. Additionally, it becomes clear that the time step is dependent on element size as well. The implicit time integration method, average acceleration, with a consistent mass matrix is stable for any time step chosen. This is because from equation 17 in the methods section, with beta = ¼ and gamma = ½, the critical sampling frequency is zero. Although any time step can be chosen, it’s important to note that the error of the approximation is directly related to the time step squared. The model will converge for any time step however the accuracy is directly proportional to time step squared so it’s important to know how accurate the approximations must be for a given application. Figure 10 from the results points to the same conclusion. The figure shows a 100 element discretization using the average acceleration and consistent mass matrix with smaller and smaller multiple time steps of the critical time step, h/c, and visually the conclusion can be drawn that the smallest time step h/4c is the closest to the exact solution using a 100 element discretization. Outside the scope of this study, the high frequency oscillations seen in the approximate solutions in figure 12 can be eliminated using the consistent mass matrix coupled with different beta and gamma values. For gamma values above ½ there is a beta value, [(gamma + ½)^2]/4, that optimizes the damping of the higher frequency oscillations. The figure below shows
  • 24. Title: CEE 235B Final Project Revision: A 20 compares the exact solution to the non damped approximation and the optimally damped approximation with gamma = 0.6 and beta = 0.3025 (black dotted line). Figure 12. Damping of high frequency oscillations in approximate solution For the case of the 1D elastic bar, the exact solution is provide via the superconvergent condition and thus the error for the approximated displacements and stresses can be calculated from the average acceleration method versus element size. From figure 9 in the results, it’s clear that time step being equal, the smaller the element size the better the approximation. Now that a visual presentation of the error in finite element approximation has been provided, the error norms of displacement and stress are quantified via the equations 19 and 20 presented at the end of the methods section. The L2 error norm calculated for displacement error is graphed versus different element lengths below. The plot is a log-log plot where the natural log of the element dimension and the error norm are displayed.
  • 25. Title: CEE 235B Final Project Revision: A 21 Figure 13. L2 Error norm of Displacement T2 represent a specific time step, the error norm was calculated on a single time step for various numbers of elements. The slope of the graph, 2, is equal to the rate of convergence and of the displacement error which is in line with the theoretical value assuming the exact solution is infinitely continuous e.g. a sinusoidal function. Most importantly, the trend is clear that the error is reduced with a smaller element size e.g. finer mesh. Similar for the error on stress, the figure below is the H1 error norm calculated for models with different element sizes. Figure 14. H1 Error Norm of Stress T2 represent a specific time step, the error norm was calculated on a single time step for various numbers of elements. The slope of the graph, 1, is equal to the rate of convergence and of the stress error which is in line with the theoretical value assuming the exact solution is infinitely continuous e.g. a sinusoidal function. Again, the trend is clear that the error is reduced with a smaller element size.
  • 26. Title: CEE 235B Final Project Revision: A 22 6 SUMMARY & CONCLUSIONS The two methods analyzed of approximating the response of the elastic bar problem provide both exact and reasonable responses when the parameters chosen are best understood. The average acceleration method utilized with the consistent mass provided a reasonable approximation regardless of the time step chosen and was better approximated with smaller time steps and smaller element sizes. The central difference method coupled with the lumped mass provided the exact solution at each node only for time steps equal to the critical time step. Theoretically the element size, for the central difference and lumped mass method should not have affected the results at a given node however due to minute computational errors compounded through the time integrations, the element size did change the magnitude of the displacements and stresses by fractions of percentage points. For practical purposes and not discussed in detail, the understanding of the limitations of a finite element model are extremely important when taking into consideration time and cost constraints. As evidenced by the results of this investigation, one approximation provided better results with smaller time steps and element sizes e.g. more expensive and timely however the other approximation distanced itself further from the exact solution with smaller time steps and similarly no accuracy was gained with smaller element sizes.
  • 27. Title: CEE 235B Final Project Revision: A 23 7 REFERENCES 1) Hughes, J. R., The Finite Element Method: Linear Static and Dynamic Finite Element Analysis, Dover Publications, Inc, Mineola, New York.
  • 28. Title: CEE 235B Final Project Revision: A A-1 APPENDIX A. MATLAB CODE %CEE 235B Final Project %John Wick % clear all; close all; clc %number of elements n=10; %Initial Conditions at all nodes @ time t=0 %initial Velocity = 1 %initial Displacement = 0 %initial Acceleration = 0 %known Material Properties/Constants (dimensionless) E=100; %Bar Elastic Modulus L=10; %Bar Length A=1; %Bar Cross Sectional Area rho=0.01; %Bar Density c=sqrt(E/rho); %Bar Material Speed of Sound L_e=L/n; %length of element %number of degrees of freedom ndof=2; %1 dimensional problem, 2 nodes %stiffness matrix for 2 node element 1D elasticity (slide 58) K = zeros(n+1,n+1); for i=1:n K(i,i)=2*E*n/L; K(i,i+1)=-E*n/L; K(i+1,i)=-E*n/L; K(i+1,i+1)=2*E*n/L; end %eliminate the last column and row -- last node displacement = 0 K(1,1)=E*(n/L); K(n+1,n+1)=E*(n/L); K(n+1,:)=[]; K(:,n+1)=[]; % display('Global stiffness matrix,');K %Construct global consistent mass matrix M_c = zeros(n+1,n+1); for ii=1:n M_c(ii,ii)=(2/3);
  • 29. Title: CEE 235B Final Project Revision: A A-2 M_c(ii,ii+1)=1/6; M_c(ii+1,ii)=1/6; end M_c(1,1)=1/3; M_c(n+1,n+1)=1/3; M_c=M_c*(rho*L_e); %Lumped Mass Matrix for 2 node elements 1D elasticity M_l = zeros(n+1,n+1); % for j=1:n % M_l(j,j)=M_c(j,j); % end % M_l(n+1,n+1)=M_c(n+1,n+1); M_c_sum=sum(M_c,2); %place M_c_sum elements into diagonals of M_l for ROW SUM Lumped Mass for u=1:n+1; M_l(u,u)=M_c_sum(u,1); end %Choose lumped mass or consistent mass M=M_c; %Define Beta and Gamma based on Mass Matrix Chosen Above if M==M_c B=1/4; gamma=1/2; %Simulation Time Constants D_t=(2*L_e)/(c); %Critical time step for trapezoidal rule with consistent mass (unconditionally stable) T_total=0.2; %duration of the whole simulation t=T_total/D_t; %total number of time steps else if M==M_l B=0; gamma=1/2; %Simulation Time Constants D_t=L_e/c; %Critical time step for central difference with lumped mass (critical time step slide 59) T_total=0.2; %duration of the whole simulation t=T_total/D_t; %total number of time steps end end %eliminate the last column and row -- last node displacement = 0 (EBCs) M(n+1,:)=[]; M(:,n+1)=[]; % display('Global Mass matrix,');M %Initial displacement Vector -- eliminate the last node displacement because its 0
  • 30. Title: CEE 235B Final Project Revision: A A-3 d_initial=zeros(n,1); %Initial velocity Vector -- eliminate the last node velocity because its 0 v_initial=zeros(n,1); for y=1:n v_initial(y,1)=v_initial(y)+1; end %Call displacement, velocity and acceleration matrices -- Pre Allocation displacement=zeros(t+1,n+1); velocity=zeros(t+1,n+1); acceleration=zeros(t+1,n+1); %Initial acceleration vector @ t=0 a=M-K*d_initial; %Place iniital time steps into Displacement, Velocity & Acceleration matrices d=d_initial; v=v_initial; displacement(1,1:n)=d_initial; velocity(1,1:n)=v_initial; acceleration(1,1:n)=a; for k=1:t %predictors d_p=d+D_t*v+0.5*((1-2*B)*((D_t)^2)*a); v_p=v+((1-gamma)*(D_t)*a); % M star and F star M_s=M+(B*((D_t)^2)*K); F_s=-K*d_p; %acceleration vector a_n+1 a=M_sF_s; %Correctors d=d_p+(B*(D_t^2)*a); v=v_p+(gamma*(D_t)*a); %assembly of looped displacement, velocity and acceleration matrices displacement(k+1,1:n)=d; velocity(k+1,1:n)=v; acceleration(k+1,1:n)=a; end %Assembly of the Stress matrix stress=zeros(t,n+1); for r=1:t
  • 31. Title: CEE 235B Final Project Revision: A A-4 for rr=1:n stress(r,rr)=(E*(displacement(r,rr+1)-displacement(r,rr)))/L_e; end end dx=zeros(t,n+1); for r=1:t for rr=1:n dx(r,rr)=((displacement(r,rr+1)-displacement(r,rr)))/L_e; end end %Exact solution M=M_l; M(n+1,:)=[]; M(:,n+1)=[]; B=0; gamma=1/2; %Simulation Time Constants D_t=L_e/(c); %Critical time step for central difference with lumped mass (critical time step slide 59) T_total=0.2; %duration of the whole simulation t=T_total/D_t; %total number of time steps %Call displacement, velocity and acceleration matrices -- Pre Allocation displacement_exact=zeros(t+1,n+1); velocity_exact=zeros(t+1,n+1); acceleration_exact=zeros(t+1,n+1); %Initial acceleration vector @ t=0 a=M-K*d_initial; %Place iniital time steps into Displacement, Velocity & Acceleration matrices d=d_initial; v=v_initial; displacement_exact(1,1:n)=d_initial; velocity_exact(1,1:n)=v_initial; acceleration_exact(1,1:n)=a; for kk=1:t %predictors d_p=d+D_t*v+0.5*((1-2*B)*((D_t)^2)*a); v_p=v+((1-gamma)*(D_t)*a); % M star and F star M_s=M+(B*((D_t)^2)*K); F_s=-K*d_p; %acceleration vector a_n+1 a=M_sF_s;
  • 32. Title: CEE 235B Final Project Revision: A A-5 %Correctors d=d_p+(B*(D_t^2)*a); v=v_p+(gamma*(D_t)*a); %assembly of looped displacement, velocity and acceleration matrices displacement_exact(kk+1,1:n)=d; velocity_exact(kk+1,1:n)=v; acceleration_exact(kk+1,1:n)=a; end % figure(2); % plot(displacement_exact) % format longG % g=max(displacement_exact(:,n/2)) %Assembly of the Stress matrix stress_exact=zeros(t,n+1); for r=1:t for rr=1:n stress_exact(r,rr)=(E*(displacement_exact(r,rr+1)- displacement_exact(r,rr)))/L_e; end end dx_exact=zeros(t,n+1); for r=1:t for rr=1:n dx_exact(r,rr)=(displacement_exact(r,rr+1)-displacement_exact(r,rr))/L_e; end end %error %subtract each displacement and square it (U - Uh)^2 error=zeros(t+1,n+1); for y=1:t+1 for yy=1:n+1 error(y,yy)=(displacement_exact(y,yy)-displacement(y,yy))^2; end end %integrate the curve at each displacement (trapezoid rule) and make an error vector that has %an error at each time step E_0=zeros(t,1); error_pre_sum=zeros(t+1,n+1);
  • 33. Title: CEE 235B Final Project Revision: A A-6 for o=1:t for oo=1:n error_pre_sum(o,oo)=(error(o,oo)+error(o,oo+1))*(n/(L*2)); end end %need to sum the row elements of each row and place them in E_0 giving you %error norm at each time step for mm=1:t E_0(mm,1)=sqrt(sum(error_pre_sum(mm,1:n))); end % figure(3); % plot(E_0) %error of derivative ie stress! %subtract each displacement and square it (U - Uh)^2 error_dx=zeros(t,n+1); for y=1:t for yy=1:n+1 error_dx(y,yy)=((dx_exact(y,yy)-dx(y,yy))^2); end end %integrate the curve at each displacement (trapezoid rule) and make an error vector that has %an error at each time step E_0_dx=zeros(t,1); error_dx_pre_sum=zeros(t+1,n+1); for o=1:t for oo=1:n error_dx_pre_sum(o,oo)=(error_dx(o,oo)+error_dx(o,oo+1))*(n/(L*2)); end end % need to sum the row elements of each row and place them in E_0 giving you % error norm at each time step for mm=1:t E_0_dx(mm,1)=sqrt(sum(error_dx_pre_sum(mm,1:n))); end % figure(4); % plot(stress)