torchspin.lft.ddn#
DDN: differentiable d^n ligand-field Hamiltonian, levels, and doublet g tensor.
- H = A M_A + B M_B + C M_C + alpha L^2 + sum_ab V[a, b] E_real[a, b] + zeta sum_i l_i.s_i
mu_B sum_i B_i (k_i L_i + g_e S_i)
in the full basis of C(10, n) Slater determinants (Telser’s DDN, via telser-tools). Every parameter may be a tensor carrying gradients, with leading batch dimensions.
Units#
Energy-valued inputs (B, C, A, zeta, alpha, slater, the ligand field
V) and energy-valued outputs are in units (default 'MHz', torchspin’s unit; use
units='cm^-1' to work in wavenumbers, or 'GHz', 'K', 'eV'). The magnetic field
is in mT. The orbital reduction k is dimensionless. Internally everything is cm^-1.
>>> from torchspin import lft
>>> V = lft.crystal_field(Dq=1200.0) # cm^-1
>>> E = lft.ddn.levels(3, B=800.0, C=3200.0, V=V, zeta=200.0, units='cm^-1')
>>> g = lft.ddn.g_tensor(9, zeta=830.0, V=lft.aom(lft.octahedron(6000.0, 1000.0)),
... k=(0.8, 0.8, 0.8), units='cm^-1')
Degenerate levels are handled by torchspin.lft._linalg: the gradient of a degenerate
eigenvalue is that of its level’s mean, and the doublet g is differentiated through the
projector onto the doublet, which is exact at the Kramers degeneracy.
- class torchspin.lft.ddn.Constants(mu_b, g_e, k_b)[source]#
Physical constants used by the d^n Hamiltonian.
- Variables:
- torchspin.lft.ddn.TORCHSPIN_CONSTANTS = (0.00046686447719298217, 2.00231930436092, 0.6950348004861274)#
Derived from
torchspin.constants.
- class torchspin.lft.ddn.DnSystem(n, *, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu')[source]#
A d^n ion with cached operators.
DnSystem(n).levels(...),.g_tensor(...),.hamiltonian(...)and.zeeman_operators(k)call the module functions with the cached operators;unitsandconstantsset here are the defaults of every call (override per call).- Parameters:
- Variables:
size (int) – Basis size
C(10, n).
Examples
>>> from torchspin import lft >>> ion = lft.ddn.DnSystem(8, units='cm^-1') >>> ion.size, ion.levels(B=900.0, C=3600.0).shape (45, torch.Size([45]))
- class torchspin.lft.ddn.GTensor(ggT, principal, g, gap)[source]#
Effective spin-1/2 g tensor of the lowest doublet (returned by
g_tensor()).- Variables:
ggT (Tensor, shape (..., 3, 3)) –
g g^Tin the molecular frame.principal (Tensor, shape (..., 3)) – Principal g values (square roots of the eigenvalues of
ggT), ascending.g (Tensor, shape (..., 3, 3)) –
(g g^T)^(1/2), the symmetric molecular-frame g (exact gradients at axial g).gap (Tensor, shape (...)) – Energy from the doublet to the next state, in the
unitsof the call. Gradients of g scale as 1/gap: check that it is large.
- torchspin.lft.ddn.g_tensor(n, *, k=(1.0, 1.0, 1.0), units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu', **kw)[source]#
Zero-field g tensor of the lowest doublet of d^n.
Computes
(g g^T)_ij = 2 tr(P mu_i P mu_j)withPthe projector onto the two lowest states andmu = k L + g_e S.- Parameters:
n (int or DnOperators) – Number of d electrons (0 to 10) or a cached operator set.
k (array_like or Tensor, shape (..., 3), default (1.0, 1.0, 1.0)) – Orbital reduction factors.
units (str, default 'MHz') – Energy unit of the Hamiltonian keywords and of
gap.constants (Constants, default TORCHSPIN_CONSTANTS) – g_e of the moment operator.
device (str or device, default 'cpu') – Device of the operators.
**kw – Hamiltonian keywords of
hamiltonian()exceptfield(B,C,A,zeta,V,alpha,slater).
- Returns:
GTensor –
ggT,principal,g(dimensionless) andgap(units).- Raises:
ValueError – If
fieldis given (this is the zero-field g).TypeError – For an unknown keyword.
- Return type:
Notes
Meaningful for odd n (Kramers doublets) or any isolated ground doublet.
Examples
d^9 (Cu(II)) in an elongated octahedron, energies in cm^-1:
>>> import torch >>> from torchspin import lft >>> V = torch.diag(torch.tensor([9900., -2100., -5100., -5100., 2400.], dtype=torch.float64)) >>> res = lft.ddn.g_tensor(9, zeta=830.0, V=V, k=(0.8, 0.8, 0.8), units='cm^-1') >>> [round(float(x), 3) for x in res.principal] [2.071, 2.071, 2.42]
- torchspin.lft.ddn.hamiltonian(n, *, B=0.0, C=0.0, A=0.0, zeta=0.0, V=None, k=(1.0, 1.0, 1.0), alpha=0.0, slater=None, field=None, units='MHz', constants=TORCHSPIN_CONSTANTS, device='cpu')[source]#
Complex Hermitian d^n Hamiltonian in the full determinant basis.
Builds
A M_A + B M_B + C M_C + alpha L^2 + sum_ab V[a, b] E_real[a, b] + zeta sum_i l_i.s_i + mu_B field . (k L + g_e S)(module docstring). Every parameter may be a tensor with leading batch dimensions and gradients.- Parameters:
n (int or DnOperators) – Number of d electrons (0 to 10) or a cached operator set.
B (float or Tensor, default 0.0) – Racah parameters, in
units.Aonly shifts all levels.C (float or Tensor, default 0.0) – Racah parameters, in
units.Aonly shifts all levels.A (float or Tensor, default 0.0) – Racah parameters, in
units.Aonly shifts all levels.zeta (float or Tensor, default 0.0) – One-electron spin-orbit coupling constant, in
units.V (array_like or Tensor, shape (..., 5, 5), optional) – Real symmetric ligand-field matrix in the real-orbital basis (x2-y2, xy, xz, yz, z2), in
units(seetorchspin.lft.ligand_field). DefaultNone: no ligand field.k (array_like or Tensor, shape (..., 3), default (1.0, 1.0, 1.0)) – Orbital reduction factors (dimensionless); enter only the Zeeman term.
alpha (float or Tensor, default 0.0) – Trees correction (coefficient of L^2), in
units.slater (tuple of 3, optional) –
(F0, F2, F4)Slater integrals inunits; replacesA, B, Cwhen given.field (array_like or Tensor, shape (..., 3), optional) – Magnetic field vector in mT. Default
None: zero field.units (str, default 'MHz') – Energy unit of the inputs and of the result:
'MHz','GHz','Hz','cm^-1','K','eV','meV'or'J'.constants (Constants, default TORCHSPIN_CONSTANTS) – mu_B and g_e of the Zeeman term.
device (str or device, default 'cpu') – Device of the operators.
- Returns:
torch.Tensor, shape (…, nd, nd), complex128 – Hamiltonian in
units,nd = C(10, n).- Raises:
ValueError – If
nis not an integer from 0 to 10 orunitsis unknown.- Return type:
Examples
>>> from torchspin import lft >>> H = lft.ddn.hamiltonian(2, B=800.0, C=3200.0, units='cm^-1') >>> H.shape, H.dtype (torch.Size([45, 45]), torch.complex128)
- torchspin.lft.ddn.levels(n, *, relative=False, units='MHz', **kw)[source]#
Ascending energy levels of d^n.
- Parameters:
n (int or DnOperators) – Number of d electrons (0 to 10) or a cached operator set.
relative (bool, default False) – If True, subtract the lowest level (ground state at 0).
units (str, default 'MHz') – Energy unit of the inputs and the result (as
hamiltonian()).**kw – Hamiltonian keywords of
hamiltonian()(B,C,A,zeta,V,k,alpha,slater,field,constants,device).
- Returns:
torch.Tensor, shape (…, nd), float64 – Eigenvalues in
units, ascending,nd = C(10, n).- Return type:
Notes
The gradient of a degenerate eigenvalue is that of its level’s mean (exact for symmetry-protected degeneracies, a symmetric subgradient at an accidental crossing).
Examples
d^3 in an octahedral field (cm^-1); the ground 4A2 level is fourfold:
>>> from torchspin import lft >>> E = lft.ddn.levels(3, B=800.0, C=3200.0, V=lft.crystal_field(Dq=1500.0), ... units='cm^-1', relative=True) >>> E.shape, [round(float(x), 6) for x in E[:4]] (torch.Size([120]), [0.0, 0.0, 0.0, 0.0])
- torchspin.lft.ddn.zeeman_operators(n, k=(1.0, 1.0, 1.0), constants=TORCHSPIN_CONSTANTS, device='cpu')[source]#
Magnetic moment operators in Bohr magnetons,
k_i L_i + g_e S_i.- Parameters:
n (int or DnOperators) – Number of d electrons (0 to 10) or a cached operator set.
k (array_like or Tensor, shape (..., 3), default (1.0, 1.0, 1.0)) – Orbital reduction factors along x, y, z (dimensionless).
constants (Constants, default TORCHSPIN_CONSTANTS) – Supplies
g_e.device (str or device, default 'cpu') – Device of the operators (ignored when
nis aDnOperators).
- Returns:
torch.Tensor, shape (…, 3, nd, nd), complex128 –
mu_x, mu_y, mu_zover mu_B in the Slater-determinant basis,nd = C(10, n).- Raises:
ValueError – If
nis not an integer from 0 to 10.- Return type:
Examples
>>> from torchspin import lft >>> lft.ddn.zeeman_operators(1).shape torch.Size([3, 10, 10])