1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Advanced Mathematics and Mechanics Applications Using MATLAB phần 4 doc

61 325 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Surface Plot of a General Polyhedron
Trường học CRC Press LLC
Chuyên ngành Advanced Mathematics and Mechanics Applications
Thể loại Lecture notes
Năm xuất bản 2003
Định dạng
Số trang 61
Dung lượng 6,24 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 1855: % This program illustrates the use of routine 6: % polhedrn to calculate the geometrical 7: % properties of a polyhedron... G

Trang 1

184 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

−2

−1 0 1 2

0 1 2 3 4

Trang 2

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 185

5: % This program illustrates the use of routine

6: % polhedrn to calculate the geometrical

7: % properties of a polyhedron

8: %

9: % User m functions called:

10: % crosmat, polyxy, cubrange, pyramid,

34: % This function determines the volume,

35: % centroidal coordinates and inertial moments

36: % for an arbitrary polyhedron

37: %

38: % x,y,z - vectors containing the corner

40: % idface - a matrix in which row j defines the

© 2003 by CRC Press LLC

Trang 3

186 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

50: %

51: % v - the volume of the polyhedron

52: % rc - the centroidal radius

53: % vrr - the integral of R*R’*d(vol)

54: % irr - the inertia tensor for a rigid body

77: % This function computes the area, centroidal

78: % coordinates, and inertial moments of an

79: % arbitrary polygon

80: %

81: % x,y - vectors containing the corner

Trang 4

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 187

87: % xbar,ybar - the centroidal coordinates

88: % axx - integral of x^2*dxdy

89: % axy - integral of xy*dxdy

90: % ayy - integral of y^2*dxdy

112: % This function determines geometrical

113: % properties of a pyramid with the apex at the

114: % origin and corner coordinates of the base

115: % stored in the rows of r

116: %

117: % r - matrix containing the corner

118: % coordinates of a polygonal base stored

120: %

121: % v - the volume of the pyramid

122: % vr - the first moment of volume relative to

124: % vrr - the second moment of volume relative

126: % h - the pyramid height

127: % area - the base area

128: % n - the outward directed unit normal to

130: %

131: % User m functions called: crosmat, polyxy

© 2003 by CRC Press LLC

Trang 5

188 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

159: % x,y,z - vectors containing the corner

161: % idface - a matrix in which row j defines the

171: % colr - character string or a vector

173: %

174: % User m functions called: cubrange

175:

% -176:

Trang 6

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 189

177: if nargin<5, colr=[1 0 1]; end

178: hold off, close; nf=size(idface,1);

179: v=cubrange([x(:),y(:),z(:)],1.1);

180: for k=1:nf

181: i=idface(k,:); i=i(find(i>0));

182: xi=x(i); yi=y(i); zi=z(i);

183: fill3(xi,yi,zi,colr); hold on;

184: end

185: axis(v); grid on;

186: xlabel(’x axis’); ylabel(’y axis’);

187: zlabel(’z axis’);

188: title(’Surface Plot of a General Polyhedron’);

189: figure(gcf); hold off;

198: % This function computes the vector cross

199: % product for vectors stored in the rows

200: % of matrices a and b, and returns the

201: % results in the rows of c

Trang 7

190 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

5.8 Evaluating Integrals Having Square Root Type Singularities

Consider the problem of evaluating the following three integrals having square root type singularities at one or both ends of the integration interval:

The singularities in these integrals can be removed using substitutions x − a =

t2, b − x = t2, and (x − a)(b − x) = (b + a)/2 + (b − a)/2 cos(t) which lead to

I1= 2

√ b−a

in-f (x) = e ux cos(vx) with constants u and v being parameters passed to the

inte-grators using the varargin construct in MATLAB Function quadgsqrt uses Gauss

quadrature to evaluate I1and I2, and uses Chebyshev quadrature [1] to evaluate I3.

When f(x) is a polynomial, then taking parameter norder in function quadgsqrt

equal to the polynomial order gives exact results With norder taken sufÞciently

high, more complicated functions can also be integrated accurately Function sqrt evaluates the three integral types using the adaptive integrator quadl, which

quadl-accommodates f(x) of quite general form The program shown below integrates the test function for parameter choices corresponding to [a, b, u, v] = [1, 4, 3, 10] with

norder=10 in quadgsqrt and tol=1e-12 in quadlsqrt Output from the program for this data case appears as comments at lines 14 thru 35 of sqrtquadtest The

integrators apparently work well and give results agreeing to Þfteen digits

