Numerical Study of the Vibration of a Periodically-supported Beam
by
Brandon C. Rush
An Engineering Project Submitted to the Graduate
Faculty of Rensselaer Polytechnic Institute
in Partial Fulfillment of the
Requirements for the degree of
MASTER OF MECHANICAL ENGINEERING IN MECHANICAL ENGINEERING
Approved:
_________________________________________
Ernesto Gutierrez-Miravete, Project Adviser
Rensselaer Polytechnic Institute
Hartford, Connecticut
November, 2009
(For Graduation December, 2009)
i
© Copyright 2009
by
Brandon C. Rush
All Rights Reserved
ii
CONTENTS
LIST OF TABLES ............................................................................................................ iv
LIST OF FIGURES ........................................................................................................... v
ACKNOWLEDGMENT .................................................................................................. vi
ABSTRACT .................................................................................................................... vii
1. Introduction.................................................................................................................. 1
2. Theory and Methodology ............................................................................................ 2
2.1
2.2
Static analysis – cantilevered beam.................................................................... 2
2.1.1
Analytic solution .................................................................................... 2
2.1.2
Finite element solution ........................................................................... 3
Dynamic analysis – cantilevered beam .............................................................. 4
2.2.1
Analytic solution .................................................................................... 4
2.2.2
Finite element solution ........................................................................... 5
3. Results.......................................................................................................................... 6
3.1
Static analysis – cantilevered beam.................................................................... 6
3.2
Dynamic analysis – cantilevered beam .............................................................. 8
4. Conclusion ................................................................................................................. 17
5. References.................................................................................................................. 18
Appendix A MATLAB Scripts ........................................................................................ 19
iii
LIST OF TABLES
Table 1: Cantilevered Beam Properties ............................................................................. 6
Table 2: 3-bay Beam Properties ..................................................................................... 10
iv
LIST OF FIGURES
Figure 1: End-loaded Cantilevered Beam.......................................................................... 3
Figure 2: Static Cantilevered Beam – 1 Element............................................................... 7
Figure 3: Static Cantilevered Beam – Multi-element ........................................................ 7
Figure 4: Dynamic Cantilevered Beam – Multi-element– 55.9 Hz ................................... 8
Figure 5: Dynamic Cantilevered Beam – Multi-element – 350.8 Hz ................................ 9
Figure 6: 3-bay Beam – COMSOL – 1st Mode................................................................ 10
Figure 7: 3-bay Beam – COMSOL – 2nd Mode............................................................... 11
Figure 8: 3-bay Beam – COMSOL – 3rd Mode ............................................................... 11
Figure 9: 3-bay Beam – COMSOL – 4th Mode ............................................................... 12
Figure 10: 3-bay Beam – 1st Mode .................................................................................. 12
Figure 11: 3-bay Beam – 2nd Mode ................................................................................. 13
Figure 12: 3-bay Beam – 3rd Mode .................................................................................. 13
Figure 13: 3-bay Beam – 4th Mode .................................................................................. 14
Figure 14: 3-bay Beam – Beam Response – Isometric.................................................... 15
Figure 15: 3-bay Beam – Beam Response ....................................................................... 16
v
ACKNOWLEDGMENT
I would like to thank my parents for their support and motivation throughout my
education. I would like to thank Dr. Ernesto Gutierrez-Miravete for his patience,
guidance, and support.
vi
ABSTRACT
This paper develops a finite element analysis code in MATLAB to solve the forced
vibration response of one-dimensional beams. The code is validated for simple static
and dynamic problems against analytical solutions and a commercial finite element
code, COMSOL, before applying it to more complicated structures. Finite element
analysis of a disordered periodic beam is used to demonstrate and investigate aspects of
periodic structure theory, including passbands and stopbands. The solution is compared
to published theoretical and experimental work.
.
vii
1. Introduction
Periodic structures can be considered a special class of vibrating structures with a
macroscopic repeating unit or building block. Examples of periodic structures include
train tracks laid over regularly-spaced railroad ties, bridges on evenly-spaced supports,
plates or equipment foundations with regularly-spaced stiffeners, or long pipes in a heat
exchanger with evenly-spaced supports. Periodic structure theory describes the unique
behavior of these structures as they transmit vibration or other waves. Newton
considered wave motion of identical mass particles connected by identical springs as
early as 1686, and Brillouin’s treatment in 1953 set the foundation for modern analysis
[1].
Application of the theory to free vibration of periodic beams was performed by
Miles [2]. Lin [3] and Bansal [4] studied disordered systems, which depart from strict
periodic structure theory. Systems of engineering interest are rarely perfectly periodic;
manufacturing tolerances, material property variability, and other perturbations can all
destroy the system’s periodicity. Bouzit [5] built several experimental systems and
recorded data on symmetric and perturbed periodicity. Bennet [6] extends the analysis to
ring stiffened cylindrical shells. Finite element analysis is particularly well-suited to
problems involving random disturbances where analytic solutions become less tractable.
A finite element program suitable for the dynamic analysis of periodically supported
structures was developed and verified against analytic and other computational solutions.
1
2. Theory and Methodology
A 2-dimensional finite element analysis code was developed in MATLAB [7] to reduce
execution times and easily vary parameters within the model. Element types and
connectivity were restricted to the one-dimensional beam being studied, which greatly
reduced the amount of bookkeeping and model verification required. The code can be
divided into two subsections, static and dynamic. The static portion of the code contains
the geometry of the problem and material stiffnesses and will provide static deflections
based on the applied load and boundary conditions. The dynamic portion of the code
introduces mass and provides the forced response at a given frequency.
2.1 Static analysis – cantilevered beam
The deflection of an end-loaded cantilevered beam was chosen as a validation problem
because it can be readily solved from first principles and is very amenable to modeling
via the finite element method.
2.1.1
Analytic solution
From elementary beam bending theory, the equation of motion for a beam is
M  EI
d2y
dx 2
Equation 2-1
with M the moment, E the modulus of elasticity, and I the area moment of inertia.
Defining a beam as shown in Figure 1 with length l and a force –P at the right end, the
moment within the beam is then given by the expression
M   P(l  x)
Equation 2-2
2
P
l
y
x
Figure 1: End-loaded Cantilevered Beam
Two boundary conditions are provided by the cantilevered end of the beam:
y  0 x 0
Equation 2-3
dy
0
dx
x 0
Equation 2-4
and
Substituting Equation 2-2 into Equation 2-1, integrating twice, and applying the
boundary conditions yields an equation for the deflection of the beam:
y ( x) 
P  1 2 1 3
  Lx  x 
