<?xml version="1.0" encoding="UTF-8"?>
<Worksheet><Version major="6" minor="1"/><View-Properties><Zoom percentage="100"/></View-Properties><Styles><Layout alignment="left" bullet="none" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="Normal" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="Maple Input" opaque="false" size="12"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="Text" opaque="false" size="12" underline="false"/></Styles><Group><Input><Text-field layout="Normal" style="Text">Analytic solution for damped, driven linear harmonic oscillator.
</Text-field><Text-field layout="Normal" style="Text">Version: 1.2 (May 15, 2006)</Text-field><Text-field layout="Normal" style="Text">Author: David A. Craig &lt;http://web.lemoyne.edu/~craigda/&gt;</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">To do:</Text-field><Text-field layout="Normal" style="Text">(i) Add envelope and critical damping curves to x(t) plot.</Text-field><Text-field layout="Normal" style="Text">(ii) Animate phase space and 3D curves.</Text-field><Text-field layout="Normal" style="Text">(iii) Get initial condition solver working properly</Text-field><Text-field layout="Normal" style="Text">
</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">restart;
with(plots):</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font style="Text">physical parameters of oscillator </Font>
m := 2;                # mass
k := 3;                # spring constant
b := .3;               # linear damping coefficient

w0 := sqrt(k/m);       # natural frequency
g := b/(2*m);          # damping parameter
wd := sqrt(w0^2-g^2);  # damped oscillation frequency
wo := sqrt(g^2-w0^2);  # overdamped oscillation 'frequency'

# comment these out if using initial condition finder [see below]
A := 1;                # amplitude (underdamped)
ph := 0;               # phase (underdamped)
B := A;                # amplitude (critical)
C := 0;                # amplitude (critical)
F := A;                # amplitude (overdamped)
G := 0;                # amplitude (overdamped)<Font style="Text">

transient cases</Font>
xU := t -&gt; A*exp(-g*t)*cos(wd*t-ph);                   # underdamped
xC := t -&gt; exp(-g*t)*(B + C*t);                        # critically damped
xO := t -&gt; exp(-g*t)*(F*exp(wo*t) + G*exp(-wo*t) );    # overdamped<Font style="Text">


transient response</Font>
xt := t -&gt; piecewise(g &lt; w0, xU(t),g=w0,xC(t), g&gt;w0,xO(t) );<Font style="Text">

physical parameters of driving force</Font>  
F0 := 1;                 # driving force
p0 := 0;                 # driving phase
w := 1;                  # driving frequency

wr := sqrt(w0^2-2*g^2);  # resonant frequency
beta := w -&gt; (F0/m)/sqrt( (w0^2-w^2)^2+4*g^2*w^2 );  # steady-state amplitude
p := w -&gt; arctan( 2*g*w/(w0^2-w^2) );               # steady-state phase<Font style="Text">

steady-state response</Font>
xSS := t -&gt; beta(w)*cos(w*t-p(w)-ph);<Font style="Text">


net response of damped, driven linear oscillator</Font>
x := t -&gt; xt(t) + xSS(t);
v := t -&gt; diff( x(t), t);

<Font style="Text">

BROKEN!
optional initial condition finder</Font>
# takes initial position and velocity, solves for unkown coefficients (A-G, above), substitutes them back into the solution
# requires that specification of the solution coefficients A-G above be commented out and the following code be uncommented
#
# broken in a number of ways:
# ic finds multiple solns in underdamped case e.g. imaginary ones; not sure what's going on yet
# x, v redefinition doesn't plug in found initial conditions to xt or xSS
# would be nice to be able to recursively redefine, but Maple complains if you try [e.g. x := t -&gt; subs( ic, x(t)) ;]
#
# x0 := 0;
# v0 := 0;
# using subs instead of D(x) [say] because D(x) can't seem to handle piecewise
# ic := solve( {x(0)=x0,subs(t=0,v(t))=v0} );
# redefine x, v
# x := 'x';
# v := 'v';
# x := t -&gt; subs( ic, xt(t) + xSS(t)) ; 
# v := t -&gt; diff( x(t), t);
 
 
</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font style="Text">plot responses</Font>
plot( [xt(t),xSS(t),x(t)],t=0..50, color=[green,red,blue]);
</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font style="Text">animate response</Font>
animate(plot,[x(t),t=0..T],T=0..100);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font style="Text">amplitude and phase of steady-state response as functions of driving frequency</Font>
plot( beta(x), x=0..20);
plot( p(x), x=0..Pi);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font style="Text">phase space</Font>
plot( [x(t),v(t),t=0..50]);
# with attractor
plot( [[x(t),v(t),t=0..50], [x(t),v(t),t=90..100]], color=[red,blue]);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font style="Text">phase space in time</Font>
spacecurve( [x(t),v(t),t], t=0..50,axes=boxed,numpoints=1000);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"/></Input></Group><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/></Worksheet>