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 (Nucsgiven as elements such as'Cu'or mixtures such as'(63,65)Cu'), each weighted by its abundance and dropped belowOptions.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(withgAStrainCorr,DStrainCorr) give orientation-dependent Gaussian widths per line,HStrainLLorentzian ones. Also read:weight,Abund,n(onlyMethod='perturb*'/'hybrid'; the matrix method raises forn > 1),initState(not with perturbation theory),tdm(withExperiment.lightBeam). Dynamics, relaxation and pulse fields (tcorr,Diff,T1,T2,lwEndor,Potential, …) are ignored.exp (Experiment) – Sweep and sample. Field sweep:
mwFreq(GHz) andRangeorCenterSweep(mT;None= automatic range for S = 1/2 systems). Frequency sweep:Field(mT) withmwRange/mwCenterSweep(GHz;None= automatic range);Fieldalone is a frequency sweep with automatic range. Also read:nPoints,Harmonic,ModAmp(field sweeps),mwPhase,Temperature,Mode/mwMode; single crystals:MolFrameand/orCrystalSymmetry(either makes the sample a crystal),SampleFrame,SampleRotation; ordered samples:Ordering; photoselection:lightBeam,lightScatter; explicit orientations:Orientations,OrientationWeights.SampleFrameorSampleRotationalone leave a powder unchanged.ExciteWidthis ignored.opt (Options, optional) – Default
None=Options(). Read:Method('matrix','exact','perturb'/'perturb1'/'perturb2','hybrid'withHybridCoreNuclei,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 harmonicExperiment.Harmonic. WithOptions.separateset, 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 ofpepper_autograd()on the autograd graph.
- Raises:
ValueError – For an unsupported combination of inputs, among others:
Method='perturb3'to'perturb5';n > 1with the matrix method;Rangemissing for a system that is not a single S = 1/2 (or has a zero g value);ModAmpwith a frequency sweep or withHarmonic = 0;Method='hybrid'with a frequency sweep,nncouplings,H0Extraor a core nucleus withn > 1;TransitionsorinitStatewith perturbation theory; an invalidTransitionslist;Field = 0withoutZeroField=True, orZeroFieldwithinitState;OrderingwithMolFrame/CrystalSymmetry, several sample orientations or a non-Ci grid;Orientationswith crystal, ordering,Sitesorseparate='transitions'/'sites';separate='transitions'for a crystal;lightBeamwithouttdmor with an unknown string;HStrainLwith the Gaussian strains; multi-electronAStrain(orgStrainin a frequency sweep).NotImplementedError –
QuadraticZeeman=Truewith field-quadraticHamterms 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_autogradThe differentiable path.
torchspin.garlic.garlicIsotropic and fast-motion spectra.
torchspin.chili.chiliSlow-motion spectra.
torchspin.gridcheck.grid_convergenceCheck
Options.GridSize.
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/Experimenttensor requires grad, pepper runspepper_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
Harmonicfalls 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 (
lwin 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.