Ph 385
Fall 2006
Fourier 2: The triangle standing Wave
( PH 385 home page |Fourier series coefficients | logon and setup )
I. Logging on and running IDL.
Start by logging onto the P&A computer system, starting the desktop, opening a terminal (or xterm) window, and changing to a subdirectory for this problem. (See previous problems Wave-1 and Wave-2 for details about logging on and starting IDL.) Just after opening the terminal window, enter
cd ph385
mkdir fourier2
cd fourier2
pwd
You should get back (or at least I did)
/Users/faculty/bland/ph385/fourier2
Open a couple morej xterm windows, and start IDL in one of them.
II. Making the wave move.
Here you should start with the program file you made for the problem Fourier-1. Copy it over like this:
cp ../fourier1/fourier1.pro ./fourier2.pro
(Look out for periods - they have to be there.) Run this program, to make sure it still works.
IDL> .rnew fourier2
IDL> fourier1
Now open the file fourier2.pro with pico and make some changes.
* Change the internal name to fourier2, to match the file's name.
Change the file to look like this:
PRO fourier2
black=0
white='ffffff'x
!p.background=white
!p.color=black
read,'Number of terms: ',nterms
L=2.
x = findgen(401)/200.; vector of 401 floating-point numbers, from
; 0.0 to 2.0 .
y=fltarr(401); y starts a a vector of zeros.
v=2.0; wave speed, in m/s
dt=0.05; time step
FOR itime=0,100 DO BEGIN
t=itime*dt
y=fltarr(401); reset to zero each time.
FOR n=1,nterms,2 DO BEGIN
an = 8./(!pi^2*n^2)*(-1)^((n-1)/2); nth coefficient
kn=n*!pi/L
omegan=kn*v
y = y + an*sin(kn*x)*cos(omegan*t); add on nth term
END
plot,x,y,title='Triangle wave, nterms = '+string(nterms)
END
END
Can you see the reasons for the
changes? We now are giving the argument
![]()
to the n-th sine wave, where kn and wn are made up using a wavelength of 4 meters (twice L) and a wave speed of 2 m/s. This should make the wave vibrate with a period of 2 seconds. The times are generated by a second loop, over the variable itime.
Run this program. It works pretty well, but runs too fast. Here is the way to slow it down. Put
str1=""; input buffer
near the front of the program, and the command
read,str1
after the plot statement. Then the program will wait while you look at the n-th iteration.
Next you may want to plot successive time steps on the same plot. To do this, add a first plot statement just after the time step, like this:
dt=0.05; time step
plot,x,y,xrange=[0,2],yrange=[-1,1],title='nterms: '+string(nterms)
This draws the axes. Then change the plot statement near the end to the simpler form
oplot,x,y
This should be enough to let you see what happens to the triangle wave when you let go!
You might fool around with the time, like making it not quite so even a number so that you can see successive plots. And you could comment out the read statement,
; read,str1
and let the program go as fast as it can!
Record and document what you have done as usual.
Explain what you learned about wave propagation on a string from these calculations.