3. Oscillating Systems

Legal Notice, Disclaimer, and Book Ordering Information:

Null

Setup

Clear["Global`*`"]\(Off[General::spell]; 
Off[General::spell1]; \)

3.2 Mathematica Commands

3.2.1  Packages

This command loads all Packages and user-defined procedures presented in Chapter 3

<< "D:\Mma\Inits\ch3init.m"

3.2.2  User-defined Procedures

Series expansion for a second-order equation

Example 1:  Second order solution

eq1  =  
      y''[t]  +  w^2 y[t]  +  a y'[t]^2  +  y[t]^3  == 0

diffSeriesOne[eq1, y, t, 2, {y[0] -> y0, y'[0] -> vy0}]

Example 2:  How the diffSeriesOne routine works

\(Clear[diffSeriesOne2]; 

    diffSeriesOne2[eqin_, z_, t_, order_, initList__List] := \ 
\ 
      Module[{}, 
\ \ \ eq = eqin[\([1]\)] - eqin[\([2]\)] == 0; 
\ \ \ 
        zSer = \ Series[z[t], {t, 0, order}]; 
\ \ \ 
        eSer = \ eq /. \((z[t] -> zSer)\) // ExpandAll; 
\ \ \ 
        eqs\  = \ Thread[CoefficientList[eSer[\([1]\)], t] == 0]; 
\ \ \ 
        vars = \((Table[D[z[t], {t, j}], {j, 2, order + 2}] /. t -> 0)\); 
        \ \ \ \ \ 
\ \ \ sol\  = \ \(Solve[eqs, vars]\)[\([1]\)]; 
\ \ \ 
        zSol = \ \(zSer /. sol\) /. initList; 
\ \ \ Return[\ zSol]\ \ 
\ ]
        \)

diffSeriesOne2[eq1, y, t, 2, {y[0] -> y0, y'[0] -> vy0}]

eq

zSer

eSer

eqs

vars

zSol =  zSer /. sol /. {y[0] -> y0, y'[0] -> vy0}

Phase plot for a one-dimensional system

Example:  Phase plot for harmonic motion

phasePlot[Sin[2  π t], D[Sin[2  π t], t], {t, 0, 3}];

Example:  Time-evolved phase plot for harmonic motion

timePhasePlot[Sin[2  π t], D[Sin[2  π t], t], {t, 0, 3}];

Example:  Phase plots and time-evolution  for harmonic motion

doublePlot[Sin[2  π t], D[Sin[2  π t], t], {t, 0, 3}];

Fourier spectrum of a one-dimensional oscillating system

Example:  Fast Fourier transform

eq1  =  
      Sin[2  π x] 
        (1  -  1/5 Sin[2  π x/2]  +  1/10 Sin[2  π x/4])

p3  =  fftSpectrum[eq1, x, 100];

Show[p3, PlotRange -> {{0, 200}, All}];

Eigenvalues and eigrnvectors for small oscillating systems

Example 1:  Two coupled particles

\(T\  = \ m/2\ \ \(q1'\)[t]^2\  + \ m/2\ \ \ \(q2'\)[t]^2; 

    V\  = \ k1/2\ \((q2[t]\  - \ q1[t])\)^2; \)

smallOsc[T, V,  {q1[t], q2[t]}, {0, 0}, t]

Example 2:  How the smallOsc routine works

\(Clear[smallOsc2]; 

    smallOsc2[T_, V_\ , coordList__, equlibList__, t_:  t] := \ 
\ \ 
      Module[{}, 
\ \ \ \ q = coordList; 
\ \ \ \ p = D[coordList, t]; 

        \ \ \ \ dim = Length[q]; 
\ \ \ \ 
        equlibRule = Thread[coordList -> \ equlibList]; 
\ \ \ \ 
        Vij = Outer[D[V, #1, #2]&, q, q]; \ 
\ \ \ \ 
        Tij = Outer[D[T, #1, #2]&, p, p]; 
\ \ \ \ 
        matrix = \ Vij - w2\ Tij\  /. equlibRule; \ 
\ \ \ \ 
        w2Sol = \ Solve[\ Det[matrix] == 0, w2] // Simplify; 
\ \ \ \ 
        freq = \ \ w2 /. w2Sol; \ 
\ \ \ \ vector = Array[a, dim]; 
\ \ \ \ 
        eqs = \ \(Thread[0 == matrix . vector] // ExpandAll\) // Simplify\ ; 
        
\ \ \ \ 
        vSol = 
\ \ \ \ 
          Table[\ 
\ \ \ \ \ \ \ 
            \(Solve[
\ \ \ \ \ \ \ \ \ \ 
                Join[eqs /. w2Sol[\([i]\)], {vector . vector == 1}]

                \ \ \ \ \ \ , vector]\)[\([2]\)]
\ \ \ \ , {i, 1, dim}]; 
        \ \ \ 
\ \ \ \ Return[{freq, vSol}]]\)

smallOsc2[T, V,  {q1[t], q2[t]}, {0, 0}, t]

equlibRule

w2Sol

\(Solve[
\ \ \ \ \ \ \ \ \ \ 
      Join[eqs /. w2Sol[\([1]\)], {vector . vector == 1}]
\ \ \ \ \ \ , 
      vector]\)

{freq, vSol}

Animation for linear motion

Example:  Linear harmonic oscillator

frames = 20;

oscMovie[Sin, 2  π, frames, {-1, 1}];