gov.nist.microanalysis.NISTMonte
Class MonteCarloSS

java.lang.Object
  extended by gov.nist.microanalysis.NISTMonte.MonteCarloSS

public final class MonteCarloSS
extends java.lang.Object

MonteCarloSS is the core class in NISTMonte - a full-featured (albeit somewhat slow) Monte Carlo for quantitative electron probe modeling and other uses. MonteCarloSS implements a electron transport model using the randomized scattering (IRandomizedScatter) and the continuous slowing down approximation.

NISTMonte makes clear distinctions between algorithms. MonteCarloSS does not know anything about x-rays (that is handled by XRayEventListener and BremsstrahlungEventListener) or electron detectors (that is handled by AnnularDetector, BackscatterDetector, ...). All MonteCarloSS knows how to do is to track electrons. MonteCarloSS ties to the x-ray models and the detectors through events via the addActionListener(...) method. All classes that are interested in events should implement the ActionListener abstract class. The events are identified by an integer index - ScatterEvent, NonScatterEvent, BackscatterEvent, TrajectoryStartEvent, TrajectoryEndEvent, LastTrajectoryEvent, FirstTrajectoryEvent, or ExitMaterialEvent.

Physical models can be changed by using setBetheElectronEnergyLoss, setScatteringAlgorithm or setGasScatteringAlgorithm.

Notes:

Copyright: Pursuant to title 17 Section 105 of the United States Code this software is not subject to copyright protection and is in the public domain

Company: National Institute of Standards and Technology

Version:
1.0
Author:
Nicholas W. M. Ritchie

Nested Class Summary
static class MonteCarloSS.Electron
           This class handles the geometric considerations tracking an electron through Monte Carlo steps.
static interface MonteCarloSS.ElectronGun
           This interface allows the user to modify the properties of the electron gun.
 class MonteCarloSS.GaussianBeam
           
 class MonteCarloSS.Region
           A Region represents a homogeneous volume of sample.
static interface MonteCarloSS.Shape
           An interface defining sufficient a sufficiently rich set of methods to implement a three dimensional volume.
 
Field Summary
static int BackscatterEvent
          BackscatterEvent - The ID of the ActionEvent that is fired when an electron trajectory strikes the walls of the chamber (forwardscatter or backscatter).
static int BeamEnergyChanged
          Fired when the setBeamEnergy(...) method is invoked.
protected static double ChamberRadius
           
static int EndSecondaryEvent
          EndSecondaryEvent fired when a secondary electron finishes its trajectory.
static int ExitMaterialEvent
          ExitMaterialEvent - Fired when an electron makes a transition from one material to another.
static int FirstTrajectoryEvent
          FirstTrajectoryEvent - Fired before the first trajectory starts in runMultipleTrajectories.
static int LastTrajectoryEvent
          LastTrajectoryEvent - Fired after the last trajectory completes in runMultipleTrajectories
static int NonScatterEvent
          NonScatterEvent - Fired whenever an electron trajectory segment ends because it is passing between one material and another.
static int ScatterEvent
          ScatterEvent - Fired whenever an electron scatters off an atom.
static int StartSecondaryEvent
          StartSecondaryEvent fired immediately before the current Electron is replaced by a secondary electron.
static int TrajectoryEndEvent
          TrajectoryEndEvent - Fired after an electron ends its trajectory.
static int TrajectoryStartEvent
          TrajectoryStartEvent - Fired before an electron starts its trajectory.
static int XAxis
          XAxis - XAxis, YAxis and ZAxis enuerate the coordinate axes.
static int YAxis
          YAxis - XAxis, YAxis and ZAxis enuerate the coordinate axes.
static int ZAxis
          ZAxis - XAxis, YAxis and ZAxis enuerate the coordinate axes.
 
