Experiment#

An Experiment describes the measurement (EasySpin’s Exp): microwave frequency and field range for field-swept spectra, or a fixed field and frequency range for frequency-swept ones, plus harmonic, modulation amplitude, temperature, and sample orientation.

Units: microwave frequency in GHz, fields in mT, temperature in K.

class torchspin.Experiment(mwFreq=None, Range=None, CenterSweep=None, mwCenterSweep=None, ModAmp=0.0, SampleFrame=None, CrystalSymmetry=None, MolFrame=None, SampleRotation=None, nPoints=1024, Harmonic=None, mwPhase=0.0, Temperature=None, lightBeam=None, lightScatter=0.0, Ordering=None, Mode='perpendicular', mwMode=None, Field=None, mwRange=None, ExciteWidth=None, Orientations=None, OrientationWeights=None)[source]#

Experimental parameters for CW EPR simulations (EasySpin Exp).

One Experiment describes the sweep, the detection and the sample. The sweep mode follows from which fields are set:

  • Field sweep (the default): set mwFreq (GHz) and Range or CenterSweep (mT). The simulators return a field axis in mT.

  • Frequency sweep: set Field (mT) and mwRange or mwCenterSweep (GHz); Range is not used. The simulators return a frequency axis in GHz.

  • Fixed field (ENDOR): set Field only. salt() runs fixed-field ENDOR; pepper() treats this as a frequency sweep with an automatic range.

Fields are validated on construction (see Raises). A field that a simulator does not read is ignored by it; the “Read by” notes below list the CW simulators that use each field.

Parameters:
  • mwFreq (float, optional) – Microwave frequency in GHz. Required (> 0) for field sweeps; not used by frequency sweeps. Default None.

  • Range (list of float, optional) – Field sweep range [Bmin, Bmax] in mT, Bmin < Bmax. Default None: pepper() and garlic() then choose the range automatically (pepper: S = 1/2 systems only, from the g and A extremes).

  • CenterSweep (list of float, optional) – Alternative to Range: [center, sweep_width] in mT, width > 0. Converted to Range = [center - width/2, center + width/2] on construction. Default None.

  • mwCenterSweep (list of float, optional) – Alternative to mwRange: [center, sweep_width] in GHz, width > 0. Converted to mwRange on construction. Default None.

  • ModAmp (float, default 0.0) – Peak-to-peak field-modulation amplitude in mT. 0 = no modulation: the harmonic is produced by differentiating the line shape. > 0: the absorption spectrum is pseudo-modulated (torchspin.fieldmod()) at Harmonic; pepper and garlic raise ValueError for Harmonic = 0 and for frequency sweeps. None is read as 0. Read by pepper, garlic and chili.

  • SampleFrame (array_like, shape (3,) or (N, 3), optional) – Euler angles [alpha, beta, gamma] in radians of the lab-to-sample frame transformation, one row per sample orientation. In pepper this describes a single crystal only together with MolFrame or CrystalSymmetry; on its own it leaves a disordered (powder) sample unchanged. Also read by chili. Default None (no rotation).

  • CrystalSymmetry (int or str, optional) – Crystal symmetry of a single crystal: space-group number (1-230), space-group symbol or point-group symbol (e.g. 'P21/c', 'C2h'). Determines the symmetry-related sites; None with MolFrame set is space group P1 (one site). Setting it makes pepper simulate a crystal. Default None.

  • MolFrame (array_like, shape (3,), optional) – Euler angles in radians of the sample-to-molecular frame transformation of a single crystal. Setting it makes pepper simulate a crystal. Default None.

  • SampleRotation (tuple, optional) – (axis, rho): rotate the sample about axis ('x', 'y', 'z' or a lab-frame 3-vector) by rho radians (a scalar or a list of angles, one sample orientation each). pepper only. Default None.

  • nPoints (int, default 1024) – Number of points of the sweep axis, at least 2.

  • Harmonic (int, optional) – Detection harmonic: 0 = absorption, 1 = first derivative, 2 = second derivative. Default None, resolved on construction to 1 for a field sweep and to 0 otherwise (frequency sweep or fixed field), whether or not mwFreq is also given. pepper falls back to 0 when the system has no line width and no strain.

  • mwPhase (float, default 0.0) – Detection phase in radians: 0 = absorption, pi/2 = dispersion. Read by pepper, garlic and chili.

  • Temperature (float, optional) – Sample temperature in K for Boltzmann populations of the levels. None (default) = infinite temperature (equal populations). inf is the same as None; a value <= 0 raises ValueError.

  • lightBeam (str or tuple, optional) – Photoselection by a polarized light beam (pepper only; requires SpinSystem.tdm): ''/None (default, none), 'perpendicular' or 'parallel' (beam along the lab y axis, linear polarization perpendicular or parallel to B0), 'unpolarized', or (k, alpha) with the propagation direction k (lab frame: a direction string such as 'y' or '-z', a 3-vector or [phi, theta]) and the angle alpha of the electric field in the plane perpendicular to k (radians, nan = unpolarized).

  • lightScatter (float, default 0.0) – Isotropic fraction of the photoselection weights, between 0 and 1: weight = (1 - lightScatter) * w + lightScatter. A value >= 1 switches photoselection off. pepper only.

  • Ordering (float or callable, optional) – Partial ordering of a disordered sample (pepper only). A scalar lambda gives the axial distribution exp(lambda * P2(cos beta)); a callable f(alpha, beta, gamma) or f(beta) (Euler angles in radians, sample to molecular frame, array arguments) returns the orientational weights. Requires a Ci grid; cannot be combined with MolFrame, CrystalSymmetry or Orientations. Default None (isotropic powder).

  • Mode (str, default 'perpendicular') – Microwave excitation geometry: 'perpendicular' (B1 perpendicular to B0, standard CW EPR, mainly Delta m_S = +-1 transitions) or 'parallel' (B1 parallel to B0, Delta m_S = 0 transitions, e.g. integer-spin systems). Used when mwMode is None.

  • mwMode (str or tuple, optional) – EasySpin’s Exp.mwMode; overrides Mode when set (pepper and the resonance-field solvers; garlic reads Mode only). 'perpendicular', 'parallel' or (k, mode2) with the propagation direction k ('x'/'y'/'z' with optional sign, a 3-vector, [phi, theta] or one polar angle, radians) and mode2 the linear polarization angle (radians) or one of 'unpolarized', 'circular+', 'circular-'. Default None.

  • Field (float, optional) – Static field in mT for frequency sweeps and fixed-field (ENDOR) experiments; None (default) for field sweeps. Must be >= 0; Field = 0 is accepted only by pepper frequency sweeps and salt with Options(ZeroField=True); every other simulator, and pepper or salt without that option, raises ValueError when called.

  • mwRange (list of float, optional) – Frequency sweep range [nu_lo, nu_hi] in GHz, nu_lo < nu_hi. Requires Field. Default None.

  • ExciteWidth (float, optional) – Microwave excitation bandwidth (FWHM) in MHz for orientation selection in fixed-field experiments (salt ENDOR, orisel, saffron). None (default) = no orientation selection; orisel() requires it (math.inf = no selection).

  • Orientations (array_like or Tensor, shape (N, 2), optional) – pepper and orisel only. Field directions [phi, theta] in radians in the molecular frame: B0 points along (sin(theta) cos(phi), sin(theta) sin(phi), cos(theta)), the convention of levels(sys, phi, theta, B) and resfields. A single [phi, theta] pair is N = 1. pepper then sums the stick spectra of these orientations, each with the powder (B1 averaged about B0) transition rates, without grid interpolation or SOPHE projection; Options.GridSize/GridSymmetry are ignored. Cannot be combined with Ordering, SampleFrame, SampleRotation, MolFrame, CrystalSymmetry, Options.Sites or Options.separate='transitions'/'sites'. orisel returns one weight per orientation. None (default) = powder average on the simulator’s grid. Tensors are kept as given (may require grad); other inputs are converted to float arrays.

  • OrientationWeights (array_like or Tensor, shape (N,), optional) – pepper only; requires Orientations. Non-negative, finite weights, not all zero, used as given (not renormalized): each is the fraction of the full sphere its orientation stands for, so weights summing to 1 give the amplitude of pepper’s powder spectrum (a solid-angle quadrature of the sphere divided by 4 pi reproduces the powder). None (default) = equal weights 1/N. May be a tensor that requires grad (pepper_autograd).

