pepper#

Solid-state (powder or single-crystal) CW EPR spectra in the rigid limit, field- or frequency-swept.

torchspin.pepper(sys_or_list, exp, opt=None)[source]#

Solid-state CW EPR spectrum (EasySpin pepper).

Simulates the field-swept or frequency-swept CW EPR spectrum of a powder (SOPHE grid with interpolation and projection), a single crystal, a partially ordered sample, or a user-given set of orientations, by finding resonance fields (or frequencies) and transition rates for each orientation and accumulating broadened lines.

A list of spin systems is simulated component by component and summed with weights SpinSystem.weight. Every component is first expanded into isotopologues (Nucs given as elements such as 'Cu' or mixtures such as '(63,65)Cu'), each weighted by its abundance and dropped below Options.IsoCutoff.

Parameters:
  • sys_or_list (SpinSystem or list of SpinSystem) – Spin system(s). pepper builds the full spin Hamiltonian with torchspin.ham(), so every interaction field is used (g, D, B, A, Q, ee, nn, sigma, gnscale, frames, OAM and crystal-field terms, Ham, H0Extra). Line widths: lw/lwpp [GaussianFWHM, LorentzianFWHM] in mT for field sweeps and in MHz for frequency sweeps, convolved after the accumulation; HStrain, gStrain, AStrain, DStrain (with gAStrainCorr, DStrainCorr) give orientation-dependent Gaussian widths per line, HStrainL Lorentzian ones. Also read: weight, Abund, n (only Method='perturb*'/'hybrid'; the matrix method raises for n > 1), initState (not with perturbation theory), tdm (with Experiment.lightBeam). Dynamics, relaxation and pulse fields (tcorr, Diff, T1, T2, lwEndor, Potential, …) are ignored.

  • exp (Experiment) – Sweep and sample. Field sweep: mwFreq (GHz) and Range or CenterSweep (mT; None = automatic range for S = 1/2 systems). Frequency sweep: Field (mT) with mwRange/mwCenterSweep (GHz; None = automatic range); Field alone is a frequency sweep with automatic range. Also read: nPoints, Harmonic, ModAmp (field sweeps), mwPhase, Temperature, Mode/mwMode; single crystals: MolFrame and/or CrystalSymmetry (either makes the sample a crystal), SampleFrame, SampleRotation; ordered samples: Ordering; photoselection: lightBeam, lightScatter; explicit orientations: Orientations, OrientationWeights. SampleFrame or SampleRotation alone leave a powder unchanged. ExciteWidth is ignored.

  • opt (Options, optional) – Default None = Options(). Read: Method ('matrix', 'exact', 'perturb'/'perturb1'/'perturb2', 'hybrid' with HybridCoreNuclei, HybridIntThreshold), GridSize, GridSymmetry, Threshold, Transitions, separate, Sites, IsoCutoff, ModellingAccuracy, QuadraticZeeman, ZeroField, PaddingMultiplier, BatchSize, device, Verbosity. garlic- and ENDOR-only options are ignored.

Returns:

  • x (torch.Tensor, shape (nPoints,)) – Sweep axis, float64: magnetic field in mT for a field sweep, microwave frequency in GHz for a frequency sweep; equally spaced from the first to the last point of the (possibly automatic) range.

  • spec (torch.Tensor, shape (nPoints,) or (nSpectra, nPoints)) – Spectrum, float64, on EasySpin’s pepper intensity scale (arbitrary units, comparable between simulations), at the detection harmonic Experiment.Harmonic. With Options.separate set, one row per component/isotopologue, transition, crystal orientation or site, stacked along axis 0 (for a list of components the rows of all components are concatenated). When an input requires grad, the result of pepper_autograd() on the autograd graph.

