Scripting Example 2

Example 2 demonstrates an alternative trajectory rendering mechanism – VRML. VRML (Virtual Reality Markup Language) is a web standard for creating interactive 3D environments. VRML can be displayed in many different freely available VRML viewers that tend to plug into web browsers. To check whether you have a VRML viewer and to download a VRML viewer if you don't visit this helpful NIST web page.

The geometry is a little bit contrived but consists of a base of pure Si, a block of SiO2 on top and a pyramidal cap of Au. In a bitmap captured from the VRML rendering it looks like this. The Jython code for the script is located at the end of this page.

If you have a VRML viewer installed, the VRML equivalent of these images is available here.

Illustration 1: A view of 20 electron trajectories in a Au pyramidal cap (green paths), on a Si02 block (red paths), on a Si block (purple paths.) Electrons that leave the sample are yellow.

Illustration 2: Another perspective on the sample sample geometry.

VRML is a very intuitive way to present electron trajectories. With a VRML viewer it is possible to pan, rotate and fly through the sample. VRML can also be used to determine whether your script produces the intended geometry.

Due to limitations in VRML and NISTMonte certain shapes can not be rendered in VRML. The following classes that implement the Shape interface also implement the TrajectoryVRML.IRender interface which is required to output to a VRML file - CylindricalShape, MultiPlaneShape, SimpleBlock, Sphere, SumShape. ShapeDifference does not.

# Example #2
import gov.nist.microanalysis.EPQLibrary as epq
import gov.nist.microanalysis.NISTMonte as nm
import java.io as jio
import java.nio.charset as cs

dest=DefaultOutput
dest.mkdirs()

dim=1.0e-6;

for phi in [0.0]: #, 15.0, 30.0, 45.0, 60.0, 75.0, 90.0]:
	# create an instance of the model
	monte=nm.MonteCarloSS()
	monte.setBeamEnergy(epq.ToSI.keV(25.0))
	monte.setElectronGun(nm.MonteCarloSS.GaussianBeam(monte,1.0e-9))
	# create the sample
	si=epq.MaterialFactory.createPureElement(epq.Element.Si)
	au=epq.MaterialFactory.createPureElement(epq.Element.Au)
	sio2=epq.MaterialFactory.createMaterial(epq.MaterialFactory.SiliconDioxide)
	base=nm.MultiPlaneShape.createBlock([dim,dim,dim],[0.0,0.0,0.0],0.0,0.0,0.0)
	block=nm.MultiPlaneShape.createBlock([dim/10.0,dim/10.0,dim/10.0],[0.0,0.0,-dim/2.0-dim/20.0],0.0,0.0,0.0)
	pyramid=nm.MultiPlaneShape.createNamid([0.0,0.0,-dim/2+-dim/20],4,dim/20.0,dim/10.0)
	#pyramid=nm.MultiPlaneShape.createNamid([0.0,0.0,0],6,dim/4,dim)
	monte.addSubRegion(monte.getChamber(),si, base)
	monte.addSubRegion(monte.getChamber(),sio2, block)
	monte.addSubRegion(monte.getChamber(),au, pyramid)
	# rotate the sample
	monte.getChamber().rotate([0.0,0.0,dim/2.0],0.0,phi*1.74533e-2,0.0)
	# Add a VRML detector
	fos=jio.FileOutputStream("%s/angle - %lg deg.wrl" % (dest, phi))
	tw=jio.OutputStreamWriter(fos,cs.Charset.forName("UTF-8"))
	vrml = nm.TrajectoryVRML(monte,tw)
	vrml.setMaxTrajectories(20)
	vrml.setTrajectoryWidth(1.0e-9)
	vrml.setDisplayBackscatter(1)
	vrml.addView("Gun",[0.0,0.0,-5.0e-5],[0.0,0.0,0.0])
	vrml.addView("X-Axis",[5.0e-5,0.0,0.0,0.0],[0.0,0.0,0.0])
	vrml.addView("Y-Axis",[0.0,5.0e-5,0.0,0.0],[0.0,0.0,0.0])
	vrml.renderSample()
	monte.addActionListener(vrml)
	monte.runMultipleTrajectories(20)
	tw.flush()
	fos.close()
print "Done!"

Text 1: The Jython script for implementing the pyramidal cap of gold on a SiO2 block.

A Porous Block

An extreme example of a complex sample rigorously modeled is this example of a porous carbon substrate.

Illustration 3: The pink areas are the pores. The blue is carbon and the dark blue are the electron trajectories. The model runs slowly but it runs. If we look at the x-ray signals from such a sample, we find that it acts just like bulk. An differences seen in experiments may be due to surface effects as the electron leaves and reenters the bulk material at each pore interface. Solid state effects are not modeled.