Constructor Summary
MonteCarloSS()
          MonteCarloSS - The constructor for the MonteCarloSS class.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener sel)
          addActionListener - Register a class that implements the ActionListener abstract class.
 MonteCarloSS.Region addSubRegion(MonteCarloSS.Region parent, Material mat, MonteCarloSS.Shape shape)
          addSubRegion - A method to simplify creating new sub-Regions and adding them to a parent Region.
 boolean allElectronsComplete()
          Have all the electron trajectories resulting from the most recent incident electron completed there trajectories? If one trajectory has finished and another Electron exists on the Electron stack, this method will remove an Electron from the stack and reinitiate tracking it.
 double[] computeDetectorPosition(double elevation, double theta)
          computeDetectorPosition - Computes the coordinates of a detector placed at the specified elevation angle at an azimuthal angle of 0.
 void estimateTrajectoryVolume(double[] c0, double[] c1)
          estimateTrajectoryVolume - Estimate the volume that will be occupied by electron paths by running the simulation a number of times and looking for the largest extent.
 java.util.Set getAtomicShellSet()
          getAtomicShellSet - Get a list of the atomic shells that may be ionized by a beam of the current initial beam energy.
 double getBeamEnergy()
          getBeamEnergy - Returns the incident electron beam energy (in Joules)
 BetheElectronEnergyLoss getBetheElectronEnergyLoss()
          getBetheElectronEnergyLoss - Returns the algorithm used to compute the continuous energy loss approximation.
 MonteCarloSS.Region getChamber()
          getChamber - An accessor to facilitate adding the sub-Regions that represent the sample.
 MonteCarloSS.Electron getElectron()
          getElectron - Get the current active electron.
 int getElectronGeneration()
          Returns the generation of Electron that is currently being tracked.
 java.lang.Class getGasScatteringAlgorithm()
          getGasScatteringAlgorithm - Returns the class of the algorithm to use to compute the electron scattering cross section for Materials derived from Gas.
 java.util.Map getMaterialMap(double[] startPt, double[] endPt)
          getMaterialMap - Creates a map containing a list of the materials through which an x-ray (or any ray) will pass on its way from startPt to endPt.
 double getMinEnergy()
          getMinEnergy - Returns the energy below which the trajectory of eletrons is not tracked.
 java.lang.Class getScatteringAlgorithm()
          getScatteringAlgorithm - Returns the Class of the algorithm to use to compute the electron scattering cross section.
 void initializeTrajectory()
          initializeTrajectory - Initialize all member variable to start a new electron trajectory.
protected  double randomizedStepLength(Material mat, double eK)
          randomizedStepLength - Computes the mean free path for an electron of the specified energy in the specified material.
protected  double randomizedStepLength2(Material mat, double eK)
          randomizedStepLength2 - Computes the mean free path for an electron of the specified energy in the specified material.
 void removeActionListener(java.awt.event.ActionListener sel)
          removeActionListener - Remove an event handler that was registered using addActionListener
 void runMultipleTrajectories(int n)
          runMultipleTrajectories - Run n complete trajectories.
 void runTrajectory()
          runTrajectory - Run a single trajectory starting the electron at the gun position and tracking it through steps until trajectoryComplete returns true.
 void setBeamEnergy(double beamEnergy)
          setBeamEnergy - Set the incident electron beam energy (in Joules)
 void setBetheElectronEnergyLoss(BetheElectronEnergyLoss beel)
          setBetheElectronEnergyLoss - Specify the algorithm to use for the continuous energy loss approximation.
 void setElectronGun(MonteCarloSS.ElectronGun gun)
          setElectronGun - Specify a class that implements the ElectronGun interface.
 void setGasScatteringAlgorithm(java.lang.Class scAlg)
          setScatteringAlgorithm - Specify the class of the algorithm to use to compute the electron scattering cross section for Materials derived from Gas.
 void setMinEnergy(double minEnergy)
          setMinEnergy - Sets the energy below which electrons are no longer tracked.
 void setScatteringAlgorithm(java.lang.Class scAlg)
          setScatteringAlgorithm - Specify the class of the algorithm to use to compute the electron scattering cross section.
 void takeStep()
          takeStep - Take a single step corresponding to zero or one scattering events.
 void trackSecondaryElectron(MonteCarloSS.Electron newElectron)
          This method takes the current Electron and stores it on a stack, the argument Electron becomes the active Electron and will be tracked until either it meets the end of trajectory criteria or it is replaced by another call to trackSecondaryElectron.
 boolean trajectoryComplete()
          trajectoryComplete - Has the active Electron (either primary or secondary) either struck a chamber wall or lost sufficient energy to be no longer worth tracking.
 void updateMaterial(Material oldMat, Material newMat)
          updateMaterial - Recurse through the sample replacing all references to oldMat with references to newMat.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ScatterEvent

