Skip to content

Simulation and fitting of Rutherford Backscattering Spectrometry (RBS), EBS, NRA and ERD spectra. Works with scripts or interactive commands with either command line or graphical user interface.

License

JYU-IBA/jabs

Repository files navigation

JaBS - Jaakko's Backscattering Simulator

DOI

Simulates and fits RBS, EBS, ERD and NRA spectra rapidly.

Copyright (C) 2021 - 2023 Jaakko Julin

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

Please see additional notes regarding copyrights of included open source code at the end of this document.

Additional information and resources might be available on JaBS home page.

Binary packages

Some ready-to-use binary packages for each release for Windows and macOS may be available. The Windows distribution includes two executables: jabs.exe (command line) and qjabs.exe (graphical interface). The macOS binary is a regular application bundle. All necessary data files (stopping etc.) are included in these distributions.

See instructions below on how to compile JaBS from sources. Supported platforms are Windows, macOS and Linux.

Getting started

One example showing basic use is provided, along with more complex test-cases. Try running help and help commands in the interactive mode. XML files in IDF format created by other programs can be imported.

See the getting started document.

Installation from sources

See instructions.

Graphical user interface

Simple Qt-based GUI is provided. Scripts can be edited and run, simulated spectra and experimental spectra are plotted (if available).

Interactive or scripted usage

Launch JaBS in interactive mode simply by running jabs or jabs --interactive. Scripts (i.e. files with commands identical to interactive mode input) can be given as command line parameters e.g. jabs script.jbs, piped in jabs < script.jbs or run using the interactive mode.

The interactive mode should be self-explanatory and an internal help is provided. Please see the example script to get started. Note that scripts are executed in the directory where the file is located, when opened in the GUI, but in the current working directory by the command-line program. This affects loading and saving filenames.

The scripting language is not a programming language, there is no flow control, new variables can not be introduced etc. However multiple simulations/fits are possible in a single file and other scripts may be loaded, which in turn may load other scripts.

Features

Implemented

  • Basic RBS spectrum simulation with Rutherford and Andersen cross-sections.
  • Atomic data, electronic stopping and straggling given by JIBAL.
  • Automatic simulation of recoil spectra when working in forward angles (ERDA) and simulation of both solutions (+/-) for RBS when possible
  • Arbitrary cross sections and reactions from R33 files. Both EBS (Q-value is zero) and p-p NRA are implemented.
  • Point-by-point and layered sample models
  • Roughness using a gamma distribution and arbitrary roughness using files (weight and thickness tables)
  • Arbitrary geometry, detector and sample tilt can be expressed in arbitrary spherical coordinates
  • Transmission geometry
  • Non-linear detector calibration (polynomial of arbitrary degree) and constant detector energy resolution or timing resolution (for ToF detectors)
  • Different calibrations are possible for different elements (Z-specific calibration).
  • Multilayer foil in front of detector
  • Reading of experimental data, integer factor compress
  • Fitting to experimental spectrum (multidimensional non-linear least squares fitting)
  • Simultaneous multi-detector simulation and fitting.
  • Faster (less accurate) modes
  • Slower (more accurate) modes
  • Two-phase fitting, where faster physics model is used in the beginning and more accurate (user configurable) model is turned on after the first phase is starting to converge. User can skip the faster fitting phase.
  • User defined "molecules" i.e. elements with fixed concentration ratios (e.g. you can fit C in SiO2 without changing Si/O ratio)
  • Weighting of cross-sections by straggling
  • Kinematic (geometric) broadening due to finite detector size and beam spot
  • Stopping corrections can be supplied by user (Bragg correction) for a specific layer as well as similar corrections for straggling and yield
  • Testing of areal sum (counts) and residuals. Some test cases are run by the developer to check sanity and accuracy of simulations for every new release.
  • Higher accuracy mode using adaptive integration for more accurate handling of sharp peaks in cross sections (resonances) and accurate weighting of cross sections by (Gaussian) straggling.
  • Conversion tool from IDF to JaBS script (partial support)
  • Export of simulations to IDF (partial support)
  • Simulation of large angle plural scattering (dual scattering model), with the assumption that first scattering is RBS (not ERD).
  • Multiprocessor support when simulating multiple detectors and when fitting multiple parameters

Not implemented, but planned or being worked on

  • Support for more input and output data formats (CSV, ...)
  • Multiple scattering (small angle)
  • Simulation of pile-up and dead time
  • Simulation of time-of-flight spectra

Distant future, if ever

  • Advanced fitting algorithms
  • Fitting of spectra from different measurements (different beam, fluence etc for each simulation)
  • Turing completeness of the scripting language

Known issues

  • Saving a detector to a file is not supported. Calibrations can be saved as a script.
  • Ad-hoc channeling correction is the same for all detectors
  • Import and export of IDF files produce intended results, since the IDF support is only partial. Use caution and common sense.

Fitting

The multidimensional nonlinear least-squares fitting is based on Levenberg-Marquardt algorithm GSL multifit.

Example:

jabs> add fit range [500:900] [1000:1200]
jabs> fit *calib*,fluence,thick1
jabs> show fit

Use show fit variables to see a list of variables that can be fitted. This list changes when the sample and detector(s) change. Using * or ? wildcards is possible, the example above will add all calibration parameters of all detectors.

Open source licenses

This repository contains following open source software, or parts of them:

  • Code derived from GSL (GNU Scientific Library) examples, e.g. in fit.c. Used under the terms of GPL v3.
  • QCustomPlot qcustomplot.cpp and qcustomplot.h, Copyright (C) 2011-2021 Emanuel Eichhammer. Used under the terms of GPL v3.
  • Coordinate rotate routine from MCERD rotate.c. Copyright Kai Arstila. Used under the terms of GPL v2.
  • Some routines from NetBSD, Copyright (c) 2011 The NetBSD Foundation, Inc. See win_compat.c for the full copyright notice.
  • Qt Toolkit examples used under terms of the BSD license.
  • Material Design icons licensed under Apache 2.0 license.
  • Version tracking from Git, cmake-git-version-tracking Copyright (c) 2020 Andrew Harding. Used under the terms of MIT License.

Binary distributions contain following open source software:

  • Qt6 GUI is distributed under the provisions of LGPL version 3. Qt Toolkit is Copyright (C) 2018 The Qt Company Ltd. and other contributors.
  • libxml2 library, used under the terms of MIT License. Copyright (C) 1998-2012 Daniel Veillard.

About

Simulation and fitting of Rutherford Backscattering Spectrometry (RBS), EBS, NRA and ERD spectra. Works with scripts or interactive commands with either command line or graphical user interface.

Topics

Resources

License

Stars

Watchers

Forks