Appendix D MATLAB® Files
Appendix D MATLAB® Files
MATLAB® Files
At various points in this book, MATLAB® functions or scripts are used to aid in the
solution process. The listings of the m-files for those functions or scripts are given below.
[Note: because of formatting changes, there may be some minor differences between these
listings and the actual m-files.] The m-files can be obtained from Cambridge University Press
at www.cambridge.org/schmerr or by sending an e-mail with the subject title “Advanced
Mechanics Codes” to the author at [email protected]
stress_invs
cantilever_d
%script cantilever_d
% This script plots the 2-d displacement field of a cantilever
% beam from engineering beam theory
% make an 8x4 grid on a beam with normalized length and width
% of 1 and 0.2, respectively.
xn = linspace(0,1,8);
yn = linspace (-0.1, 0.1, 4);
[x,y] = meshgrid(xn, yn);
% choose values for Poisson’s ratio and normalized height hn =
% h/L
nu = 1/3;
hn = 0.1;
557
ISTUDY
558 Appendix D
stress_strain
strain_stress
ISTUDY
MATLAB® Files 559
E = E*10^-3;
G = E/(2*(1+nu));
strain(1,1) = (1/E)*(stress(1,1) -nu*(stress(2,2). . . +stress(3,3)));
strain(2,2) = (1/E)*(stress(2,2) -nu*(stress(1,1). . . +stress(3,3)));
strain(3,3) = (1/E)*(stress(3,3) -nu*(stress(1,1). . . +stress(2,2)));
strain(1,2) = stress(1,2)/(2*G); % note: these are tensor
% strains
strain(1,3) = stress(1,3)/(2*G);
strain(2,3) = stress(2,3)/(2*G);
strain(2,1) = strain(1,2);
strain(3,1) = strain(1,3);
strain(3,2) = strain(2,3);
M_Matrix
function M = M_Matrix(l)
% M = M_Matrix(l) takes as its input argument the direction
% cosine matrix l whose transpose, lt, transforms the x-
% coordinates to the x’-coordinates through the relation {x’}
% = [lt]{x}. The function returns the 6x6 matrix, M, which
% transforms the 6x6 matrix of elastic constants,C, as
% measured in the x-coordinates, to the matrix of elastic
% constants,C’, as measured in the x’-coordinates, through the
% relation [C’] = [M][C][Mt], where Mt is the transpose of M.
M = zeros(6,6);
M(1,1) = l(1,1)^2;
M(1,2) = l(2,1)^2;
M(1,3) = l(3,1)^2;
M(1,4) = 2*l(2,1)*l(3,1);
M(1,5) = 2*l(3,1)*l(1,1);
M(1,6) = 2*l(2,1)*l(1,1);
M(2,1) = l(1,2)^2;
M(2,2) = l(2,2)^2;
M(2,3) = l(3,2)^2;
M(2,4) = 2*l(2,2)*l(3,2);
M(2,5) = 2*l(1,2)*l(3,2);
M(2,6) = 2*l(1,2)*l(2,2);
M(3,1) = l(1,3)^2;
M(3,2) = l(2,3)^2;
M(3,3) = l(3,3)^2;
M(3,4) = 2*l(2,3)*l(3,3);
ISTUDY
560 Appendix D
M(3,5) = 2*l(1,3)*l(3,3);
M(3,6) = 2*l(1,3)*l(2,3);
M(4,1) = l(1,2)*l(1,3);
M(4,2) = l(2,2)*l(2,3);
M(4,3) = l(3,2)*l(3,3);
M(4,4) = l(2,2)*l(3,3) + l(3,2)*l(2,3);
M(4,5) = l(1,2)*l(3,3) + l(3,2)*l(1,3);
M(4,6) = l(1,2)*l(2,3) + l(2,2)*l(1,3);
M(5,1) = l(1,1)*l(1,3);
M(5,2) = l(2,1)*l(2,3);
M(5,3) = l(3,1)*l(3,3);
M(5,4) = l(2,1)*l(3,3) + l(3,1)*l(2,3);
M(5,5) = l(1,1)*l(3,3) + l(3,1)*l(1,3);
M(5,6) = l(1,1)*l(2,3) + l(2,1)*l(1,3);
M(6,1) = l(1,1)*l(1,2);
M(6,2) = l(2,1)*l(2,2);
M(6,3) = l(3,1)*l(3,2);
M(6,4) = l(2,1)*l(3,2) + l(3,1)*l(2,2);
M(6,5) = l(1,1)*l(3,2) + l(3,1)*l(1,2);
M(6,6) = l(1,1)*l(2,2) + l(2,1)*l(1,2);
m_to_v
ISTUDY
MATLAB® Files 561
y(4) = 2*input(2,3);
y(5) = 2*input(1,3);
y(6) = 2*input(1,2);
else
error(’wrong type’)
end
% put in column vector
y = y’;
v_to_m
ISTUDY
562 Appendix D
rosette
function [exx, eyy, exy] = rosette(anga, angb, angc, ea, eb,. . . ec)
% [exx, eyy, exy] = rosette(anga, angb, angc, ea, eb, ec)
% takes the three angles (anga, angb, angc) of the three gages
% in a rosette gage (as measured in degrees from the x-
% axis)and the three strains (ea, eb, ec)measured by those
% gages, and returns the tensor strains(exx, eyy, exy)
nax = cos(anga*pi/180);
nay = sin(anga*pi/180);
nbx = cos(angb*pi/180);
nby = sin(angb*pi/180);
ncx = cos(angc*pi/180);
ncy = sin(angc*pi/180);
Coeff = [ nax^2 nay^2 2*nax*nay;...
nbx^2 nby^2 2*nbx*nby; ...
ncx^2 ncy^2 2*ncx*ncy];
vals = [ ea eb ec]’;
strains = Coeff\vals;
exx = strains(1);
eyy = strains(2);
exy = strains(3);
stress_singularity
function stress_singularity()
% stress_singularity determines the singular behavior of the
% stresses near a sharp notch and plots the behavior of the
% parameter that controls the order of the singularity as a
% function of the notch angle.
warning off
a = linspace(0, pi, 100); %angle alpha
out = zeros (1,100);
for k =1:100
val = 0.5 +0.5*a(k)/pi; % choose initial guesses
out(k) = fzero(@singularity, val, [ ],a(k)); % find roots
end
plot((180/pi)*a(1:100), out(1:100))
axis([ 0 180 0 1.0])
xlabel(’\alpha , degrees’)
ISTUDY
MATLAB® Files 563
cross_section
ISTUDY
564 Appendix D
sections
% script sections
% This script computes the location of the centroid and area
% moments for a L-section, a T-section, a J-section, a Z-
% section, and a I-section. In the command window one must
% enter a string ’L’, ’T’, ’J’, ’Z’, or ’L’ in a variable
% named type and then enter the lengths b, h, c and the
% thicknesses t1, t2, t3 (or a subset of these values) in the
% command window and then run this script. The script uses the
% function cross_section to return the location of the
% centroid and the area moments
switch type
case{’L’}
Ly(1) = b- t2; Ly(2) = t2;
Lz(1) = t1; Lz(2) = h;
Yc(1) = t2 + (b-t2)/2; Yc(2) =t2/2;
Zc(1) = t1/2; Zc(2) = h/2;
case{’T’}
Ly(1) = b; Ly(2) = t2;
Lz(1) = t1; Lz(2) = h-t1;
Yc(1) = 0; Yc(2) = 0;
Zc(1) = t1/2; Zc(2) = t1 + (h- t1)/2;
case{’J’}
Ly(1) = b -t2; Ly(2) = t2; Ly(3) = c-t2;
Lz(1) = t1; Lz(2) = h; Lz(3) = t3;
Yc(1) = t2 + (b-t2)/2; Yc(2) = t2/2; Yc(3) = t2 . . .
+(c-t2)/2;
Zc(1) = t1/2; Zc(2) = h/2; Zc(3) = h - t3/2;
case{’Z’}
Ly(1) = b - t2; Ly(2) = t2; Ly(3) = c -t2;
Lz(1) = t1; Lz(2) = h; Lz(3) = t3;
Yc(1) = t2 + (b-t2)/2; Yc(2) = t2/2; Yc(3) = -(c-t2)/2;
Zc(1) = t1/2; Zc(2) = h/2; Zc(3) = h -t3/2;
case{’I’}
Ly(1) = b; Ly(2) = t2; Ly(3) = c;
Lz(1) = t1; Lz(2) = h - t1 -t3; Lz(3) = t3;
Yc(1) = 0; Yc(2) = 0; Yc(3) = 0;
Zc(1) = t1/2; Zc(2) = t1 + (h -t1 -t3)/2;Zc(3) = . . .
h -t3/2;
otherwise
disp([’Unknown type’])
end
[yc, zc, Iy, Iz, Iyz] = cross_section(Ly, Lz, Yc, Zc)
ISTUDY
Index
Airy stress function, 149, 153, 190 direction cosine matrix, 35 Gauss’s theorem, 70
Airy stress function, Cartesian distortional strain energy density, 232 Gauss’s theorem -2D, 76
coordinates, 191 dummy load, 261 generalized displacements, 174
Airy stress function, polar coordinates, generalized forces, 174
197 eddy current NDE, 513 generalized Hooke’s law, 119
alternating stress, 502 effective maximum radius, 414 generalized strains, 174
effective polar area moment, 414, 527 Gerber curve, 504
Beltrami–Michell compatibility effective stress, 61, 500 Goodman curve, 504
equations, 149, 539 eigenvalue problem, 44 governing equations, 146
bending moment, 6 eigenvalues, 44
Betti–Rayleigh theorem, see reciprocal eigenvectors, 44 Hertz contact theory, 212
theorem of Betti–Rayleigh elastic bodies in contact, see Hertz Hooke’s law, 5
biaxial state of stress, 51 contact theory
bifurcation instability, 517 elastic constants, 122 interference, 188
biharmonic equation, 158 Engesser’s first theorem, 260 isotropic material, 119, 127
biharmonic equation, Cartesian Engesser’s second theorem, 264
coordinates, 191 engineering beam theory, 9 Kronecker delta, 35
biharmonic equation, polar coordinates, engineering shear strain, 14, 90
197 equilibrium equations, Cartesian Lamé constants, 148
biharmonic operator, 153 coordinates, 71 Laplace’s equation, 412
bimoment, 490 equilibrium equations, cylindrical limit-load instability, 517
boundary conditions, 158 coordinates, 82 local average rotation, 94
boundary element method, 148, 361 equilibrium equations, plane strain,
buckling, 515 154 maximum distortional strain energy
equilibrium equations, plane stress, 84 theory, 499
Castigliano’s first theorem, 256 equilibrium equations, spherical maximum normal stress theory,
Castigliano’s second theorem, 260 coordinates, 83 496
center of twist, 433 equivalent stress, 61 maximum shearing stress theory,
centroid, 527, 540 Euler buckling load, see critical buckling 497
Clapeyron’s theorem, 229 load Maxwell stress function, 149
combined bending and torsion, thin, mean stress, 502
closed sections, 477 fatigue failure, 502 membrane analogy, 423
combined bending and torsion, thin, fatigue strength, 504 Michell solutions, 197
open sections, 475 finite differences method, 148 Miner rule, see Palmgren-Miner rule
compatibility equations, 101, 303 first area moments, 527, 540 mixed second area moment, 8, 527, 540
compatibility matrix, 304, 312 first sectorial moment, 542 modified sectorial area function, 459
complementary strain energy density, flexibility matrix, 299 modified warping constant, 462
233 flexure stress, unsymmetrical bending, Mohr’s circle, 53
compliance matrix, 124 375 moment–curvature relationship, 8
concentrated force on a planar surface, force-based finite element method, axial Morera stress function, 149
209 loads, 295 Morrow curve, 504
concentrated force on a wedge, 208 force-based finite element method, beam
configuration factor, 509 bending, 329 Navier’s equations, 147, 310
constant life curves, 503 force-based finite element method, Navier’s table problem, 166
critical buckling load, 516 general body, 358 Neumann problem, 435
critical flaw size, 511 force-based finite element method, neutral axis, 7
cubic material, 127 specified displacements, 347 nonuniform torsion, 427
curved beam, 202 four pillars, 18 normal strain, 3, 88
fracture mechanics, 508 normal stress, 4, 32
deviatoric stress, 67 fracture toughness, 510 normalized Prandtl stress function, 419
dilatation, 98 fundamental solutions, 362 null space, 314
565
ISTUDY
566 Index
octahedral plane, 60 rosette strain gage, see strain gage strain invariants, 95
orthogonal matrix, 37 rosette strain transformation equations, 95
orthotropic material, 124 row-reduced echelon form, 313 strain–displacement relations, 91
strains, cylindrical coordinates, 112
Palmgren–Miner rule, 507 Saint-Venant torsional theory, see stress concentration at a circular hole,
parallel axis theorem, 531 uniform torsion 198
Paris law, 512 Saint-Venant’s principle, 161 stress intensity factor, 509
plane strain, 154 second area moments, 8, 527, 540 stress invariants, 43
plane stress, 51, 73 secondary twisting moment, 436 stress range, 502
planes of extreme shear stress, 56 secondary warping, 428 stress singularities, 214
Poisson’s equation, 418 sectorial area function, 391, 540 stress transformation equations, 34
Poisson’s ratio, 3 sectorial area origin, 541 stress vector, 28
polar area moment, 15, 540 sectorial area pole, 541
Prandtl stress function, 149, 417 sectorial products of areas, 527, 542 tensor shear strain, 90
primary twisting moment, 436 sectorial second moment, see warping theorem of minimum potential energy,
primary warping function, 428 constant 242
principal area moments, 531 shape functions, 281 thick-wall pressure vessel, 183
principal directions, 42 shear stress, 30 total shear stress, 32
principal origin, 549 shear center, 389 traction vector, see stress vector
principal planes, 42 shear flow, 17, 385 transformation of elastic constants, 132
principal pole, 545 shear flow expression, unsymmetrical transversely isotropic material, 126
principal sectorial area function, 527, bending, 386 Tresca theory, see maximum shearing
543 shear force, 9 stress theory
principal strains, 95 shear modulus, 14 true stress, 504
principal stresses, 42 shear strain, 89
principle of complementary virtual shear stress, 9 ultimate stress, 504
work, 250 shrink-fit, 187 ultrasonic NDE, 513
principle of complementary virtual work single plane of loading, 376 uniform torsion, 411
- axial loads, 280 single-valued displacement, 103 uniqueness, 243
principle of complementary virtual work singularity functions, 20 unit load method, 262
- beam bending, 319 S–N curve, 502
principle of least work, 264 snap-through buckling, 517 virtual displacements, 239
principle of minimum complementary Soderberg curve, 504 virtual work, 240
potential energy, 251 Somigliana’s identity, 364 Voigt notation, 124
principle of virtual work, 240 state of strain, 93 von Mises failure theory, 499
principle of virtual work, axial loads, state of stress, 29 von Mises stress, 61, 500
278 stiffness matrix, 148, 283
principle of virtual work, beam bending, stiffness-based finite element method, warping constant, 432, 527
316 148 warping constant, thin sections, 447
proper orthogonal matrix, 37 stiffness-based finite element method, warping function, 411
pseudostiffness matrix, 311, 333 axial loads, 281 warping normal stress, 428
pure bending of a curved beam, 202 stiffness-based finite element method, work, 224
beam bending, 320
Rayleigh–Ritz method, 257 stiffness-based finite element method, X-ray NDE, 514
reciprocal theorem of Betti–Rayleigh, general body, 356
268 strain energy, 226 yield normal stress, 498
reciprocity, 267 strain energy density, 226 yield shear stress, 497
redundants, 263 strain gage rosette, 141 Young’s modulus, 5
ISTUDY