def triLayerLineOnSubstrate(matTopL, matMidL, matBotL, matSub, htTopL, htMidL, htBotL, width, length, det, title, e0=20.0, withPoisson=True, nTraj=100, dose=120.0, sf=True, bf=True, xtraParams={}, bVerbose=False): """triLayerLineOnSubstrate(matTopL, matMidL, matBotL, matSub, htTopL, htMidL, htBotL, width, length, det, title, e0=20.0, withPoisson=True, nTraj=100, dose=120.0, sf=True, bf=True, xtraParams={}) Monte Carlo simulate a spectrum from a bilayer line on a substrate of the specified materials (matTopL, matMid, matBotL, matSub) and layer heights ( htTopL, htMidL, htBotL; z in m ) and width and length (x and y in m).""" def buildBlock(monte, chamber, origin, buildParams): matSub = buildParams["Mat Subs"] matTopL = buildParams["Mat Top"] matMidL = buildParams["Mat Mid"] matBotL = buildParams["Mat Bot"] htTopL = buildParams["Hei Top"] htMidL = buildParams["Hei Mid"] htBotL = buildParams["Hei Bot"] width = buildParams["Width"] length = buildParams["Length"] monte.addSubRegion(chamber, matTopL, nm.MultiPlaneShape.createBlock([width, length, htTopL], epu.Math2.plus(origin, [0.0, 0.0, 0.5*htTopL]), 0.0, 0.0, 0.0)) monte.addSubRegion(chamber, matMidL, nm.MultiPlaneShape.createBlock([width, length, htMidL], epu.Math2.plus(origin, [0.0, 0.0, 0.5*htMidL+htTopL]), 0.0, 0.0, 0.0)) monte.addSubRegion(chamber, matBotL, nm.MultiPlaneShape.createBlock([width, length, htBotL], epu.Math2.plus(origin, [0.0, 0.0, 0.5*htBotL+htTopL+htMidL]), 0.0, 0.0, 0.0)) monte.addSubRegion(chamber, matSub, nm.MultiPlaneShape.createSubstrate([0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, htTopL+htMidL+htBotL]))) tmp = u"triLayerLineOnSub-%s" % title params = {"Mat Top" : matTopL, "Mat Mid" : matMidL, "Mat Bot" : matBotL, "Mat Subs": matSub, "Hei Top" : htTopL, "Hei Mid" : htMidL, "Hei Bot" : htBotL, "Width" : width, "Length" : length} if (bVerbose==120.0): print(params) return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildBlock, params, xtraParams)
def coatedSphereOnFilm(mat, radius, coating, cThick, film, fThick, det, e0=20.0, withPoisson=True, nTraj=100, dose=100, sf=True, bf=True, xtraParams={}): """coatedSphereOnFilm(mat, radius, coating, cThick, film, fThick, det, e0=20.0, withPoisson=True, nTraj=100, dose=100, sf=True, bf=True, xtraParams={}) Monte Carlo simulate a spectrum from a spherical particle of the specified material (mat) and radius (in m). \ on a film of material film and thickness fThick immediately \ below the particle.""" if radius < 0.0: raise "The sphere radius must be larger than zero." if cThick < 0.0: raise "The coating thickness must be larger than zero." if fThick < 0.0: raise "The film thickness must be larger than zero." def buildSphere(monte, chamber, origin, buildParams): mat = buildParams["Material"] radius = buildParams["Radius"] coating = buildParams["Coating"] cThick = buildParams["Coating Thickness"] film = buildParams["Film"] fThick = buildParams["Film Thickness"] coatSphere = nm.Sphere(epu.Math2.plus(origin, [0.0, 0.0, radius + cThick]), radius + cThick) srC = monte.addSubRegion(chamber, coating, coatSphere) sphere = nm.Sphere(epu.Math2.plus(origin, [0.0, 0.0, radius + cThick]), radius) monte.addSubRegion(srC, mat, sphere) monte.addSubRegion(chamber, film, nm.MultiPlaneShape.createFilm([0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, 2.0 * radius]), fThick)) tmp = u"MC simulation of a %0.3f micron sphere of %s coated with %0.3f microns of %s on %0.3f microns of %s at %0.1f keV%s%s" % (radius * 1.0e6, mat, cThick * 1.0e6, coating, fThick* 1.0e6, film, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildSphere, {"Film": film, "Radius" : radius, "Material" : mat, "Coating" : coating, "Coating Thickness" : cThick, "Film Thickness" : fThick}, xtraParams)
def multiLayersOnSubstrate(layers, sub, det, e0=20.0, pc=1.0, lt=120., nTraj=100, withPoisson=True, sf=True, bf=True, xtraParams={}): """multiLayersOnSubstrate(layers, sub, det, e0=20.0, pc=1.0, lt=100., nTraj=100, withPoisson=True, sf=True, bf=True, xtraParams={}) Monte Carlo simulate a spectrum from a multilayer thin film on a substrate. Parameters ---------- layers: iterable list Layers is a iterable list of [material, thickness (meters)]. Note that the materials must have associated densities. sub: material The material to use for the substrate det: detector The detector to use e0: float (20.0) The accelerating voltage in kV pc: float (1.0) The probe current in nA lt: float (100.0) the spectrum live time (sec) nTraj: an integer (100) Number of trajectories to compute withPoisson: boolean (True) Flag to include Poisson noise sf: boolean (True) Flag to include spectrum fluorescence bf: boolean (True) Flag to include brehmstrung fluorescence xtraParams: dictionary ({}) A dictionary of extra parameters Returns ------- spc: the simulated spectrum """ dose = pc * lt # sl = "%s" % (",".join("%0.2f um of %s" % (1.0e6 * layer[1], layer[0]) for layer in layers) tmp = u"MC simulation of a multilayer film" # [%s] on %s at %0.1f keV%s%s" %(sl , sub, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) def buildFilm(monte, chamber, origin, buildParams): sr = chamber sub = buildParams["Sub"] for layer in buildParams["Layers"]: if layer[1] <= 0.0: raise "The layer thickness must be larger than zero." sr = monte.addSubRegion(sr, layer[0], nm.MultiPlaneShape.createSubstrate([0.0, 0.0, -1.0], origin)) origin = epu.Math2.plus(origin, [0.0, 0.0, layer[1]]) sr = monte.addSubRegion(sr, sub, nm.MultiPlaneShape.createSubstrate([0.0, 0.0, -1.0], origin)) return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildFilm, {"Layers": layers , "Sub": sub}, xtraParams)
def coatedSphereOnFilm(mat, radius, coating, cThick, film, fThick, det, e0=20.0, withPoisson=True, nTraj=100, dose=100, sf=True, bf=True, xtraParams={}): """coatedSphereOnFilm(mat, radius, coating, cThick, film, fThick, det, e0=20.0, withPoisson=True, nTraj=100, dose=100, sf=True, bf=True, xtraParams={}) Monte Carlo simulate a spectrum from a spherical particle of the specified material (mat) and radius (in m). \ on a film of material film and thickness fThick immediately \ below the particle.""" if radius < 0.0: raise "The sphere radius must be larger than zero." if cThick < 0.0: raise "The coating thickness must be larger than zero." if fThick < 0.0: raise "The film thickness must be larger than zero." def buildSphere(monte, chamber, origin, buildParams): mat = buildParams["Material"] radius = buildParams["Radius"] coating = buildParams["Coating"] cThick = buildParams["Coating Thickness"] film = buildParams["Film"] fThick = buildParams["Film Thickness"] coatSphere = nm.Sphere( epu.Math2.plus(origin, [0.0, 0.0, radius + cThick]), radius + cThick) srC = monte.addSubRegion(chamber, coating, coatSphere) sphere = nm.Sphere(epu.Math2.plus(origin, [0.0, 0.0, radius + cThick]), radius) monte.addSubRegion(srC, mat, sphere) monte.addSubRegion( chamber, film, nm.MultiPlaneShape.createFilm( [0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, 2.0 * radius]), fThick)) tmp = u"MC simulation of a %0.3f micron sphere of %s coated with %0.3f microns of %s on %0.3f microns of %s at %0.1f keV%s%s" % ( radius * 1.0e6, mat, cThick * 1.0e6, coating, fThick * 1.0e6, film, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) return mc3.base( det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildSphere, { "Film": film, "Radius": radius, "Material": mat, "Coating": coating, "Coating Thickness": cThick, "Film Thickness": fThick }, xtraParams)
def coatedOverBlock(mat, height, width, coating, thickness, substrate, det, e0=20.0, withPoisson=True, nTraj=defaultNumTraj, dose=defaultDose, sf=defaultCharFluor, bf=defaultBremFluor, xtraParams=defaultXtraParams): """coatedOverBlock(mat, height, width, coating, thickness, substrate, det, e0=20.0, withPoisson=True, nTraj=defaultNumTraj, dose=defaultDose, sf=defaultCharFluor, bf=defaultBremFluor, substrate=None, xtraParams={}) Monte Carlo simulate a spectrum from a block shaped particle of the specified material (mat) and height (z in m) and width (x and y in m). \ The block and subtrate is coated in a material 'coating' of the specified thickness which fully encapsulates the particle and covers the substrate too.""" def buildBlock(monte, chamber, origin, buildParams): height = buildParams["Height"] width = buildParams["Width"] subMat = buildParams["Substrate"] mat = buildParams["Material"] coating = buildParams["Coating"] thickness = buildParams["Thickness"] ccDims = [width + 2.0 * thickness, width + 2.0 * thickness, height + thickness] ccPt = epu.Math2.plus(origin, [0.0, 0.0, 0.5*(height + thickness)]) coatedCube = nm.MultiPlaneShape.createBlock(ccDims, ccPt, 0.0, 0.0, 0.0) sr1 = monte.addSubRegion(chamber, coating, coatedCube) cDims = [width, width, height] cPt = epu.Math2.plus(origin, [0.0, 0.0, thickness+0.5*height]) cube = nm.MultiPlaneShape.createBlock(cDims, cPt, 0.0, 0.0, 0.0) monte.addSubRegion(sr1, mat, cube) sideSlabWidth = 2.5*1.0e-6 - (thickness + 0.5*width) sideSlabDims = [sideSlabWidth, 5.*1.0e-6, thickness] leftSidePt = epu.Math2.plus(origin, [0.5*(width+sideSlabWidth), 0.0, thickness+height]) leftSide = nm.MultiPlaneShape.createBlock(sideSlabDims, leftSidePt, 0.0, 0.0, 0.0) monte.addSubRegion(chamber, coating, leftSide) rightSidePt = epu.Math2.plus(origin, [-0.5*(width+sideSlabWidth), 0.0, thickness+height]) rightSide = nm.MultiPlaneShape.createBlock(sideSlabDims, rightSidePt, 0.0, 0.0, 0.0) monte.addSubRegion(chamber, coating, rightSide) subNorm = [0.0, 0.0, -1.0] subPt = epu.Math2.plus(origin, [0.0, 0.0, height + thickness]) monte.addSubRegion(chamber, subMat, nm.MultiPlaneShape.createSubstrate(subNorm, subPt)) s1 = u"MC simulation of a [%0.2f,%0.2f,%0.2f] micron block of %s%s" % (width * 1.0e6, width * 1.0e6, height * 1.0e6, mat, (" on %s" % substrate if substrate else "")) s2 = u" coated with %0.2f microns of %s at %0.1f keV%s%s" % (thickness* 1.0e6, coating, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) tmp = s1 + s2 # tmp = u"MC simulation of a [%0.2f,%0.2f,%0.2f] micron block of %s%s coated with %0.2f microns of %s at %0.1f keV%s%s" % (width * 1.0e6, width * 1.0e6, height * 1.0e6, mat, (" on %s" % substrate if substrate else ""), coating, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) params = {"Substrate": substrate, "Width" : width, "Height" : height, "Material" : mat, "Coating" : coating, "Thickness" : thickness} return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildBlock, params, xtraParams)
def lineInMatrix(lin, blk, nmLinWid, umBlock, det, e0=20.0, withPoisson=True, nTraj=100, dose=120.0, sf=True, bf=True, xtraParams={}): """lineInMatrix(lin, blk, nmLinWid, umBlock, det, e0=20.0, withPoisson=True, nTraj=100, dose=120.0, sf=True, bf=True, xtraParams={}""" def buildBlock(monte, chamber, origin, buildParams): lin = buildParams["Line"] blk = buildParams["Block"] nmLinWid = buildParams["Width"] umBlock = buildParams["Size"] sc = 1.0e-6 # scale from microns to meters for positions # createBlock(double[] dims, double[] point, double phi, double theta, double psi) # createBlock - Create a block of: # dimensions specified in dims, # centered at point, # then rotated by the euler angles phi, theta, psi. block = nm.MultiPlaneShape.createBlock( [umBlock * sc, umBlock * sc, umBlock * sc], [0.0, 0.0, 0.5 * umBlock * sc], 0.0, 0.0, 0.0) matrix = monte.addSubRegion(monte.getChamber(), blk, block) monte.addSubRegion( matrix, lin, nm.MultiPlaneShape.createBlock( [1.0e-9 * nmLinWid, umBlock * sc, umBlock * sc], [0.0, 0.0, 0.5 * umBlock * sc], 0.0, 0.0, 0.0)) tmp = u"MC3-sim-%g-nm-%s-line-in-%g-um-%s-block-%0.1f-kV" % ( nmLinWid, lin, umBlock, blk, e0) params = {"Line": lin, "Width": nmLinWid, "Block": blk, "Size": umBlock} return (mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildBlock, params, xtraParams))
def coatedBlock(mat, height, width, coating, thickness, substrate, det, e0=20.0, withPoisson=True, nTraj=1000, dose=120.0, sf=False, bf=False, xtraParams={}): """coatedBlock(mat, height, width, coating, thickness, substrate, det, e0=20.0, withPoisson=True, nTraj=1000, dose=120.0, sf=False, bf=False, substrate=None, xtraParams={}) Monte Carlo simulate a spectrum from a block shaped particle of the specified material (mat) and height (z in m) and width (x and y in m). \ The block and subtrate is coated in a material 'coating' of the specified thickness which fully encapsulates the particle and covers the substrate too.""" def buildBlock(monte, origin, buildParams): height = buildParams["Height"] width = buildParams["Width"] subMat = buildParams["Substrate"] mat = buildParams["Material"] coating = buildParams["Coating"] thickness = buildParams["Thickness"] coatedCube = nm.MultiPlaneShape.createBlock([width+2.0*thickness, width+2.0*thickness, height+thickness], epu.Math2.plus(origin, [0.0, 0.0, 0.5 * (height+thickness)]), 0.0, 0.0, 0.0) sr1=monte.addSubRegion(monte.getChamber(), coating, coatedCube) cube = nm.MultiPlaneShape.createBlock([width, width, height], epu.Math2.plus(origin, [0.0, 0.0, thickness + 0.5 * height]), 0.0, 0.0, 0.0) monte.addSubRegion(sr1, mat, cube) monte.addSubRegion(monte.getChamber(), coating, nm.MultiPlaneShape.createFilm([0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, height+thickness]), thickness)) monte.addSubRegion(monte.getChamber(), subMat, nm.MultiPlaneShape.createSubstrate([0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, height+2.0*thickness]))) tmp = u"MC simulation of a [%0.2f,%0.2f,%0.2f] micron block of %s%s coated with %s at %0.1f keV%s%s" % (width * 1.0e6, width * 1.0e6, height * 1.0e6, mat, (" on %s" % substrate if substrate else ""), coating, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) params = {"Substrate": substrate, "Width" : width, "Height" : height, "Material" : mat, "Coating" : coating, "Thickness" : thickness} return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildBlock, params, xtraParams)
def lineInMatrix(lin, blk, nmLinWid, umBlock, det, e0=20.0, withPoisson=True, nTraj=100, dose=120.0, sf=True, bf=True, xtraParams={}): """lineInMatrix(lin, blk, nmLinWid, umBlock, det, e0=20.0, withPoisson=True, nTraj=100, dose=120.0, sf=True, bf=True, xtraParams={}""" def buildBlock(monte, chamber, origin, buildParams): lin = buildParams["Line"] blk = buildParams["Block"] nmLinWid = buildParams["Width"] umBlock = buildParams["Size"] sc = 1.0e-6 # scale from microns to meters for positions # createBlock(double[] dims, double[] point, double phi, double theta, double psi) # createBlock - Create a block of: # dimensions specified in dims, # centered at point, # then rotated by the euler angles phi, theta, psi. block = nm.MultiPlaneShape.createBlock([umBlock*sc, umBlock*sc, umBlock*sc],[0.0,0.0, 0.5*umBlock*sc],0.0,0.0,0.0) matrix = monte.addSubRegion(monte.getChamber(), blk, block) monte.addSubRegion(matrix, lin, nm.MultiPlaneShape.createBlock([1.0e-9*nmLinWid, umBlock*sc, umBlock*sc],[0.0, 0.0, 0.5*umBlock*sc],0.0,0.0,0.0)) tmp = u"MC3-sim-%g-nm-%s-line-in-%g-um-%s-block-%0.1f-kV" % (nmLinWid, lin, umBlock, blk, e0) params = { "Line": lin, "Width" : nmLinWid, "Block" : blk, "Size" : umBlock } return (mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildBlock, params, xtraParams))
def triLayerLineOnSubstrate(matTopL, matMidL, matBotL, matSub, htTopL, htMidL, htBotL, width, length, det, title, e0=20.0, withPoisson=True, nTraj=100, dose=120.0, sf=True, bf=True, xtraParams={}, bVerbose=False): """triLayerLineOnSubstrate(matTopL, matMidL, matBotL, matSub, htTopL, htMidL, htBotL, width, length, det, title, e0=20.0, withPoisson=True, nTraj=100, dose=120.0, sf=True, bf=True, xtraParams={}) Monte Carlo simulate a spectrum from a bilayer line on a substrate of the specified materials (matTopL, matMid, matBotL, matSub) and layer heights ( htTopL, htMidL, htBotL; z in m ) and width and length (x and y in m).""" def buildBlock(monte, chamber, origin, buildParams): matSub = buildParams["Mat Subs"] matTopL = buildParams["Mat Top"] matMidL = buildParams["Mat Mid"] matBotL = buildParams["Mat Bot"] htTopL = buildParams["Hei Top"] htMidL = buildParams["Hei Mid"] htBotL = buildParams["Hei Bot"] width = buildParams["Width"] length = buildParams["Length"] monte.addSubRegion( chamber, matTopL, nm.MultiPlaneShape.createBlock([width, length, htTopL], epu.Math2.plus( origin, [0.0, 0.0, 0.5 * htTopL]), 0.0, 0.0, 0.0)) monte.addSubRegion( chamber, matMidL, nm.MultiPlaneShape.createBlock( [width, length, htMidL], epu.Math2.plus(origin, [0.0, 0.0, 0.5 * htMidL + htTopL]), 0.0, 0.0, 0.0)) monte.addSubRegion( chamber, matBotL, nm.MultiPlaneShape.createBlock( [width, length, htBotL], epu.Math2.plus(origin, [0.0, 0.0, 0.5 * htBotL + htTopL + htMidL]), 0.0, 0.0, 0.0)) monte.addSubRegion( chamber, matSub, nm.MultiPlaneShape.createSubstrate( [0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, htTopL + htMidL + htBotL]))) tmp = u"triLayerLineOnSub-%s" % title params = { "Mat Top": matTopL, "Mat Mid": matMidL, "Mat Bot": matBotL, "Mat Subs": matSub, "Hei Top": htTopL, "Hei Mid": htMidL, "Hei Bot": htBotL, "Width": width, "Length": length } if (bVerbose == 120.0): print(params) return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildBlock, params, xtraParams)
def coatedOverBlock(mat, height, width, coating, thickness, substrate, det, e0=20.0, withPoisson=True, nTraj=defaultNumTraj, dose=defaultDose, sf=defaultCharFluor, bf=defaultBremFluor, xtraParams=defaultXtraParams): """coatedOverBlock(mat, height, width, coating, thickness, substrate, det, e0=20.0, withPoisson=True, nTraj=defaultNumTraj, dose=defaultDose, sf=defaultCharFluor, bf=defaultBremFluor, substrate=None, xtraParams={}) Monte Carlo simulate a spectrum from a block shaped particle of the specified material (mat) and height (z in m) and width (x and y in m). \ The block and subtrate is coated in a material 'coating' of the specified thickness which fully encapsulates the particle and covers the substrate too.""" def buildBlock(monte, chamber, origin, buildParams): height = buildParams["Height"] width = buildParams["Width"] subMat = buildParams["Substrate"] mat = buildParams["Material"] coating = buildParams["Coating"] thickness = buildParams["Thickness"] coatedCube = nm.MultiPlaneShape.createBlock([ width + 2.0 * thickness, width + 2.0 * thickness, height + thickness ], epu.Math2.plus(origin, [0.0, 0.0, 0.5 * (height + thickness)]), 0.0, 0.0, 0.0) sr1 = monte.addSubRegion(chamber, coating, coatedCube) cube = nm.MultiPlaneShape.createBlock( [width, width, height], epu.Math2.plus(origin, [0.0, 0.0, thickness + 0.5 * height]), 0.0, 0.0, 0.0) monte.addSubRegion(sr1, mat, cube) sideSlabWidth = 2.5 * 1.0e-6 - (thickness + 0.5 * width) sideSlabDims = [sideSlabWidth, 5. * 1.0e-6, thickness] leftSidePt = epu.Math2.plus( origin, [0.5 * (width + sideSlabWidth), 0.0, thickness + height]) leftSide = nm.MultiPlaneShape.createBlock(sideSlabDims, leftSidePt, 0.0, 0.0, 0.0) monte.addSubRegion(chamber, coating, leftSide) rightSidePt = epu.Math2.plus( origin, [-0.5 * (width + sideSlabWidth), 0.0, thickness + height]) rightSide = nm.MultiPlaneShape.createBlock(sideSlabDims, rightSidePt, 0.0, 0.0, 0.0) monte.addSubRegion(chamber, coating, rightSide) fbSlabDims = [width, sideSlabWidth, thickness] frontSidePt = epu.Math2.plus( origin, [0.0, 0.5 * (width + sideSlabWidth), thickness + height]) frontSide = nm.MultiPlaneShape.createBlock(fbSlabDims, frontSidePt, 0.0, 0.0, 0.0) monte.addSubRegion(chamber, coating, frontSide) backSidePt = epu.Math2.plus( origin, [0.0, -0.5 * (width + sideSlabWidth), thickness + height]) backSide = nm.MultiPlaneShape.createBlock(fbSlabDims, backSidePt, 0.0, 0.0, 0.0) monte.addSubRegion(chamber, coating, backSide) # no substrate - don't want film under block... # monte.addSubRegion(chamber, coating, nm.MultiPlaneShape.createFilm([0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, height + thickness]), thickness)) monte.addSubRegion( chamber, subMat, nm.MultiPlaneShape.createSubstrate( [0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, height + 2 * thickness]))) s1 = u"MC simulation of a [%0.2f,%0.2f,%0.2f] micron block of %s%s" % ( width * 1.0e6, width * 1.0e6, height * 1.0e6, mat, (" on %s" % substrate if substrate else "")) s2 = u" coated with %0.2f microns of %s at %0.1f keV%s%s" % ( thickness * 1.0e6, coating, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) tmp = s1 + s2 # tmp = u"MC simulation of a [%0.2f,%0.2f,%0.2f] micron block of %s%s coated with %0.2f microns of %s at %0.1f keV%s%s" % (width * 1.0e6, width * 1.0e6, height * 1.0e6, mat, (" on %s" % substrate if substrate else ""), coating, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) params = { "Substrate": substrate, "Width": width, "Height": height, "Material": mat, "Coating": coating, "Thickness": thickness } return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildBlock, params, xtraParams)
def multiLayersOnSubstrate(layers, sub, det, e0=20.0, pc=1.0, lt=120., nTraj=100, withPoisson=True, sf=True, bf=True, xtraParams={}): """multiLayersOnSubstrate(layers, sub, det, e0=20.0, pc=1.0, lt=100., nTraj=100, withPoisson=True, sf=True, bf=True, xtraParams={}) Monte Carlo simulate a spectrum from a multilayer thin film on a substrate. Parameters ---------- layers: iterable list Layers is a iterable list of [material, thickness (meters)]. Note that the materials must have associated densities. sub: material The material to use for the substrate det: detector The detector to use e0: float (20.0) The accelerating voltage in kV pc: float (1.0) The probe current in nA lt: float (100.0) the spectrum live time (sec) nTraj: an integer (100) Number of trajectories to compute withPoisson: boolean (True) Flag to include Poisson noise sf: boolean (True) Flag to include spectrum fluorescence bf: boolean (True) Flag to include bremsstrahlung fluorescence xtraParams: dictionary ({}) A dictionary of extra parameters Returns ------- spc: the simulated spectrum """ dose = pc * lt # sl = "%s" % (",".join("%0.2f um of %s" % (1.0e6 * layer[1], layer[0]) for layer in layers) tmp = u"MC simulation of a multilayer film" # [%s] on %s at %0.1f keV%s%s" %(sl , sub, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) def buildFilm(monte, chamber, origin, buildParams): sr = chamber sub = buildParams["Sub"] for layer in buildParams["Layers"]: if layer[1] <= 0.0: raise "The layer thickness must be larger than zero." sr = monte.addSubRegion( sr, layer[0], nm.MultiPlaneShape.createSubstrate([0.0, 0.0, -1.0], origin)) origin = epu.Math2.plus(origin, [0.0, 0.0, layer[1]]) sr = monte.addSubRegion( sr, sub, nm.MultiPlaneShape.createSubstrate([0.0, 0.0, -1.0], origin)) return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildFilm, { "Layers": layers, "Sub": sub }, xtraParams)
def coatedBlock(mat, height, width, coating, thickness, substrate, det, e0=20.0, withPoisson=True, nTraj=1000, dose=120.0, sf=False, bf=False, xtraParams={}): """coatedBlock(mat, height, width, coating, thickness, substrate, det, e0=20.0, withPoisson=True, nTraj=1000, dose=120.0, sf=False, bf=False, substrate=None, xtraParams={}) Monte Carlo simulate a spectrum from a block shaped particle of the specified material (mat) and height (z in m) and width (x and y in m). \ The block and subtrate is coated in a material 'coating' of the specified thickness which fully encapsulates the particle and covers the substrate too.""" def buildBlock(monte, origin, buildParams): height = buildParams["Height"] width = buildParams["Width"] subMat = buildParams["Substrate"] mat = buildParams["Material"] coating = buildParams["Coating"] thickness = buildParams["Thickness"] coatedCube = nm.MultiPlaneShape.createBlock([ width + 2.0 * thickness, width + 2.0 * thickness, height + thickness ], epu.Math2.plus(origin, [0.0, 0.0, 0.5 * (height + thickness)]), 0.0, 0.0, 0.0) sr1 = monte.addSubRegion(monte.getChamber(), coating, coatedCube) cube = nm.MultiPlaneShape.createBlock( [width, width, height], epu.Math2.plus(origin, [0.0, 0.0, thickness + 0.5 * height]), 0.0, 0.0, 0.0) monte.addSubRegion(sr1, mat, cube) monte.addSubRegion( monte.getChamber(), coating, nm.MultiPlaneShape.createFilm([0.0, 0.0, -1.0], epu.Math2.plus( origin, [0.0, 0.0, height + thickness]), thickness)) monte.addSubRegion( monte.getChamber(), subMat, nm.MultiPlaneShape.createSubstrate( [0.0, 0.0, -1.0], epu.Math2.plus(origin, [0.0, 0.0, height + 2.0 * thickness]))) tmp = u"MC simulation of a [%0.2f,%0.2f,%0.2f] micron block of %s%s coated with %s at %0.1f keV%s%s" % ( width * 1.0e6, width * 1.0e6, height * 1.0e6, mat, (" on %s" % substrate if substrate else ""), coating, e0, (" + CSF" if sf else ""), (" + BSF" if bf else "")) params = { "Substrate": substrate, "Width": width, "Height": height, "Material": mat, "Coating": coating, "Thickness": thickness } return mc3.base(det, e0, withPoisson, nTraj, dose, sf, bf, tmp, buildBlock, params, xtraParams)