Multiple Scattering in a Gas (II)

We can now complete our simulation of the multiple scattering of an electron moving through a gas. In the first section below we will define three functions. One generates the 'smeared' scattering angle, the second calculates the trajectory of the electron with no multiple scattering, and the last one is used to make histograms. In Section 2 you will assemble these pieces into the final code and then investigate the physics.

1.0 Some Necessary Commands.

In this section several Mathematica commands that will be useful in your simulation are demonstrated  or defined.

1.1 Generating a scattering angle from a Gaussian distribution

The code fragment here defines a function that returns the randomly selected angle. The input to the code is the length of the upcoming step. In other words,

                                     steplength = vplus*step    
                                      
where vplus is the length of the velocity vector at that point and step is the time step size.  To define the function place the cursor anywhere in the cell and hit Enter.

\(MSAngle[
        steplength_]\  := 
	\((\  (*\ 
          set\ up\ the\ constants\ *) 
		MeanFreePath\  = \ 
          10816; 
		ThetaWidth\  = \ 15; 
		Ncoll\  = \ 
          steplength/MeanFreePath; 
		variance\  = \ 
          Ncoll*\((ThetaWidth^2)\); 
		sigma\  = \ 
          Sqrt[variance]; 
		 (*\ 
          Initial\ test\ values\ *) 
		FunctionValue\  = \ 
          1.0; 
		TestValue\  = \ 2.0; 
		 (*\ 
          Loop\ until\ you\ land\ on\ the\ area\ defined
			\ \ by\ the\ \(\(Gaussian\)\(.\)\)\ *) 
		While[
          TestValue > FunctionValue, 
\ \ \ 	\ \ \ DeltaTheta\  = \ 
            Random[Real, {\(-2\)*sigma, 
                2*sigma}]; 
\ \ \ 	\ \ \ FunctionValue\  = \ 
            Exp[\(-DeltaTheta^2\)/\((2*
                    variance)\)]; 
\ \ \ \ \ \ 	TestValue\  = \ 
            Random[Real, {0, 
                1}]
\ \ \ \ 	]; 
		DeltaTheta
		)\)\)

1.2 Calculating the unscattered trajectory.

The function defined here calculates the 'unsmeared' trajectory of the electron and returns the angle of the velocity vector to the horizontal. The argument of the function is the speed of the lectron in units of c, the speed of light. To define the function place the cursor anywhere in the cell and hit Enter.

\(FinalAngle[
        beta_]\  := \ \((\ 
	
 (*\ input\ \(\(parameters\)\(.\)\)\ *) 


        LightSpeed\  = \ 3*10^8; \ \  (*\ m/s\ *) 

        mass\  = \ 9.11*10^\(-31\); \ \ \ \  (*\ kg\ *) 

        Bfield\  = \ 2.1*10^\(-3\); \ \ \ \  (*\ Tesla\ *) 

        charge\  = \ 1.6*10^\(-19\); \ \  (*\ Coulombs\ *) 

        side\  = \ 
          0.4; \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ 
          meters\ *) 

        LowerLimit\  = \ \(-side\)/2; \  (*\ 
          where\ the\ electron\ leaves
			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ \(\(spectrometer\)\(.\)\)\ *) 

 (*\ 
          step\ size\ in\ seconds\ *) 

        step\  = \ 0.25*10^\(-10\); 

 (*\ 
          starting\ point . \ 
              Put\ the\ origin\ at\ the\ entrance\ point\ *) 

        t0\  = \ 0.0; 
vx0\  = \ beta*LightSpeed; 
vy0\  = \ 0.0; 

        x0\  = \ 0.0; 

        y0\  = \ 0.0; 

 (*\ 
          Integration\ limits . \ 
              Set\ tmax\ to\ something\ large
			so\ there\ is\ plenty\ of\ time\ to\ complete\ the
			\(\(trajectory\)\(.\)\)\ *) 

        tmin\  = \ t0 + step; 

        tmax\  = \ 20.0*10^\(-8\); 
		
 (*\ 
          Initialize\ the\ loop\ counter\ and\ the\ upper\ limit
			on\ the\ number\ of\ \(\(interations\)\(.\)\)\ *) 
nloops\  = \ 0; 

        MaxLoops\  = \ 5000; 

 (*\ 
          Set\ up\ the\ starting\ point\ of\ the\ \(\(loop\)\(.\)\)\ *) 
			
 (*	x - components\ *) 
vxmid\  = \ vx0; 

        xmid\  = \ x0; 
		
 (*\ y\ components\ *) 
vymid\  = \ vy0; 

        ymid\  = \ y0; 

 (*\ 
          Do\ \(it!\)\ Check\ first\ that\ the\ trajectory\ has\ not
			passed\ below\ LowerLimit\ and\ out\ of\ the\ spectrometer
			and\ that\ we\ don' t\ have\ a\ runaway\ loop . \ 
              Use\ a\ right\ 
			derivative\ formula\ to\ generate\ the\ \(\(algorithm\)\(.\)\)\ *) 
\ 
 (*\ 
          Lump\ a\ bunch\ of\ constants\ into\ a\ single\ \(\(factor\)\(.\)\)\ *) 
factor\  = \ step*charge*Bfield/mass; 
		

        While[\ ymid\  > \ LowerLimit\ \  && \ \ nloops\  < \ 
              MaxLoops, 
	\ \ \ \  (*\ 
            x - \ and\ y - \ 
              
              components\ of\ the\ velocity\ first\ *) 
	\ \ \ \ vxplus\  = \ vxmid\  + \ factor*vymid; 
	\ \ \ \ vyplus\  = \ 
            vymid\  - \ factor*vxmid; 
	
	\ \ \ \  (*\ 
            x - \ and\ y - 
              components\ of\ the\ position\ next\ *) 
\ \ \ \ \ \ \ xplus\  = \ xmid\  + \ step*vxmid; 
\ \ \ \ \ \ \ yplus\  = \ 
            ymid\  + \ step*vymid; 

	\ \ \ \  (*\ 
            Increment\ time\ and\ loop\ counter\ *) 
\ \ \ \ \ \ \ t\  = \ 
            t\  + \ step; 
	\ \ \ \ \ nloops\  = \ 
            nloops\  + \ 1; 
		
	\ \  (*\ 
            get\ x - 
              components\ ready\ for\ next\ \(\(iteration\)\(.\)\)\ *) 
		\ vxmid\  = \ vxplus; 
		\ xmid\  = \ xplus; 
	
	\ \ \ \  (*\ 
            get\ y - 
              components\ ready\ for\ next\ \(\(iteration\)\(.\)\)\ *) 
		\ vymid\  = \ vyplus; 
		\ ymid\  = \ yplus
]; \ 
		
 (*\ 
          Warn\ the\ user\ if\ the\ number\ of\ loops\ was\ 
			\(\(exceeded\)\(.\)\)\ *) 

        If[nloops\  > \ 
            MaxLoops - 
              1, 
			Print["Maximum number of loops exceeded."]]; 
				
 (*\ 
          Calculate\ the\ angle\ of\ the\ velocity\ vector\ after
			the\ electron\ leaves\ the\ spectrometer . \ 
              This\ last
			quantity\ in\ the\ function\ will\ be\ the\ value\ the\ 
			function\ \(\(returns\)\(.\)\)\ *) 

        ArcTan[vxmid, vymid]*180/Pi
)\)\)