public static final int ScatterEvent
ScatterEvent - Fired whenever an electron scatters off an atom. Each trajectory segment one and only one of ScatterEvent, NonScatterEvent or BackscatterEvent will be fired.

See Also:
Constant Field Values

NonScatterEvent

public static final int NonScatterEvent
NonScatterEvent - Fired whenever an electron trajectory segment ends because it is passing between one material and another.

See Also:
Constant Field Values

BackscatterEvent

public static final int BackscatterEvent
BackscatterEvent - The ID of the ActionEvent that is fired when an electron trajectory strikes the walls of the chamber (forwardscatter or backscatter). This can also be thought of as an exit chamber region event. The electron is permenantly gone and the trajectory is over.

See Also:
Constant Field Values

ExitMaterialEvent

public static final int ExitMaterialEvent
ExitMaterialEvent - Fired when an electron makes a transition from one material to another. GetCurrentRegion will return the region from which the electron is about to exit (not the one into which it is going.) When an electron exits a Material two events are fired; first a NonScatterEvent and then an ExitMaterialEvent.

See Also:
Constant Field Values

TrajectoryStartEvent

public static final int TrajectoryStartEvent
TrajectoryStartEvent - Fired before an electron starts its trajectory.

See Also:
Constant Field Values

TrajectoryEndEvent

public static final int TrajectoryEndEvent
TrajectoryEndEvent - Fired after an electron ends its trajectory.

See Also:
Constant Field Values

LastTrajectoryEvent

public static final int LastTrajectoryEvent
LastTrajectoryEvent - Fired after the last trajectory completes in runMultipleTrajectories

See Also:
Constant Field Values

FirstTrajectoryEvent

public static final int FirstTrajectoryEvent
FirstTrajectoryEvent - Fired before the first trajectory starts in runMultipleTrajectories.

See Also:
Constant Field Values

StartSecondaryEvent

public static final int StartSecondaryEvent
StartSecondaryEvent fired immediately before the current Electron is replaced by a secondary electron.

See Also:
Constant Field Values

EndSecondaryEvent

public static final int EndSecondaryEvent
EndSecondaryEvent fired when a secondary electron finishes its trajectory. The current Electron is still the secondary.

See Also:
Constant Field Values

BeamEnergyChanged

public static final int BeamEnergyChanged
Fired when the setBeamEnergy(...) method is invoked. Useful for clearing caches in detection devices etc...

See Also:
Constant Field Values

XAxis

public static final int XAxis
XAxis - XAxis, YAxis and ZAxis enuerate the coordinate axes.

See Also:
Constant Field Values

YAxis

public static final int YAxis
YAxis - XAxis, YAxis and ZAxis enuerate the coordinate axes.

See Also:
Constant Field Values

ZAxis

public static final int ZAxis
ZAxis - XAxis, YAxis and ZAxis enuerate the coordinate axes.

See Also:
Constant Field Values

ChamberRadius

protected static final double ChamberRadius
See Also:
Constant Field Values
Constructor Detail

MonteCarloSS

public MonteCarloSS()
MonteCarloSS - The constructor for the MonteCarloSS class.

Method Detail

randomizedStepLength

protected double randomizedStepLength(Material mat,
                                      double eK)
randomizedStepLength - Computes the mean free path for an electron of the specified energy in the specified material. Uses the physics model's totalCrossSection function. Returns the mean free path times a random number distributed according to the exponential distribution.

Parameters:
mat - Material - The material
eK - double - The electron energy (in Joules)
Returns:
double - The mean free path in meters

randomizedStepLength2

protected double randomizedStepLength2(Material mat,
                                       double eK)
randomizedStepLength2 - Computes the mean free path for an electron of the specified energy in the specified material. Uses the physics model's totalCrossSection function. Returns the mean free path times a random number distributed according to the exponential distribution.

Parameters:
mat - Material - The material
eK - double - The electron energy (in Joules)
Returns:
double - The mean free path in meters

addSubRegion

public MonteCarloSS.Region addSubRegion(MonteCarloSS.Region parent,
                                        Material mat,
                                        MonteCarloSS.Shape shape)
addSubRegion - A method to simplify creating new sub-Regions and adding them to a parent Region. The sub-Region must be fully enclosed within the parent region. This method does not verify this requirement.