Raises:

ValueError – On construction, if Range and CenterSweep (or mwRange and mwCenterSweep) are both given; a CenterSweep/mwCenterSweep is not [center, width] with width > 0; ModAmp < 0; Field < 0 in a frequency sweep or fixed-field experiment; mwRange (frequency sweep) or Range (field sweep) is not an increasing pair; a field sweep has no positive mwFreq; Harmonic is not 0, 1 or 2; nPoints < 2; Temperature <= 0; or Orientations/OrientationWeights have the wrong shape, are not finite, or the weights are negative or all zero (or given without Orientations).

See also

Options, SpinSystem, torchspin.pepper.pepper, torchspin.garlic.garlic

Notes

Single-crystal and ordered-sample conventions follow EasySpin; see KNOWN_LIMITATIONS.md, “Simulator — user-supplied orientations in pepper (0.7.6)” for Orientations and “Pepper and salt — zero field, Options.ZeroField (0.7.4)” for Field = 0.

Examples

A field sweep at X band; Harmonic defaults to the first derivative:

>>> from torchspin import Experiment
>>> exp = Experiment(mwFreq=9.5, CenterSweep=[340.0, 20.0], nPoints=512)
>>> exp.Range, exp.Harmonic
([330.0, 350.0], 1)

A frequency sweep at a fixed field; Harmonic defaults to absorption:

>>> exp = Experiment(Field=340.0, mwRange=[9.3, 9.7])
>>> exp.is_freq_swept, exp.Harmonic
(True, 0)
property is_freq_swept: bool[source]#

True when Field and mwRange are both set (frequency-swept mode).

property is_fixed_field: bool[source]#

True when only Field is set (fixed-field mode, e.g. ENDOR).

See also

Options for computational settings, PulseExperiment for pulse experiments in saffron().