Top Banner
Fourier Series, Fourier Transforms, and Periodic Response to Periodic Forcing CEE 541. Structural Dynamics Department of Civil and Environmental Engineering Duke University Henri P. Gavin Fall, 2014 This document describes methods to analyze the steady-state forced-response of single degree of freedom (SDOF) systems to general periodic loading. The analysis is carried out using Fourier series representation of the periodic external forcing and the resulting periodic steady-state response. 1 Fourier Series for Real-Valued Functions Any real-valued function, f (t), that is: periodic, with period T , ··· = f (t - 2T )= f (t - T )= f (t)= f (t + T )= f (t +2T )= ··· square-integrable T 0 f 2 (t)dt < . may be represented as a series expansion of sines and cosines, in a Fourier series, ˆ f (t; a, b)= 1 2 a 0 + q=1 a q cos 2πqt T + q=1 b q sin 2πqt T , (1) where the Fourier coefficients, a q and b q are given by the Fourier integrals, a q = 2 T T 0 f (t) cos 2πqt T dt , q =1, 2,... (2) b q = 2 T T 0 f (t) sin 2πqt T dt , q =1, 2,... (3) The Fourier series ˆ f (t; a, b) is a least-squares fit to the function f (t). This may be shown by first defining the error function, e(t)= f (t) - ˆ f (t; a, b), the quadratic error criterion, J (a, b)= T 0 e 2 (t)dt, and finding the Fourier coefficients by solving the linear equations resulting from minimizing J (a, b) with respect to the coefficients a and b. (by setting ∂J (a, b)/∂ a and ∂J (a, b)/∂ b equal to zero). So doing, J (a, b) = T 0 f (t) - ˆ f (t; a, b) 2 dt = T 0 f 2 (t) - 2f (t) ˆ f (t; a, b)+ ˆ f 2 (t; a, b) dt. (4)
15

Fourier

Dec 18, 2015

Download

Documents