Parameters:
parent - Region - A non-null parent region
mat - Material - The material from which the sub-region will be constructed.
shape - Shape - The shape of the sub-region
Returns:
Region - The instance of the new sub-region

getMaterialMap

public java.util.Map getMaterialMap(double[] startPt,
                                    double[] endPt)
getMaterialMap - Creates a map containing a list of the materials through which an x-ray (or any ray) will pass on its way from startPt to endPt. Associated with each material is the measure of the length of the path through the material. This information can be used to compute the absorption of x-rays generated in the sample as they pass towards a detector.

Parameters:
startPt - double[] - The start of the x-ray trajectory (usually the electron scattering point)
endPt - double[] - The end of the x-ray trajectory (usually the detector)
Returns:
Map - the key class is Material and value class is Double

getChamber

public MonteCarloSS.Region getChamber()
getChamber - An accessor to facilitate adding the sub-Regions that represent the sample. The sample should be located so that the center of the desired beam impact location is on the z-axis.

Returns:
Region - The Region representing the vacuum chamber.

initializeTrajectory

public void initializeTrajectory()
initializeTrajectory - Initialize all member variable to start a new electron trajectory.


takeStep

public void takeStep()
takeStep - Take a single step corresponding to zero or one scattering events. If the step would remain within the current Region then a scattering event will take place. If the step would take the electron into a new Region then the step ends at the boundary of the new Region without producing a scattering event. In either case the electron loses the appropriate amount of energy corresponding to the distance traveled.


trackSecondaryElectron

public void trackSecondaryElectron(MonteCarloSS.Electron newElectron)
This method takes the current Electron and stores it on a stack, the argument Electron becomes the active Electron and will be tracked until either it meets the end of trajectory criteria or it is replaced by another call to trackSecondaryElectron. When the argument Electron ends its trajectory it will be released and the Electron stack will be checked. If there exists an Electron on the Electron stack then the Electron will be popped from the top of the Electron stack. It will become the active electron and will be tracked. The incident Electron trajectory will end when all Electrons added using trackSecondaryElectron have completed their trajectories.

Parameters:
newElectron -

getElectronGeneration

public int getElectronGeneration()
Returns the generation of Electron that is currently being tracked. 0 for primary electron, 1 for secondary (generated by the primary), 2 for tertiary (generated by the secondary) etc. During a StartSecondaryEvent getElectronGeneration will return the generation of the electron generating the secondary (the parent). During a EndSecondaryEvent getElectronGeneration will return the generation of the secondary electron that is about to die. All other times getElectronGeneration will return the generation of the current active Electron which is also the highest generation Electron currently in existence.

Returns:
int 0->Primary, 1->Secondary, 2->Tertiary, ...

addActionListener

public void addActionListener(java.awt.event.ActionListener sel)
addActionListener - Register a class that implements the ActionListener abstract class. Appropriate examples include MCSS_XRayEventListener, MCSS_BackscatterStats and MCSS_BremsstrahlungEventListener.

Parameters:
sel - ActionListener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener sel)
removeActionListener - Remove an event handler that was registered using addActionListener

Parameters:
sel - ActionEvent

trajectoryComplete

public boolean trajectoryComplete()
trajectoryComplete - Has the active Electron (either primary or secondary) either struck a chamber wall or lost sufficient energy to be no longer worth tracking.

Returns:
boolean - true when the trajectory of the active Electron is complete

allElectronsComplete

public boolean allElectronsComplete()
Have all the electron trajectories resulting from the most recent incident electron completed there trajectories? If one trajectory has finished and another Electron exists on the Electron stack, this method will remove an Electron from the stack and reinitiate tracking it.

Returns:
boolean

runTrajectory

