torchspin.lft.ddnfit#

DDNFIT: least-squares fit of d^n ligand-field parameters to band energies, with the exact Jacobian.

A thin Telser-named front end to torchspin.lft.fit.JointFit with one Bands data set. States are numbered as DDNFIT does: 1-based over all C(10, n) states in ascending order, energies relative to state 1, in units. Add susceptibility, magnetization, g values or an EPR spectrum by using JointFit directly (see fit() for an example).

torchspin.lft.ddnfit.fit(n, parameters, model, states, energies, sigma=1.0, units='MHz', **kw)[source]#

Fit d^n ligand-field parameters to band energies (DDNFIT), with the exact Jacobian.

Parameters:
  • n (int) – Number of d electrons, 0 to 10.

  • parameters (sequence of FitParameter) – Named fit parameters with start values, bounds and fixed flags (torchspin.lft.fit.FitParameter).

  • model (callable) – model(p) -> dict: maps a dict of named scalar tensors to keywords of torchspin.lft.ddn.hamiltonian() (B, C, zeta, V, …), in units.

  • states (sequence of int) – 1-based state numbers as DDNFIT counts them: all C(10, n) states in ascending energy, state 1 the ground state. A degenerate level is fitted through its mean.

  • energies (sequence of float) – Observed energies relative to state 1, in units.

  • sigma (float or sequence of float, default 1.0) – Uncertainties of energies in units (residuals are divided by them).

  • units (str, default 'MHz') – Energy unit of the model keywords and of the data.

  • **kw – Passed to torchspin.lft.fit.JointFit.fit() (and on to scipy.optimize.least_squares(); default trust-region reflective with bounds).

Returns:

torchspin.lft.fit.JointOutcome – The fit result (values, standard errors), chi^2 per data set and undetermined parameter combinations.

Raises:

ValueError – If a state number is below 1 or parameter names repeat.

Return type:

JointOutcome

See also

torchspin.lft.fit.JointFit

Joint fits of bands, chi, M, g and spectra.

Examples

Racah B and Dq of a d^3 ion from two band energies (cm^-1), C = 4 B:

>>> from torchspin import lft
>>> from torchspin.lft.fit import FitParameter
>>> out = lft.ddnfit.fit(3, [FitParameter('B', 700, 400, 1100), FitParameter('Dq', 1500, 800, 2500)],
...                      lambda p: dict(B=p['B'], C=4.0 * p['B'], V=lft.crystal_field(p['Dq'])),
...                      states=[5, 17], energies=[17400.0, 24000.0], sigma=50.0, units='cm^-1')
>>> out.result.names, out.chi2['bands'] < 1e-6
(['B', 'Dq'], True)