Physics 319
Homework #6
Oscillators

Double click on the ⌉  symbol with an arrow on the bottom at the far right of the subsection heading to open the subsection of interest.  Double clicking again will close it back up.

Simple Harmonic Oscillator

Below is a definition of a simple Harmonic Oscillator.  Actually, it is a miniature Mathematica program.  Note that the function has inputs for mass, spring constant k, amplitude and phase.  Also note the syntax for this type of definition -- underscores in the argument imply variable parameters; square brackets make this a new "instrinsic function" like Sin[] or Exp[]; the ";" symbol after the definition of ω separates lines in this mini-program, etc.

Mathematica note:  this "cell" is formatted as a "text" format as opposed to an "input" format which actually calculates things.  You can change the cell format by clicking on the cell brackets to the right and from the toolbar using Format -> Style.

To execute the cell below (to enter this mini-program into your Mathematica session) click in the cell or on the brackets to the right and press Shift-Enter or the Number Pad Enter by itself.

\(xsho[m_, k_, A_, δ_, t_] := 
      \((
		ωo = Sqrt[k/m]; 
		A*Cos[ωo*t - δ])
        \)\)

We can now use this function like any other (e.g., Sin[], Log[], Exp[]...), putting in values for the different parameters.  So, first the program calculates ω given values for k and m, and then it finds xsho[t]=A*Cos[ωo*t-δ]), using the other parameter values.  Let m=1kg, k=2N/m, A=4m, δ=1rad, t=2.5s.  Execute the cell below to see how it works.

xsho[1, 2, 4, 1, 2.5]

Now let's plot the function.  Notice that t is left as a variable for Plot[] to vary.

xplot = Plot[xsho[1, 2, 4, 1, t], {t, 0, 7}]

Although this is a cosine function, the peak is not centered at zero.  Find the expected offset given the parameters used in calculating xsho[t].  Does the calculated value agree with the graph? .....

	(answer here)

Let's find the velocity by taking the derivative of the position.  Note there are no underscores in the xsho[] function, because I'm not defining the function here, but using it with parameters m, k, A, δ, and t.  This function is a little weird...if you're interested, maybe you can figure out a better way to do it. We need to take the derivative of xsho[] with respect to the varaible t, but we can't differentiate with respect to a number that we're putting in for t.  So, I've created a new function dummyv that depends on a new variable, dumt.  We first take the derivative with respect to dumt, and then Evaluate[] it to get an expression for dummyv. Finally, we can substitute our value for t into dumt and evaluate the function.....

\(vsho[m_, k_, A_, δ_, t_] := 
      \((
		dummyv[dumt_] := 
          Evaluate[D[xsho[m, k, A, δ, dumt], dumt]]; 
		dummyv[t])
        \)\)

Plotting with the same values as above we have...

vplot = Plot[vsho[1, 2, 4, 1, t], {t, 0, 7}]

To view the phase relationship more closely, let's overlay the two plots.

Show[xplot, vplot]

Now, let's make a phase plot by plotting x[t] versus v[t].  We'll use ParametricPlot[], the AspectRatio->1 option just makes the vertical and horizontal axes the same size.  Also, we'll use PlotRange to use the same size axes.

ParametricPlot[{xsho[1, 2, 4, 1, t], vsho[1, 2, 4, 1, t]},  {t, 0, 7}, 
      PlotRange -> {{-6, 6}, {-6, 6}},  AspectRatio -> 1, 
      AxesLabel -> {"x",  "v"}]

Why is it an ellipse that closes on itself?.....

	(answer here)

Damped Harmonic Oscillator

Now, you get to follow the same routine as above but for the Damped Harmonic Oscillator.  I'll get you started; you fill in the rest.  I'm using the symbols in the BasicInput panel to your right.  If you don't have these symbols, you can use other variables.

Here we're solving the differential equation:  \(TraditionalForm\`x\&¨ + \(b\/m\) x\&. + \(k\/m\) x = 0\).  
Let's first double check the class notes, and solve this diffyQ using Mathematica.

DSolve[{x''[t] + b/m*x'[t] + k/m*x[t] == 0, x'[0] == 0, 
        x[0] == A}, x[t],  t]

On a separate sheet of paper, show that this is indeed the same expression given in class for the above initial conditions.....

Now, let's create the funtion.  Fill in the missing equations below following the general expression for the damped harmonic oscillator given in class for the above initial conditions.

\(xdho[m_, k_, A_, b_, t_] := 
      \((
		\(\(ωo =. \)....\); 
		\(\(β =. \)....\); 

        		\(0.5  A\ Exp[\(-β\)*t]...\)..
					)\)\)

Now plot it for the following values, m=1kg, k=2N/m, A=4m, b=0.1.   Plot it with a range of t big enough to really see the function.

dho1 =. ....

Is this critically damped, overdamped or underdamped?  Does this make sense given the oscillator parameters?  If not, check your equations....

	(answer here)

Let b=0.5 kg/s and replot. Use PlotRange->{miny, maxy} to get a pretty plot.  If you have questions on syntax, type ??Plot in an input cell.

dho2 =. ....

Overlay the two plots.

Show[dho1, dho2]

You want to be able to clearly see individual oscillations, so if the two plots are on too big a scale or are on different scales, replot the individual plots on the same scale and redo the Show[] command.

Describe the differences in the two plots.....

 	(answer here)

What value of b gives a critically damped solution (see notes)?  In which case is the drag force the biggest?

	(answer here)


Plot xdho[] for the critically damped case.

Try the same plot with 25% less b to see the beginnings of underdamping.

Finally  we need to make a Phase Plot to compare with the no, damping case.  But first we need to create a velocity function.  You should be able to follow what was done above to create your new function.....Remember that Mathematica remembers variables you've already defined, so if you screw something up, you may need to go back and re-evaluate a previous definition (just click on the cell, e.g., xdho[] where the function is defined, and hit the numpad enter.)  Or, you may need to clear things out, e.g., Clear[vdho]

Plot your result for the case of m=1kg, k=2N/m, A=4m, b=0.5.

Now make your Phase Plot for these same parameters.  Make the plot pretty, by adjusting the t range and the PlotRange->{{minx,maxx},{minv,maxv}}  option.

Why is the curve a spiral?....

	(answer here)

When you are ready to print the whole thing out, please do the following to minimize paper usage
•Go back through the document and clean things up, like deleting unnecessary returns, trial runs, and pesky messages about variables being named like other variables, etc...
•Then click on Format on the Toolbar and choose Printing Style Environment -> Printout.
•Under File click Printing Settings -> Page Setup and make sure you're set for Portrait.
•Now under File click Print.  In the print dialog box choose the Layout tab and select 2 pages per sheet.
•Click Print.