Probe Software Users Forum

Software => DTSA II => Topic started by: Ben Buse on February 05, 2025, 06:21:48 AM

Title: SF from inclusion
Post by: Ben Buse on February 05, 2025, 06:21:48 AM
Hi

Whilst in GUI can by an inclusion in a host, it seems to be centered on the host

Can you set a distance away from the inclusion within the host to measure the amount of SF from the inclusion on host measurement

Thanks
Title: Re: SF from inclusion
Post by: Ben Buse on February 12, 2025, 03:04:37 AM
It be great to do this by dtsa2 GUI

I'm trying to do this by code using embeded sphere and xtraparameters configurebeam which is defined as

def configureBeam(x, y, z, szNm):
  """configureBeam(x,y,z, szNm)
  Create xtraParams entries to configure the beam for the simulation.
  Input:
  x, y, z - positions of the beam in meters
  szNm    - the beam diameter in nm (converted to m internally)"""
  return { "PosX" : x, "PosY" : y, "PosZ": z, "nmSize": szNm}

however I get the following error

Traceback (most recent call last):
  File "<stdin>", line 8, in <module>
  File "C:/DTSAii/SimpleSimulationScript_withPhiRhoZ_calcite_embedded sphere2.py", line 23
    specSample = mc3.embeddedSphere(sample,0.000000500,matrixsubstrate,0.000000500,det,e0=e0, nTraj=nE, dose=500.0, sf=True, bf=True,xtraParams=xtraP)
    ^
SyntaxError: no viable alternative at input 'specSample'

Any ideas what I'm doing wrong?

The code is
import dtsa2 as dtsa2
import dtsa2.mcSimulate3 as mc3

det = findDetector("SDD") # Replace with your detector's name
nE = 100 # number of electrons simulated
e0 = 15    # kV

sample = epq.Material(epq.Composition(map(dtsa2.element,["Ca","O","C","Mg"],),[0.39,0.48,0.12,0.01],"calcite-Mg"),epq.ToSI.gPerCC(2.84))    # epq.ToSI.gPerCC(2.72) converts 2.65g/cc into SI units 2650 kg/m3, composition is mass fraction
matrixsubstrate = epq.Material(epq.Composition(map(dtsa2.element,["Si","O"],),[0.47,0.53],"quartz"),epq.ToSI.gPerCC(2.65))    # epq.ToSI.gPerCC(2.72) converts 2.65g/cc into SI units 2650 kg/m3, composition is mass fraction
range = dtsa2.electronRange(sample,e0,density=None)

