Legal Notice, Disclaimer, and Book Ordering Information:

(* Legal Notice, Disclaimer, and Book Ordering Information:

Last Modified: FIO January 1, 1995

Mathematica For Physics
Robert L. Zimmerman and Fredrick I. Olness
MathSource Number: 0206-862 

ISBN 0-201-53796-6
For ordering information, call 1-800-822-6339
Addison-Wesley Publishing Company

Communication with the authors:
Fredrick I. Olness:  olness@mail.physics.smu.edu
Robert L. Zimmerman: bob@zim.uoregon.edu

Copyright 1995, Addison-Wesley Publishing Company, Inc. The material in
this file may be distributed freely  so long as the content remains
unchanged, and the copyright and  reference notices are included. The
publisher grants permission for the noncommercial use of these programs
and program segments.  All other uses require the prior written consent
of the publisher.    

All rights are reserved with regard to the  material in the
"Mathematica For Physics" text, and may not be reproduced, stored in a
retrieval system, or transmitted,  in any form or by any means,
electronic, mechanical, photocopying,  recording, or otherwise, without
the prior written permission  of the publisher. 

The programs and applications presented in this book have been included
for  their instructional value. They have been tested with care but are
not  guaranteed for any particular purpose. The publisher does not
offer any  warranties or representations, nor does it accept any
liabilities with  respect to the programs or applications. 

 *)

Chapter 6, Section 1, Problem 3: 
Particle Hitting a Finite Step Potential 
Code to Generate Animation ONLY!!!

Clear["Global`*"];

psiL[x_]=E^(I*k1*x) + E^(-I*k1*x)*R;
psiR[x_]=E^(I*k2*x)*T;
RTrule={R -> (k1 - k2)/(k1 + k2), T -> (2*k1)/(k1 + k2)};
kRule2={k1 -> (2^(1/2)*(En*m)^(1/2))/hbar, k2 -> (2^(1/2)*(m*(En - V))^(1/2))/hbar};
values={V -> 1, m -> 1, hbar -> 1};

timeplot[time_,wave_,Energy_,thickness_,xrange_]:= 
  Plot[Evaluate[Re[Exp[-I Energy time]* wave
           /.RTrule/.kRule2/.values/.En->Energy ] ]
      ,xrange
      ,PlotStyle-> Thickness[thickness] 
      ,AxesOrigin->{0,0}
      ,DisplayFunction->Identity   
    ];

tnumber=6;
 timestep=2 Pi/(tnumber);
 Energy=1.1;
 Do[ Show[{timeplot[time,psiL[x][[1]],Energy,.006,{x,-10,0}]
          ,timeplot[time,psiL[x][[2]],Energy,.004,{x,-10,0}]
          ,timeplot[time,psiR[x][[1]],Energy,.001,{x, 0,10}]}
       ,DisplayFunction->$DisplayFunction]
   ,{time,0,2 Pi-timestep,timestep}
   ]

tnumber=6;
 timestep=2 Pi/(tnumber);
 Energy=0.9;
 Do[ Show[{timeplot[time,psiL[x][[1]],Energy,.006,{x,-10,0}]
          ,timeplot[time,psiL[x][[2]],Energy,.004,{x,-10,0}]
          ,timeplot[time,psiR[x][[1]],Energy,.001,{x, 0,10}]}
       ,DisplayFunction->$DisplayFunction]
       ,{time,0,2 Pi-timestep,timestep}
   ]

An extra plot not in the text:

Clear[psi];
psi[x0_ /; x0<=0,Energy_]:=  
   psiL[x] /.RTrule /.kRule2 /.values /.{x->x0,En->Energy};
            
psi[x0_ /; x0 >0,Energy_]:=  
   psiR[x] /.RTrule /.kRule2 /.values /.{x->x0,En->Energy};

waveplot2Dtime[Energy_,time_]:=
Plot[ {Re[Exp[-I Energy time]*psi[x Pi,Energy]]
      ,Im[Exp[-I Energy time]*psi[x Pi,Energy]]} //Evaluate
     ,{x,-10,10}
     ,PlotStyle->{Dashing[{0.1,0.0}],Dashing[{0.03,0.02}]}
     ,AxesOrigin->{0,0}
     ,DisplayFunction->Identity 
   ];

Show@GraphicsArray[{waveplot2Dtime[1.2,0]
                   ,waveplot2Dtime[0.9,0]}];

tnumber=6;
 timestep=2 Pi/(tnumber);
 Energy=0.9;
 Do[ Show[waveplot2Dtime[1.2,time]
         ,DisplayFunction->$DisplayFunction]
   ,{time,0,2 Pi-timestep,timestep}
   ]

tnumber=6;
 timestep=2 Pi/(tnumber);
 Energy=1.2;
 Do[ Show[waveplot2Dtime[1.2,time]
         ,DisplayFunction->$DisplayFunction]
   ,{time,0,2 Pi-timestep,timestep}
   ]