torchspin.lft.ddpowh#

DDPOWH: powder EPR, FDMR, ENDOR and NMR/NQR spectra at field points, with Telser’s level strain.

Torch port of Josh Telser’s DDPOWH in its exact mode (via telser-tools, telser_tools_diff.ddpowh), on a torchspin SpinSystem. The Hamiltonian is torchspin’s (ham: H = H0 - B n.mu), plus two optional Telser terms that torchspin’s core does not carry yet (zeeman2 for the second-order Zeeman w (mu_B B.S)^2 and h0_extra for the I.S^3 hyperfine U; torchspin.lft.telser2torchspin builds both). Unlike pepper no resonance field is searched: for every orientation n of the grid and every field B of the sweep, H(B n) is diagonalized and every selected level pair (i, j) adds:

y(B) += w(n) P_ij pop_ij F(nu_ij) f(nu_ij(B) - nu_mw; W_ij(n, B))
  • f: Telser’s DLINE.F line (Gaussian or Lorentzian, HWHM W, cut at cutoff half widths), evaluated in the frequency domain at each field point. The field-swept line is the frequency line mapped through the exact nu_ij(B), so curved and looping levels need no linearization (the 1/abs(d nu/dB) weight is implicit).

  • W_ij(n, B) = W(n) (B/B_set)^b (1 + [sqrt(sum_b abs(c_bi)^2 w_b) + sqrt(sum_b abs(c_bj)^2 w_b)]/2) with W(n)^2 = sum_k W_k^2 n_k^2. The square brackets are Telser’s level strain: w_b is a weight per basis state |m_S, m_I> and c_bi the components of level i, so the width of a transition depends on what its two levels are made of. strain_weights() builds DDPOWH’s w_b = WMS(m_S) + WMI(m_I); torchspin.lft.ddpowj.strain_weights() DDPOWJ’s product WMS1(m_1) WMS2(m_2).

  • P_ij: the B1-averaged abs(<i|mu|j>)^2 / mu_B^2 (perpendicular mode; parallel for h1mode < 0; perpendicular + h1mode x parallel for h1mode > 0). With moment='electron' (default, Telser’s) mu is the electron Zeeman moment only (g.S: no nuclear moment, no third-order Zeeman u); with moment='full' it is torchspin’s -dH/dB moment.

  • pop_ij = p_i - p_j: Boltzmann populations at temperature (normalized; None: no populations).

  • F(nu) = nu (Gaussian) or nu^3/nu_mw^2 (Lorentzian), nu in cm^-1: the Flygare frequency factor (frequency_factor=False removes it, as in EasySpin/pepper).

  • w(n): the grid weight times the partial-orientation factor exp(lam_x cos^2 phi + lam_z cos^2 theta) (ordering=(lam_x, lam_z)).

Functions: epr() (field sweep), fdmr() (frequency sweep at one field, zero field included), endor() (rf sweep at one field, orientation selection by the EPR line) and nmr() (S = 0 NMR/NQR, Telser’s DDPOWH NMR mode, with the chemical shielding sigma_k in kHz).

Units#

Fields in mT, microwave frequency in GHz, temperature in K, rf axes in MHz. width, nmr_width and the FDMR axis are in units (default 'MHz'; 'cm^-1', 'GHz', … via torchspin.lft.units). Intensities are DDPOWH’s exact-mode values (P as above, the line in 1/MHz, F in cm^-1), except that field-derivative spectra are d/dB per mT (10x DDPOWH’s per-gauss values). constants (a SpinConstants) sets mu_B (P normalization), k_B and cm^-1 -> MHz; parity tests pass telser-tools’ CODATA 2018 values through SpinConstants.from_telser().

Example (an S = 3/2 system with D = 6000 MHz whose +-3/2 levels are broadened by level strain):

>>> import torch
>>> from torchspin import SpinSystem
>>> from torchspin.lft import ddpowh
>>> sys = SpinSystem(S=1.5, g=[2.0, 2.0, 2.0], D=[-2000., -2000., 4000.])   # MHz
>>> w = ddpowh.strain_weights(sys, ms=[1.0, 0.0, 0.0, 1.0])
>>> res = ddpowh.epr(sys, torch.linspace(50, 450, 201), 9.5, width=60.0,
...                  strain=ddpowh.Strain(w), igloo=6)
>>> res.spectrum.shape, res.n_orientations
(torch.Size([201]), 98)