How-ever, quadlsqrt took more than four hundred times as long to run as quadgsqrt Furthermore, the structure of quadgsqrt is such that it could easily be modiÞed to

accommodate a form of f(x) which returns a vector.

5.8.1 Program Listing

Singular Integral Program

1: function [vg,tg,vL,tL,pctdiff]=sqrtquadtest

Trang 8

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 191

2: %

3: % [vg,tg,vL,tL,pctdiff]=sqrtquadtest

4: %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

5: % This function compares the accuracy and

6: % computation time for functions quadgsqrt

7: % and quadlsqrt to evaluate:

17: % EVALUATING INTEGRALS WITH SQUARE ROOT TYPE

18: % SINGULARITIES AT THE END POINTS

26: % Results from function gquadsqrt

27: % 4.836504484e+003 -8.060993912e+003 -4.264510048e+003

28: % Computation time = 0.0159 sec

29:

30: % Results from function quadlsqrt

31: % 4.836504484e+003 -8.060993912e+003 -4.264510048e+003

32: % Computation time = 7.03 sec

33:

34: % Percent difference for the two methods

35: % -3.6669e-012 -1.5344e-012 1.4929e-012

Trang 9

192 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

54: disp(’EVALUATING INTEGRALS WITH SQUARE ROOT TYPE’)

55: disp(’ SINGULARITIES AT THE END POINTS’)

56: disp(’ ’)

57: disp(’Function integrated:’)

58: disp(’ftest(x,u,v)=exp(u*x).*cos(v*x)’)

59: disp(’ ’)

60: disp([’a = ’,num2str(a),’ b = ’,num2str(b)])

61: disp([’u = ’,num2str(u),’ v = ’,num2str(v)])

62: disp(’ ’)

63: disp(’Results from function gquadsqrt’)

64: fprintf(’%17.9e %17.9e %17.9e\n’,vg)

65: disp([’Computation time = ’,num2str(tg),’ sec.’])

74: disp(’Results from function quadlsqrt’)

75: fprintf(’%17.9e %17.9e %17.9e\n’,vL)

76: disp([’Computation time = ’,num2str(tL),’ sec.’])

77:

78: pctdiff=100*(vg-vL)./vL; disp(’ ’)

79: disp(’Percent difference for the two methods’)

80: fprintf(’%13.4e %12.4e %12.4e\n’,pctdiff)

Trang 10

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 193

92: % square root type singularity at one or both ends

93: % of the integration interval a<x<b Composite

94: % Gauss integration is used with func(x) treated

95: % as a polynomial of degree norder

96: % The integrand has the form:

97: % func(x)/sqrt(x-a) if type==1

98: % func(x)/sqrt(b-x) if type==2

99: % func(x)/sqrt((x-a)*(b-x)) if type==3

100: % The integration interval is subdivided into

101: % nsegs subintervals of equal length

102: %

103: % func - a character string or function handle

106: % type - 1 if the integrand is singular at x=a

108: % 3 if the integrand is singular at both

110: % a,b - integration limits with b>a

111: % norder - polynomial interpolation order within

113: % nsegs - number of integration subintervals

114: %

115: % User m functions called: gcquad

116: %

117: % Reference: Abromowitz and Stegun, ’Handbook of

119: %

-120:

121: if nargin<6, nsegs=1; end;

122: if nargin<5, norder=50; end

123: switch type

124: case 1 % Singularity at the left end

126: [dumy,bp,wf]=gcquad(

127: ’’,0,sqrt(b-a),norder+1,nsegs);

128: t=a+bp.^2; y=feval(func,t,varargin{:});

129: v=wf(:)’*y(:)*2;

130: case 2 % Singularity at the right end

Trang 11

194 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

151: % This function uses the MATLAB integrator quadl

152: % to evaluate integrals having square root type

153: % singularities at one or both ends of the

162: % type - 1 if the integrand is singular at x=a

164: % 3 if the integrand is singular at both

166: % a,b - integration limits with b > a

167:

168: if nargin<6 | isempty(trace), trace=0; end

169: if nargin<5 | isempty(tol), tol=1e-8; end

Trang 12

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 195

189: % This function shifts arguments to produce

190: % a nonsingular integrand called by quadl

5.9 Gauss Integration of a Multiple Integral

Gauss integration can be used to evaluate multiple integrals having variable limits Consider the instance typiÞed by the following triple integral

Trang 13

196 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

has a value of 88π/15 Shown below is a function quadit3d and related limit and

integrand functions The function triplint(n) computes the ratio of the numerically integrated function to the exact result The function speciÞcation triplint(20) yields

