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, aslevel_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_CONSTANTStorchspin’s CODATA values.
- 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) andk_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_cmandk_b = k_b_cm * mhz_per_cm.- Return type:
- 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), wherec_biare the components of level i in the basis state b andw_bare 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 bystrain_weights()(DDPOWH) ortorchspin.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.
- class torchspin.lft.ddpowj.PowderResult(axis, spectrum, n_orientations, grid)[source]#
Result of
epr(),fdmr(),endor()andnmr().- Variables:
axis (Tensor, shape (npts,)) – The sweep axis as used: fields in mT (
epr()), energies inunits(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,phiin radians,weight, unitdirections(n_orientations, 3), …).
- 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 ifms1isNone.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
sysonly: the single weight of the S = 0 site that multiplies the electron’s factors; defaults12_weight.
- Returns:
torch.Tensor, shape (nStates,) – Weights for every basis state
|m1, m2>(both m descending), to be passed asStrain(weights). Tensors keep their graph.- Raises:
ValueError – If
syshas nuclei or not one or two electron spins, or a factor vector has the wrong length.- Return type:
See also
torchspin.lft.ddpowh.strain_weightsDDPOWH’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 onlyi < jis 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’si >= jpairs are a telser-tools reproduction option, not ported.)- Return type:
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:
sys (SpinSystem) – The dimer (two electron spins coupled by
ee/ee2), e.g. fromtorchspin.lft.telser2torchspin.dimer2sys().fields (array_like or Tensor, shape (npts,)) – Field points in mT.
width (float or array_like, shape (3,)) – HWHM
(Wx, Wy, Wz)inunits(default MHz).pairs (sequence of (int, int), optional) – 0-based level pairs with
i < j(level_range_pairs());None(default): every pair.strain (Strain, optional) – Level strain with
strain_weights()(product form).**kwargs – Every other keyword of
torchspin.lft.ddpowh.epr().
- Returns:
PowderResult –
axis=fields(mT),spectrumof shape(npts,).- Raises:
ValueError – If a pair has
i >= j, and astorchspin.lft.ddpowh.epr().- Return type:
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')orddpowj2sys(..., target='lft'); itsextras['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
conversionwas not made withtarget='lft'.- Return type:
tuple[PowderResult, …]