Author Topic: Show emitted spectrum by using DTSA-II script  (Read 137 times)

ZhaiQ

  • Graduate
  • **
  • Posts: 6
Show emitted spectrum by using DTSA-II script
« on: July 07, 2024, 01:33:51 PM »
Hi everyone,

I am a new user of the DTSA-II software, and trying to run multiple Monte Carlo simulations by using the script. Currently I am able to run thin film simulations with different material thicknesses, which is exactly what I want. However I've noticed that all my results are "Noisy". There're always two spectra when I use "smilation alien" GUI to run Monte Carlo simulations, one is "Noisy" and another one is "Emitted". May I ask how should I get the "Emitted" spectrum by using script? Thank you very much!

Nicholas Ritchie

  • Moderator
  • Professor
  • *****
  • Posts: 155
    • NIST DTSA-II
Re: Show emitted spectrum by using DTSA-II script
« Reply #1 on: July 07, 2024, 04:25:35 PM »
Code: [Select]
import dtsa2.mcSimulate3 as mc3
mc3.simulate("NaAlSi3O8", d1, 20.0, withPoisson=False)



This does convolve the displayed spectrum with the detector function.

In the simulation alien you can also uncheck "Apply simulated noise statistics" or to reduce noise just increase the dose (probe current x live time)
« Last Edit: July 07, 2024, 07:47:39 PM by John Donovan »
"Do what you can, with what you have, where you are"
  - Teddy Roosevelt

ZhaiQ

  • Graduate
  • **
  • Posts: 6
Re: Show emitted spectrum by using DTSA-II script
« Reply #2 on: July 07, 2024, 07:50:33 PM »
Hi Prof Ritchie,

Thank you for your answer! I've tried out your method and I attached the result below. Seems the Poisson=False option still gives a spectrum convolved with the detector response. May I consult how should I can get the "Emitted" spectrum (blue one in the figure) by using the script?

I paste my code here as well for your reference:

Graphite # my material of films
thick # thickness of films
d201 # EDS detector I defined

import dtsa2.mcSimulate3 as mc3
for thick in range(1,10,1):
     mc3.multiFilm([[Graphite,thick*1e-6],[Graphite,1e-6]],d201,e0=20.0,withPoisson=False,nTraj=5000,dose=1000).display()
« Last Edit: July 07, 2024, 09:39:58 PM by John Donovan »

Nicholas Ritchie

  • Moderator
  • Professor
  • *****
  • Posts: 155
    • NIST DTSA-II
Re: Show emitted spectrum by using DTSA-II script
« Reply #3 on: July 08, 2024, 07:17:07 PM »
In the function
Code: [Select]
def base(det, e0, withPoisson, nTraj, dose, sf, bf, name, buildSample, buildParams, xtraParams): (line 383)
in mcSimulate3.py, replace the call to
Code: [Select]
spec = det.getSpectrum((dose * 1.0e-9) / (nTraj * epq.PhysicalConstants.ElectronCharge))with
Code: [Select]
spec = det.getgetRawXRayData((dose * 1.0e-9) / (nTraj * epq.PhysicalConstants.ElectronCharge))
"Do what you can, with what you have, where you are"
  - Teddy Roosevelt

ZhaiQ

  • Graduate
  • **
  • Posts: 6
Re: Show emitted spectrum by using DTSA-II script
« Reply #4 on: July 09, 2024, 12:04:33 AM »
Hi Prof,

Thank you for your reply, this method works well ;D!

For other users who may have the similar problem, you can find mcSimulate3.py here: your installation location\NIST\Lib\dtsa2\mcSimulate3.py. And there's a typo in Prof Ritchie's reply (one extra "get"). Just replace
Code: [Select]
spec = det.getSpectrum((dose * 1.0e-9) / (nTraj * epq.PhysicalConstants.ElectronCharge))
with
Code: [Select]
spec = det.getRawXRayData((dose * 1.0e-9) / (nTraj * epq.PhysicalConstants.ElectronCharge))

Nicholas Ritchie

  • Moderator
  • Professor
  • *****
  • Posts: 155
    • NIST DTSA-II
Re: Show emitted spectrum by using DTSA-II script
« Reply #5 on: July 09, 2024, 11:40:21 AM »
Thanks for fixing my cut-and-paste error.
"Do what you can, with what you have, where you are"
  - Teddy Roosevelt