a value of 1.000067 Even though the triple integration procedure is not

computa-tionally very fast, it is nevertheless robust enough to produce accurate results when

a sufÞciently high integration order is chosen.

Trang 14

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 197

5.9.1 Example: Evaluating a Multiple Integral

Triple Integration Program

26: % where a1 and a2 are functions of y and z, b1

27: % and b2 are functions of z, and c is a vector

28: % containing constant limits on the z variable

29: % Hence, as many as five external functions may

30: % be involved in the call list For example,

31: % when the integrand and limits are:

Trang 15

198 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

41: % The approximation produced from a 20 point

42: % Gauss formula is accurate within 007 percent

43: %

44: % f - a function f(x,y,z) which must return

47: % a1,a2 - integration limits on the x variable

48: % which may specify names of functions

49: % or have constant values If a1 is a

50: % function it should have a call list

51: % of the form a1(y,z) A similar form

53: % b1,b2 - integration limits on the y variable

54: % which may specify functions of z or

56: % c - a vector defined by c=[c1,c2] where

59: % w - this argument defines the quadrature

61: % three possible forms If w is omitted,

62: % a Gauss formula of order 12 is used

63: % If w is a positive integer n, a Gauss

64: % formula of order n is used If w is an

65: % n by 2 matrix, w(:,1) contains the base

66: % points and w(:,2) contains the weight

67: % factors for a quadrature formula over

76: % function gcquad generates base points

77: % and weight factors

Trang 16

GAUSS INTEGRATION WITH GEOMETRIC PROPERTY APPLICATIONS 199

Trang 17

200 ADVANCED MATH AND MECHANICS APPLICATIONS USING MATLAB

Trang 18

Chapter 6

Fourier Series and the Fast Fourier

Transform

6.1 DeÞnitions and Computation of Fourier CoefÞcients

Trigonometric series are useful to represent periodic functions A function deÞned for−∞ < x < ∞ has a period of 2π if f(x+2π) = f(x) for all x In most practical

situations, such a function can be expressed as a complex Fourier series

which is called a Fourier sine-cosine expansion This series is especially appealing

when f(x) is real valued For that case c − = c  for all , which implies that c0must

be real and

a = 2 real(c  ) , b =−2 imag(c)for  > 0.

Suppose we want a Fourier series expansion for a more general function f(x) having period p instead of 2π If we introduce a new function g(x) deÞned by

Trang 19

then g(x) has a period of 2π Consequently, g(x) can be represented as

A need sometimes occurs to expand a function as a series of sine terms only, or as a

series of cosine terms only If the function is originally deÞned for 0 < x < p

by using a smoothing procedure described by Lanczos [60] Use is made of Fourier series of a closely related function ˆf (x)deÞned by a local averaging process accord- ing to

ˆ

f (x) = 1

 x+∆ 2

2 An important property of ˆf (x)is that it agrees

closely with f(x) for small α but has a Fourier series which converges more rapidly than the series for f(x) Furthermore, from its deÞnition,

where ˆc0 = c0and ˆc  = c  sin(πα)/(πα) for 

Þcients of ˆf (x) are easily obtainable from those of f(x) When the series for f(x)

converges slowly, using the same number of terms in the series for ˆf (x)often gives

an approximation preferable to that provided by the series for f(x) This process is

called smoothing.

Trang 20

6.1.1 Trigonometric Interpolation and the Fast Fourier Transform

Computing Fourier coefÞcients by numerical integration is very time consuming Consequently, we are led to investigate alternative methods employing trigonometric polynomial interpolation through evenly spaced data The resulting formulas are the basis of an important algorithm called the Fast Fourier Transform (FFT) Although the Fourier coefÞcients obtained by interpolation are approximate, these coefÞcients can be computed very rapidly when the number of sample points is an integer power

of 2 or a product of small primes We will discuss next the ideas behind trigonometric polynomial interpolation among evenly spaced data values.

Suppose we truncate the Fourier series and only use harmonics up to some order

N We assume f(x) has period 2π so that

func-It is well known that the functions e ıxsatisfy an orthogonality condition for

inte-gration over the interval 0 to 2π They also satisfy an orthogonality condition

regard-ing summation over equally spaced data The latter condition is useful for derivregard-ing a discretized approximation of the integral formula for the exact Fourier coefÞcients Let us choose data points

Suppose we pick an arbitrary integer n in the range −N < n < N Multiplying the

last equation by t −kn and summing from k = 0 to 2N − 1 gives

Trang 21

where ζ = e ı(−n)π/N Summing the inner geometric series gives

We Þnd, for all k and n in the stated range, that