EI  2
6 
Equation 2-5
and the maximum deflection is found at the free end x  L ,
Pl 3
y
3EI
Equation 2-6
This analytical solution will be used in Section 3.1 to verify the stiffness matrix
formulation, basic element connectivity, and input deck structure for the code.
2.1.2
Finite element solution
The code implements linear (2-noded) Timoshenko beam elements with 3 degrees of
freedom at each node: 2 translations and 1 rotation. Nodes are defined along the line y=0
3
and adjacent nodes are connected with a single beam element. The stiffness matrix is
uses the formulation developed by Cook in [8]. The correct nodal deflection is expected
with a single linear finite element.
2.2 Dynamic analysis – cantilevered beam
Dynamic analyses require information about the system mass. One common solution
method is eigenvalue analysis, which identifies resonant frequencies and mode shapes of
the system. This approach is used to solve for the natural frequencies of a cantilevered
beam in Section 2.2.1. One of its drawbacks is that the solution at any particular
frequency must be approximated as the sum of the contributions of many modes,
although it identifies mode shapes and resonant frequencies with efficiently and good
accuracy within the limitations of the modeling process. Another approach, the direct
solution, solves for the exact solution by including a frequency-dependent mass matrix
into the system equations and simply solving the combined equations. This approach is
more computationally intensive and limited to the frequency resolution at which it was
run. The code developed in this paper uses the direct method.
2.2.1
Analytic solution
An analytic solution to the transverse vibration of a cantilevered beam is presented by
Timoshenko p. 426 [9]. The frequency equation for the beam is given by
coskl coshkl  1
Equation 2-7
where l is the length of the beam and k is the wavenumber, which is related to the
natural frequency of the beam in Hertz, f, by
2
fi 
ak i
2
Equation 2-8
The term a is a measure of the transverse bending speed, given by
a
EI
A
Equation 2-9
4
with E the modulus of elasticity, I the moment of inertia,  the density, and A the
beam’s cross-sectional area. The first four roots of kl are 1.875, 4.694, 7.855, and
10.996 [9]. This analysis is used to validate that the mass matrix formulation and the
direct solution method provide accurate results for a vibration problem.
2.2.2
Finite element solution
The mass matrix is a combination mass matrix described by Cook [8]. Combination
mass matrices calculate both the lumped mass and consistent mass representations of the
mass matrix and weight them to determine the final matrix. Lumped mass
representations are preferred if many elements are used and rotations or transverse
displacements are not significant; otherwise, they distribute the mass too widely and tend
to underestimate natural frequencies. Consistent mass representations are preferred when
few elements are used and transverse displacements are significant; however, they tend
to overestimate natural frequencies. Both representations were given equal weight in the
code developed here.
Forced vibration responses are solved via direct solution (time-harmonic analysis)
instead of eigenvalue analysis as this provides the complete solution at a given frequency
without consideration for how many modes are participating. The penalty is that a new
matrix must be factored for each frequency, and the fidelity of the result is limited by the
number of frequencies solved. The low matrix bandwidth inherent to the beam problem
results in a low wavefront and rapid solutions.
5
3. Results
The analytical models from Chapter 2 are used to develop confidence in the finite
element program before it is applied to additional problems and compared to test data.
3.1 Static analysis – cantilevered beam
Consider a simple end-loaded cantilever beam as shown in Figure 1 with the parameters
shown in Table 1. The terms are as defined in Section 2.1.1 with the addition of  , the
density, A, the cross-sectional area, and  , the ratio of damping to critical damping. This
small, representative amount of damping is included to prevent large displacements at
resonance. As with most finite element codes, any units may be used provided they form

