Scripting Example 1

This script demonstrates how NISTMonte can be used to generate φ(ρz) curves for three different elastic scattering models. It is in fact the script used to generate the data presented in Does NISTMonte Work? This script demonstrates many interesting things. One of the more unusual is the way in which algorithms can be iterated in a for-loop.

# A very simple script for a simple bulk material
import gov.nist.microanalysis.EPQLibrary as epq
import gov.nist.microanalysis.NISTMonte as nm
import java.io as jio
# create an instance of the model
print "Start...";
monte=nm.MonteCarloSS()
for alg in [epq.CzyzewskiMottScatteringAngle, 
            epq.NISTMottScatteringAngle, 
            epq.ScreenedRutherfordScatteringAngle]:
	print "Starting "+alg.getName()
	monte.setScatteringAlgorithm(alg)
	monte.setBeamEnergy(epq.ToSI.keV(25.0))
	# create the material, shape and region
	mat=epq.MaterialFactory.createPureElement(epq.Element.Al)
	mat.setDensity(epq.ToSI.gPerCC(1.0))
	# create a solid of Al
	plane = nm.MultiPlaneShape.createSubstrate([0.0, 0.0, -1.0],[0.0, 0.0, 0.0])
	r1=nm.MonteCarloSS.Region(monte, monte.getChamber(), mat, plane)
	# add event listeners
	xrel=nm.XRayEventListener(monte,monte.computeDetectorPosition(40*(3.1415926/180),0.0))
	monte.addActionListener(xrel)
	przs=nm.PhiRhoStats.watchDefaultTransitions(xrel,0.0e-6,20.0e-6)
	# add a trajectory image
	img=nm.TrajectoryImage(2048,2048,20.0e-6)
	monte.addActionListener(img)
	# add generation images
	imgs=nm.EmissionImage.watchDefaultTransitions(xrel,512,20.0e-6)
	# run the simulation
	monte.runMultipleTrajectories(10000)
	# determine where to save the results
	dest=DefaultOutput+PathSep+monte.getScatteringAlgorithm().getName()+PathSep
	# output the phi-rho-z stats
	nm.PhiRhoStats.dumpToFiles(przs,dest)
	# output the trajectory image
	img.dumpToFile(dest)
	# output the transition image
	nm.EmissionImage.dumpToFiles(imgs,dest)
print "Done!"
# NWMR 16-Mar-2006

Example 1: This script sets up a pure Al sample of density 1.0 g/cc (since φ(ρz) curves are usually normalized to 1 g/cc). The detectors are configured to accumulate a φ(ρz) curve and an emission image for the default Al transitions (K-family). The script runs 10000 trajectories and saves the results. This process is iterated over three different algorithms for the elastic scattering cross-section.

Results

Emission images


Illustration A: A generation image showing the spatial distribution of the Al K-LIII x-rays generated as would be measured by a detector at a take-off angle of 40°. The color scale is a thermal. The brightest white region represent the most x-ray generation and the black represents the least. The strips to the left and at the bottom show the vertical and horizontal distribution of x-ray emission.

Trajectory Images

Illustration B: An electron trajectory image. The light blue lines show the trajectories of the first 100 electrons. In multi-material samples, the color of the trajectories changes in each material.

Phi(rho-z) curves