xtraP = {}
#xtraP = {"Characteristic Accumulator":True, "Char Fluor Accumulator":True, "Brem Fluor Accumulator":True}
xtraP.update(mc3.configureXRayAccumulators(mc3.suggestTransitions("CaOCMg",e0),charAccum=True,charFluorAccum=True,bremFluorAccum=True))
#xtraP.update(mc3.configureOutput(DefaultOutput))
xtraP.update(mc3.configurePhiRhoZ(1.5*range))
xtraP.update(mc3.configureEmissionImages(mc3.suggestTransitions("CaOCMg",e0), 1.5*range, size = 512))
xtraP.update(mc3.configureTrajectoryImage(1.5*range, size = 512))
xtraP.update(mc3.configureOutput('C:\DTSAii\Scripts'))    # change to output folder
xtraP.update(mc3.configureBeam(0.000001,0,0,10)
#print xtraP

specSample = mc3.embeddedSphere(sample,0.000000500,matrixsubstrate,0.000000500,det,e0=e0, nTraj=nE, dose=500.0, sf=True, bf=True,xtraParams=xtraP)
specSample.save("%s/%s.msa" % ( 'C:\DTSAii\Scripts', specSample ))        # change to output folder
specSample.display()

Also can the code create the html report?
Title: Re: SF from inclusion
Post by: Ben Buse on February 12, 2025, 03:22:17 AM
Ok something wrong with xtraP

If I try this works but that's without beam configure

xrts=mc3.suggestTransitions("CaOCMg")
xtraParams={}
xtraParams.update(mc3.configureXRayAccumulators(xrts,charAccum=True,charFluorAccum=True,bremFluorAccum=False))
xtraParams.update(mc3.configureEmissionImages(xrts,1.0e-5,512))
xtraParams.update(mc3.configureContinuumImages( ((2.3,2.5), (4.2,4.4 )), 1.0e-5, 512 ))
xtraParams.update(mc3.configurePhiRhoZ(1.0e-5))
xtraParams.update(mc3.configureTrajectoryImage(1.0e-5,512))
#xtraParams.update(mc3.configureVariablePressure(pathLen, gas))
#xtraParams.mc3.configureVRML(nElectrons = 40)
print xtraParams

specSample = mc3.embeddedSphere(sample,0.000000500,matrixsubstrate,0.000000500,det,e0=e0, nTraj=nE, dose=500.0, sf=True, bf=True,xtraParams=xtraParams)
specSample.save("%s/%s.msa" % ( 'C:\DTSAii\Scripts', specSample ))        # change to output folder
specSample.display()


If I include beam configure it fails

xtraParams.update(mc3.configureBeam(0.000001,0,0,10)
And any idea why I have to reboot DTSA-ii for it to run the code again
Title: Re: SF from inclusion
Post by: Nicholas Ritchie on February 13, 2025, 09:06:52 AM
I think you are missing a closing parenthesis.  The interpreter is waiting for the parenthesis when you enter the next command and as a result seems to hang.
Title: Re: SF from inclusion
Post by: Nicholas Ritchie on February 13, 2025, 09:10:22 AM
This works:
import dtsa2 as dtsa2
import dtsa2.mcSimulate3 as mc3

det = findDetector("SDD") # Replace with your detector's name
nE = 100 # number of electrons simulated
e0 = 15    # kV

sample = epq.Material(epq.Composition(map(dtsa2.element,["Ca","O","C","Mg"],),[0.39,0.48,0.12,0.01],"calcite-Mg"),epq.ToSI.gPerCC(2.84))    # epq.ToSI.gPerCC(2.72) converts 2.65g/cc into SI units 2650 kg/m3, composition is mass fraction
matrixsubstrate = epq.Material(epq.Composition(map(dtsa2.element,["Si","O"],),[0.47,0.53],"quartz"),epq.ToSI.gPerCC(2.65))    # epq.ToSI.gPerCC(2.72) converts 2.65g/cc into SI units 2650 kg/m3, composition is mass fraction
range = dtsa2.electronRange(sample,e0,density=None)

xtraP = {}
#xtraP = {"Characteristic Accumulator":True, "Char Fluor Accumulator":True, "Brem Fluor Accumulator":True}
xtraP.update(mc3.configureXRayAccumulators(mc3.suggestTransitions("CaOCMg",e0),charAccum=True,charFluorAccum=True,bremFluorAccum=True))
#xtraP.update(mc3.configureOutput(DefaultOutput))
xtraP.update(mc3.configurePhiRhoZ(1.5*range))
xtraP.update(mc3.configureEmissionImages(mc3.suggestTransitions("CaOCMg",e0), 1.5*range, size = 512))
xtraP.update(mc3.configureTrajectoryImage(1.5*range, size = 512))
xtraP.update(mc3.configureOutput('C:\DTSAii\Scripts'))    # change to output folder
xtraP.update(mc3.configureBeam(0.000001,0,0,10))
print xtraP
specSample = mc3.embeddedSphere(sample,0.000000500,matrixsubstrate,0.000000500,det,e0=e0, nTraj=nE, dose=500.0, sf=True, bf=True,xtraParams=xtraP)
specSample.save("%s/%s.msa" % ( 'C:\DTSAii\Scripts', specSample ))        # change to output folder
specSample.display()
Title: Re: SF from inclusion
Post by: Ben Buse on February 19, 2025, 03:20:58 AM
Thanks for spotting this, obviously I need to use a better editor which will highlight it.

Just wondering whether it's possible to generate the html report result from script
Title: Re: SF from inclusion
Post by: Nicholas Ritchie on February 19, 2025, 06:44:10 AM
Unfortunately, it is not possible to generate the HTML report from a script.
Title: Re: SF from inclusion
Post by: parishcm on March 04, 2025, 09:51:04 AM
Quote from: Nicholas Ritchie on February 19, 2025, 06:44:10 AMUnfortunately, it is not possible to generate the HTML report from a script.

Ha! I logged in today specifically to ask that question. Glad I checked the archive first.
Title: Re: SF from inclusion
Post by: Ben Buse on March 12, 2025, 06:10:03 AM
Any help: what's happening here - if I run the two parts seperately it works in DTSAii, if I run together it works in python but not DTSAii

where code is
createlist=[]
#range as microns
#initial short step
for d in range(0,20,2):
    #store as meters
    print(d)
    createlist.append(float('%s' % float('%.11g' % (d*1e-6))))
#then larger step
#upper limit one extra
for dd in range(20,55,5):
    createlist.append(float('%s' % float('%.11g' % (dd*1e-6))))
    print(dd)

And output in dtsa2 is

Elapse: 0:00:00.0
6> createlist=[]
#range as microns
#initial short step
for d in range(0,20,2):
    #store as meters
    print(d)
    createlist.append(float('%s' % float('%.11g' % (d*1e-6))))
0
2
4
6
8
10
12
14
16
18
Elapse: 0:00:00.0
7> for dd in range(20,55,5):
    createlist.append(float('%s' % float('%.11g' % (dd*1e-6))))
    print(dd)
20
25
30
35
40
45
50
Elapse: 0:00:00.0
8> createlist=[]
#range as microns
#initial short step
for d in range(0,20,2):
    #store as meters
    print(d)
    createlist.append(float('%s' % float('%.11g' % (d*1e-6))))
#then larger step
#upper limit one extra
for dd in range(20,55,5):
    createlist.append(float('%s' % float('%.11g' % (dd*1e-6))))
    print(dd)
  File "<stdin>", line 7
    for dd in range(20,55,5):
    ^
SyntaxError: required (...)+ loop did not match anything at input 'for'
  File "<stdin>", line 1
    createlist.append(float('%s' % float('%.11g' % (dd*1e-6))))
    ^
SyntaxError: no viable alternative at input '    '
  File "<stdin>", line 1
    print(dd)
    ^
SyntaxError: no viable alternative at input '    '
Elapse: 0:00:00.0