a consistent set. From Equation 2-6, the maximum deflection will be y = 0.0333. As
shown in Figure 2, the exact solution is found using a single finite element. The element
nodal displacements are plotted, effectively using linear interpolation for displacements
within the element. Figure 3 shows a multi-element beam, which again finds the exact
analytical solution. These cases validate basic element formulation, element
connectivity, and that material properties are handled correctly.

Property
Value
P
1
l
100
E
1E6
I
1E-3

1
A
0.1

0.01
Table 1: Cantilevered Beam Properties
6
Results - Cantilevered Beam - 1 element
0.02
Elements
Clamped
Displaced
0.01
0
-0.01
-0.02
-0.03
-0.04
-0.05
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
Figure 2: Static Cantilevered Beam – 1 Element
Results - Cantilevered Beam - multi element
0.02
Elements
Clamped
Displaced
0.01
0
-0.01
-0.02
-0.03
-0.04
-0.05
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
Figure 3: Static Cantilevered Beam – Multi-element
7
3.2 Dynamic analysis – cantilevered beam
Continuing with the cantilever beam example from Section 3.1, Equation 2-8 predicts
the first two natural frequencies of the beam will fall at 55.95 and 350.7 Hz. The code
was executed on a large number of frequencies between 10 and 1500 Hz. Figure 4 and
Figure 5 show the displacement of the beam at 55.9 and 350.8 Hz. Inset into each figure
is a frequency response plot showing the response in dB against frequency on a
logarithmic scale. The first few resonances are clearly visible as peaks in the response,
and the red line on the graph indicates which frequency is being plotted. The resonant
frequencies are in good agreement and the displaced shapes match those predicted by
Cook p. 386 [8].
Results - Cantilevered Beam - Multi-element 55.9 Hz
Elements
Clamped
Displaced
1.5
1
0.5
-0.5
-1
Displacement (dB re. 1)
Displacement
0
-1.5
-2
-2.5
-3
-1
-0.5
0
50
0
-50
-100
1
10
0.5
Length
2
10
Frequency (Hz)
1
1.5
3
10
2
Figure 4: Dynamic Cantilevered Beam – Multi-element– 55.9 Hz
8
Results - Cantilevered Beam - Multi-element 350.8 Hz
Elements
Clamped
Displaced
0.04
0.03
0.02
0
-0.01
Displacement (dB re. 1)
Displacement
0.01
-0.02
-0.03
-0.04
-0.05
-0.06
-0.5
0
50
0
-50
-100
1
10
0.5
Length
2
10
Frequency (Hz)
1
1.5
3
10
2
Figure 5: Dynamic Cantilevered Beam – Multi-element – 350.8 Hz
3.3 Dynamic analysis – 3-bay beam
Bouzit [5] has built a beam simply supported by 4 supports evenly spaced 12 inches
apart with a 1 inch overhang on the left-hand side to analyze the frequency response and
vibration localization. Dimensions for this beam are shown in Table 2. This beam was
modeled in COMSOL and the first four mode shapes are shown in Figure 6through
Figure 9. The equivalent figures with the code developed here are Figure 10 through
Figure 13 and the mode shapes agree well with the COMSOL results and the results
demonstrated theoretically and experimentally by Bouzit p. 657 [5].
9

Property
Value
P
10
l
37
E
30E6
I
8.138E-5

7.246E-4
A
0.0625

