Skip to content

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multispec Fitting Software

Overview

Python designed for simultaneous fitting of multiple spectra, particularly useful for analyzing datasets with shared spectral features across changing conditions, such as Variable Temperature, Variable Field (VTVH) Magnetic Circular Dichroism (MCD) spectroscopy. Uses standard python packages (Scipy, Numpy, Matplotlib)

Key Features & Physics Implemented

  • Simultaneous Global Fitting: Fit multiple spectra simultaneously, tying parameters (band shape) across datasets while allowing amplitudes to float independently.
  • Gaussian and Pseudo-Voigt Deconvolution: Fitting of user selected Gaussian and Pseudo-Voigt lineshapes.
  • Amplitude and Sign Constraints: Set specific boundaries on parameters, including opposite-signed amplitudes.
  • Vibronic Progressions: Built-in support for modeling vibronic coupling using the Huang-Rhys factor and Poisson distributions, automatically calculating vibrational spacing.
  • Custom Parameter Constraints: Define explicit mathematical relationships between different spectral bands directly in input file (via asteval).
  • Temperature Dependent Peak Width Broadening Constrained modeling of peak width broadening across temperature gradients.
  • Optimization Algorithms Option to use least-squared (default), differential evolution (DE), dual annealing, Nelder-Mead, or L-BFGS-B algorithms, with ability to choose different methods for global fitting and for SH fitting.
  • Spin Hamiltonian Includes an integrated spin Hamiltonian solver to extract magnetic parameters (D, E, g-tensor), band transition dipoles (Mxy,yz,xz) and polarizations directly from VTVH amplitudes.

Example Single Spectra from VTVH fit

Fitted 2.5K 10T data from the VTVH fit

*Fitted example using VTVH MCD data [1]*

Installation

Requires: Python 3.11 or newer (for tomllib)

Clone the repository and install the required dependencies:

git clone git@github.com:drice987/multispec_fitting.git
cd multispec_fitting
pip install -r requirements.txt

Quick Start

The software is executed directly from command line and relies on a single .toml config file to define the dataset, initial guesses, and constraints.

  1. Configure the fit: Edit the input file (e.g., example/N2Q_t_indep_width.toml) to define temperatures, magnetic fields, and spectral band parameters. A detailed input explaining the variables is found at example/commented_input.toml
  2. Run the fit Execute the script in terminal:
python multispec_fitting.py python example/N2Q_SH_with_golbal-fit.toml

Outputs:

Upon successful global fit, the script will generate:

  • output_parameters.csv: The optimized centers, widths, and vibronic parameters.
  • output_amplitudes.csv: The intensity amplitudes for every spectra combination.
  • output_spectra.csv: The x-axis, expeirmenta y-values, total fit, and individual band fits for each spectra.
  • fitted_results.toml: A new configuration file containing the optimized parameters.
  • fit_results.png: A grid plot visuallying overlaying total fits and individual bands for each spectra. ** Spin Hamiltonian Outputs (saved in sh_outputs/):
  • magnetization_fits.png: A grid plot with magnetization curves (with option for reduced magnetization axis) for all bands.
  • isofield__{target_field}T.png: A plot overlaying all temperature-dependent curves at a constant field.
  • sh_fit_parameters.csv: All spin Hamiltonian parameters from the fit (D, E, g-tensor) and band dipole products and % polarizations.
  • sh_simulated_curves.csv: Long-format table of all coordinates for both the experimental data and the simulated curves.

References

  1. Derek B. Rice et al., Sci. Adv. 10, eado1603(2024). DOI:10.1126/sciadv.ado1603