torchspin.lft.ddnmag#
DDNMAG: differentiable molar magnetization M(B, T) of a d^n ion from the full ligand-field model.
m(n, B, T) = <-n.(k L + g_e S)>_T (Bohr magnetons per ion along the field direction n)
with H = H_LF(d^n) + mu_B abs(B) n.(k L + g_e S), the exact thermal average over every state of the
d^n configuration (Hellmann-Feynman), and powder averages as weighted sums over an
torchspin.lft.grids.OrientationGrid. This is Telser’s DDNMAG with method="exact";
DDN’s finite-difference schemes (Hendrickson, McGarvey, …) approximate the same quantity and
are not ported.
The thermal average uses torchspin.lft._linalg.thermal_average, whose derivative
(Daleckii-Krein) is exact through the degeneracies M always has (Kramers pairs, cubic levels,
field-induced crossings), so every ligand-field parameter can carry gradients.
Units#
field in mT, T in K. Energy-valued ligand-field parameters in units (default ‘MHz’;
‘cm^-1’ etc. on request; see torchspin.lft.ddn). M_units: 'muB' (Bohr magnetons
per ion, as torchspin.curry() returns), 'emu/mol' (DDNMAG’s unit; 1 N_A mu_B = 5585
emu/mol) or 'SI' (A m^2/mol). Temperature-independent paramagnetism chi0 is in
chi_units ('SI' m^3/mol, default, or 'cgs' cm^3/mol).
- class torchspin.lft.ddnmag.MagConstants(mu_b, g_e, k_b, N_A, mu_b_SI, mu0)[source]#
Physical constants of the magnetometry functions.
- Variables:
mu_b (float) – Bohr magneton over h c, in cm^-1 per mT.
g_e (float) – Free-electron g value.
k_b (float) – Boltzmann constant over h c, in cm^-1 per K.
N_A (float) – Avogadro constant, 1/mol.
mu_b_SI (float) – Bohr magneton in J/T.
mu0 (float) – Vacuum permeability in H/m.
ddn (Constants) – Property: the
(mu_b, g_e, k_b)subset astorchspin.lft.ddn.Constants.
- torchspin.lft.ddnmag.MAG_CONSTANTS = (0.00046686447719298217, 2.00231930436092, 0.6950348004861274, 6.02214076e+23, 9.2740100657e-24, 1.25663706127e-06)#
From
torchspin.constants(CODATA 2022 mu_B and mu_0).
- class torchspin.lft.ddnmag.MagResult(per_direction, powder)[source]#
Magnetization (or susceptibility) per field direction and powder averaged.
- Variables:
- torchspin.lft.ddnmag.fit(n, parameters, model, field, T, values, sigma=0.01, *, M_units='muB', grid=None, units='MHz', **kw)[source]#
DDNMAG fit: ligand-field parameters to powder M(field_i, T_i), with the exact Jacobian.
Thin front end to
torchspin.lft.fit.JointFitwith oneMagnetizationdata set.- Parameters:
n (int) – Number of d electrons.
parameters (sequence of FitParameter) – Fit parameters (
torchspin.lft.fit.FitParameter).model (callable) – Maps a dict of named scalar tensors to keywords of
torchspin.lft.ddn.hamiltonian()(inunits).field (array_like) – Data points: fields in mT, temperatures in K, magnetizations in
M_units(broadcast together).T (array_like) – Data points: fields in mT, temperatures in K, magnetizations in
M_units(broadcast together).values (array_like) – Data points: fields in mT, temperatures in K, magnetizations in
M_units(broadcast together).sigma (float or array_like, default 0.01) – Uncertainties of
values(M_units).M_units ({'muB', 'emu/mol', 'SI'}, default 'muB') – Unit of
values.grid (OrientationGrid, optional) – Powder grid; default the exact Gauss hemisphere, n = 6.
units (str, default 'MHz') – Energy unit of the model’s keywords.
**kw – Passed to
torchspin.lft.fit.JointFit.fit()(and on toscipy.optimize.least_squares()).
- Returns:
torchspin.lft.fit.JointOutcome
- torchspin.lft.ddnmag.magnetization(n, field, T, *, grid=None, M_units='muB', chi0=0.0, chi_units='SI', units='MHz', k=(1.0, 1.0, 1.0), ddn_mirror=False, constants=MAG_CONSTANTS, chunk=None, device='cpu', **params)[source]#
Molar magnetization of a d^n ion along the field, per direction and powder averaged.
- Parameters:
n (int or DnOperators) – Number of d electrons (0 to 10) or cached operators.
field (array_like or Tensor, shape (nB,)) – Field magnitudes in mT.
T (array_like or Tensor, shape (nT,)) – Temperatures in K, all > 0.
grid (OrientationGrid or array_like, optional) – Field directions and weights (
torchspin.lft.grids), or direction vectors (normalized, equal weights). DefaultNone: the field along z only.M_units ({'muB', 'emu/mol', 'SI'}, default 'muB') – Unit of the result: Bohr magnetons per ion, emu/mol (DDNMAG’s unit,
1 N_A mu_B = 5585 emu/mol) or A m^2/mol.chi0 (float or Tensor, default 0.0) – Temperature-independent paramagnetism in
chi_units; addschi0 * H.chi_units ({'SI', 'cgs'}, default 'SI') – Unit of
chi0: m^3/mol or cm^3/mol.units (str, default 'MHz') – Energy unit of the ligand-field keywords.
k (array_like or Tensor, shape (3,), default (1.0, 1.0, 1.0)) – Orbital reduction factors.
ddn_mirror (bool, default False) – Apply
mirror_y()toV(DDN’s convention).constants (MagConstants, default MAG_CONSTANTS) – Physical constants.
chunk (int, optional) – Directions diagonalized at once (memory).
**params – Ligand-field keywords of
torchspin.lft.ddn.hamiltonian()(B,C,A,zeta,V,alpha,slater) inunits; may be batched and carry gradients.
- Returns:
MagResult –
per_direction(…, ndir, nB, nT) andpowder(…, nB, nT) inM_units.- Raises:
ValueError – For a non-positive temperature, unknown
M_unitsor (with a nonzerochi0) unknownchi_units.TypeError – For an unknown keyword.
- Return type:
Examples
d^1 in a strong octahedral field (cm^-1), field along z:
>>> from torchspin import lft >>> m = lft.ddnmag.magnetization(1, [1000.0, 5000.0], [2.0, 300.0], ... V=lft.crystal_field(Dq=2000.0), zeta=500.0, units='cm^-1') >>> m.per_direction.shape, m.powder.shape (torch.Size([1, 2, 2]), torch.Size([2, 2]))
- torchspin.lft.ddnmag.moment_core(H0, mu, field, T, directions, constants=MAG_CONSTANTS, chunk=None)[source]#
Thermal average of the moment along the field, in Bohr magnetons per ion.
Low-level kernel of
magnetization():<-n.mu>_TforH = H0 + mu_B B n.mu, exact over every state. The moment is set to 0 at B = 0 (time reversal).- Parameters:
H0 (Tensor, shape (..., nd, nd)) – Zero-field Hamiltonian in cm^-1.
mu (Tensor, shape (..., 3, nd, nd)) – Moment operators
k L + g_e Sin mu_B.field (array_like or Tensor, shape (nB,)) – Field magnitudes in mT.
T (array_like or Tensor, shape (nT,)) – Temperatures in K, all > 0.
directions (array_like, shape (ndir, 3)) – Unit field directions.
constants (MagConstants, default MAG_CONSTANTS) – mu_B and k_B.
chunk (int, optional) – Directions diagonalized at once (memory); default automatic.
- Returns:
torch.Tensor, shape (…, ndir, nB, nT), float64 – Moment in mu_B per ion.
- Raises:
ValueError – If a temperature is not positive.
- Return type:
- torchspin.lft.ddnmag.mirror_y(V)[source]#
Ligand field of the mirror image (y -> -y),
P V PwithP = diag(1, -1, 1, -1, 1).This is what DDNSUS/DDNMAG effectively compute (their internal field is
conj(V_m)); passddn_mirror=Truetomagnetization()to reproduce DDN’s numbers for a general field direction.