In the cases where n = ±N, the procedure just outlined only gives a relationship

governing c N + c −N Since the Þrst and last terms cannot be computed uniquely, we

customarily take N large enough to discard these last two terms and write simply

This formula is the basis for fast algorithms (called FFT for Fast Fourier Transform)

to compute approximate Fourier coefÞcients The periodicity of the terms depending

on various powers of e ıπ/N can be utilized to greatly reduce the number of

trigono-metric function evaluations The case where N equals a power of 2 is especially

attractive The mathematical development is not provided here However, the related theory was presented by Cooley and Tukey in 1965 [21] and has been expounded in many textbooks [53, 96] The result is a remarkably concise algorithm which can

be comprehended without studying the details of the mathematical derivation For our present interests it is important to understand how to use MATLAB’s intrinsic

function for the FFT (fft).

Suppose a periodic function is evaluated at a number of equidistant points ranging over one period It is preferable for computational speed that the number of sample

points should equal an integer power of two (n = 2 m) Let the function values for argument vector

x = p/n ∗ (0 : n − 1)

be an array f denoted by

f ⇐⇒ [f1, f2, · · · , f n ].

The function evaluation fft(f) produces an array of complex Fourier coefÞcients

multiplied by n and arranged in a peculiar fashion Let us illustrate this result for

n = 8 If

f = [f1, f2, · · · , f8]

then fft(f)/8 produces

c = [c0, c1, c2, c3, c ∗ , c −3 , c −2 , c −1 ].

Trang 22

The term denoted by c ∗ actually turns out to equal c4+ c −4, so it would not be used

in subsequent calculations We generalize this procedure for arbitrary n as follows Let N = n/2 − 1 In the transformed array, elements with indices of 1, · · · , N + 1

correspond to c0, · · · , c N and elements with indices of n, n − 1, n − 2, · · · , N +

3 correspond to c −1 , c −2 , c −3 , · · · , c −N It is also useful to remember that a real

valued function has c −n = conj(c n) To Þx our ideas about how to evaluate a Fourier series, suppose we want to sum an approximation involving harmonics from

order zero to order (nsum − 1) We are dealing with a real valued function deÞned

by func with a real argument vector x The following code expands func and sums

the series for argument x using nsum terms.

struc-or analytically deÞned functions.

6.2.1 Using the FFT to Compute Integer Order Bessel Functions

The FFT provides an efÞcient way to compute integer order Bessel functions

J n (x) which are important in various physical applications [119] Function J n (x) can be obtained as the complex Fourier coefÞcient of e ınθin the generating function described by

Trang 23

Figure 6.1: Surface Plot for J n (x)

The Fourier coefÞcients represented by J n (x)can be computed approximately with the FFT The inÞnite series converges very rapidly because the function it represents

has continuous derivatives of all Þnite orders Of course, e ıx sin(θ)is highly tory for large|x|, thereby requiring a large number of sample points in the FFT to

oscilla-obtain accurate results For n < 30 and |x| < 30, a 128-point transform is adequate

to give about ten digit accuracy for values of J n (x) The following code implements the above ideas and plots a surface showing how J n changes in terms of n and x.

Trang 24

4: % This program computes integer order Bessel

5: % functions of the first kind by using the FFT

12: zlabel(’function value’), figure(gcf);

13: print -deps plotjrun

21: % Integer order Bessel functions of the

22: % first kind computed by use of the Fast

29: % nft - number of function evaluations used

30: % in the FFT calculation This value

31: % should be an integer power of 2 and

32: % should exceed twice the largest

33: % component of n When nft is omitted

34: % from the argument list, then a value

35: % equal to 512 is used More accurate

36: % values of J are computed as nft is

37: % increased For max(n) < 30 and

38: % max(z) < 30, nft=256 gives about

40: % J - a matrix of values for the integer

© 2003 by CRC Press LLC

Trang 25

41: % order Bessel function of the first

42: % kind Row position matches orders

43: % defined by n, and column position

44: % corresponds to arguments defined by

6.2.2 Dynamic Response of a Mass on an Oscillating Foundation

Fourier series are often used to describe time dependent phenomena such as quake ground motion Understanding the effects of foundation motions on an elastic structure is important in design The model in Figure 6.2 embodies rudimentary as- pects of this type of system and consists of a concentrated mass connected by a spring

earth-and viscous damper to a base which oscillates with known displacement Y (t) The system is assumed to have arbitrary initial conditions y(0) = y0and ˙y(0) = v0when the base starts moving The resulting displacement and acceleration of the mass are