Generated			8.1896E1
Transmitted				6.2111E1
Ratio					7.5842E-1
phi-rho-Z
z	generated	transmitted
0.0000E0	1.0814E0	1.0750E0
2.0000E-7	1.1773E0	1.1569E0
4.0000E-7	1.2561E0	1.2201E0
6.0000E-7	1.3561E0	1.3019E0
8.0000E-7	1.4270E0	1.3541E0
1.0000E-6	1.5089E0	1.4152E0
1.2000E-6	1.5861E0	1.4704E0
1.4000E-6	1.6277E0	1.4916E0
1.6000E-6	1.6998E0	1.5396E0
1.8000E-6	1.7710E0	1.5856E0
2.0000E-6	1.8086E0	1.6005E0
2.2000E-6	1.8890E0	1.6523E0
2.4000E-6	1.9161E0	1.6566E0
2.6000E-6	1.9336E0	1.6524E0
2.8000E-6	1.9769E0	1.6699E0
3.0000E-6	1.9906E0	1.6621E0
3.2000E-6	1.9988E0	1.6496E0
3.4000E-6	1.9816E0	1.6164E0
3.6000E-6	1.9967E0	1.6099E0
3.8000E-6	2.0003E0	1.5941E0
4.0000E-6	1.9851E0	1.5637E0
4.2000E-6	1.9676E0	1.5319E0
4.4000E-6	1.9522E0	1.5024E0
4.6000E-6	1.9555E0	1.4875E0
4.8000E-6	1.9228E0	1.4458E0
5.0000E-6	1.8859E0	1.4016E0
5.2000E-6	1.8579E0	1.3648E0
5.4000E-6	1.8170E0	1.3193E0
5.6000E-6	1.8040E0	1.2947E0
5.8000E-6	1.7480E0	1.2400E0
6.0000E-6	1.6804E0	1.1783E0
6.2000E-6	1.6560E0	1.1477E0
6.4000E-6	1.6056E0	1.1000E0
6.6000E-6	1.5533E0	1.0518E0
6.8000E-6	1.5062E0	1.0081E0
7.0000E-6	1.4689E0	9.7182E-1
7.2000E-6	1.4038E0	9.1793E-1
7.4000E-6	1.3492E0	8.7206E-1
7.6000E-6	1.3115E0	8.3787E-1
7.8000E-6	1.2596E0	7.9540E-1
8.0000E-6	1.1755E0	7.3375E-1
8.2000E-6	1.0925E0	6.7399E-1
8.4000E-6	1.0340E0	6.3058E-1
8.6000E-6	9.8596E-1	5.9430E-1
8.8000E-6	9.2974E-1	5.5393E-1
9.0000E-6	8.8243E-1	5.1965E-1
9.2000E-6	8.3262E-1	4.8465E-1
9.4000E-6	8.0333E-1	4.6219E-1
9.6000E-6	7.4513E-1	4.2375E-1
9.8000E-6	6.8500E-1	3.8509E-1
1.0000E-5	6.1711E-1	3.4286E-1
1.0200E-5	5.7923E-1	3.1809E-1
1.0400E-5	5.3353E-1	2.8963E-1
1.0600E-5	4.8135E-1	2.5828E-1
1.0800E-5	4.1566E-1	2.2046E-1
1.1000E-5	3.7542E-1	1.9679E-1
1.1200E-5	3.4138E-1	1.7687E-1
1.1400E-5	3.0538E-1	1.5641E-1
1.1600E-5	2.5517E-1	1.2917E-1
1.1800E-5	2.3064E-1	1.1541E-1
1.2000E-5	1.8606E-1	9.2040E-2
1.2200E-5	1.5160E-1	7.4118E-2
1.2400E-5	1.2924E-1	6.2460E-2
1.2600E-5	1.0055E-1	4.8029E-2
1.2800E-5	8.7344E-2	4.1234E-2
1.3000E-5	6.6818E-2	3.1177E-2
1.3200E-5	5.6772E-2	2.6190E-2
1.3400E-5	4.8506E-2	2.2116E-2
1.3600E-5	3.5835E-2	1.6153E-2
1.3800E-5	2.2976E-2	1.0237E-2
1.4000E-5	1.3809E-2	6.0821E-3
1.4200E-5	7.9224E-3	3.4481E-3
1.4400E-5	6.4004E-3	2.7529E-3
1.4600E-5	3.8077E-3	1.6206E-3
1.4800E-5	1.3584E-3	5.7058E-4
1.5000E-5	8.4557E-4	3.5159E-4
1.5200E-5	2.6877E-4	1.1020E-4
1.5400E-5	1.8123E-4	7.3769E-5
1.5600E-5	0.0000E0	0.0000E0
1.5800E-5	0.0000E0	0.0000E0
1.6000E-5	0.0000E0	0.0000E0
1.6200E-5	0.0000E0	0.0000E0
1.6400E-5	0.0000E0	0.0000E0
1.6600E-5	0.0000E0	0.0000E0
1.6800E-5	0.0000E0	0.0000E0
1.7000E-5	0.0000E0	0.0000E0
1.7200E-5	0.0000E0	0.0000E0
1.7400E-5	0.0000E0	0.0000E0
1.7600E-5	0.0000E0	0.0000E0
1.7800E-5	0.0000E0	0.0000E0
1.8000E-5	0.0000E0	0.0000E0
1.8200E-5	0.0000E0	0.0000E0
1.8400E-5	0.0000E0	0.0000E0
1.8600E-5	0.0000E0	0.0000E0
1.8800E-5	0.0000E0	0.0000E0
1.9000E-5	0.0000E0	0.0000E0
1.9200E-5	0.0000E0	0.0000E0
1.9400E-5	0.0000E0	0.0000E0
1.9600E-5	0.0000E0	0.0000E0
1.9800E-5	0.0000E0	0.0000E0
---------------
Sum		8.1896E1	6.2111E1

Table 1:Phi(rho-z) data is output in ASCII format to files with an extension of '.prn'. This format can be readily imported into OpenOffice Calc or other spreadsheet programs.