public void runTrajectory()
runTrajectory - Run a single trajectory starting the electron at the gun position and tracking it through steps until trajectoryComplete returns true. If this electron generates child, grandchild etc electrons (via trackSecondaryElectronthen all of these electrons will be tracked to completion before runTrajectory will return.


runMultipleTrajectories

public void runMultipleTrajectories(int n)
runMultipleTrajectories - Run n complete trajectories.

Parameters:
n - int

getBeamEnergy

public double getBeamEnergy()
getBeamEnergy - Returns the incident electron beam energy (in Joules)

Returns:
double

setElectronGun

public void setElectronGun(MonteCarloSS.ElectronGun gun)
setElectronGun - Specify a class that implements the ElectronGun interface. This method takes the current beam energy and copies it into the new electron gun. (Previous versions had also copied the beam center but this anti-feature has been removed.)

Parameters:
gun - ElectronGun

setBeamEnergy

public void setBeamEnergy(double beamEnergy)
setBeamEnergy - Set the incident electron beam energy (in Joules)

Parameters:
beamEnergy - double

computeDetectorPosition

public double[] computeDetectorPosition(double elevation,
                                        double theta)
computeDetectorPosition - Computes the coordinates of a detector placed at the specified elevation angle at an azimuthal angle of 0. This function is designed to place the detector according to the microanalysis conventions for specifying the take-off angle assuming that the beam starts on the z-axis at a negative z-value heading towards positive z.

Parameters:
elevation - double
theta - double
Returns:
double[] - A 3D coordinate

getElectron

public MonteCarloSS.Electron getElectron()
getElectron - Get the current active electron.

Returns:
Electron

getMinEnergy

public double getMinEnergy()
getMinEnergy - Returns the energy below which the trajectory of eletrons is not tracked.

Returns:
double

setMinEnergy

public void setMinEnergy(double minEnergy)
setMinEnergy - Sets the energy below which electrons are no longer tracked. The smallest permissible minEnergy is 1.0 eV.

Parameters:
minEnergy - double

getAtomicShellSet

public java.util.Set getAtomicShellSet()
                                throws EPQException
getAtomicShellSet - Get a list of the atomic shells that may be ionized by a beam of the current initial beam energy. The method takes into account all the elements in all the regions within the chamber Region.

Returns:
Set - A set of AtomicShell objects.
Throws:
EPQException

estimateTrajectoryVolume

public void estimateTrajectoryVolume(double[] c0,
                                     double[] c1)
estimateTrajectoryVolume - Estimate the volume that will be occupied by electron paths by running the simulation a number of times and looking for the largest extent.

Parameters:
c0 - double[]
c1 - double[]

setBetheElectronEnergyLoss

public void setBetheElectronEnergyLoss(BetheElectronEnergyLoss beel)
setBetheElectronEnergyLoss - Specify the algorithm to use for the continuous energy loss approximation.

Parameters:
beel -

getBetheElectronEnergyLoss

public BetheElectronEnergyLoss getBetheElectronEnergyLoss()
getBetheElectronEnergyLoss - Returns the algorithm used to compute the continuous energy loss approximation.

Returns:
BetheElectronEnergyLoss

setScatteringAlgorithm

public void setScatteringAlgorithm(java.lang.Class scAlg)
setScatteringAlgorithm - Specify the class of the algorithm to use to compute the electron scattering cross section. The Class specified must be derived from the IRandomizedScatter interface (CzyzewskiMottScatteringAngle, GasScatteringCrossSection, NISTMottScatteringAngle, ScreenedRutherfordScatteringAngle)

Parameters:
scAlg -

getScatteringAlgorithm

public java.lang.Class getScatteringAlgorithm()
getScatteringAlgorithm - Returns the Class of the algorithm to use to compute the electron scattering cross section.

Returns:
Class

setGasScatteringAlgorithm

public void setGasScatteringAlgorithm(java.lang.Class scAlg)
setScatteringAlgorithm - Specify the class of the algorithm to use to compute the electron scattering cross section for Materials derived from Gas. (If none is specified or if setGasScatteringAlgorithm(null) is called then the algorithm from getScatteringAlgorithm is used by default.)

Parameters:
scAlg -

getGasScatteringAlgorithm

public java.lang.Class getGasScatteringAlgorithm()
getGasScatteringAlgorithm - Returns the class of the algorithm to use to compute the electron scattering cross section for Materials derived from Gas. (If none is specified or if setGasScatteringAlgorithm(null) is called then the algorithm from getScatteringAlgorithm is used by default.)

Returns:
Class

updateMaterial

public void updateMaterial(Material oldMat,
                           Material newMat)
updateMaterial - Recurse through the sample replacing all references to oldMat with references to newMat. This is useful for running an identical geometry with different materials.

Parameters:
oldMat -
newMat -