Gauss_Newton_Solver

class nmrcryspy.Gauss_Newton_Solver(fit_function: List[Callable], structure: pymatgen.core.structure.Structure, data_dictionary: dict, max_iter: int = 1000, tolerance_difference: float = 1e-10, tolerance: float = 1e-09)

Bases: object

The Gauss-Newton solver class. Given data dictionary, the crystal structure and a list of fit functions, minimize sum(residual^2) where residual = f(structure) - y.

fit_function
Type:

List of callable functions that need to be fitted;

structure
Type:

a pymatgen structure containing the initial structure to be optimized.

data_dictionary
Type:

a Dict object containing the observations for the fit_functions.

max_iter
Type:

An int representing maximum number of iterations for optimization.

tolerance_difference

iterations smaller than tolerance.

Type:

A float. Terminate iteration if RMSE difference between

tolerance
Type:

a float. Terminate iteration if RMSE is smaller than tolerance.

fit()

Optimize the atom positions in structure by minimizing RMSE. Returns a list of dictionaries containing information for each iteration of the fit. Each entry contains: the iteration step, step; the step size used, alpha; the chi^2 value, chi; and the structure at that step, structure.

Returns: dict

get_residuals_and_jacobian(data_dictionary, structure)

Calculates the residual vector and Jacobian matrix for a given structure.

Parameters:
  • data_dictionary – dictionary containing the type of calculation to perform on an index relevant indicies of neighboring atoms.

  • structure – pymatgen.Structure object to calculate residuals and Jacobian on.

Returns: np.array, np.ndarray

make_symmetry_dictionary()

Given the structure, finds the mapping between the atoms in the complete cell and the base atoms. Returns a dictionary where each entry is an atom in the structure, its symmetry operation, and the original atom it is derived from.

Returns: dict

update_structure(structure, sym_dict, x_prime, alpha)

Function to apply a translation to the atoms in the structure while respecting the original spacegroup of the structure. Saves the new structure as the class attribute structure.

Parameters:
  • structure – pymatgen.Structure object containing initial structure.

  • sym_dict – dict object containing the symmetry operations that correspond to each atom in the above structure from a set of base atoms.

  • x_prime – a np.ndarray vector containing the translation vectors for each of the base atoms.

  • alpha – a float representing the step size for the translations.