Fourier Series, Fourier Transforms, and
Perio dic Resp onse to Perio dic Forcing
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Fourier Series, Fourier Transforms, andPeriodic Response to Periodic Forcing

    CEE 541. Structural DynamicsDepartment of Civil and Environmental Engineering

    Duke University

    Henri P. GavinFall, 2014

    This document describes methods to analyze the steady-state forced-response of singledegree of freedom (SDOF) systems to general periodic loading. The analysis is carried outusing Fourier series representation of the periodic external forcing and the resulting periodicsteady-state response.

    1 Fourier Series for Real-Valued Functions

    Any real-valued function, f(t), that is:

    periodic, with period T ,

    = f(t 2T ) = f(t T ) = f(t) = f(t+ T ) = f(t+ 2T ) = square-integrable T

    0f 2(t)dt

  • 2 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

    Setting J/a0 equal to zero results in

    0 = T

    0

    a0

    [f 2(t) 2f(t)f(t; a,b) + f 2(t; a,b)

    ]dt

    = 2 T

    0f(t)

    a0f(t; a,b)dt+ 2

    T0f(t; a,b)

    a0f(t; a,b)dt

    = 2 T

    0f(t) 12dt+ 2

    T0

    12a0 +

    q=1

    aq cos2piqtT

    +q=1

    bq sin2piqtT

    12dt=

    T0f(t)dt+

    T0

    12a0dt+

    q=1

    aq

    T0

    cos 2piqtT

    dt+q=1

    bq

    T0

    sin 2piqtT

    dt

    = T

    0f(t)dt+ 12a0T +

    q=1

    aq 0 +q=1

    bq 0

    From which,

    a0 =2T

    T0f(t) dt. (5)

    Note here that (a0/2) is the average value of f(t).Proceeding with the rest of the a coefficients, setting J(a,b)/ak equal to zero results in

    0 = T

    0

    ak

    [f 2(t) 2f(t)f(t; a,b) + f 2(t; a,b)

    ]dt

    = 2 T

    0f(t)

    akf(t; a,b)dt+ 2

    T0f(t; a,b)

    akf(t; a,b)dt

    = T

    0f(t) cos 2pikt

    Tdt+

    T0

    a02 +

    q=1

    aq cos2piqtT

    +q=1

    bq sin2piqtT

    cos 2piktT

    dt

    = T

    0f(t) cos 2pikt

    Tdt+

    a02

    T0

    cos 2piqtT

    dt+q=1

    aq

    T0

    cos 2piqtT

    cos 2piktT

    dt+q=1

    bq

    T0

    sin 2piqtT

    cos 2piktT

    dt

    = T

    0f(t) cos 2pikt

    Tdt+ a02 0 + ak

    T0

    cos2 2piktT

    dt+q=1

    bq 0

    = T

    0f(t) cos 2pikt

    Tdt+ 0 + ak T2 + 0

    From which,

    ak =2T

    T0f(t) cos 2pikt

    Tdt. (6)

    In a completely similar fashion, J(a,b)/bk = 0 results in

    bk =2T

    T0f(t) sin 2pikt

    Tdt. (7)

    CC BY-NC-ND H.P. Gavin

  • Fourier Series and Periodic Response to Periodic Forcing 3

    The derivation of the Fourier integrals (equations (5), (6), and (7)) make use of orthogonalityproperties of sine and cosine functions.

    T0

    sin2(npit

    T

    )dt = T2 , n = 1, 2, T

    0cos2

    (npit

    T

    )dt = T2 , n = 1, 2, T

    0sin

    (npit

    T

    )sin

    (mpit

    T

    )dt = 0 , n 6= m , n,m = 1, 2, T

    0cos

    (npit

    T

    )cos

    (mpit

    T

    )dt = 0 , n 6= m , n,m = 1, 2, T

    0sin

    (npit

    T

    )cos

    (mpit

    T

    )dt = 0 , n 6= m , n,m = 1, 2,

    1.1 The complex exponential form of Fourier series

    Recall the trigonometric identities for complex exponentials, ei = cos +i sin . Definingthe complex scalar F as F = 12(a ib), and its complex conjugate, F as F = 12(a + ib), itis not hard to show that

    Fei + F ei = a cos + b sin . (8)

    Note that the left hand side of equation (8) is the sum of complex conjugates, and that theright hand side is the sum of real values. So complex conjugates can be used to express thereal Fourier series given in equation (1). Substituting equation (8) into equation (1),

    f(t; a,b) = 12a0 +q=1

    [aq cos

    2piqtT

    + bq sin2piqtT

    ]

    = 12a0 +q=1

    [12(aq ibq) exp

    [i2piqTt]

    + 12(aq + ibq) exp[i2piq

    Tt]]

    = 12a0 +q=1

    Fq exp[i2piqTt]

    +q=1

    F q exp[i2piq

    Tt]

    = 12a0 +q=1

    Fq exp[i2piqTt]

    +1

    q=F q exp

    [i2piqTt]

    =

    q=Fq exp

    [i2piqTt]

    =

    q=Fq e

    iqt (9)

    where the Fourier frequency q is 2piq/T , F0 = 12a0, Fq =12(aq ibq), and F q = Fq. The

    condition F q = Fq holds for the Fourier series of any real-valued function that is periodic

    CC BY-NC-ND H.P. Gavin

  • 4 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

    and integrable. Going the other way,

    f(t;F) =q=+q=

    Fq eiqt

    = F0 +q=1q=

    Fq eiqt +

    q=+q=1

    Fq eiqt

    = F0 +q=+q=1

    Fqeiqt +q=+q=1

    Fqeiqt

    = F0 +q=1

    [Fq e

    iqt + Fq eiqt]

    = F0 +q=1

    [(F q + iF q ) (cosqt+ i sinqt) + (F q iF q ) (cosqt i sinqt)

    ]

    = F0 +q=1

    [2F q cosqt 2F q sinqt

    ]

    So, the real part of Fq, F q, is half of aq, the imaginary part of Fq, F q , is half of bq, andFq = F q. The real Fourier coefficients, aq, are even about q = 0 and the imaginary Fouriercoefficients, bq, are odd about q = 0.

    Just as the Fourier expansion may be expressed in terms of complex exponentials, thecoefficients Fq may also be written in this form.

    Fq =12 (aq ibq) =

    1T

    T0f(t)

    [cos 2piq

    Tt i sin 2piq

    Tt]

    = 1T

    T0f(t) exp

    [i2piq

    Tt]dt (10)

    Since the integrand, f(t)eiqt, of the Fourier integral is periodic in T , the limits of integrationcan be shifted arbitrarily without affecting the resulting Fourier coefficients. T

    0f(t)eiqt dt =

    0f(t)eiqt dt+

    T+

    f(t)eiqt dt T+T

    f(t)eiqt dt.

    But, since the integrand is periodic in T , 0f(t)eiqt dt =

    T+T

    f(t)eiqt dt .

    So, the interval of integration can be shifted arbitrarily. T0f(t)eiqt dt =

    T+0+

    f(t)eiqt dt.

    On the other hand, shifting the function in time, affects the relative values of aq and bq(i.e., the phase the the complex coefficeint Fq), but does not affect the magnitude, |Fq| =12

    a2q + b2q. If f(t) =

    Fqe

    iqt, then f(t + ) = Fqeiq(t+) = (Fqeiq ) eiqt, and|Fq| = |Fqeiq |.

    CC BY-NC-ND H.P. Gavin

  • Fourier Series and Periodic Response to Periodic Forcing 5

    2 Fourier Integrals in Maple

    The Fourier integrals for real valued functions (equations (6) and (7)) can be evaluatedusing symbolic math software, such as Maple or Mathematica.

    2.1 a periodic square wave function: f(t) = sgn(t) on pi < t < pi and f(t) = f(t+ n(2pi))

    > assume (k::integer);> f := signum(t);> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);

    ak := 0

    > bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);k

    2 ((-1) - 1)bk := - --------------

    Pi k

    2.2 a periodic sawtooth function: f(t) = t on pi < t < pi and f(t) = f(t+ n(2pi))

    > assume (k::integer);> f := t;> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);

    ak := 0

    > bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);(1 + k)

    2 (-1)bk := --------------

    k

    2.3 a periodic triangle function: f(t) = pi/2 t sgn(t) on pi < t < pi and f(t) = f(t+n(2pi))

    > assume (k::integer);> f := Pi/2 - t * signum(t);> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);

    k2 ((-1) - 1)

    ak := - --------------2

    Pi k

    > bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);bk := 0

    CC BY-NC-ND H.P. Gavin

  • 6 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

    3 Fourier Transforms

    Recall for periodic functions of period, T , the Fourier series expansion may be written

    f(t) =q=q=

    Fq eiqt , (11)

    where the Fourier coefficients, Fq, have the same units as f(t), and are given by the Fourierintegral,

    Fq =1T

    T/2T/2

    f(t) eiqt dt , (12)

    in which the limits of integration have been shifted by = T/2.

    Now, consider a change of variables, by defining a frequency increment, , and a scaledamplitude, F (q).

    = 1 =2piT

    (q = q ) (13)

    F (q) = TFq =2piFq (14)

    Where the scaled amplitude, F (q), has units of f(t) t or f(t)/.

    Using these new variables,

    f(t) = 12pi

    q=q=

    F (q) eiqt , (15)

    F (q) = T/2T/2

    f(t) eiqt dt . (16)

    Finally, taking the limit as T , implies d and f(t) = 12pi

    F () eit d , (17)

    F () =

    f(t) eit dt . (18)

    These expressions are the famous Fourier transform pair. Equation (17) is commonly calledthe inverse Fourier transform and equation (18) is commonly called the forward Fouriertransform. They differ only by the sign of the exponent and the factor of 2pi.

    CC BY-NC-ND H.P. Gavin

  • Fourier Series and Periodic Response to Periodic Forcing 7

    4 Fourier Approximation

    Any periodic function may be approximated as a truncated series expansion of sines andcosines, as a Fourier series,

    f(t) = 12a0 +Qq=1

    aq cos2piqtT

    +Qq=1

    bq sin2piqtT

    , (19)

    where the Fourier coefficients, aq and bq may be found by solving the Fourier integrals,

    aq =2T

    T/2T/2

    f(t) cos 2piqtT

    dt , q = 1, 2, . . . , Q (20)

    bq =2T

    T/2T/2

    f(t) sin 2piqtT

    dt , q = 1, 2, . . . , Q (21)

    The Fourier approximation (19) may also be represented using complex exponential notation.

    f(t) =q=Qq=Q

    Fq eiqt = 1

    T

    q=Qq=Q

    F (q) eiqt (22)

    where eiqt = cosqt+ i sinqt, q = 2piq/T , Fq = 12(aq ibq), Fq = F q, and

    Fq =1T

    T/2T/2

    f(t) eiqt dt . (23)

    The accuracy of Fourier approximations of non-sinusoidal functions increases with thenumber of terms, Q, in the series. Especially for time series that are discontinuous in time,such as square-waves or saw-tooth waves, Fourier approximations, f(t), will contain a degreeof over-shoot at the discontinuity and will oscillate about the approximated function f(t).This is called Gibbs phenomenon. In section 7 we illustrate this effect for square waves andtriangle waves.

    5 Discrete Fourier Transform

    If the function f(t) is represented by N uniformly-spaced points in time, tn = (n)(t),(n = 0, , N1), the N Fourier coefficients are computed by the discrete Fourier transform,

    Fq =1N

    N1n=0

    f(tn) exp[i2piqn

    N

    ], q = [N/2 + 1, ,2,1, 0, 1, , N/2] (24)

    and the N -point discrete Fourier approximation is computed by the inverse discrete Fouriertransform,

    f(tn) =N/2

    q=N/2+1Fq exp

    [i2piqnN

    ](25)

    With the normalization given in equations (24) and (25), 1N

    f 2n =

    |Fq|2. By convention,in the fast Fourier transform (FFT) the factor (1/N) is applied to equation (25) instead ofequation (24). Also, by convention, the Fourier frequencies, q = 2piq/T are sorted as follows:q = 0, 1, , N/2,N/2 + 1, ,2,1. The lowest positve frequency in the FFT is 1/THertz, and the highest frequency is 1/(2t) Hertz, which is called the Nyquist frequency.

    CC BY-NC-ND H.P. Gavin

  • 8 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

    6 Fourier Series and Periodic Responses of Dynamic Systems

    The response of a system described by a frequency response function H() to arbitraryperiodic forces described by a Fourier series may be found in the frequency domain, or in thetime domain.

    Complex exponential notation allows us to directly determine the steady-state periodicresponse to general periodic forcing, in terms of both the magnitude of the response and thephase of the response. Recall the relationship between the complex magnitudes X and F fora sinusoidally-driven spring-mass-damper oscillator is

    Xq = H(q) Fq =1

    (k m2q ) + i(cq)Fq (26)

    The function H() is called the frequency response function for the dynamic system relatingthe input f(t) to the output x(t).

    Because the oscillator is linear, if the response to f1(t) is x1(t), and the response to f2(t)is x2(t), then the response to c1f1(t) + c2f2(t) is c1x1(t) + c2x2(t). More generally, then,

    x(t) =q=q=

    H(q) Fq eiqt =q=q=

    1(k m2q ) + i(cq)

    Fq eiqt (27)

    where q = 2piq/T .

    Note that q is not the same symbol as n. The natural frequency,k/m, has the symbol

    n. The symbol q = 2piq/T is the frequency of a component of a periodic forcing functionof period T .

    For this frequency response function H(), the series expansion for the response x(t)converges with fewer terms than the Fourier series for the external forcing, because |H(q)|decreases as 1/2q .

    CC BY-NC-ND H.P. Gavin

  • Fourier Series and Periodic Response to Periodic Forcing 9

    7 Examples

    In the following examples, the external forcing is periodic with a period, T , of 2pi (sec-onds). For functions periodic in 2pi seconds, the frequency increment in the Fourier series is1 radian/second. In this case, the frequency index number, q, is also the frequency, q, inradians per second, otherwise, q = 2piq/T .

    The system is a forced spring-mass-damper oscillator,

    x(t) + 2nx(t) + 2nx(t) =1mf ext(t) . (28)

    The complex-valued frequency response function from the external force, f ext(t), to the re-sponse displacement, x(t), is given by

    H() = 1/2n

    1 2 + i 2 , (29)

    where is the frequency ratio, /n,

    In the following three numerical examples, n = 10 rad/s, = 0.1, m = 1 kg, andQ = 16 terms. The three examples consider external forcing in the form of a square-wave, asawtooth-wave, and a triangle-wave. In each example six plots are provided.

    In the (a) plots, the solid line represents the exact form of f(t), the dashed lines representthe real-valued form of the Fourier approximation and the complex-valued form of the Fourierapproximation, and the circles represent 2Q sample points of the function f(t) for use in fastFourier transform (FFT) computations. The two dashed lines are exactly equal.

    In the (b) plots, the impulse-lines show the values of the Fourier coefficients, Fq, found byevaluating the Fourier integral, equation (23), and the circles represent the Fourier coefficientsreturned by the FFT.

    In the (c) plots, the red solid lines show the cosine terms of the Fourier series and theblue dashed lines show the sine terms of the Fourier series.

    The (d) and (f) plots show the magnitude and phase of the transfer function, H() as asolid line, the Fourier coefficients, Fq, as the green circles, and H(q)Fq as the blue circles.

    In the (e) plots, the solid line represents x(t) as computed using equation (27), the circlesrepresent the real part of the result of the inverse FFT calculation and the dots representthe imaginary part of the result of the inverse FFT calculation.

    The numerical details involved in the correct representation of periodic functions andfrequency indexing for FFT computations are provided in the attached Matlab code.

    CC BY-NC-ND H.P. Gavin

  • 10 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

    7.1 Example 1: square wave

    The external forcing is given by

    f ext(t) = sgn(t) ; pi < t < pi (30)

    The Fourier coefficients for the real-valued Fourier series are:aq = 0 and bq = (2/(qpi)) (1q 1).

    (a)-1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    -3 -2 -1 0 1 2 3

    func

    tion,

    f(t), (

    N)

    time, t, (s) (b)-0.7

    -0.6

    -0.5

    -0.4

    -0.3

    -0.2

    -0.1

    0

    0 2 4 6 8 10 12 14 16Fo

    urie

    r coe

    fficie

    nts,

    Fq,

    (N

    )frequency, , (rad/s)

    (c)-1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    -3 -2 -1 0 1 2 3

    cosi

    ne a

    nd s

    ine

    term

    s

    time, t, (s) (d) 1e-04

    0.001

    0.01

    0.1

    1

    0 2 4 6 8 10 12 14 16

    frequ

    ency

    resp

    onse

    frequency, , (rad/s)

    (e)-0.025

    -0.02

    -0.015

    -0.01

    -0.005

    0

    0.005

    0.01

    0.015

    0.02

    0.025

    -3 -2 -1 0 1 2 3

    resp

    onse

    , x, (m

    )

    time, t, (s) (f)-200

    -150

    -100

    -50

    0

    50

    100

    150

    200

    0 2 4 6 8 10 12 14 16

    phas

    e le

    ad, (d

    egree

    s)

    frequency, , (rad/s)

    Figure 1. (a): = fext(t); - - = f ext(t). (b): red solid =

  • Fourier Series and Periodic Response to Periodic Forcing 11

    7.2 Example 2: sawtooth wave

    The external forcing is given by

    f ext(t) = t ; pi < t < pi (31)

    The Fourier coefficients for the real-valued Fourier series are:aq = 0 and bq = (2/q) (1q).

    (a)-4

    -3

    -2

    -1

    0

    1

    2

    3

    4

    -3 -2 -1 0 1 2 3

    func

    tion,

    f(t), (

    N)

    time, t, (s) (b)-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0 2 4 6 8 10 12 14 16

    Four

    ier c

    oeffi

    cient

    s, F

    q, (N

    )frequency, , (rad/s)

    (c)-2

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    2

    -3 -2 -1 0 1 2 3

    cosi

    ne a

    nd s

    ine

    term

    s

    time, t, (s) (d) 1e-04

    0.001

    0.01

    0.1

    1

    0 2 4 6 8 10 12 14 16

    frequ

    ency

    resp

    onse

    frequency, , (rad/s)

    (e)-0.08

    -0.06

    -0.04

    -0.02

    0

    0.02

    0.04

    -3 -2 -1 0 1 2 3

    resp

    onse

    , x, (m

    )

    time, t, (s) (f)-200

    -150

    -100

    -50

    0

    50

    100

    150

    0 2 4 6 8 10 12 14 16

    phas

    e le

    ad, (d

    egree

    s)

    frequency, , (rad/s)

    Figure 2. (a): = fext(t); - - = f ext(t). (b): red solid =

  • 12 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

    7.3 Example 3: triangle wave

    The external forcing is given by

    f ext(t) = pi/2 t sgn(t) ; pi < t < pi (32)

    The Fourier coefficients for the real-valued Fourier series are:aq = (2/q2pi)(1q 1) and bq = 0.

    (a)-2

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    2

    -3 -2 -1 0 1 2 3

    func

    tion,

    f(t), (

    N)

    time, t, (s) (b)-0.1

    0

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0 2 4 6 8 10 12 14 16

    Four

    ier c

    oeffi

    cient

    s, F

    q, (N

    )frequency, , (rad/s)

    (c)-1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    -3 -2 -1 0 1 2 3

    cosi

    ne a

    nd s

    ine

    term

    s

    time, t, (s) (d) 1e-05

    1e-04

    0.001

    0.01

    0.1

    1

    0 2 4 6 8 10 12 14 16

    frequ

    ency

    resp

    onse

    frequency, , (rad/s)

    (e)-0.02

    -0.015

    -0.01

    -0.005

    0

    0.005

    0.01

    0.015

    0.02

    -3 -2 -1 0 1 2 3

    resp

    onse

    , x, (m

    )

    time, t, (s) (f)-200

    -150

    -100

    -50

    0

    50

    100

    150

    200

    0 2 4 6 8 10 12 14 16

    phas

    e le

    ad, (d

    egree

    s)

    frequency, , (rad/s)

    Figure 3. (a): = fext(t); - - = f ext(t). (b): red solid =

  • Fourier Series and Periodic Response to Periodic Forcing 13

    7.4 Matlab code1 function [Fq ,wq,x,t] = Fourier(type,Q,wn,z)2 % [F,w, x ] = Fourier ( type ,Q,wn, z )3 % Compute the Fourier s e r i e s c o e f f i c i e n t s o f a pe r i od i c s i gna l , f ( t ) ,4 % in two d i f f e r e n t ways :5 % complex exponen t i a l expansion ( i . e . , s ine and cos ine expansion )6 % f a s t Fourier transform7 %8 % The type o f p e r i od i c s i g n a l may be9 % square a square wave

    10 % sawtooth a sawt oo th wave11 % t r i an g l e a t r i a n g l e wave12 %13 % The per iod o f the s i gna l , f ( t ) , i s f i x e d at 2 p i ( second ) .14 %15 % The number o f Fourier s e r i e s c o e f f i c i e n t s i s input as Q.16 % This r e s u l t s in a 2Q Fourier transform c o e f f i c i e n t s .17 %18 % The Fourier approximation i s then used to compute the steadys t a t e19 % response o f a s i n g l e degree o f freedom (SDOF) o s c i l l a t o r , d e s c r i b ed by20 %21 % 222 % x( t ) + 2 z wn x ( t ) + wn x ( t ) = f ( t ) ,23 %24 % where the mass o f the system i s f i x e d at 1 ( kg ) .25 %26 % see : h t t p :// en . w ik iped ia . org/wik i / Fou r i e r s e r i e s27 % ht tp ://www. jhu . edu/ s i g n a l s / f ou r i e r 2 / index . html28 %2930 i f nargin < 431 help Fourier32 return33 end343536 T = 2*pi; % per iod o f e x t e rna l forc ing , s3738 a = zeros(1,Q); % co e f f i c i e n t s o f cos ine par t o f Fourier s e r i e s39 b = zeros(1,Q); % co e f f i c i e n t s o f s ine par t o f Fourier s e r i e s4041 q = [1:Q]; % po s i t i v e f requency index va lue42 wq = 2*pi*q/T; % po s i t i v e f requency va lues , rad/sec , eq n (13)4344 dt = T/(2*Q); % 2Q d i s c r e t e po in t s in time fo r FFT sampling45 ts = [-Q:Q-1]*dt; % 2Q d i s c r e t e po in t s in time fo r FFT sampling4647 % s h i f t e d time . . . T/2

  • 14 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

    71 end7273 i f strcmp( type,sawtooth ) % sawtooth wave74 b = -(2./q) .* (-1).q;75 f_true = t; f_true (1) = 0; f_true (2*P+1) = 0;76 f_samp = ts;77 f_samp (1) = 0; % ge t p e r i o d i c i t y r i gh t , f (p i ) = 078 end7980 i f strcmp( type,triangle ) % t r i a n g l e wave81 a = -(2./(pi*q.2)) .* ( ( -1).q - 1 );82 f_true = pi/2 - t .* sign(t);83 f_samp = pi/2 - ts.* sign(ts);84 end858687 f_approxR = a * cos(q*t) + b * sin(q*t); % rea l Fourier s e r i e s8889 Fq = (a - i*b)/2; % complex Fourier c o e f f i c i e n t s9091 % Complex Fourier s e r i e s ( p o s i t i v e and nega t i v e exponents )92 f_approxC = Fq * exp(i*wq *t) + conj(Fq) * exp(-i*wq *t);939495 % The imagniary par t o f the complex Fourier s e r i e s i s e x a c t l y zero !96 imag_over_real_1 = max(abs(imag(f_approxC ))) / max(abs( real (f_approxC )))979899 % The f a s t Fourier transform (FFT) method

    100 % In Matlab , the forward Fourier transform has a nega t i v e exponent .101 % According to a convent ion o f the FFT method , index number 1 i s f o r time = dt102 % t s (1) = Q dt = T/2 ; t s (Q) = dt ; t s (Q+1)=0 ; t s (2Q) = (Q1)dt = T/2dt103 % . . . see the t a b l e at the end o f t h i s f i l e .104105 F_FFT = f f t ( [ f_samp(Q+1:2*Q) f_samp (1:Q) ] ) / (2*Q); % Fourier coe f f s106107108 % coe f = [ Fq F FFT(2 :Q+1) ] % d i s p l a y the Fourier c o e f f i c i e n t s109110 % P lo t t i n g 111112 figure (1);113 plot(t,f_true ,-r , ts ,f_samp ,*r , t,f_approxR ,-c , t,f_approxC ,-b )114 xlabel(time , t, (s))115 ylabel(function , f(t), (N))116 axis (1.05*[ -pi ,pi])117 legend(true,sampled ,real Fourier approx ,complex Fourier approx )118 plot(wq , real (Fq),r, wq,imag(Fq),b , ...119 wq, real (F_FFT (2:Q+1)),*r, wq,imag(F_FFT (2:Q+1)),*b )120 ylabel(Fourier coefficients , F(w), (N))121 xlabel(frequency , {/ Symbol w}, (rad/s))122 legend(real(F), imag(F), real(FFT(f)), imag(FFT(f)))123124125 figure (2);126 plot(t,a*ones(1,2*P+1).*cos(q*t),-r , t,b*ones(1,2*P+1).* sin(q*t),-b);127 xlabel(time , t, (s))128 ylabel(cosine and sine terms)129 axis (1.05*[ -pi ,pi])130131132 % =======================================================================133 % Steadys t a t e response o f a SDOF o s c i l l a t o r to genera l p e r i od i c f o r c i n g .134135 % Complexva lued frequency response funct ion , H(w) , has un i t s o f [m/N]136 H = (1/wn2) ./ ( 1 - (wq/wn).2 + 2*i*z*(wq/wn) );137138 % Complex Fourier s e r i e s ( p o s i t i v e and nega t i v e exponents )139 x_approxC = (H .* Fq) * exp(i*wq *t) + (conj(H) .* conj(Fq)) * exp(-i*wq *t);140141 % In Matlab , the inve r s e Fourier transform has a p o s i t i v e exponent .

    CC BY-NC-ND H.P. Gavin

  • Fourier Series and Periodic Response to Periodic Forcing 15

    142 % . . . see the t a b l e at the end o f t h i s f i l e f o r the s o r t i n g convent ion .143 x_FFT = i f f t ( [ (1/wn2) , H , conj(H(Q-1: -1:1)) ] .* F_FFT ) * (2*Q);144145 figure (3); % p l o t f requency response func t i ons146 semilogy(wq ,abs(Fq),*g, wq,abs(H),-r, wq ,abs(H.*Fq),*b )147 xlabel(frequency , {/ Symbol w}, (rad/s))148 ylabel(frequency response )149 legend(|F|, |H|, |H*F|)150151 plot (wq ,angle(Fq )*180/pi ,*g, wq,angle(H)*180/pi ,-r, wq,angle(H.*Fq )*180/pi ,*b)152 xlabel(frequency , {/ Symbol w}, (rad/s))153 ylabel(phase lead , (degrees))154155 figure (4); % p l o t time response156 ts = [ ts(Q+1:2*Q) ts(1:Q) ]; % res o r t the time ax i s157 plot ( t,x_approxC ,-r , ts , real (x_FFT),*b , ts, imag(x_FFT),.b )158 axis (1.05*[ -pi ,pi])159 xlabel(time , t, (s))160 ylabel(response , x, (m))161 legend(x(t) - complex Fourier series , real(x(t)) - FFT, imag(x(t)) - FFT)162163164 % The imaginary par t i s e x a c t l y zero f o r the complex exponent s e r i e s method !165 imag_over_real_2 = max(abs(imag(x_approxC ))) / max(abs( real (x_approxC )))166167 % The imaginary par t i s p r a c t i c a l l y zero f o r the FFT method !168 imag_over_real_3 = max(abs(imag(x_FFT ))) / max(abs( real (x_FFT )))169170 % 171 % SORTING of the FFT c o e f f i c i e n t s number o f data po in t s = N = 2Q172 % note : f max = 1/(2 dt ) ; d f = f max /(N/2) = 1/(N dt ) = 1/T;173 %174 %175 % index time frequency176 % ===== ==== =========177 % 1 0 0178 % 2 dt d f179 % 3 2 dt 2 d f180 % 4 3 dt 3 d f181 % : : :182 % N/21 (N/22) dt f max2d f = ( N/22) d f183 % N/2 (N/21) dt f maxd f = ( N/21) d f184 % N/2+1 (N/2) dt +/ f max = ( N/2 ) d f185 % N/2+2 (N/2+1) dt f max+df = (N/2+1) d f186 % N/2+3 (N/2+2) dt f max+2d f = (N/2+2) d f187 % : : : :188 % N2 (N3)dt 3d f189 % N1 (N2)dt 2d f190 % N (N1)dt d f191 %

    CC BY-NC-ND H.P. Gavin

    Fourier Series for Real-Valued FunctionsThe complex exponential form of Fourier series

    Fourier Integrals in Maplea periodic square wave function: f(t) = sgn(t) on -