Gradients#

Every tensor parameter of the SpinSystem that ham keeps on the graph (g, D, A, Q principal values, full tensors, ee, the Euler frames …), the widths, the strain weights, b, B_set, the microwave frequency, the temperature, ordering, zeeman2, h0_extra, the shielding and scale carry gradients. Eigenvalues and eigenvectors come from torchspin.lft._linalg.eigh_gauge. Discrete choices are made on detached values: which (orientation, field) points carry a line (the cutoff), the window of each FDMR/ENDOR line and the ENDOR selection sign test.

Strain inside a degenerate level (e.g. zero field with isotropic exchange) uses per-state weights, which are basis dependent there, as in Telser’s program.

Not ported (Fortran reproduction, see telser-tools docs/FINDINGS.md): EPRTRANS/NMRTRANS probabilities, the Fortran thresholds, the IEND/JEND strain bug (DDPOWH-06), the sqrt(ICUTOFF) cut is available as exact_cutoff=False, the original phi windows as grid='fortran', d/dnu derivatives as field_derivative=False and unnormalized populations as normalized_populations=False.

class torchspin.lft.ddpowh.SpinConstants(mu_b, k_b, mhz_per_cm)[source]#

Physical constants used by the DDPOWH/DDPOWJ simulations.

Variables:
  • mu_b (float) – Bohr magneton over Planck’s constant, mu_B/h, in MHz per mT (normalizes the transition probabilities P).

  • k_b (float) – Boltzmann constant over Planck’s constant, k_B/h, in MHz per K.

  • mhz_per_cm (float) – MHz per cm^-1 (energy conversion of widths, axes and the Flygare frequency factor).

See also

TORCHSPIN_CONSTANTS

torchspin’s CODATA values.

mu_b: float#

Alias for field number 0

k_b: float#

Alias for field number 1

mhz_per_cm: float#

Alias for field number 2

classmethod from_telser(c)[source]#

Build from a telser-tools Constants-like object.

Parameters:

c (object) – Any object with attributes mu_b_mhz (MHz per gauss), mu_b_cm (cm^-1 per gauss) and k_b_cm (cm^-1 per K), e.g. telser-tools’ CODATA 2018 constants (used by the parity tests).

Returns:

SpinConstants – mu_b = 10 * mu_b_mhz (MHz/mT), mhz_per_cm = mu_b_mhz / mu_b_cm and k_b = k_b_cm * mhz_per_cm.

Return type:

SpinConstants

torchspin.lft.ddpowh.TORCHSPIN_CONSTANTS = (13.996244917056908, 20836.619123327575, 29979.245800000004)#

Derived from torchspin.constants (CODATA 2022 mu_B).

class torchspin.lft.ddpowh.Strain(weights, b=0.0, field=1.0)[source]#

Telser’s level strain of a DDPOWH/DDPOWJ EPR line.

The half width of the line between levels i and j at field B is W(n) (B/B_set)^b (1 + [sqrt(sum_b abs(c_bi)^2 w_b) + sqrt(sum_b abs(c_bj)^2 w_b)]/2), where c_bi are the components of level i in the basis state b and w_b are the basis weights.

Variables:
  • weights (Tensor, shape (nStates,)) – One weight per basis state of the SpinSystem (nStates = sys.nStates, states |m_S1, m_S2, ..., m_I1, ...> with every m descending, torchspin’s order), dimensionless. Built by strain_weights() (DDPOWH) or torchspin.lft.ddpowj.strain_weights() (DDPOWJ). May require grad.

  • b (float or Tensor, default 0.0) – Field exponent of the width.

  • field (float or Tensor, default 1.0) – Reference field B_set in mT; only used when b != 0.

weights: Tensor#

Alias for field number 0

b: float | Tensor#

Alias for field number 1

field: float | Tensor#

Alias for field number 2

class torchspin.lft.ddpowh.PowderResult(axis, spectrum, n_orientations, grid)[source]#

Result of epr(), fdmr(), endor() and nmr().

