Workflow - asche1/PyCrystalField GitHub Wiki

There are three basic operations that PyCrystalField carries out: building a CEF Hamiltonian, fitting a CEF Hamiltonian, and calculating observables based on the CEF Hamiltonian.
PyCrystalField can build a crystal field Hamiltonian in two ways: directly define CEF parameters, or build a point charge model.
There are two ways to build a CEF Hamiltonian from CEF parameters:
-
Call
CFLevels.Bdict(ion, Bdict)(recommended method)
ionis a string (e.g.,'Nd3+')
Bdictis a dictionary with labels Bnm and values of CEF parameters, e.g.:{'B20': 0.45, 'B44', -0.034, ...} -
Call
CFLevels(StevensOperators, Parameters)
StevensOperatorsis a list of operators generated byStevensOp(J,n,m), andParametersare the CEF parameters.
Note there is also a third way CFLevels.Hamiltonian(H), where one provides a Hamiltonian matrix H as an input. This method is only meant for use when building CEF Hamiltonians within fit functions (it reduces the number of operations).
PyCrystalField can construct a point charge model two ways:
-
Import structure from a .cif file using
importCIF(ciffile, mag_ion)(recommended method)
One must specify the cif file and the name of the central ion, and PyCrystalField automatically aligns the axes along the symmetry directions to minimize the number of CEF parameters. One can also specify custom axes, which basis to calculate, the number of nearest neighbors, etc. -
Create an instance of
Ligands(ion, ligandPos, latticeParams, ionPos), and then use theLigands.PointChargeModelfunction. [add hyperlinks] ``
The CFLevels.fitdata function is a wrapper around scipy's minimize function. The user must provide a cost function to minimize which has a CFLevels object as its first argument, and specify which variables in the cost function are to be fit.
Ligands.FitCharges is a similar function which is set up to fit effective charges of a point charge model.
The CFLevels class has many functions which can calculate observable quantities:
| function | description |
|---|---|
CFLevels.neutronSpectrum |
calculates the energy-dependent (Q-independent) neutron spectrum |
CFLevels.normalizedNeutronSpectrum |
calculates the neutron spectrum without the k_i/k_f correction (common for time-of-flight measurements). |
CFLevels.neutronSpectrum2D |
computes the Q and E dependent neutron spectrum |
CFLevels.magnetization |
compute the directional magnetization for a given temperature and applied magnetic field |
CFLevels.susceptibility |
compute magnetic susceptibility (single-crystal or powder-averaged) for the ion |
CFLevels.gtensor |
returns the g-tensor of the ion computed numerically |
The CFLevels class also has some functions which print key quantities of interest:
| function | description |
|---|---|
CFLevels.printEigenvectors |
prints the eigenvalues and eigenvectors of a CEF Hamiltonian |
CFLevels.printLaTexEigenvectors |
prints the eigenvalues and eigenvectors in the format of a LaTex ruledtabular table |
CFLevels.gsExpectation |
prints <J_x>, <J_y>, and <J_z> for the ground state |