1.3 Running the simulation.

In Section 2 you will be asked to modify some of the functions defined above to complete the simulation of multiple scattering. Once you have completed the tasks in Section 2 you will run your simulation many times to accumulate a histogram of the final angle of the electron when ot leaves the spectrometer. The code below is an example of how you would use a Do loop to run many cases of your simulation. When you first run it Mathematica produces error messages about exceeding the recursion limit. Don't worry about them.

\(\(\( (*\ Running\ the\ \(\(simulation\)\(.\)\)\ *) \)\(
\)\(
\)\( (*\ 
      Enter\ the\ velocity\ of\ the\ entering\ \(\(electron\)\(.\)\)\ *) \)\(
\)\(\(beta\  = \ 0.25;\)

 (*\ 
      Initialize\ the\ table\ that\ will\ hold\ the\ final
	\ \ angle\ of\ the\ electron' 
        s\ velocity\ when\ it\ leaves
	\ \ the\ \(\(spectrometer\)\(.\)\)\ *) 

    \(MyTable\  = \ {};\)

 (*\ Do\ \(it!\)\ *) 

    Do[
	angle\  = \ FinalAngle[beta]; 
	
      MyTable\  = \ Append[MyTable, angle], 
	{n, 1, 5}]\)\)\)

MyTable

\(\(\(
\)\( (*\ 
      Plot\ the\ \(\(results\)\(.\)\)\ *) \)\(
\)\(\(lo\  = \ \(-100\);\)

    \(hi\ \  = \ \(-80\);\)

    \(nbins\  = \ 20;\)

    \(MyBins = Table[n, {n, \(-100\), \(-80\), 1}];\)

    Histogram[MyTable, \ HistogramCategories -> MyBins]\)\)\)

2.0 Putting It All Together.

We now want to pull all the pieces together to complete the code and then investigate some of the physics.

a. Consider the function above called FinalAngle. It calculates the final angle of the velocity of the electron as it leaves the spectrometer. Write briefly in words what must be done to include multiple scattering in this function. Where in FinalAngle would you insert the commands to 'smear out' the angle? What calculations must you perform? Consult with your instructor before going to the next part.

b. Implement the code you designed in the previous section by modifying the function FinalAngle.

c. We often use the full-width-half-maximum (FWHM) as a measure of the width of a distribution. Run the simulation for enough events so you can make an accurate measurement of the width of the distribution. Record the central angle of the distribution and the upper and lower points where the distribution drops to one-half the maximum.

d. If no multiple scattering occurred, then the only way to get different exit angles of the velocity would be to vary the momentum. In a real detector with multiple scattering the 'smearing out' degrades the momentum resolution. Now, different momenta may have the same exit angle. We want to now determine what 'unsmeared' momenta could contribute to the angular range you found in Part 2.c and establish our momentum resolution. We can still use the function  FinalAngle, but we have to make one modification; we have to turn off the multiple scattering. How could you do this in a 'simple' way that would be easy to implement? Once you have turned off multiple scattering, test your code by running it several times. You should now get the same exit angle each time. Next, vary the incoming velocity to determine what unsmeared velocities can contibute to the angular range you found in Part 2.c. To what momentum range does this velocity range correspond? Express your answer as a central value and a percent uncertainty (i.e., p=7.0 ×(10^(-23))kg-m/s ± 10% ).