torchspin.lft.ddnpow#
DDNPOW: powder EPR (field-swept and frequency-domain) directly from the complete d^n model.
Torch port of Josh Telser’s DDNPOW in its exact mode (via telser-tools,
telser_tools_diff.ddnpow), built on torchspin.lft.ddn. No spin Hamiltonian is
involved: for every orientation n of the grid and every field B of the sweep,
H = H0 + mu_B B n . (k L + g_e S) of the full d^n basis is diagonalized and every requested
pair (i, j) adds (Flygare eqs. 7-38 and 7-8):
y(B) += P_ij pop_ij nu_ij f(nu_ij(B) - nu_mw; W(n)) Gaussian
y(B) += P_ij pop_ij nu_ij^3/nu_mw^2 f(nu_ij(B) - nu_mw; W(n)) Lorentzian
with f Telser’s DLINE.F line, the HWHM W(n)^2 = sum_k W_k^2 n_k^2, P the B1-averaged
abs(<i|B1.(k L + g_e S)|j>)**2, pop_ij = p_i - p_j (Boltzmann, normalized) and nu_ij in cm^-1.
fdmr() is the frequency-domain counterpart (one field, y(nu) += P pop nu_ij f(nu - nu_ij)).
Every Hamiltonian parameter, the line widths, the microwave frequency, the temperature and
scale may carry gradients.
Units#
Energy-valued inputs (B, C, A, zeta, alpha, slater, V), the line
widths width (HWHM, x/y/z) and the FDMR axis are in units (default 'MHz';
'cm^-1', 'GHz', …). The field axis is in mT, the microwave frequency in GHz, the
temperature in K, angles in radians (degrees=True for Telser-style input). Intensities are
arbitrary units defined exactly as DDNPOW’s exact mode, independent of units (nu in cm^-1
in the Flygare factor, the line in 1/MHz), except that field-derivative spectra are d/dB per
mT (10x DDNPOW’s per-gauss values).
>>> import torch
>>> from torchspin import lft
>>> V = torch.diag(torch.tensor([9900., -2100., -5100., -5100., 2400.], dtype=torch.float64)) # cm^-1
>>> res = lft.ddnpow.simulate(9, torch.linspace(250, 380, 261), 9.5, V=V, zeta=830.0,
... k=(0.8, 0.8, 0.8), width=(1.0e-3, 1.0e-3, 2.0e-3), units='cm^-1',
... igloo=10, derivative=True)
>>> res.spectrum.shape
torch.Size([261])
With units='cm^-1' the widths are in cm^-1 too (30 MHz = 1.0e-3 cm^-1).
Rayleigh-Ritz subspace (subspace=True, the default)#
The field sweep is solved in the span Q of the low eigenvectors at three fields of the sweep and at zero field (orthonormalized by an SVD), as telser-tools does. Q is a discrete choice and is built on DETACHED values. The forward values are the Ritz pairs of Q^H H Q.
Derivatives (since 0.9.30, B94). Only the kk lowest Ritz pairs (the states needed plus the rest
of their zero-field cluster) are accurate eigenpairs; the other directions of Q are SVD mixtures
of higher states. With a parameter on the graph (reverse or forward mode), the Ritz pairs are
taken as values and their derivatives come from first-order perturbation theory, as zero-valued
graph terms: energies by Hellmann-Feynman on the low Ritz vectors (level mean at degeneracies, as
torchspin.lft._linalg.eigh_gauge), eigenvectors from the couplings inside that cluster
plus the reduced-resolvent solve (P (H - lambda) P + W W^H)^-1 P dH v in its complement
(P = 1 - W W^H, W the cluster), done only at the (orientation, field) points that enter the
spectrum. The derivative is exact up to the Ritz residual. Before 0.9.30 the eigenvectors were
differentiated inside the fixed Q only, which drops their components outside Q: the transition
probabilities’ derivatives were wrong whenever the parameters move the low states’ admixture of
states outside Q (d^7 Co(II): spectrum gradients 10-28 % off). Measured against
subspace=False (full N x N eigh at every point): d^7 (120 states) spectra 1.4e-9, Jacobians
(e_sigma, zeta, Racah B, k) 1.7e-9 to 3.5e-9 of the largest response; d^8 (45 states) spectra
< 1e-7. Without graph inputs the extra work is skipped and the values are bit-identical; with
them a d^7 sweep costs ~4-6x the no-gradient run (the full basis ~40-60x).
Discrete choices (all on detached values): the grid extent (extent='auto': the octant when
the detached V has D2h symmetry about x, y, z, otherwise the hemisphere; a perturbation of V
that breaks D2h switches the grid, a discontinuity of the program itself), the number of states
kept, the (orientation, field) points inside the line cutoff and the FDMR line windows.
Accuracy. The levels lie at 10^4-10^5 cm^-1, each transition is a difference of two of them, and the lines are 10^-3-10^-2 cm^-1 wide, so the spectrum is only defined to about 2 N eps max(abs(E)) / W relative to its peak: telser-tools’ NumPy DDNPOW itself moves by 2e-9 to 1e-8 when the energy origin is shifted. Parity with it is therefore ~1e-8, not 1e-10.
Not ported (Fortran reproduction): DDN’s hole problem and constants (ddn_model), the mirror
image (mirror; apply torchspin.lft.ddnloop.mirror_image() to V by hand), EPRTRANS
(probabilities='fortran', DDNPOW-01), the H0 = 0 Fortran loop (zero_field='fortran',
DDNPOW-05) and the 1e-10 thresholds; passing any of them raises NotImplementedError.
Supported Fortran switches: grid='fortran' (DDNPOW-04), extent='octant' (DDNPOW-03),
field_derivative=False (d/dnu, DDNPOW-06), normalized_populations=False (DDNPOW-07) and
exact_cutoff=False (sqrt(ICUTOFF) cut, DDNPOW-08).
- class torchspin.lft.ddnpow.PowderResult(axis, spectrum, n_orientations, subspace_used, grid)[source]#
Powder spectrum returned by
simulate()andfdmr().- Variables:
axis (Tensor, shape (npts,), float64) – Field axis in mT (
simulate()) or energy axis inunits(fdmr()).spectrum (Tensor, shape (npts,), float64) – Intensity in DDNPOW’s arbitrary units (module docstring).
n_orientations (int) – Number of grid orientations.
subspace_used (bool) – Whether the Rayleigh-Ritz subspace path was taken (always False for
fdmr()).grid (torchspin.lft._powder.Grid) – The orientations (
theta,phiin radians,weight,directions).
- grid: Grid#
Alias for field number 4
- torchspin.lft.ddnpow.FORTRAN_DEG = 0.01745329252#
the Fortran’s degree constant, used by
grid='fortran'.- Type:
ddnpow.f l. 76
- torchspin.lft.ddnpow.fdmr(n, axis, *, width, field=0.0, pairs=((0, 1),), shape='gaussian', cutoff=8, temperature=None, h1mode=0.0, igloo=10, angle_range=None, degrees=False, grid='exact', extent='auto', normalized_populations=True, exact_cutoff=True, frequency_factor=True, scale=1.0, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu', **params)[source]#
Frequency-domain (FDMR) powder spectrum of d^n at one static field.
Each pair adds
P pop nu_ij f(nu - nu_ij)on the energy axis (absorption only).- Parameters:
n (int) – Number of d electrons, 0 to 10.
axis (array_like or Tensor, shape (npts,)) – Energy (frequency) axis in
units(detached).width (array_like or Tensor, shape (3,)) – Half widths at half maximum
(Wx, Wy, Wz)inunits.field (float, default 0.0) – Static field magnitude in mT (converted with
float; not differentiated). Atfield <= 0the levels and the isotropic probability(1/3) sum_k abs(<i|mu_k|j>)**2(times1 + h1modeforh1mode > 0) are the same for every orientation and only the widths are averaged over the grid.**kw –
pairs,shape,cutoff,temperature,h1mode,igloo,angle_range,degrees,grid,extent,normalized_populations,exact_cutoff,frequency_factor,scale,units,constants,deviceand the Hamiltonian keywords, assimulate().
- Returns:
PowderResult –
axisis the energy axis inunits.- Raises:
- Return type:
Examples
Zero-field splitting of a tetragonal Ni(II) (d^8), axis in cm^-1:
>>> import torch >>> from torchspin import lft >>> res = lft.ddnpow.fdmr(8, torch.linspace(0.0, 20.0, 201, dtype=torch.float64), ... width=(0.3, 0.3, 0.3), pairs=[(0, 1), (0, 2)], B=900.0, C=3600.0, ... V=lft.crystal_field(Dq=850.0, Ds=300.0, Dt=50.0), zeta=600.0, ... units='cm^-1', igloo=4) >>> round(float(res.axis[res.spectrum.argmax()]), 1) 1.6
- torchspin.lft.ddnpow.is_d2h(V, tol=1e-9)[source]#
Whether a real-orbital d ligand field has D2h symmetry about x, y, z.
True when the only off-diagonal elements are the x2-y2 / z2 pair. Used by
extent='auto'to choose the octant grid.- Parameters:
- Returns:
bool
- Return type:
Examples
>>> from torchspin import lft >>> lft.ddnpow.is_d2h(lft.crystal_field(Dq=1000.0, Ds=200.0)) True
- torchspin.lft.ddnpow.simulate(n, fields, mw_freq, *, width, pairs=((0, 1),), shape='gaussian', derivative=False, cutoff=8, temperature=None, h1mode=0.0, igloo=10, angle_range=None, degrees=False, grid='exact', extent='auto', field_derivative=True, normalized_populations=True, exact_cutoff=True, frequency_factor=True, subspace=True, scale=1.0, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu', **params)[source]#
Field-swept powder (or partial-orientation) EPR spectrum of d^n from the full model.
For every grid orientation and every field of the sweep the full d^n Hamiltonian is diagonalized and each requested pair adds a line with DDNPOW’s Flygare intensity factor (module docstring).
- Parameters:
n (int) – Number of d electrons, 0 to 10.
fields (array_like or Tensor, shape (npts,)) – Field axis in mT (not differentiated). DDNPOW’s own axis is
linspace(B_min, B_max, npts + 1).mw_freq (float or Tensor) – Microwave frequency in GHz (may carry gradients).
width (array_like or Tensor, shape (3,)) – Line half widths at half maximum
(Wx, Wy, Wz)inunits; the width at direction n issqrt(sum_k W_k**2 n_k**2).pairs (sequence of (int, int), default ((0, 1),)) – 0-based state pairs (i, j), i < j (DDNPOW: i in [NSIMIN, NSIMAX], j in [NSJMIN, NSJMAX]).
shape ({'gaussian', 'lorentzian'}, default 'gaussian') – Line shape (also
'G'/'L').derivative (bool, default False) – First-derivative spectrum.
cutoff (int, default 8) – Lines are cut at
cutoffhalf widths.temperature (float or Tensor, optional) – Temperature in K for Boltzmann population differences. Default
None: no population factor.h1mode (float, default 0.0) – Excitation mode: 0 perpendicular, < 0 parallel, > 0 perpendicular +
h1modetimes parallel.igloo (int, default 10) – Grid size (rings per 90 degrees).
angle_range (sequence of 4 float, optional) –
(theta_min, theta_max, phi_min, phi_max): a partial orientation range instead of the powder (radians unlessdegrees).degrees (bool, default False) –
angle_rangeis in degrees.grid ({'exact', 'fortran'}, default 'exact') – Exact grid or DDNPOW’s (DDNPOW-04).
extent ({'auto', 'octant', 'hemisphere'}, default 'auto') – Part of the sphere sampled;
'auto'uses the octant when the (detached)Vhas D2h symmetry (is_d2h()).field_derivative (bool, default True) – With
derivative: d/dB per mT (True) or DDNPOW’s d/dnu (False, DDNPOW-06).normalized_populations (bool, default True) – Normalize the Boltzmann factors (False: DDNPOW-07).
exact_cutoff (bool, default True) – Exact cutoff radius (False: DDNPOW’s sqrt(ICUTOFF), DDNPOW-08).
frequency_factor (bool, default True) – Include the Flygare nu factor (False: none, as EasySpin/torchspin).
subspace (bool, default True) – Allow the Rayleigh-Ritz subspace path (module docstring); it is used only when the system is large enough.
scale (float or Tensor, default 1.0) – Multiplies the spectrum.
units (str, default 'MHz') – Energy unit of
widthand of the Hamiltonian keywords.constants (Constants, default TORCHSPIN_CONSTANTS) – mu_B, g_e, k_B.
**params – One (unbatched) parameter set of
torchspin.lft.ddn.hamiltonian():B,C,A,zeta,V,k,alpha,slater.
- Returns:
PowderResult –
axisisfields(mT).- Raises:
NotImplementedError – For DDNPOW’s Fortran-reproduction keywords (
mode,ddn_model,mirror,probabilities,zero_field,thresholds).TypeError – For any other unknown keyword.
ValueError – For batched parameters,
widthnot of shape (3,), an invalid pair,shape,grid,extentorangle_range.
- Return type:
Examples
Cu(II) (d^9) at X band, energies and widths in cm^-1:
>>> import torch >>> from torchspin import lft >>> V = torch.diag(torch.tensor([9900., -2100., -5100., -5100., 2400.], dtype=torch.float64)) >>> res = lft.ddnpow.simulate(9, torch.linspace(250, 380, 131), 9.5, V=V, zeta=830.0, ... k=(0.8, 0.8, 0.8), width=(1.0e-3, 1.0e-3, 2.0e-3), ... units='cm^-1', igloo=5, derivative=True) >>> res.spectrum.shape, res.n_orientations (torch.Size([131]), 22)