torchspin.lft.ddpowj#

DDPOWJ: field-swept powder EPR of an exchange-coupled dimer, with Telser’s product level strain.

Torch port of Josh Telser’s DDPOWJ in its exact mode (via telser-tools, telser_tools_diff.ddpowj). A dimer is a two-electron torchspin SpinSystem (ee, ee2; build it from Telser’s parameters with torchspin.lft.telser2torchspin.dimer2sys() or ddpowj2sys()), so the spectrum is torchspin.lft.ddpowh.epr() with DDPOWJ’s defaults:

  • every level pair i < j (pairs=None; DDPOWJ’s level ranges are 0-based (i, j) lists here, as level_range_pairs() builds them);

  • the strain weights of a basis state |m1, m2> are the product WMS1(m1) WMS2(m2) of the two sites’ factors (strain_weights()), not DDPOWH’s sum.

Open question (DDPOWJ-10, waiting on J. Telser): an S = 1/2 site has no m_S strain factors (WMS = 0), so in the exact model every product weight of a dimer with an S = 1/2 partner is 0, and only (B/B_set)^b W(n) remains. The Fortran instead sets WMS = 1 for S = 1/2 sites, which makes every weight 1 and doubles every width (1 + (1 + 1)/2 = 2). s12_weight keeps both readings: 0.0 (default, exact) or 1.0 (Fortran). Until Telser answers, treat strain fits of dimers with an S = 1/2 partner as provisional.

Units, intensities, gradients and the other keywords: torchspin.lft.ddpowh.

class torchspin.lft.ddpowj.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

class torchspin.lft.ddpowj.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.ddpowj.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.ddpowj.strain_weights(sys, ms1=None, ms2=None, *, s12_weight=0.0, partner_weight=None)[source]#

DDPOWJ’s product strain weights WMS1(m1) WMS2(m2) of a dimer.

Parameters:
  • sys (SpinSystem) – The dimer: one or two electron spins and no nuclei. A one-electron system is the dimer of an S = 0 site with a spin S.

  • ms1 (array_like or Tensor, shape (2S1+1,), optional) – Site 1 factors for m = S1, ..., -S1 (Telser’s order), dimensionless. None: zeros.

  • ms2 (array_like or Tensor, shape (2S2+1,), optional) – Site 2 factors. For a one-electron sys, used if ms1 is None.

  • s12_weight (float or Tensor, default 0.0) – Weight of every state of a site with S < 1, which has no factors in Telser’s input (given factors are ignored): 0.0 is the exact model, 1.0 the Fortran (finding DDPOWJ-10; see the module docstring).

  • partner_weight (float or Tensor, optional) – One-electron sys only: the single weight of the S = 0 site that multiplies the electron’s factors; default s12_weight.

Returns:

torch.Tensor, shape (nStates,) – Weights for every basis state |m1, m2> (both m descending), to be passed as Strain(weights). Tensors keep their graph.

Raises:

ValueError – If sys has nuclei or not one or two electron spins, or a factor vector has the wrong length.

Return type:

Tensor

See also

torchspin.lft.ddpowh.strain_weights

DDPOWH’s additive weights.

Examples

An S = 1 site coupled to an S = 1/2 site, Fortran reading of the S = 1/2 weights:

>>> from torchspin import SpinSystem
>>> from torchspin.lft import ddpowj
>>> dimer = SpinSystem(S=[1, 0.5], ee=3000.0)
>>> ddpowj.strain_weights(dimer, ms1=[1.0, 0.0, 1.0], s12_weight=1.0).tolist()
[1.0, 1.0, 0.0, 0.0, 1.0, 1.0]
torchspin.lft.ddpowj.level_range_pairs(level_range, n_levels)[source]#

DDPOWJ’s level-range pair selection.

Parameters:
  • level_range (sequence of 4 int) – (a, b, c, d), 1-based level numbers (ascending energy at each orientation and field): i runs over a to b, j over c to d, and only i < j is kept.

  • n_levels (int) – Number of levels; pairs beyond it are dropped.

Returns:

tuple of tuple of int – 0-based pairs (i, j). (The Fortran’s i >= j pairs are a telser-tools reproduction option, not ported.)

Return type:

tuple[tuple[int, int], …]

Examples

>>> from torchspin.lft import ddpowj
>>> ddpowj.level_range_pairs((1, 2, 3, 4), 6)
((0, 2), (0, 3), (1, 2), (1, 3))
torchspin.lft.ddpowj.epr(sys, fields, mw_freq, *, width, pairs=None, strain=None, **kwargs)[source]#

Field-swept powder EPR of a dimer: torchspin.lft.ddpowh.epr() with DDPOWJ’s defaults.

Parameters:
Returns:

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

Raises:

ValueError – If a pair has i >= j, and as torchspin.lft.ddpowh.epr().

Return type:

PowderResult

Examples

Two S = 1/2 spins with strong exchange (a triplet at g = 2):

>>> import torch
>>> from torchspin import SpinSystem
>>> from torchspin.lft import ddpowj
>>> dimer = SpinSystem(S=[0.5, 0.5], ee=30000.0)
>>> res = ddpowj.epr(dimer, torch.linspace(300, 380, 81), 9.5, width=50.0, igloo=6)
>>> res.spectrum.shape
torch.Size([81])
torchspin.lft.ddpowj.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, …]