0.01
Table 2: 3-bay Beam Properties
Figure 6: 3-bay Beam – COMSOL – 1st Mode
10
Figure 7: 3-bay Beam – COMSOL – 2nd Mode
Figure 8: 3-bay Beam – COMSOL – 3rd Mode
11
Figure 9: 3-bay Beam – COMSOL – 4th Mode
Results - 3-bay Beam 80.7 Hz
Elements
Roller
Displaced
1
0.5
-0.5
Displacement (dB re. 1)
Displacement
0
-1
-1.5
-2
0
5
10
50
0
-50
-100
0
10
15
2
10
Frequency (Hz)
20
25
30
4
10
35
Length
Figure 10: 3-bay Beam – 1st Mode
12
Results - 3-bay Beam 103.5 Hz
1.5
Elements
Roller
Displaced
1
0
Displacement (dB re. 1)
Displacement
0.5
-0.5
-1
50
0
-50
-100
0
10
-1.5
0
5
10
15
2
10
Frequency (Hz)
20
25
30
4
10
35
Length
Figure 11: 3-bay Beam – 2nd Mode
Results - 3-bay Beam 151.3 Hz
Elements
Roller
Displaced
0.4
0.2
-0.2
Displacement (dB re. 1)
Displacement
0
-0.4
-0.6
50
0
-50
-100
0
10
-0.8
0
5
10
15
2
10
Frequency (Hz)
20
25
30
4
10
35
Length
Figure 12: 3-bay Beam – 3rd Mode
13
Results - 3-bay Beam 323.4 Hz
Elements
Roller
Displaced
0.1
0.05
-0.05
Displacement (dB re. 1)
Displacement
0
-0.1
-0.15
-0.2
0
5
10
50
0
-50
-100
0
10
15
2
10
Frequency (Hz)
20
25
30
4
10
35
Length
Figure 13: 3-bay Beam – 4th Mode
The results can also be viewed across frequency, which provides insight into regions of
modal density, called pass bands, and regions where the supports reject or quickly
attenuate displacement, called stop bands. Figure 14 provides an isometric view of the
displacement as a surface with beam position and frequency as the X-axis and Y-axis
and colored by the beam response in dB re. 1 inch as elevation of the Z-axis. Figure 15
contains the same data but is turned on edge to better highlight the pass and stop bands.
14
Figure 14: 3-bay Beam – Beam Response – Isometric
15
Figure 15: 3-bay Beam – Beam Response
16
4. Conclusion
Finite element analysis of a disordered periodic beam was used to demonstrate and
investigate aspects of periodic structure theory. A direct solution static finite element
code was developed in MATLAB capable of solving static and dynamic beam flexure
problems. The code was validated for simple static and dynamic problems against
analytical solutions and a commercial finite element code, COMSOL, before applying it
to more complicated structures.
The solutions compare favorably to published
theoretical and experimental results.
17
5. References
[1] L. Brillouin, Wave Propagation In Periodic Structures, New York: Dover, 1953.
[2] Miles, J. W., Vibration of Beams on Many Supports, Journal of Engineering
Mechanics Division, ASCE (1956) 82(1), 1-9
[3] Lin, Y. K. and J. N. Lang, Free Vibration of a Disordered Periodic Beam, Journal of
Applied Mechanics (1974) 41E, 383-391
[4] Bansal, A. S., Free Waves in Periodically Disordered Systems: Natural and
Bounding Frequencies of Unsymmetric Systems and Normal Mode Localizations,
Journal of Sound and Vibration (1997) 207(3), 365-382
[5] Bouzit, Djamel and C. Pierre, Wave localization and conversion phenomena in multicoupled multi-span beams, Chaos, Solitons and Fractals 11 (2000) 1575-1596
[6] Bennett, M. S. and M. L. Accorsi, Free Wave Propagation in Periodically Ring
Stiffened Cylindrical Shells, Journal of Sound and Vibration (1994) 171(1), 4966
[7] MATLAB 7.4.0 (R2007a), The Mathworks
[8] Cook, Robert D., et al., Concepts and Applications of Finite Element Analysis,
Fourth Edition, New York: John Wiley & Sons, 2002
[9] Timshenko, S., et al., Vibration Problems in Engineering, Fourth Edition, New
York: John Wiley & Sons, 1974.
18
Appendix A MATLAB Scripts
% This script file contains series of commands that create various
plots
close all;
% Plot some static results. plotDeck.m is slightly outdated and legend
% entries may be inaccurate. Results and plot figure information are
stored
% in the same structure as the input deck, dat.
dat = plotStatic(calcStatic(quickDeck('1 elem canti')));
axis([-.3 1.3 -0.05 0.02]); grid on;
title('Results - Cantilevered Beam - 1 element');
dat = plotStatic(calcStatic(quickDeck('multi elem canti')),'Results Cantilevered Beam - Multi-element');
axis([-.3 1.3 -0.05 0.02]); grid on;
dat = calcDynamic(quickDeck('multi elem canti'));
plotStatic(dat,55.9,'Results - Cantilevered Beam - Multi-element');
plotStatic(dat,350.7,'Results - Cantilevered Beam - Multi-element');
% Plot our response at the frequencies closes to the experimental
resonance
% frequencies
dat = calcDynamic(quickDeck('exper3'));
plotStatic(dat,80.905,'Results - 3-bay Beam');
plotStatic(dat,103.681,'Results - 3-bay Beam');
plotStatic(dat,151.396,'Results - 3-bay Beam');
plotStatic(dat,323.621,'Results - 3-bay Beam');
% Repeat for disordered beam
dat = calcDynamic(quickDeck('exper3-disorder'));
plotStatic(dat,73.9,'Results - Disordered 3-bay Beam');
plotStatic(dat,93.66,'Results - Disordered 3-bay Beam');
plotStatic(dat,153.40,'Results - Disordered 3-bay Beam');
plotStatic(dat,282.5,'Results - Disordered 3-bay Beam');
% Plot a 3D surface on a db (log) scale based on the absolute value of
% displacement
v = dat.u(2:3:end,:);
figure;
[x y] = meshgrid(dat.freq,dat.x);
surf(x,y,20*log10(abs(v)),'linestyle','none'); colorbar
set(gca,'xscale','log')
xlabel('Frequency (Hz)')
ylabel('Length (in)')
zlabel('Displacement (dB re. 1)')
% Sweep through the frequency spectrum plotting different mode shapes.
This
% highlights the pass and stop-band phenomena. You can see more and
more
% wavelengths fitting within the specimen at higher frequencies and the
way
% the displacements are concentrated near the driving end by the
disordered
% supports
animDynamic(calcDynamic(quickDeck('exper12-disorder')))
19
function dat = quickDeck(name)
% This file contains frequently-used input decks
% Decks are stored as a structure, dat, with the following fields:
%
% == Static and dynamic parameters ==
% .x
- x locations of nodes. Nodes are automatically
%
numbered sequentially
% .constraint - array containing model constraints. Each constraint is
a row in
%
the matrix of form [node# constraint#] with
%
constraint#: 1 = displacement-x, 2 = displacement-y, 3
= rotation
% .load
- array containing loads. Each load is a row with the
form
%
[node# force moment]
% .Ei
- product of the modulus of elasticity E and moment of
inertia I
%
for beams in this model
%
% == Dynamic parameters ==
% .rhoA
- product of the beam density rho and area A for beams
in this model
% .freq
- vector of frequencies
% .eta
- loss factor as a percent of critical damping for the
model
%
(eta = 0.2 --> 0.2%)
experimentalBeam.E = 30E6;
experimentalBeam.G = experimentalBeam.E/(2*(1+0.3));
experimentalBeam.I = 0.5*0.125^3/12; % bh^3/12
experimentalBeam.rho = 0.28/386.4; % 0.28 lb/in3 -> slugs
experimentalBeam.A = 0.5*0.125;
experimentalBeam.freq = logspace(1.6,3.3,300);
experimentalBeam.eta = 1; % percent critical damping
experimentalBeam.load = [...
1 0 -10 0]; % Drive overhanging edge
if nargin % If we were handed an argument
switch lower(name)
case '1 elem canti' % Note: static only
% Theoretical solution for an end-loaded cantilevered beam:
% ymax = -F*L^3/(3*E*I) = -100*1^3/3/1000 = 0.03333
% L=1;
% F1 = 3.533*sqrt(dat.E*dat.I/(dat.A*dat.rho*L^4))/2/pi
dat.x = [0 1]; % 2 nodes, 1 element
dat.constraint = [... % clamp the left end, all DOF
1 1
1 2
1 3];
dat.load = [...
2 0 -100 0];
dat.A = 0.1;
dat.E = 1E6;
dat.G = dat.E/(2*(1+0.3));
dat.I = 1E-3;
dat.rho = 1;
dat.freq = logspace(1,3,1500);
dat.eta = 1;
case 'multi elem canti' % Note: static only
dat.x = 0:.025:1;
dat.constraint = [...
1 1
20
1 2
1 3];
dat.load = [...
length(dat.x) 0 -100 0];
dat.A = 0.1;
dat.E = 1E6;
dat.G = dat.E/(2*(1+0.3));
dat.I = 1E-3;
dat.rho = 1;
dat.freq = logspace(1,3,1500);
dat.eta = 1;
case 'exper3'
% Small experimental setup from Bouzit and Pierre
% E: 30E6 psi
rho: 0.28 lb/in3
% width: 0.5 in thickness: 0.125 in -> I = bh^3/12 = 8.138E-5
% eta = 1%
%
% Force applied at a 1-inch overhang. Span length nominal 12 in
%
% Bernoulli-Euler bending wave
% rho=.28/386.4; omega=2*pi*[1 10 100]; E=30E6; h=0.5;
% c = sqrt(omega)*sqrt(sqrt(E*h^2/12/rho))
% sqrt(omega)*sqrt(sqrt(30E6*0.5^2/12/0.28))
% 135.8 429.6 4296
%
% Timoshenko-Mindlin bending wave
% rho=.28/386.4; omega=2*pi*[.1 1 100]; E=30E6; h=0.5;
% c =
sqrt(1./(1.7*rho/E+sqrt(12*rho./(omega.^2*E*h^2)+(0.7*rho/E)^2)))
dat = experimentalBeam;
dat.x = -1:.5:36;
dat.constraint = [... % constraints for -1:.5:36 spacing
3 2
27 2
51 2
75 2
];
%
dat.constraint = [5:48:150;2*ones(1,4)]'; % constraints
for -1:.25:36 spacing
case 'exper3-disorder'
dat = experimentalBeam;
xLen = [12.25
10+15/16
13+5/8];
xPos = [0 cumsum(xLen)];
dat.x = [];
for iL = 1:length(xLen)
dat.x = [dat.x linspace(xPos(iL),xPos(iL+1),25)];
end
dat.x = [-1 -.5 unique(dat.x)];
dat.constraint = [...
3 2
27 2
51 2
75 2
];
case 'exper12'
dat = experimentalBeam;
dat.x = -1:.5:120;
dat.constraint = [3:20:243;2*ones(1,13)]';
case 'exper12-disorder'
dat = experimentalBeam;
xLen = [9.8 9.35 11.3 10 10.9 9.05 10.3 8.7 9.7 11.1 10.5 9.3];
21
xPos = [0 cumsum(xLen)];
dat.x = [];
for iL = 1:length(xLen)
dat.x = [dat.x linspace(xPos(iL),xPos(iL+1),21)];
end
dat.x = [-1 -.5 unique(dat.x)];
dat.constraint = [3:20:243;2*ones(1,13)]';
end
else
error('No deck defined')
end
22
function dat = calcStatic(dat)
% Calculate the static deformation given an input deck of the format
% described in quickDeck.m
%
% Functions called:
% quickDeck.m
% trussK.m
if ~nargin % Use a default deck if not provided
close all; clc
dat = quickDeck();
end
L = diff(dat.x);
nE = length(L); % number of elements
nN = nE+1;
% number of nodes
k = zeros(20*nE,1); % preallocate vectors to hold indices into K
ky = k;
kx = k;
for iE = 1:nE
startDof = 3*(iE-1)+1; % Starting degree of freedom...row (or
column) of a 2D K
startInd = 20*(iE-1)+1; % Starting index for this section of
indices to K
targInd = startInd:(startInd+19); % Where to store the next 20
terms
[lilKx,lilKy,lilK] =
trussK(dat.A,dat.E,dat.G,dat.I,L(iE),startDof);
%
targDof = startDof:startDof+5;
%
K(targDof,targDof) = K(targDof,targDof) +
sparse(lilKx,lilKy,lilK);
k(targInd) = lilK;
kx(targInd) = lilKx;
ky(targInd) = lilKy;
end
K = sparse(kx,ky,k); % Build the stiffness matrix as a sparse matrix
F = zeros(3*nN,1);
loadNode = dat.load(:,1);
loadForceX = dat.load(:,2);
loadForceY = dat.load(:,3);
loadMoment = dat.load(:,4);
F(loadNode*3-2) = loadForceX;
F(loadNode*3-1) = loadForceY;
F(loadNode*3)
= loadMoment;
consNode = dat.constraint(:,1);
consVal = dat.constraint(:,2);
consList = zeros(length(consNode),1);
for iC = 1:length(consNode)
consList(iC) = 3*(consNode(iC)-1)+consVal(iC); % constraints, by
overall DOF number
end
K(consList,:) = [];
K(:,consList) = [];
F(consList) = [];
reducedU = K\F;
23
% Before saving the final u, include the constrained DOF. They are all
zero.
dat.u = zeros(3*nN,1);
goodInd = setdiff(1:3*nN,consList);
dat.u(goodInd) = reducedU;
24
function [x y s] = trussK(A,E,G,I,L,startInd)
% Build a combination bar-beam (truss) element, [u1 v1 theta1 u2 v2
theta2]
% Calculate k in a syntax appropriate for MATLAB's sparse matrix
% manipulations. Nonzero elements are presented in vectors x,y,s where
% (x(i),y(i)) = s(i).
% Use the Timoshenko beam formulation (Cook p. 27 eq. 2.3-7)
% L=1; E=1; G=1; I=1; A=1; startInd=1; % (debug) set inputs
ky = 0; % 1.2 for solid rectangular sections
phi = 12*E*I*ky/(A*G*L^2);
X = A*E/L;
Y1 =
12*E*I/((1+phi)*L^3);
Y2 =
6*E*I/((1+phi)*L^2);
Y3 = (4+phi)*E*I/((1+phi)*L);
Y4 = (2-phi)*E*I/((1+phi)*L);
% The code only handles elements connecting adjacent nodes, and we need
to know
% the number of DOF (indices) to offset
x = (startInd-1)+[1 1 4 4 2 2
2 2 3 3
3 3
5
5 5
5 6
6
6 6]';
y = (startInd-1)+[1 4 1 4 2 3
5 6 2 3
5 6
2
3 5
6 2
3
5 6]';
s =
[X -X -X X Y1 Y2 -Y1 Y2 Y2 Y3 -Y2 Y4 -Y1 -Y2 Y1 -Y2 Y2
Y4 -Y2 Y3]';
25
function dat = calcDynamic(dat)
% Calculate the dynamic response given an input deck of the format
% described in quickDeck.m
%
% Functions called:
% quickDeck.m
% trussK.m
% trussM.m
if ~nargin % Use a default deck if not provided
close all; clc
dat = quickDeck('canti');
end
L = diff(dat.x);
nE = length(L); % number of elements
nN = nE+1;
% number of nodes
nf = length(dat.freq); % number of frequencies
k
ky
kx
m
mx
my
=
=
=
=
=
=
zeros(20*nE,1); % preallocate vectors to hold indices into K
k;
k;
k;
k;
k;
for iE = 1:nE
startDof = 3*(iE-1)+1; % Starting degree of freedom...row (or
column) of a 2D K
startInd = 20*(iE-1)+1; % Starting index for this section of
indices to K
targInd = startInd:(startInd+19); % Where to store the next 16
terms
[lilKx,lilKy,lilK] =
trussK(dat.A,dat.E,dat.G,dat.I,L(iE),startDof);
k(targInd) = lilK;
kx(targInd) = lilKx;
ky(targInd) = lilKy;
[lilMx,lilMy,lilM] = trussM(dat.rho,dat.A,L(iE),startDof);
m(targInd) = lilM;
mx(targInd) = lilMx;
my(targInd) = lilMy;
end
K = sparse(kx,ky,k);
M = sparse(mx,my,m);
F = zeros(3*nN,1);
loadNode = dat.load(:,1);
loadForceX = dat.load(:,2);
loadForceY = dat.load(:,3);
loadMoment = dat.load(:,4);
F(loadNode*3-2) = loadForceX;
F(loadNode*3-1) = loadForceY;
F(loadNode*3)
= loadMoment;
consNode = dat.constraint(:,1);
consVal = dat.constraint(:,2);
consList = zeros(length(consNode),1);
for iC = 1:length(consNode)
consList(iC) = 3*(consNode(iC)-1)+consVal(iC); % constraints, by
overall DOF number
end
26
K(consList,:)
K(:,consList)
M(consList,:)
M(:,consList)
F(consList) =
= [];
= [];
= [];
= [];
[];
% Use complex stiffness to allow for damping
K = K * (1+dat.eta/100*i);
opt.disp = 0;
numEig = min(10,size(K,1));
try
[dat.phi dat.eig] = eigs(K,M,numEig,'sm',opt);
dat.modalFreq = real(sqrt(diag(dat.eig))/2/pi);
catch
dat.eig = 'Eigs failed';
dat.phi = 'Eigs failed';
end
% Before saving the final u, include the constrained DOF. They are all
zero.
dat.u = zeros(3*nN,nf);
goodInd = setdiff(1:3*nN,consList);
for iF = 1:nf
G = -(dat.freq(iF)*2*pi)^2*M + K;
reducedU = G\F;
dat.u(goodInd,iF) = reducedU;
end
27
function [x y s] = trussM(rho,A,L,startInd)
% Build a combination bar-beam (truss) element, [u1 v1 theta1 u2 v2
theta2]
% Cook p. 377-380
%
% consistent mass matrix:
% m = m/420*[ 156
22*L
54
-13*L
%
22*L
4*L^2 13*L -3*L^2
%
54
13*L
156 -22*L
%
-13*L -3*L^2 -22*L 4*L^2];
%
% lumped mass matrix:
% m = m*[0.5 L^2/24 0.5 L^2/24];
% where mass terms are applied at each node and thus lie on the
diagonal
%
% Implementing a combination mass matrix, 0.5*lumped + 0.5*consistent,
% calculate m in a syntax appropriate for MATLAB's sparse matrix
% manipulations. Nonzero elements are presented in vectors x,y,s where
% (x(i),y(i)) = s(i).
% L=1; rho=1; A=1; startInd=1;
% The code only handles elements connecting adjacent nodes, and we need
to know
% the number of DOF (indices) to offset
x = (startInd-1)+[2 2 2 2 3 3 3 3 5 5 5 5 6 6 6 6]';
y = (startInd-1)+[2 3 5 6 2 3 5 6 2 3 5 6 2 3 5 6]';
%
1
2
3
4
5
raw = rho*A*L/840*[366 22*L 54 -13*L 21.5*L^2
22*L]'; % Calculate each number only once
6
13*L
7
-3*L^2
8
-
s = raw([1 2 3 4 2 5 6 7 3 6 1 8 4 7 8 5]); % Index our calculated list
repeatedly
% 4 terms to handle extension
x = [x; (startInd-1)+[1 1 4 4]'];
y = [y; (startInd-1)+[1 4 1 4]'];
raw = rho*A*L/12*[5 1];
s = [s; raw([1 2 2 1])'];
28
function dat = plotStatic(dat,freq,titleStr)
% Plots the results of a single deformation. For dynamic runs, optional
argument
% freq plots the result at the nearest solved frequency and includes a
% small frequency response plot
if ~nargin
close all; clc;
dat = calcDynamic(quickDeck('multi elem canti')); % default deck
end
if size(dat.u,2) == 1 || nargin < 2 % If a static analysis
freqInd = 1;
freq = 0;
else
freqInd = interp1(dat.freq,1:length(dat.freq),freq,'nearest');
if freq<dat.freq(1);freqInd=1;end;
if freq>dat.freq(end);freqInd=length(dat.freq);end;
end
globalU
= dat.u(1:3:end,freqInd);
globalV
= dat.u(2:3:end,freqInd);
globalAlpha = dat.u(3:3:end,freqInd);
if ~isfield(dat,'hFig') % Plot deck
if nargin<3; titleStr = ''; end;
dat = plotDeck(dat,max(abs(real([globalU(:);
globalV(:)]))),titleStr);
end
nN = length(dat.x); % number of nodes
nE = nN-1;
% number of elements
nDiv = 10;
% number of points per element (omits first point
in model)
dat.h(5) = plot(dat.x'+globalU,real(globalV),'b:');
if size(dat.u,2) > 1 % If a dynamic analysis
newTitleStr = sprintf('%s %.1f Hz',titleStr,dat.freq(freqInd));
title(newTitleStr)
dat.ax(2) = axes('position',[0.55 0.2 0.3 0.25]);
box on
semilogx(dat.freq,max(20*log10(abs(dat.u(1:2:end,:))),[],1)); hold
on;
xlabel('Frequency (Hz)')
ylabel('Displacement (dB re. 1)')
ax = axis;
plot([freq freq],ax(3:4), 'r-'); grid on;
end
dat.legendStr{5} = 'Displaced';
legend(dat.h(dat.h~=0),dat.legendStr(dat.h~=0));
29
function dat = plotDeck(dat,maxVal,titleStr)
% Plots the input geometry and boundary conditions for a deck. Y-axis
is
% scaled based on the maximum displacement in the model, thus, the
input
% structure must contain a solution
if ~nargin
close all;
dat = calcStatic(quickDeck('multi elem canti'));
end
if nargin < 2
globalV = dat.u(2:3:end,:);
maxVal = max(abs(globalV(:)));
end
% Plot an input deck
nN = length(dat.x); % number of nodes
hFig = figure;
axis([min(dat.x)-1 max(dat.x)+1 -3*maxVal 3*maxVal]); hold on;
dat.ax = gca;
dat.h(1) = plot(dat.x,zeros(size(dat.x)),'k.-');
dat.constraint = sortrows(dat.constraint);
consNode = dat.constraint(:,1);
consVal = dat.constraint(:,2);
% For plotting purposes, when constraining both DOF use a unique symbol
repeats = ~logical(diff(consNode));
% deltas will be 1 at repeated nodes since we sorted, and 1 element
shorter
% than consNode. Delete one value and set the other to '3'
consVal([false; repeats]) = 3;
consVal([repeats; false]) = [];
consNode = unique(consNode);
if any(consVal==1)
temp = plot(dat.x(consNode(consVal==1)),0,'r^');
dat.h(2) = temp(1); % Save one handle only
end
if any(consVal==2)
temp = plot(dat.x(consNode(consVal==2)),0,'ro');
dat.h(3) = temp(1);
end
if any(consVal==3) % We have a clamped node
temp = plot(dat.x(consNode(consVal==3)),0,'rx','markersize',12);
dat.h(4) = temp(1);
end
dat.legendStr = {'Elements','Pinned','Roller','Clamped'};
legend(dat.h(dat.h~=0),dat.legendStr(dat.h~=0));
xlabel('Length')
ylabel('Displacement')
if nargin==3
title(titleStr);
end
dat.load = sortrows(dat.load);
loadNode = dat.load(:,1);
loadForce = dat.load(:,2);
loadMoment = dat.load(:,3);
blank = zeros(size(loadNode));
if any(loadForce)
quiver(dat.x(loadNode),blank,blank,0.2*sign(loadForce))
end
30
function dat = animDynamic(dat)
% Sweep through the displaced shapes of a dynamic run
if ~nargin
close all; clc;
dat = calcDynamic(quickDeck('exper12')); % default deck
end
if ~isfield(dat,'hFig') % Plot deck if
dat = plotDeck(dat,eps);
end
nN = length(dat.x); % number of nodes
nE = nN-1;
% number of elements
nDiv = 10;
% number of points per element (omits first point
in model)
globalU
= dat.u(1:3:end,:);
globalV
= dat.u(2:3:end,:);
globalAlpha = dat.u(3:3:end,:);
dat.h(5) = plot(dat.x'+real(globalU(:,1)),real(globalV(:,1)),'b:');
ax = axis;
yLim = ax(4);
dat.legendStr{5} = 'Displaced';
legend(dat.h(dat.h~=0),dat.legendStr(dat.h~=0));
hTitle = title(sprintf('%g Hz',dat.freq(1)));
axis auto
% pauseLen = 0.01;
for iF = 1:size(globalU,2);
newV = real(globalV(:,iF));
if yLim < 1.1*max(abs(newV))
yLim = 2*max(abs(newV));
axis([ax(1:2) -yLim yLim]);
end
if yLim > 4*max(abs(newV)) && yLim > 0.05
yLim = max([0.05 1.5*max(abs(newV))]);
axis([ax(1:2) -yLim yLim]);
end
set(dat.h(5),'yData',newV);
set(hTitle,'string',sprintf('%g Hz',round(10*dat.freq(iF))/10));
drawnow;
%
pause(pauseLen);
end
31