Variables:
  • axis (Tensor, shape (npts,)) – The sweep axis as used: fields in mT (epr()), energies in units (fdmr()) or radio frequencies in MHz (endor(), nmr()); detached, float64.

  • spectrum (Tensor, shape (npts,)) – The spectrum on axis (DDPOWH’s exact-mode intensity scale, see the module docstring), on the autograd graph of differentiable inputs.

  • n_orientations (int) – Number of grid orientations.

  • grid (Grid) – The orientation grid (theta, phi in radians, weight, unit directions (n_orientations, 3), …).

axis: Tensor#

Alias for field number 0

spectrum: Tensor#

Alias for field number 1

n_orientations: int#

Alias for field number 2

grid: Grid#

Alias for field number 3

torchspin.lft.ddpowh.strain_weights(sys, ms=None, mi=None, *, electron=0, nucleus=0)[source]#

DDPOWH’s basis-state strain weights w_b = WMS(m_S) + WMI(m_I).

Parameters:
  • sys (SpinSystem) – The spin system; one weight is returned per basis state.

  • ms (array_like or Tensor, shape (2S+1,), optional) – WMS for m_S = S, S-1, ..., -S of electron electron (Telser’s input order), dimensionless. None: zeros.

  • mi (array_like or Tensor, shape (2I+1,), optional) – WMI for m_I = I, ..., -I of nucleus nucleus. None: zeros.

  • electron (int, default 0) – 0-based electron index for ms.

  • nucleus (int, default 0) – 0-based nucleus index for mi.

Returns:

torch.Tensor, shape (nStates,) – The weights in torchspin’s basis order, float64; tensor inputs keep their graph.

Raises:

ValueError – If ms/mi does not have 2S+1/2I+1 values, or if the electron or nucleus does not exist and more than one value is given (a single value for an absent spin, Telser’s WMI(1) without a nucleus, is added to every state).

Return type:

Tensor

Examples

>>> from torchspin import SpinSystem
>>> from torchspin.lft import ddpowh
>>> sys = SpinSystem(S=0.5, Nucs='14N', A=[20.0, 20.0, 95.0])
>>> ddpowh.strain_weights(sys, ms=[1.0, 0.0], mi=[0.5, 0.0, 0.5]).tolist()
[1.5, 1.0, 1.5, 0.5, 0.0, 0.5]
torchspin.lft.ddpowh.manifold_pairs(ms_range, manifold_size)[source]#

DDPOWH’s level-range pair selection.

The levels, sorted by energy, are grouped in consecutive manifolds of manifold_size levels (Telser: 2I + 1, the m_S manifolds at high field). Level i runs over manifolds a to b, level j over c to d, and only i < j is kept.

Parameters:
  • ms_range (sequence of 4 int) – (a, b, c, d), 1-based manifold numbers; (1, 1, 2, 2) selects the transitions from the lowest manifold to the next.

  • manifold_size (int) – Levels per manifold.

Returns:

tuple of tuple of int – 0-based level pairs (i, j). (DDPOWJ’s default, all pairs, is all_pairs().)

Return type:

tuple[tuple[int, int], …]

Examples

>>> from torchspin.lft import ddpowh
>>> ddpowh.manifold_pairs((1, 1, 2, 2), 2)
((0, 2), (0, 3), (1, 2), (1, 3))
torchspin.lft.ddpowh.all_pairs(n)[source]#

Every level pair (i, j), i < j, of n levels.

Parameters:

n (int) – Number of levels.

Returns:

tuple of tuple of int – 0-based pairs of levels numbered by ascending energy.

Return type:

tuple[tuple[int, int], …]

Examples