to be computed.

We assume that Y (t) can be represented well over some time interval p by a

Four-ier series of the form

Trang 26

Y (t)

m

y(t)

c k

Figure 6.2: Mass System

where y −n = conj(y n)since y s (t)is real valued Substituting the series solution

into the differential equation and comparing coefÞcients of e ıω n ton both sides leads to

Because these values usually will not match the desired initial conditions, the total

solution consists of y s (t) and y h (t) which satisÞes the homogeneous differential equation

m¨ y h + c ˙ y h + ky h = 0.

© 2003 by CRC Press LLC

Trang 27

the constants g1and g2are obtained by solving the two simultaneous equations

g1+ g2= y(0) − y s (0) , s1g1+ s2g2 = ˙y(0) − ˙y s (0).

The roots s1and s2are equal when c = 2 √

mk Then the homogeneous solution

assumes an alternate form given by (g1+ g2t)e st with s = −c/(2m) In this special

case we Þnd that

g1= y(0) − y s (0) , g2= ˙y(0) − ˙y s(0)− sg1.

It should be noted that even though roots s1and s2will often be complex numbers, this causes no difÞculty since MATLAB handles the complex arithmetic automat- ically (just as it does when the FFT transforms real function values into complex Fourier coefÞcients).

The harmonic response solution works satisfactorily for a general forcing function

as long as the damping coefÞcient c is nonzero A special situation can occur when

c = 0, because the forcing function may resonate with the natural frequency of

the undamped system If c is zero, and for some n we have

k/m = 2πn/p, a condition of harmonic resonance is produced and a value of zero in the denominator

occurs when the corresponding y nis computed In the undamped resonant case the

particular solution grows like [te ıω n t], quickly becoming large Even when c is small and

k/m ≈ 2πn/p, undesirably large values of y n can result Readers interested

in the important phenomenon of resonance can Þnd more detail in Meirovitch [68] This example concludes by using a base motion resembling an actual earthquake excitation Seismograph output employing about 2700 points recorded during the Imperial Valley, California, earthquake of 1940 provided the displacement history for

written to analyze system response due to a simulated earthquake base excitation The following program modules are used:

Trang 28

runimpv sets data values and generates graphical results

fouaprox generates Fourier series approximations for a general

function

imptp piecewise linear function approximating the Imperial

Valley earthquake data

shkbftss computes steady-state displacement and acceleration

for a spring-mass-dashpot system subjected to base motion expandable in a Fourier series

hsmck computes the homogeneous solution for the

spring-mass-dashpot system subjected to general initial ditions

con-Numerical results were obtained for a system having a natural period close to one

second (2π/6 ≈ 1.047) and a damping factor of 5 percent The function imptp

was employed as an alternative to the actual seismograph data to provide a concisely expressible function which still embodies characteristics of a realistic base motion.

twenty-term Fourier series The series representation is surprisingly good considering the fact that such a small number of terms is used The use of two-hundred terms gives

an approximation which graphically does not deviate perceptibly from the actual function Results showing how rapidly the Fourier coefÞcients diminish in magni- tude with increasing order appear in Figure 6.5 The dynamical analysis produced displacement and acceleration values for the mass Figure 6.6 shows both the total displacement as well as the displacement contributed from the homogeneous solution alone Evidently, the steady-state harmonic response function captures well most of the motion, and the homogeneous part could probably be neglected without serious error Figure 6.7 also shows the total acceleration of the mass which is, of course, proportional to the resultant force on the mass due to the base motion.

Before proceeding to the next example, the reader should be sure to appreciate the following important fact Once a truncated Fourier series expansion of the forcing function using some appropriate number of terms is chosen, the truncated series deÞnes an input function for which the response is computed exactly If the user takes enough terms in the truncated series so that he/she is well satisÞed with the

function it approximates, then the computed response value for y(t) will also be

acceptable This situation is distinctly different from the more complicated type of approximations occurring when Þnite difference or Þnite element methods produce discrete approximations for continuous Þeld problems Understanding the effects of grid size discretization error is more complex than understanding the effects of series truncation in the example given here.

© 2003 by CRC Press LLC

Trang 29

Normalized Base Displacement

Figure 6.3: Normalized Base Displacement

Result from a 20−Term Fourier Series

Figure 6.4: Result from a 20-Term Fourier Series

Trang 30

0 10 20 30 40 50 60 70 80 90 100 0

Figure 6.6: Total and Homogeneous Response

© 2003 by CRC Press LLC

Ngày đăng: 08/08/2014, 11:21

TỪ KHÓA LIÊN QUAN