Ph 385

Fall 2006

 

WAVE 2:  Reflection of Traveling Waves

 

This problem concerns traveling pulses, and the explanation of the sign reversal of a pulse upon reflection from a fixed end of the string. We will use IDL for this problem.

 

I.  Logging on, creating a directory. 

Log onto one of the Department's computers, and change to your ph385 directory, by entering

            cd ph385

Make a directory for this problem, by entering

            mkdir wave2

            cd wave2

            pwd

 

II.  Program to create an asymmetrical pulse.

 

Open a report window, with Open Office or Microsoft Word.  Now open a couple of command-shell windows (xterm, for example), and use one of them to enter the following program, using nano or your favorite text editor. (For variety, you might try pico, or kedit, or gedit, or emacs.)

 

            nano pulse1.pro

Now enter the program.
 
FUNCTION agauss,x
; This function is an asymmetric-gaussian pulse.
   alpha=1.; amount of "speed-up function"
   beta=1.; scale factor for rising edge
   xmod=x*(1+alpha*(atan(beta*x)+!pi/2.))
   f=exp(-xmod^2/2.)
   RETURN,f
END
   
 
PRO pulse1
; This routine calculates and plots test pulses.
   black=0
   white='ffffff'x
   red=255
   !p.background=white
   !p.color=0
   device,decomposed=1; Use truecolor.  Note:  to write a color 
               ; jpeg, use write_jpeg,'wave2.jpg',tvrd(true=3),true=3
   vt=-2.
   x=(findgen(101)-50.)/10.; x runs from -5 to +5
   plot,x,agauss(x-vt)+agauss(-x-vt)
   oplot,[0.],[0.],psym=4,color=red
   oplot,[0.],[0.],psym=4,color=red,symsize=3
   save
END
   

When you have entered this program and saved it as pulse1.pro, run IDL.  NOTE:  IDL will not run on many of the LINUX machines in TH 123 without a work-around.  Here it is:

   There is a sort of bug which has apparently become a feature, which makes many of the Linux computers on our system refuse to run IDL unless you set a certain environmental variable.
   IDL should open up OK.  But when you try to plot something, it crashes, with a complaint involving a "segmentation fault."  In this case, you should enter, from the command line,
      setenv LIBGL_ALWAYS_INDIRECT true
I will paste Alan Der's fuller explanation below.  You can also put this statement in one of your configuration files, if you know how to do that.
   The other workaround is to use a different Linux machine.  To do this, open a terminal window or an xterm window.  From the command line, enter
      ssh -Y th123-13.sfsu.edu
and give your password.  Other forms also work:
      ssh -X th123-13.sfsu.edu
      ssh -X th123-33.sfsu.edu
I think this command should be on the board in the computer room.

 

Now:  run IDL and compile the program from the IDL comand line:

 
        IDL> .rnew pulse1
   

When the program compiles without errors, use the command line to see what the shape of the pulse is:

 
        IDL> x=(findgen(101)-50.)/10.  values from -5 to 5
        IDL> plot,agauss(x)            pulse going to the right
        IDL> plot,agauss(-x)           pulse going to the left
   

Note: on the Linux machines, color is funny; you may have to execute an IDL command making a graph twice before it shows up. The first plot should show a pulse which looks like it is going to the right, and the second, a pulse which seems to be traveling to the left. So, f(x) and f(-x) are reversed with respect to the x axis. Don't worry about the warning about underflow. This means that the Gaussian gets VERY close to zero far away from its center. The details of the equation for the pulse, as coded into the function agauss, are not too important; I just fooled around with a Gaussian for a while to get a skewed form of a Gaussian which seems to indicate a direction of propagation. Now we will use it to show how a pulse moves with time.

 

III.  Propagation of a traveling wave.


Now run the program pulse1 which calls the subroutine agauss and plots the result:

 
      IDL> pulse1
   

This routine plots the linear combination f(x-vt)+f(-(x-vt)). The first f should represent a pulse propagating with velocity +v, and the second f should give a pulse propagating with velocity -v, and "facing" the other way. To see how this works, add some additional plots, like this.  First, add the following line, near the front of the program.  It sets up a graphical window with five plots, for five different times of propagation.

 
   !p.multi=[0,1,5,0,0]        add this near the front of the program
 
Now, after the lines
   vt=-2.
   x=(findgen(100)-50.)/10.; x runs from -5 to +4.9
   plot,x,agauss(x-vt)+agauss(-x-vt)
   oplot,[0.],[0.],psym=4,color=red
   oplot,[0.],[0.],psym=4,color=red,symsize=3
add the three lines below.
   vt=-1.
   plot,x,agauss(x-vt)+agauss(-x-vt)
   oplot,[0.],[0.],psym=4,color=red,symsize=2
   

This adds one more plot. Continue this procedure and extend this program to plot for times vt = 0, 1, and 2. [Hint on cut and paste with pico:  to cut three lines, hit Ctrl-K three times; then to paste them back, hit Ctrl-U.]  Watch the pulses approach each other, merge, then separate and go their own ways.

Save this graph as a JPEG file and save the program.  You will need to somehow get them into a word-processor document. NOTE: since we are using color, determined by the device,decomposed=1 statement, you have to save the graphic as a color jpeg:

 
               IDL> write_jpeg,'wave2.jpg',tvrd(true=3),true=3
   

IV.  Reflection of a Pulse from a Fixed End of the String

 

The program used shows a pulse being reflected without changing sign. And the displacement at x = 0 (the red diamond) is not zero, as it should be for a string fixed at that point. Now change the program so that it adds a positive, right-ward-propagating pulse and a negative, leftward-propagating pulse, and show that the sum of these two keeps the point at x = 0 fixed.

Save this graph too, and get it and the program listing into the word-processor document. It is OK to make some notations about the graph, showing, for instance, where the wall is supposed to be where the pulse is reflected.