>>> from torchspin.lft import ddpowh
>>> ddpowh.all_pairs(3)
((0, 1), (0, 2), (1, 2))
torchspin.lft.ddpowh.epr(sys, fields, mw_freq, *, width, shape='gaussian', derivative=False, cutoff=8, temperature=None, h1mode=0.0, pairs=None, strain=None, frequency_factor=True, igloo=10, extent='hemisphere', angle_range=None, degrees=False, ordering=None, grid='exact', field_derivative=True, normalized_populations=True, exact_cutoff=True, moment='electron', zeeman2=None, h0_extra=None, scale=1.0, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu', chunk_budget=4_000_000)[source]#

Field-swept powder (or partial-orientation) EPR spectrum at the field points fields.

For every grid orientation and every field point the Hamiltonian is diagonalized and every selected level pair adds a line evaluated in the frequency domain (see the module docstring for the intensity formula).

Parameters:
  • sys (SpinSystem) – Spin system; its Hamiltonian is built by torchspin.ham().

  • fields (array_like or Tensor, shape (npts,)) – Field points in mT (not differentiated). Telser’s axis is linspace(B_min, B_max, npts + 1).

  • mw_freq (float or Tensor) – Microwave frequency in GHz.

  • width (float or array_like, shape (3,)) – Line half width at half maximum (Wx, Wy, Wz) along the molecular axes, in units (frequency domain); a scalar is isotropic. The width for direction n is sqrt(sum_k W_k^2 n_k^2).

  • shape ({'gaussian', 'lorentzian'}, default 'gaussian') – Line shape (Telser’s DLINE.F; 'g'/'l' also accepted).

  • derivative (bool, default False) – First-derivative spectrum: d/dB per mT (field_derivative=False: the Fortran’s d/dnu).

  • cutoff (int, default 8) – Lines are cut at cutoff half widths.

  • temperature (float or Tensor, optional) – Temperature in K for Boltzmann population differences. None (default): no population factor.

  • h1mode (float, default 0.0) – Microwave mode: 0 perpendicular, < 0 parallel, > 0 perpendicular + h1mode x parallel.

  • pairs (sequence of (int, int), optional) – 0-based level pairs (i, j), i < j, levels numbered by ascending energy at each (orientation, field). None (default): all pairs. manifold_pairs() builds Telser’s m_S ranges.

  • strain (Strain, optional) – Telser’s level strain; None (default): width W(n) only.

  • frequency_factor (bool, default True) – Include the Flygare frequency factor (nu for Gaussian, nu^3/nu_mw^2 for Lorentzian lines, nu in cm^-1); False as EasySpin/pepper.

  • igloo (int, default 10) – Grid rings per 90 degrees of theta.

  • extent ({'hemisphere', 'octant'}, default 'hemisphere') – Powder grid extent: a hemisphere (general) or one octant (D2h systems; Telser’s NROT = 1).

  • angle_range (sequence of 4 float, optional) – (theta_min, theta_max, phi_min, phi_max): a restricted orientation range instead of the powder, in radians (degrees with degrees=True).

  • degrees (bool, default False) – angle_range is in degrees.

  • ordering (tuple of 2 float or Tensor, optional) – (lam_x, lam_z): orientation weight exp(lam_x cos^2(phi) + lam_z cos^2(theta)), applied whenever given (Telser applies it only with angle_range).

  • moment ({'electron', 'full'}, default 'electron') – Transition operator: the electron Zeeman moment g.S only (Telser) or torchspin’s full -dH/dB moment.

  • zeeman2 (array_like or Tensor, shape (3, 3, nStates, nStates), optional) – Field-quadratic Zeeman operator in MHz/mT^2: H += B^2 n.Z2.n (torchspin.lft.telser2torchspin.second_order_zeeman_operator()).

  • h0_extra (array_like or Tensor, shape (nStates, nStates), optional) – Extra field-independent Hamiltonian in MHz (e.g. torchspin.lft.telser2torchspin.u_term_operator()).

  • scale (float or Tensor, default 1.0) – Multiplies the spectrum.

  • units (str, default 'MHz') – Unit of width ('MHz', 'GHz', 'cm^-1', … of torchspin.lft.units).

  • constants (SpinConstants, default TORCHSPIN_CONSTANTS) – mu_B/h, k_B/h and MHz per cm^-1.

  • device (str or device, default 'cpu') – Device of the computation.

  • grid ({'exact', 'fortran'}, default 'exact') – 'fortran' reproduces the original phi windows of the grid.

  • field_derivative (bool, default True) – With derivative: d/dB per mT (False: d/dnu as the Fortran).

  • normalized_populations (bool, default True) – Normalize the Boltzmann populations (False: as the Fortran).

  • exact_cutoff (bool, default True) – Cut lines exactly at cutoff half widths (False: Telser’s sqrt(ICUTOFF) rule).

  • chunk_budget (int, default 4000000) – Approximate number of complex matrix elements per batch of orientations (memory control).

Returns:

PowderResult – axis = fields (mT), spectrum of shape (npts,).

Raises:

ValueError – For an unknown shape, extent, grid or moment; a width that is not a scalar or 3 values; angle_range without 4 values; a pair outside 0 <= i < j < n; strain weights not of length n; zeeman2 not of shape (3, 3, n, n).

Return type:

PowderResult

Examples

>>> import torch
>>> from torchspin import SpinSystem
>>> from torchspin.lft import ddpowh
>>> sys = SpinSystem(S=0.5, g=[2.0, 2.0, 2.2])
>>> res = ddpowh.epr(sys, torch.linspace(300, 350, 101), 9.5, width=50.0, igloo=6)
>>> res.axis.shape, res.spectrum.shape, res.n_orientations
(torch.Size([101]), torch.Size([101]), 98)
torchspin.lft.ddpowh.fdmr(sys, axis, field, *, width, shape='gaussian', derivative=False, cutoff=8, temperature=None, h1mode=0.0, pairs=None, frequency_factor=True, igloo=10, extent='hemisphere', angle_range=None, degrees=False, ordering=None, grid='exact', normalized_populations=True, exact_cutoff=True, moment='electron', zeeman2=None, h0_extra=None, scale=1.0, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu')[source]#

Frequency-domain (FDMR) powder spectrum at one field.

field = 0 is a true zero field: the levels are the same for every orientation, and the transition probability is still averaged over B1 about each grid direction (as DDPOWH does). There is no strain (Telser’s FDMR input has none).

Parameters:
  • sys (SpinSystem) – Spin system.

  • axis (array_like or Tensor, shape (npts,)) – Transition energies at which the spectrum is evaluated, in units (not differentiated).

  • field (float or Tensor) – Static field in mT (0 allowed).

  • width (float or array_like, shape (3,)) – HWHM (Wx, Wy, Wz) in units, or one isotropic value.

  • derivative (bool, default False) – d/dnu spectrum.

  • frequency_factor (bool, default True) – Flygare factor: nu (Gaussian) or nu^3/x^2 (Lorentzian), with x the axis in cm^-1.

  • shape (str) – As for epr().

  • cutoff (int) – As for epr().

  • temperature – As for epr().

  • h1mode (float) – As for epr().

  • pairs – As for epr().

  • igloo (int) – As for epr().

  • extent (str) – As for epr().

  • angle_range – As for epr().

  • degrees (bool) – As for epr().

  • ordering – As for epr().

  • moment (str) – As for epr().

  • zeeman2 – As for epr().

  • h0_extra – As for epr().

  • scale – As for epr().

  • units (str) – As for epr().

  • constants (SpinConstants) – As for epr().

  • device – As for epr().

  • grid (str) – As for epr().

  • normalized_populations (bool) – As for epr().

  • exact_cutoff (bool) – As for epr().

Returns:

PowderResult – axis in units, spectrum of shape (npts,).

Raises:

ValueError – As for epr().

Return type:

PowderResult

See also

epr

Examples

Zero-field FDMR of an S = 1 system (D = 3000 MHz, E = 300 MHz):

>>> import torch
>>> from torchspin import SpinSystem
>>> from torchspin.lft import ddpowh
>>> res = ddpowh.fdmr(SpinSystem(S=1, D=[3000.0, 300.0]), torch.linspace(2000, 4000, 201),
...                   0.0, width=50.0, igloo=6)
>>> round(float(res.axis[res.spectrum.argmax()]))
3300
torchspin.lft.ddpowh.endor(sys, rf, field, mw_freq, *, width, nmr_width, shape='gaussian', nmr_shape='gaussian', derivative=False, epr_derivative=False, cutoff=8, nmr_cutoff=None, temperature=None, h1mode=0.0, pairs=None, epr_pairs=None, nucleus=0, strain=None, field_strain=True, intensity_shape='nmr', frequency_factor=True, igloo=10, extent='hemisphere', angle_range=None, degrees=False, ordering=None, grid='exact', normalized_populations=True, exact_cutoff=True, moment='electron', zeeman2=None, h0_extra=None, scale=1.0, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu')[source]#

Powder ENDOR spectrum at one field, with orientation selection by the EPR line.

Every orientation is weighted by its EPR excitation, the sum over epr_pairs of P_kl f(nu_kl - nu_mw; W_kl) with the EPR width, shape and strain; orientations with a non-positive weight are dropped. Each NMR pair then adds P_NMR pop nu f(rf - nu_ij; w(n)), where P_NMR is the B1-averaged abs(<i|I|j>)^2 of nucleus nucleus (no g_N, no hyperfine enhancement; Telser’s NMRTRANS in exact form).

Parameters:
  • sys (SpinSystem) – Spin system with at least one nucleus (without electron spins every orientation has weight 1).

  • rf (array_like or Tensor, shape (npts,)) – Radio frequencies in MHz (absolute, uniform).

  • field (float or Tensor) – Static field in mT.

  • mw_freq (float or Tensor) – Microwave frequency in GHz.

  • width (float or array_like, shape (3,)) – EPR HWHM (Wx, Wy, Wz) in units for the orientation selection.

  • nmr_width (float or array_like, shape (3,)) – NMR HWHM (wx, wy, wz) in units.

  • shape ({'gaussian', 'lorentzian'}, default 'gaussian') – EPR (selection) line shape.

  • nmr_shape ({'gaussian', 'lorentzian'}, default 'gaussian') – NMR line shape.

  • derivative (bool, default False) – d/d(rf) spectrum.

  • epr_derivative (bool, default False) – Use the derivative EPR line for the selection weights.

  • cutoff (int, default 8) – Cut of the EPR selection line in half widths.

  • nmr_cutoff (int, optional) – Cut of the NMR lines; default cutoff.

  • pairs (sequence of (int, int), optional) – 0-based NMR level pairs; None: all.

  • epr_pairs (sequence of (int, int), optional) – 0-based EPR level pairs for the selection; None: all.

  • nucleus (int, default 0) – 0-based nucleus whose spin operator drives the NMR transitions.

  • strain (Strain, optional) – Level strain of the EPR selection line.

  • field_strain (bool, default True) – Include the (B/B_set)^b factor of strain.

  • intensity_shape ({'nmr', 'epr'}, default 'nmr') – Which line type selects the nu or nu^3/rf^2 Flygare factor ('nmr': Telser exact; 'epr': the Fortran’s ELNTYP flag).

  • temperature – As for epr().

  • h1mode (float) – As for epr().

  • frequency_factor (bool) – As for epr().

  • igloo (int) – As for epr().

  • extent (str) – As for epr().

  • angle_range – As for epr().

  • degrees (bool) – As for epr().

  • ordering – As for epr().

  • moment (str) – As for epr().

  • zeeman2 – As for epr().

  • h0_extra – As for epr().

  • scale – As for epr().

  • units (str) – As for epr().

  • constants (SpinConstants) – As for epr().

  • device – As for epr().

  • grid (str) – As for epr().

  • normalized_populations (bool) – As for epr().

  • exact_cutoff (bool) – As for epr().

Returns:

PowderResult – axis = rf (MHz), spectrum of shape (npts,).

Raises:

ValueError – For an unknown intensity_shape or a nonexistent nucleus, and as for epr().

Return type:

PowderResult

See also

epr, nmr, torchspin.salt

Examples

>>> import torch
>>> from torchspin import SpinSystem
>>> from torchspin.lft import ddpowh
>>> sys = SpinSystem(S=0.5, g=[2.0, 2.0, 2.1], Nucs='1H', A=[5.0, 5.0, 12.0])
>>> res = ddpowh.endor(sys, torch.linspace(5, 25, 201), 340.0, 9.5, width=30.0,
...                    nmr_width=0.2, igloo=6)
>>> res.spectrum.shape
torch.Size([201])
torchspin.lft.ddpowh.nmr(sys, rf, field, *, nmr_width, shape='gaussian', derivative=False, cutoff=8, temperature=None, h1mode=0.0, pairs=None, shielding_khz=None, frequency_factor=True, igloo=10, extent='hemisphere', angle_range=None, degrees=False, ordering=None, grid='exact', normalized_populations=True, exact_cutoff=True, h0_extra=None, scale=1.0, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu')[source]#

Powder NMR/NQR spectrum of a system without electron spins (Telser’s DDPOWH NMR mode).

The nuclear levels (nuclear Zeeman + quadrupole) are computed at every grid orientation and each pair adds P pop nu f(rf - nu_ij; w(n)) with P the B1-averaged abs(<i|I|j>)^2 (no g_N). field = 0 gives the NQR spectrum. Differentiable in Q, the shielding, the widths and the temperature.

Parameters:
  • sys (SpinSystem) – Spin system with S=[] and at least one nucleus, e.g. SpinSystem(S=[], Nucs='14N', Q=...); only the first nucleus is driven.

  • rf (array_like or Tensor, shape (npts,)) – Radio frequencies in MHz.

  • field (float or Tensor) – Static field in mT (0: NQR).

  • nmr_width (float or array_like, shape (3,)) – HWHM (wx, wy, wz) in units.

  • shielding_khz (array_like, shape (3,), optional) – Telser’s shielding (sigma_x, sigma_y, sigma_z): the shift of the Larmor frequency in kHz for the field along each molecular axis (a positive sigma lowers abs(nu_N)); the nuclear Zeeman moment along k is scaled by 1 - sigma_k/abs(nu_N(B)). Ignored at zero field.

  • shape (str) – As for epr() (shape is the NMR line shape).

  • derivative (bool) – As for epr() (shape is the NMR line shape).

  • cutoff (int) – As for epr() (shape is the NMR line shape).

  • temperature – As for epr() (shape is the NMR line shape).

  • h1mode (float) – As for epr() (shape is the NMR line shape).

  • pairs – As for epr() (shape is the NMR line shape).

  • frequency_factor (bool) – As for epr() (shape is the NMR line shape).

  • igloo (int) – As for epr() (shape is the NMR line shape).

  • extent (str) – As for epr() (shape is the NMR line shape).

  • angle_range – As for epr() (shape is the NMR line shape).

  • degrees (bool) – As for epr() (shape is the NMR line shape).

  • ordering – As for epr() (shape is the NMR line shape).

  • h0_extra – As for epr() (shape is the NMR line shape).

  • scale – As for epr() (shape is the NMR line shape).

  • units (str) – As for epr() (shape is the NMR line shape).

  • constants (SpinConstants) – As for epr() (shape is the NMR line shape).

  • device – As for epr() (shape is the NMR line shape).

  • grid (str) – As for epr().

  • normalized_populations (bool) – As for epr().

  • exact_cutoff (bool) – As for epr().

Returns:

PowderResult – axis = rf (MHz), spectrum of shape (npts,).

Raises:

ValueError – If the system has electron spins or no nucleus, shielding_khz is not three values, and as for epr().

Return type:

PowderResult

See also

endor

Examples

14N NQR (e2qQ/h = 3 MHz, eta = 0.2):

>>> import torch
>>> from torchspin import SpinSystem
>>> from torchspin.lft import ddpowh
>>> sys = SpinSystem(S=[], Nucs='14N', Q=[3.0, 0.2])
>>> res = ddpowh.nmr(sys, torch.linspace(0.1, 3.0, 300), 0.0, nmr_width=0.02, igloo=6)
>>> round(float(res.axis[res.spectrum.argmax()]), 1)
2.4
torchspin.lft.ddpowh.simulate(conversion, sys=None, **overrides)[source]#

Every spectrum of a converted Telser DDPOWH/DDPOWJ input.

Parameters:
  • conversion (TelserConversion) – Result of telser2torchspin.ddpowh2sys(inp, target='lft') or ddpowj2sys(..., target='lft'); its extras['spectra'] lists the spectra (function name and keywords).

  • sys (SpinSystem, optional) – Replaces the converted SpinSystem (e.g. one rebuilt with tensor parameters for gradients).

  • **overrides – Keywords that replace those of every spectrum (width=, strain=, temperature=, …).

Returns:

tuple of PowderResult – One result per spectrum, in input order. The axis Telser writes is in conversion.extras['spectra'][k]['x'] (G or T, cm^-1 or THz, MHz).

Raises:

ValueError – If conversion was not made with target='lft'.

Return type:

tuple[PowderResult, …]