Raises:
  • ValueError – For an unsupported combination of inputs, among others: Method='perturb3' to 'perturb5'; n > 1 with the matrix method; Range missing for a system that is not a single S = 1/2 (or has a zero g value); ModAmp with a frequency sweep or with Harmonic = 0; Method='hybrid' with a frequency sweep, nn couplings, H0Extra or a core nucleus with n > 1; Transitions or initState with perturbation theory; an invalid Transitions list; Field = 0 without ZeroField=True, or ZeroField with initState; Ordering with MolFrame/CrystalSymmetry, several sample orientations or a non-Ci grid; Orientations with crystal, ordering, Sites or separate='transitions'/'sites'; separate='transitions' for a crystal; lightBeam without tdm or with an unknown string; HStrainL with the Gaussian strains; multi-electron AStrain (or gStrain in a frequency sweep).

  • NotImplementedError – QuadraticZeeman=True with field-quadratic Ham terms and a perturbation or hybrid method; a configuration the differentiable path does not support when an input requires grad.

See also

torchspin.pepper_autograd.pepper_autograd

The differentiable path.

torchspin.garlic.garlic

Isotropic and fast-motion spectra.

torchspin.chili.chili

Slow-motion spectra.

torchspin.gridcheck.grid_convergence

Check Options.GridSize.

SpinSystem, Experiment, Options

Notes

  • Methods: 'matrix' is exact. Second-order perturbation theory is inaccurate when a hyperfine coupling is a sizable fraction of the microwave frequency: for isotropic 91Zr with A = 780 MHz at 9.65 GHz (A/nu = 0.08), 'perturb' differs from 'matrix' by 0.18 relative L2. See KNOWN_LIMITATIONS.md, “Pepper — choosing a method, and what each costs (2026-10-07)”.

  • If any SpinSystem/Experiment tensor requires grad, pepper runs pepper_autograd() instead and returns a spectrum on the autograd graph (KNOWN_LIMITATIONS.md, “Autograd — differentiable pepper”).

  • With neither line width nor strain the spectrum is a stick/projection absorption spectrum and Harmonic falls back to 0 (EasySpin raises when a harmonic is requested explicitly).

  • Line widths (lw) are applied by FFT convolution after accumulation, with edge padding (Options.PaddingMultiplier); strain widths are added per line. See KNOWN_LIMITATIONS.md, “Pepper — final line-width convolution (0.8.5)”.

  • Powder averaging uses the SOPHE grid (Wang & Hanson, 1995) with EasySpin’s grid interpolation and triangle/zone projection.

  • Validated against EasySpin (MATLAB) reference spectra (torchspin/tests/test_pepper*_matlab_validation*.py).

Examples

A nitroxide at X band (first-derivative field sweep):

>>> from torchspin import SpinSystem, Experiment, Options, pepper
>>> sys = SpinSystem(S=0.5, g=[2.0088, 2.0061, 2.0027], Nucs='14N',
...                  A=[20.0, 20.0, 95.0], lw=0.5)
>>> exp = Experiment(mwFreq=9.5, Range=[330.0, 345.0], nPoints=512)
>>> B, spc = pepper(sys, exp)
>>> B.shape, spc.shape, float(B[0]), float(B[-1])
(torch.Size([512]), torch.Size([512]), 330.0, 345.0)

Two components weighted 70:30, returned separately:

>>> sys_a = SpinSystem(S=0.5, g=[2.0, 2.1, 2.2], lw=1.0, weight=0.7)
>>> sys_b = SpinSystem(S=0.5, g=2.0037, lw=0.8, weight=0.3)
>>> exp = Experiment(mwFreq=9.5, Range=[300.0, 350.0], nPoints=256)
>>> B, spc = pepper([sys_a, sys_b], exp, Options(separate='components'))
>>> spc.shape
torch.Size([2, 256])

A frequency sweep at fixed field (lw in MHz; absorption by default):

>>> exp = Experiment(Field=340.0, mwRange=[9.4, 9.7], nPoints=300)
>>> nu, spc = pepper(SpinSystem(S=0.5, g=[2.0, 2.0, 2.05], lw=10.0), exp)
>>> round(float(nu[0]), 2), round(float(nu[-1]), 2), exp.Harmonic
(9.4, 9.7, 0)

See also

differentiable_spectrum() for gradients with respect to spin Hamiltonian parameters, grid_convergence() to check the orientation grid, and TorchSpin — EPR Simulation Quickstart and TorchSpin — pepper playground: simulate, then fit with every esfit method for worked examples.