torchspin.lft.dsoxf#
DSOXF: one free-ion term (2S+1)L of d^n or f^n in a crystal field, differentiable.
The Hamiltonian of Telser’s DSOXF (via telser-tools), in its |m_L m_S> basis (m_L
outer, both descending):
H = H_CF + s abs(lambda) L.S + rho SS + mu_B B . (s_L k L + g_e S)
for the d and f shells, high and low spin (low-spin d4/d5 as the fictitious L~ = 1 term), Oh/Td,
cubic/axial/rhombic and tetragonal/trigonal fields, with both conventions ('corrected',
the default, or 'dsoxf' = the compiled program). SS = -[(L.S)^2 + L.S/2 -
L(L+1)S(S+1)/3] is the Abragam-Bleaney spin-spin term (zero for S < 1).
For a fixed configuration and discrete setting, H_CF is linear in the crystal-field parameters
(CF_PARAMETERS: dq, ds, dt4 (= Delta4 = -Dt), v2, v4 for d; b4,
b6, b20 … b66 for f, as DSOXF reads them). The matrices are probed once from the
NumPy model (torchspin.lft._engines.dsoxf.DsoxfModel) and checked for linearity, so the
Stevens operators, DSOXF’s scalings (B2X, B4X, F_kq), the symmetry selection and the whole sign
table keep one definition. lam is a magnitude: lambda_eff = s abs(lambda) with the
sign s that the program chooses (d abs(lambda)/d lambda := +1 at 0).
Units#
Energy-valued inputs (lam, rho and every crystal-field parameter) and energy-valued
outputs (H, energies, doublet energies) are in units (default 'MHz'; 'cm^-1',
'GHz', 'K', 'eV', …; see torchspin.lft.units). The magnetic field is in
mT (DSOXF itself takes gauss), temperatures in K. k, g values and occupancies are
dimensionless; transition moments abs(<i|mu.b1|j>)**2 are in mu_B^2. Level tolerances
(tol) are in cm^-1 whatever units is. Internally everything is cm^-1.
Gauge#
Per-state quantities (<S>, occupancies, abs(<i|mu|j>)**2) depend on the arbitrary basis
inside a degenerate level, exactly as in DSOXF, and have no derivative there; their sums over
the level (level_matrix(E) @ x, level_sum(), Solution.level_transition_moments())
are gauge-invariant and differentiable. Kramers-doublet g tensors use the doublet projector.
Not ported: DSOXF’s legacy EPR probabilities ((sum_a abs(<i|S_a|j>))**2, a sum of moduli
that depends on eigenvector phases and is not smooth; telser-tools finding DSOXF-05), the
listing and spin-magnitude cutoffs, the input-file reader and the printed report.
Examples
Cu(II), d9, tetragonally elongated (telser-tools’ DSOXF quick start): the ground Kramers doublet has g_perp = 2.069 and g_par = 2.421.
>>> import torch
>>> from torchspin.lft import dsoxf
>>> s = dsoxf.DsoxfSystem("d", 9, symmetry="axial", units="cm^-1", lam=830.0, dq=1200.0,
... ds=2000.0, dt4=-500.0, k=(0.8, 0.8, 0.8))
>>> sol = s.solve()
>>> [round(e, 2) for e in sol.relative[::2].tolist()]
[0.0, 10392.24, 12010.6, 15304.75, 16176.33]
>>> [round(g, 4) for g in sol.kramers_g()[0].principal.tolist()]
[2.0686, 2.0686, 2.4212]
Derivatives flow from every continuous parameter, here Ds at a field of 300 mT along z:
>>> ds = torch.tensor(2000.0, dtype=torch.float64, requires_grad=True)
>>> sol = s.solve(field=(0.0, 0.0, 300.0), ds=ds)
>>> (dE,) = torch.autograd.grad(sol.energies[2], ds)
>>> sol.energies.shape, sol.spin_expectation().shape, sol.orbital_occupancies().shape
(torch.Size([10]), torch.Size([10, 3]), torch.Size([10, 5]))
- torchspin.lft.dsoxf.LEVEL_TOL = 1e-06#
DSOXF’s level criterion for Kramers doublets and level sums (cm^-1, chained).
- class torchspin.lft.dsoxf.DoubletG(energy, principal, ggT, g)[source]#
g tensor of one Kramers doublet.
- Variables:
energy (Tensor) – Mean energy of the doublet, in the solution’s units (0 if no energies were given).
principal (Tensor, shape (..., 3)) – Principal values
abs(g), ascending.ggT (Tensor, shape (..., 3, 3)) –
g g^T(gauge-invariant).g (Tensor, shape (..., 3, 3)) –
(g g^T)^(1/2), symmetric, with exact gradients at axial g.
- class torchspin.lft.dsoxf.DsoxfOperators(shell, code, term, L, S, nl, ns, cf, LS, SS, Lv, Sv, so_sign, zeeman_sign)[source]#
Constant operators of one DSOXF configuration and discrete setting (energies in cm^-1).
Built and cached by
dsoxf_operators();N = nl * nsis the size of the|m_L m_S>basis.- Variables:
shell (str) –
'd'or'f'.code (int) – DSOXF’s configuration number (see
dsoxf_operators()).term (str) – Free-ion term, e.g.
'2D';'3P~'/'2P~'for the low-spin L~ = 1 terms.L (int) – Orbital quantum number of the term.
S (float) – Spin quantum number of the term.
ns (nl,) – Orbital (2L+1) and spin (2S+1) dimensions.
cf (Tensor, shape (18, N, N), float64) – Crystal-field operators in
CF_PARAMETERSorder:H_CF = sum_p value_p cf[p](parameters inactive in this setting have zero matrices).SS (LS,) – L.S and the spin-spin (rho) operator (zero for S < 1).
Sv (Lv,) – Orbital and spin angular-momentum vectors.
so_sign (float) – The sign s of
lambda_eff = s abs(lambda).zeeman_sign (float) – s_L, the sign of the orbital Zeeman term (-1 for the corrected L~ = 1 terms).
- class torchspin.lft.dsoxf.DsoxfSystem(shell='d', code=1, *, geometry='Oh', symmetry='cubic', axis='tetragonal', conventions='corrected', units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu', **params)[source]#
One DSOXF configuration with stored parameter values and cached operators.
- Parameters:
shell (str) – The configuration and discrete setting, as
dsoxf_operators().code (int) – The configuration and discrete setting, as
dsoxf_operators().geometry (str) – The configuration and discrete setting, as
dsoxf_operators().symmetry (str) – The configuration and discrete setting, as
dsoxf_operators().axis (str) – The configuration and discrete setting, as
dsoxf_operators().conventions (str) – The configuration and discrete setting, as
dsoxf_operators().units (str, default 'MHz') – Energy unit of the stored parameters, of per-call overrides and of every returned energy; fixed for the system.
constants (Constants, optional) – Physical constants, default
torchspin.lft.ddn.TORCHSPIN_CONSTANTS.device (str or device, default 'cpu') – Device of the operators.
**params – Stored defaults:
lam(abs(lambda), default 0),rho(default 0),k(default(1, 1, 1)) and any ofCF_PARAMETERS(default 0), energies inunits.
- Raises:
TypeError – For an unknown parameter name (also for per-call overrides).
Examples
>>> import torch >>> from torchspin.lft import dsoxf >>> s = dsoxf.DsoxfSystem("f", 1, symmetry="axial", axis="trigonal", units="cm^-1", ... lam=600.0, b4=2000.0, b6=800.0) >>> s.ops.term, s.size ('2F', 14) >>> E = s.levels(b20=torch.tensor(300.0), relative=True) # keyword overrides per call >>> E.shape torch.Size([14])
- classmethod from_model(model, *, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu')[source]#
Build from a DSOXF model object holding Telser’s cm^-1 values.
modelistorchspin.lft._engines.dsoxf.DsoxfModelor telser-tools’DsoxfModel; its energies are converted from cm^-1 tounits.
- parameters(**kw)[source]#
Stored parameters updated with the keyword overrides
kw(raisesTypeErrorfor unknown names).
- hamiltonian(field=None, **kw)[source]#
Hamiltonian (n, n) in
self.units;fieldin mT, keywords override the stored parameters (hamiltonian()).
- levels(field=None, relative=False, **kw)[source]#
Ascending energies (n,) in
self.units;fieldin mT, keywords override the stored parameters (levels()).
- class torchspin.lft.dsoxf.Solution(ops, field, energies, vectors, mu, units, constants)[source]#
Eigenstates of one DSOXF Hamiltonian (returned by
solve()andDsoxfSystem.solve()).- Variables:
ops (DsoxfOperators) – Configuration operators.
energies (Tensor, shape (N,)) – Ascending eigenvalues in
units.vectors (Tensor, shape (N, N), complex128) – Eigenvector columns in the
|m_L m_S>basis.mu (Tensor, shape (3, N, N), complex128) – Magnetic-moment operator in mu_B.
field (array_like or None) – Field vector in mT, or None.
units (str) – Energy unit of
energies.constants (Constants) – Physical constants used.
- level_sum(x, tol=LEVEL_TOL)[source]#
Per-state
xsummed over each degenerate level (level_sum();tolin cm^-1).
- spin_along_field()[source]#
<S . h>per state,hthe unit field vector (DSOXF’s “<S para>”);h = zat zero field.
- ml_occupancies()[source]#
m_Lweights per state, shape (N, 2L+1) (ml_occupancies()).
- orbital_occupancies(kind='real')[source]#
Real-orbital weights per state, shape (N, 2L+1) (
orbital_occupancies()).
- g_tensor(states=(0, 1))[source]#
g of the doublet spanned by
states(default the lowest two); use at zero field. ReturnsDoubletG.
- field_g(i, j)[source]#
DSOXF’s g(obs) of the pair of states
i,j.g(obs) = (E_j - E_i) / (mu_B abs(B))with the energies in cm^-1 andmu_Bin cm^-1/mT.- Raises:
ValueError – If the solution has no field or a zero field.
- populations(temperature)[source]#
Boltzmann factors
exp(-(E_i - E_0) / k_B T)per state.temperaturein K (float or tensor). DSOXF’s “relative population”: not normalized.
- transition_moments(b1=None)[source]#
Squared transition moments
abs(<i|mu . b1|j>)**2in mu_B^2, shape (N, N).b1is the microwave-field direction; default the static-field direction (parallel mode; z at zero field).
- level_transition_moments(b1=None, tol=LEVEL_TOL)[source]#
Transition moments summed over the members of both levels (gauge-invariant).
abs(<I|mu . b1|J>)**2in mu_B^2, shape (N, N);b1astransition_moments(),tolin cm^-1.
- torchspin.lft.dsoxf.doublet_g(V, mu, idx, E=None)[source]#
g tensor of the doublet spanned by two eigenvectors.
(g g^T)_ij = 2 tr(P mu_i P mu_j)withPthe doublet projector, so the result is gauge-invariant. Meaningful at zero field.- Parameters:
- Returns:
DoubletG
- Return type:
- torchspin.lft.dsoxf.dsoxf_operators(shell='d', code=1, *, geometry='Oh', symmetry='cubic', axis='tetragonal', conventions='corrected', device='cpu')[source]#
Cached constant operators of one DSOXF configuration and discrete setting.
- Parameters:
shell ({'d', 'f'}, default 'd') – Electron shell.
code (int, default 1) – DSOXF’s configuration number. d: 1 … 9 (high spin, d^n), -4 … -7 (low spin d4 … d7; -4 and -5 are the fictitious L~ = 1 terms); f: 1 … 13.
geometry ({'Oh', 'Td'}, default 'Oh') – ‘Td’ reverses the sign of every crystal-field parameter.
symmetry ({'cubic', 'axial', 'rhombic'}, default 'cubic') – Which crystal-field parameters act, as DSOXF reads them. d shell: cubic
dq; axial addsds,dt4; rhombic addsv2,v4. f shell: cubicb4,b6; axial addsb20,b40,b60andb44,b64(tetragonal) orb43,b63,b66(trigonal); rhombic addsb22,b42,b62. Inactive parameters are ignored.axis ({'tetragonal', 'trigonal'}, default 'tetragonal') – Quantization axis: z along C4 or along C3.
conventions ({'corrected', 'dsoxf'}, default 'corrected') – ‘corrected’ fixes the signs of the L~ = 1 spin-orbit and orbital-Zeeman terms, the F-term rank-2 terms and low-spin d7 (telser-tools findings DSOXF-01 to -03); ‘dsoxf’ reproduces the compiled program.
device (str or device, default 'cpu') – Device of the operator tensors.
- Returns:
DsoxfOperators – Cached per (setting, device); unit-free (cm^-1).
- Raises:
ValueError – For an unknown
shell/code,geometry,symmetry,axisorconventions.- Return type:
Examples
>>> from torchspin.lft import dsoxf >>> ops = dsoxf.dsoxf_operators("d", 7, symmetry="axial") >>> ops.term, ops.size, tuple(ops.cf.shape) ('4F', 28, (18, 28, 28))
- torchspin.lft.dsoxf.hamiltonian(ops, *, lam=0.0, rho=0.0, k=(1.0, 1.0, 1.0), field=None, units='MHz', constants=TORCHSPIN_CONSTANTS, **cf)[source]#
DSOXF Hamiltonian as a complex Hermitian matrix.
- Parameters:
ops (DsoxfOperators) – Configuration operators (
dsoxf_operators()).lam (float or Tensor, default 0.0) – Magnitude
abs(lambda)of the spin-orbit constant, inunits; the sign is chosen by the configuration (ops.so_sign).rho (float or Tensor, default 0.0) – Spin-spin parameter in
units(acts only for S >= 1).k (array_like or Tensor, shape (..., 3), default (1, 1, 1)) – Orbital reduction factors (Zeeman term only).
field (array_like or Tensor, shape (..., 3), optional) – Magnetic field vector in mT;
None(default) = zero field.units (str, default 'MHz') – Energy unit of the energy inputs and of the result.
constants (Constants, optional) – Physical constants, default
torchspin.lft.ddn.TORCHSPIN_CONSTANTS.**cf (float or Tensor) – Crystal-field parameters, any of
CF_PARAMETERS(default 0), inunits; which act depends on the setting (dsoxf_operators()).gradients. (Every value may be a tensor with leading batch dimensions and)
- Returns:
torch.Tensor, shape (…, N, N), complex128 – H in
units.- Raises:
TypeError – For a keyword that is not one of
CF_PARAMETERS.ValueError – For an unknown
units.
- Return type:
- torchspin.lft.dsoxf.level_matrix(E, tol=LEVEL_TOL, units='MHz')[source]#
Indicator matrix of degenerate levels.
- Parameters:
- Returns:
torch.Tensor, shape (…, N, N) – 1 where states i and j belong to the same level, else 0 (decided on detached energies).
level_matrix(E) @ xsums a per-state quantity over each level (gauge-invariant), andD @ M @ Dsums a pair quantity over both levels.- Return type:
- torchspin.lft.dsoxf.level_sum(E, x, tol=LEVEL_TOL, units='MHz')[source]#
Sum a per-state quantity over each state’s degenerate level.
- Parameters:
- Returns:
torch.Tensor – Same shape as
x; entry i is the sum over the level containing state i.- Return type:
- torchspin.lft.dsoxf.levels(ops, *, relative=False, units='MHz', **kw)[source]#
Eigenvalues of the DSOXF Hamiltonian.
- Parameters:
ops (DsoxfOperators) – Configuration operators.
relative (bool, default False) – Subtract the lowest eigenvalue (ground state at 0).
units (str, default 'MHz') – Energy unit of the inputs and of the result.
**kw –
lam,rho,k,field(mT),constantsand crystal-field parameters, ashamiltonian().
- Returns:
torch.Tensor, shape (…, N), float64 – Ascending energies in
units. A degenerate eigenvalue gets its level’s mean derivative.- Return type:
- torchspin.lft.dsoxf.ml_occupancies(V, ops)[source]#
Weights of the
m_Lcomponents of eigenvectors.- Parameters:
V (Tensor, shape (..., N, N)) – Eigenvectors as columns.
ops (DsoxfOperators) – Configuration operators.
- Returns:
torch.Tensor, shape (…, N, 2L+1) –
sum over m_S of abs(c(m_L, m_S))**2, columnsm_L = L ... -L.- Return type:
- torchspin.lft.dsoxf.orbital_occupancies(V, ops, kind='real')[source]#
Weights of the real orbitals in eigenvectors; each row sums to 1.
- Parameters:
V (Tensor, shape (..., N, N)) – Eigenvectors as columns.
ops (DsoxfOperators) – Configuration operators.
kind ({'real', 'general', 'cubic'}, default 'real') – L = 2: ignored, columns
D_ORBITALS. L = 3:'general'(F_GENERAL_ORBITALS) or'cubic'(F_CUBIC_ORBITALS).
- Returns:
torch.Tensor, shape (…, N, 2L+1) – Real-orbital weights per eigenvector.
- Return type:
- torchspin.lft.dsoxf.solve(ops, *, field=None, k=(1.0, 1.0, 1.0), units='MHz', constants=TORCHSPIN_CONSTANTS, **kw)[source]#
Diagonalize the DSOXF Hamiltonian.
- Parameters:
ops (DsoxfOperators) – Configuration operators.
field (array_like or Tensor, shape (3,), optional) – Field vector in mT.
k (array_like, shape (3,), default (1, 1, 1)) – Orbital reduction factors.
units (str, default 'MHz') – Energy unit of the inputs and of the solution.
constants (Constants, optional) – Physical constants.
**kw –
lam,rhoand crystal-field parameters, ashamiltonian().
- Returns:
Solution – Eigenvalues and eigenvectors with degenerate-safe derivatives.
- Return type:
- torchspin.lft.dsoxf.spin_expectation(V, ops)[source]#
Spin expectation values of eigenvectors.
- Parameters:
V (Tensor, shape (..., N, N)) – Eigenvectors as columns, in the
|m_L m_S>basis.ops (DsoxfOperators) – Configuration operators.
- Returns:
torch.Tensor, shape (…, N, 3) –
<S_x>, <S_y>, <S_z>of every eigenvector (gauge dependent inside degenerate levels).- Return type:
- torchspin.lft.dsoxf.transition_moments(V, mu, b1)[source]#
Squared transition moments
abs(<i|mu . b1|j>)**2.- Parameters:
V (Tensor, shape (..., N, N)) – Eigenvectors as columns.
mu (Tensor, shape (..., 3, N, N)) – Moment operators in mu_B (
zeeman_operators()).b1 (array_like or Tensor, shape (..., 3)) – Microwave-field direction (not normalized here).
- Returns:
torch.Tensor, shape (…, N, N) – In mu_B^2 (gauge dependent inside degenerate levels; see
level_matrix()).- Return type:
- torchspin.lft.dsoxf.zeeman_operators(ops, k=(1.0, 1.0, 1.0), constants=TORCHSPIN_CONSTANTS)[source]#
Magnetic-moment operators
mu / mu_B = s_L k_i L_i + g_e S_i.- Parameters:
ops (DsoxfOperators) – Configuration operators.
k (array_like or Tensor, shape (..., 3), default (1, 1, 1)) – Orbital reduction factors (dimensionless) along x, y, z.
constants (Constants, optional) – Physical constants (
g_e); defaulttorchspin.lft.ddn.TORCHSPIN_CONSTANTS.
- Returns:
torch.Tensor, shape (…, 3, N, N), complex128 – The x, y, z components in units of mu_B.
- Return type: