Options#

Options collects computational settings (EasySpin’s Opt): the method (matrix diagonalization or perturbation theory), the orientation grid (GridSize, GridSymmetry), transition selection thresholds, the device and dtype, and verbosity. Defaults reproduce EasySpin’s defaults unless noted.

class torchspin.Options(Method='matrix', HybridCoreNuclei=None, HybridIntThreshold=0.005, AccumMethod=None, Accuracy=1e-12, MaxIterations=15, GridSize=<factory>, GridSymmetry='auto', Threshold=0.0001, Verbosity=0, BatchSize=None, EquivalentNuclei=True, Sites=None, separate='', IsoCutoff=0.0001, Stretch=0.25, ModellingAccuracy=2e-06, RediagLimit=0.999, device='cpu', QuadraticZeeman=False, Enhancement=False, ZeroField=False, Transitions=None, PaddingMultiplier=3.0, TPSGridSymm='D2h', TPSGridSize=4)[source]#

Computational options for the CW EPR and ENDOR simulators (EasySpin Opt).

Every simulator reads only the fields it needs and ignores the others; the description of each field names the functions that use it. Values are validated on construction (see Raises).

Parameters:
  • Method (str, default 'matrix') –

    Resonance solver. Accepted on construction: 'matrix', 'exact', 'hybrid', 'perturb', 'perturb1' to 'perturb5'; which of them a simulator implements differs:

    • pepper(): 'matrix' (or 'exact'), exact diagonalization; 'perturb'/'perturb2' second-order and 'perturb1' first-order perturbation theory; 'hybrid', an exactly diagonalized core (all electrons plus HybridCoreNuclei) with the other nuclei treated by perturbation theory. 'perturb3' to 'perturb5' raise ValueError.

    • garlic(): 'exact' ('matrix' is read as 'exact'), the Breit-Rabi fixed-point solver; 'perturb' (fifth order) or 'perturb1' to 'perturb5' (that order); 'hybrid' raises ValueError. The bare name 'perturb' therefore means different orders in pepper and garlic, as in EasySpin.

    • salt() finds resonance fields by diagonalization and ENDOR frequencies by first-order perturbation theory for one electron without quadrupole couplings, by matrix diagonalization otherwise (and always with Enhancement=True or SpinSystem.Ham; an explicit 'perturb*' with SpinSystem.Ham raises). Both ENDOR paths give abs(<i|mu_perp|j>)**2 intensities in (MHz/mT)^2.

    See KNOWN_LIMITATIONS.md, “Pepper — choosing a method, and what each costs (2026-10-07)”.

  • HybridCoreNuclei (int or list of int, optional) – pepper with Method='hybrid' only. 1-based indices into SpinSystem.Nucs of the nuclei kept in the exactly diagonalized core; all electron spins are always in the core. None or empty (default) makes every nucleus perturbational. For Cu(II) with nitrogen ligands, [1] keeps the copper exact.

  • HybridIntThreshold (float, default 0.005) – pepper with Method='hybrid' only. Nuclear sub-lines whose amplitude summed over the grid is below this fraction of the strongest are dropped.

  • AccumMethod (str, optional) – garlic only. How lines are accumulated into the spectrum: 'binning' (nearest-bin stick spectrum, then convolution), 'linear' (each line split between its two neighboring bins, differentiable in the line positions) or 'explicit' (one analytic line shape per line). None (default) = 'explicit' in the fast-motion regime and 'binning' otherwise. When the inputs require grad, 'binning' (given or automatic) is replaced by 'linear'. Experiment.mwPhase != 0 needs 'explicit'.

  • Accuracy (float, default 1e-12) – garlic only. Relative convergence criterion of the Breit-Rabi fixed-point/Newton iterations.

  • MaxIterations (int, default 15) – garlic only. Iteration cap of the resonance-position solvers.

  • GridSize (int or list of int, default [19, 4]) – Powder grid size for pepper (and the orientation grids of orisel, saffron and chili’s slow-motion solver). An integer N: resonances are computed at a grid with N knots along a quarter meridian (at least 2), without interpolation. [N_coarse, N_interp]: resonances are computed on the N_coarse grid and spline interpolated to a fine grid of (N_coarse - 1) * N_interp + 1 knots per quarter meridian before the spectrum is accumulated (N_coarse >= 2, N_interp >= 1). The default gives 73 fine knots; increase N_coarse for strongly anisotropic or narrow-line spectra (grid_convergence() checks convergence).

  • GridSymmetry (str, default 'auto') – Symmetry of the powder grid, i.e. which part of the sphere is sampled. 'auto' or '': the symmetry of the spin Hamiltonian (including strains) is detected and the matching grid and frame are used. Otherwise one of 'O3' (isotropic, one orientation), 'Dinfh' (axial, one meridian), 'D6h', 'D4h', 'Oh', 'D3d', 'Th', 'D2h' (one octant), 'C6h', 'C4h', 'S6', 'C2h', 'Ci' (a hemisphere) or 'C1' (the full sphere). A given symmetry is used in the molecular frame without checking it against the Hamiltonian; 'Ci' is valid for any spin Hamiltonian. See KNOWN_LIMITATIONS.md, “Automatic grid symmetry — strains are symmetry inputs (deliberate deviation from EasySpin, 0.9.24)”.

  • Threshold (float, default 1e-4) – Relative intensity cutoff: transitions whose intensity stays below Threshold times the strongest are discarded. Read by pepper, pepper_autograd, salt, chili and the resonance-field solvers, not by garlic. In salt() (all matrix paths) a level pair is kept if its nuclear-moment rate summed over the TPSGridSymm/TPSGridSize grid exceeds Threshold times the maximum.

  • Verbosity (int, default 0) – Progress messages printed to stdout: 0 = silent, 1 = progress, 2 = detailed (pepper, garlic, salt, chili, cardamom).

  • BatchSize (int, optional) – Orientations per batched resonance search (pepper, pepper_autograd, salt). None (default) = automatic: all orientations at once, capped so that the batched Hamiltonians (orientations x field knots x dim^2) stay below about 400 MB; for pepper’s matrix method that is 96 orientations per batch at dimension 36 and 24 at dimension 72. 1 processes orientations one at a time (debugging, low memory).

  • EquivalentNuclei (bool, default True) – pepper, Method='matrix': nuclei with the same isotope, hyperfine tensor and frame, and without quadrupole coupling, enter the Hamiltonian only through their total spin, so each such set is simulated as its total-spin blocks (three 14N: K = 3, 2, 1, 0) and the block spectra are summed. This is exact, much faster (dimension 7 in place of 27 for three 14N) and avoids the exactly degenerate levels of the full space, in which single-transition intensities are arbitrary (see KNOWN_LIMITATIONS.md). It also lets the matrix method take SpinSystem.n > 1. False diagonalizes the full space (the behavior up to 0.9.38). Not applied with nn, H0Extra, a full-space initState, Transitions given as level pairs, or separate other than '' and 'components'.

  • Sites (list of int, optional) – pepper single-crystal simulations only: 1-based indices of the symmetry-related crystal sites to include. None (default) = all sites. Cannot be combined with Experiment.Orientations.

  • separate (str, default '') – Return separate spectra instead of their sum (pepper, garlic). '' = one summed spectrum. 'components': one row per component and isotopologue (pepper, garlic). pepper also accepts 'transitions' (one row per transition; not for crystals or Experiment.Orientations), 'orientations' (one row per crystal sample orientation or per Experiment.Orientations entry) and 'sites' (one row per crystal site). Rows are stacked along axis 0 of the returned spectrum.

  • IsoCutoff (float, default 1e-4) – Isotopologues whose abundance is below this fraction of the most abundant one are dropped from the isotope-mixture expansion (SpinSystem.Nucs entries such as 'Cu' or '(63,65)Cu'). Read by pepper, garlic and chili.

  • Stretch (float, default 0.25) – garlic only. Padding of the automatic sweep range (when Experiment.Range/mwRange is None), as a fraction of the spread of the line positions.

  • ModellingAccuracy (float, default 2e-6) – Accuracy of the segment model of the pepper matrix resonance-field search, relative to mwFreq.

  • RediagLimit (float, default 0.999) – pepper matrix route, spin systems of dimension 16 or more: at a resonance, the two transition eigenvectors are interpolated between the neighboring field knots (cubic Hermite, with the eigenvector derivatives from perturbation theory) when both states overlap with themselves across the segment by at least this much, and the field gets a Rayleigh-quotient Newton step; otherwise, and whenever a transition level is degenerate at a knot, the Hamiltonian is diagonalized at the resonance. RediagLimit >= 1 diagonalizes at every resonance (exact, as before 0.9.39). At the default, spectra differed from exact by <= 6.3e-7 of the maximum in the 18 cases checked (S = 1/2 to 7/2, dimensions 16 to 216, coupled dimers, strain, 5 K populations) at 1.0-2.0x the speed; 0.99 was as fast but reached 1e-4 for Cu(II) + 14N. Smaller systems and gradient runs always diagonalize. EasySpin Opt.RediagLimit (default 0.95 there, with linear interpolation).

  • device (str, default 'cpu') – torch device for the large tensors (pepper, pepper_autograd, salt, saffron). A 'cuda' device without CUDA available falls back to 'cpu' with a RuntimeWarning.

  • QuadraticZeeman (bool, default False) – Include the field-quadratic and field-cubic terms of SpinSystem.Ham (orders lB = 2 and 3) in the resonance search, so that the field-dependent Hamiltonian equals ham(sys, B). False: these terms are dropped. Supported by pepper and pepper_autograd with Method='matrix' (field and frequency sweeps, powders and crystals) and by resfreqs_matrix(); the perturbation and hybrid methods, resfields(), garlic and salt raise NotImplementedError when it is on and such terms are present. Transition moments stay those of the linear moment operators. See KNOWN_LIMITATIONS.md, “Simulator — field-quadratic Zeeman terms, Options.QuadraticZeeman (0.7.1)”.

  • Enhancement (bool, default False) – endorfrq() and salt only. False: the rf transition operator is the nuclear magnetic moment. True: the total (electron + nuclear) magnetic moment, which includes hyperfine enhancement; salt then always uses its matrix ENDOR path, and endorfrq_perturb() raises. Transition selection still uses the nuclear-only rates, and electronic (EPR) level pairs are excluded. See KNOWN_LIMITATIONS.md, “ENDOR — hyperfine enhancement (Options.Enhancement, 0.7.3)”.

  • ZeroField (bool, default False) – pepper frequency sweeps and salt fixed-field ENDOR only. True allows Experiment.Field = 0 (zero-field EPR/FDMR, zero-field ENDOR): degenerate levels are grouped into clusters (relative tolerance 1e-9 of the level spread) and each transition between two clusters carries the summed rate of its level pairs, so intensities do not depend on the eigenbasis inside a degenerate subspace; the isotropic O3 shortcut is replaced by a D2h grid. See KNOWN_LIMITATIONS.md, “Pepper and salt — zero field, Options.ZeroField (0.7.4)”.

  • Transitions (str or list of tuple of int, optional) – Transition selection for pepper, pepper_autograd and the ENDOR matrix paths of endorfrq and salt. None (default): automatic pre-selection with Threshold. 'all': every level pair u < v, without pre-selection and without the Threshold post-selection. A list of 1-based level pairs (u, v) (levels numbered by ascending energy at the resonance field): exactly those transitions, normalized to u < v with duplicates removed; the Threshold post-selection still applies. With Method='hybrid' the levels are those of the exact core. Not available with Method='perturb*' or salt’s ZeroField (raises). See KNOWN_LIMITATIONS.md, “Simulator — transition selection, Options.Transitions (0.7.5)”.

  • PaddingMultiplier (float, default 3.0) – pepper, pepper_autograd and salt. When the spectrum is nonzero at the first or last point, both ends are extended by round(PaddingMultiplier * max(lw) / increment) copies of the edge values before the final line-width convolution and cropped afterwards, so the convolution does not see a step to zero. 0 disables the padding. Must be a finite number >= 0. See KNOWN_LIMITATIONS.md, “Pepper and salt — range padding, Options.PaddingMultiplier (0.9.6)”.

  • TPSGridSymm (str, default 'D2h') – endorfrq and salt only. Symmetry of the coarse molecular-frame grid on which the automatic ENDOR transition selection sums the nuclear-moment rates (independent of GridSize).

  • TPSGridSize (int, default 4) – endorfrq and salt only. Size of that grid.

Raises:

ValueError – On construction, if Method or AccumMethod is not one of the accepted names; GridSize is not an integer >= 2 or a list [N_coarse >= 2, N_interp >= 1]; PaddingMultiplier is not a finite number >= 0; or GridSymmetry is not 'auto', '' or one of the grid symmetries listed above.

Warns:

RuntimeWarning – If device names a CUDA device and CUDA is not available (device is then set to 'cpu').

See also

Experiment, SpinSystem, torchspin.pepper.pepper, torchspin.garlic.garlic

Examples

>>> from torchspin import Options
>>> opt = Options(GridSize=[31, 4], Method='perturb')
>>> opt.grid_size_coarse, opt.grid_size_interp
(31, 4)
>>> Options(GridSize=31).grid_size_interp
1
property grid_size_coarse: int[source]#

Coarse grid knot count (N_coarse from GridSize).

property grid_size_interp: int[source]#

Interpolation factor (N_interp from GridSize, 1 = no interpolation).

See also

grid_convergence() checks whether GridSize is fine enough for a given spectrum. Pitfalls lists valid settings that quietly degrade a result.