Line Search functions

nmrcryspy.linesearch.update_chi2(functions, alpha, x_prime, sym_dict, data_dictionary, initial_struct, NUM_ATOMS, UNIQUE_IND)

Updates the chi squared in response to a perturbation

Parameters:
  • functions – list of callable optimizer functions.

  • alpha – float of the stepsize

  • x_prime – np.ndarray for perturbation vector directions.

  • sym_dict – symmetry dictionary mappings for the structure.

  • data_dictionary – Dict of the data_dictionary attribute from the Gauss_Newton_Solver

  • initial_structure – unmodified pymatgen.Structure object

  • NUM_ATOMS – int of the number of unique atoms in the structure

  • UNIQUE_IND – np.ndarray of the indicies of each group of unique atoms.

Returns: float

nmrcryspy.linesearch.get_derivative(function, phi, alpha, x_prime, sym_dict, data_dictionary, initial_struct, NUM_ATOMS, UNIQUE_IND, epsilon=0.01)

calculates numerical derivative of the chi squared with respect to the stepsize.

Parameters:
  • functions – list of callable optimizer functions.

  • phi – float of the chi squared

  • alpha – float of the stepsize

  • x_prime – np.ndarray for perturbation vector directions.

  • sym_dict – symmetry dictionary mappings for the structure.

  • data_dictionary – Dict of the data_dictionary attribute from the Gauss_Newton_Solver

  • initial_structure – unmodified pymatgen.Structure object

  • NUM_ATOMS – int of the number of unique atoms in the structure

  • UNIQUE_IND – np.ndarray of the indicies of each group of unique atoms.

  • epsilon – float stepsize for the calculation of numerical derivatives

Returns: float

nmrcryspy.linesearch.quadratic_interpolation(alpha_low, phi_low, d_phi_low, alpha_high, phi_high)

Quadratic interpolation scheme to find an alpha value between alpha high and alpha low

Parameters:
  • alpha_low – lower bound alpha value

  • phi_low – chi squared term at lower alpha

  • d_phi_low – derivative of chi squared at lower alpha

  • alpha_high – upper alpha bound

  • phi_high – chi squared at upper alpha bound

Returns: Float

nmrcryspy.linesearch.cubic_interpolation(alpha_low, phi_alpha_low, d_alpha_low, alpha_high, phi_alpha_high, alpha_test, phi_alpha_test)

Cubic interpolation scheme to find an alpha value between alpha high and alpha low with knowledge of an intermediate alpha value

Parameters:
  • alpha_low – lower bound alpha value

  • phi_low – chi squared term at lower alpha

  • d_phi_low – derivative of chi squared at lower alpha

  • alpha_high – upper alpha bound

  • phi_high – chi squared at upper alpha bound

  • alpha_test – intermediate alpha value

  • phi_alpha_test – chi squared at the intermediate alpha value

Returns: float

nmrcryspy.linesearch.zoom(function, phi_0, dphi_0, alpha_low, alpha_high, x_prime, sym_dict, dist_test_dict, struct, NUM_ATOMS, UNIQUE_IND, epsilon=0.01, c1=0.0001, c2=0.9)

Zoom function of linesearch algorithm. Uses algorithm described as algorithm 3.6 in Wright and Nocedal, ‘Numerical Optimization’, 1999, pp. 61

Parameters:
  • function – list of callable optimizer functions.

  • phi_0 – float of the alpha = 0 chi squared

  • dphi_0 – float derivative of the alpha = 0 chi squared

  • alpha_low – float lower bound of alpha range to check

  • alpha_high – float upper bound of alpha range to check

  • x_prime – np.ndarray for perturbation vector directions.

  • sym_dict – symmetry dictionary mappings for the structure.

  • dist_test_dict – Dict of the data_dictionary attribute from the Gauss_Newton_Solver

  • structure – unmodified pymatgen.Structure object

  • NUM_ATOMS – int of the number of unique atoms in the structure

  • UNIQUE_IND – np.ndarray of the indicies of each group of unique atoms.

  • epsilon – float stepsize for the calculation of numerical derivatives

  • max_iter – integer of maximum iterations of linesearch procedure

  • c1 – float for Armijo condition rule

  • c2 – float for curvature condition rule

Returns: float, float

Line search function to find the optimal step size along a descent path. Uses algorithm described in Wright and Nocedal, ‘Numerical Optimization’, 1999, pp. 59-61 to enforce strong Wolfe conditions.

Parameters:
  • function – list of callable optimizer functions.

  • phi_0 – float of the alpha = 0 chi squared

  • x_prime – np.ndarray for perturbation vector directions.

  • sym_dict – symmetry dictionary mappings for the structure.

  • dist_test_dict – Dict of the data_dictionary attribute from the Gauss_Newton_Solver

  • structure – unmodified pymatgen.Structure object

  • NUM_ATOMS – int of the number of unique atoms in the structure

  • UNIQUE_IND – np.ndarray of the indicies of each group of unique atoms.

  • epsilon – float stepsize for the calculation of numerical derivatives

  • max_iter – integer of maximum iterations of linesearch procedure

  • c1 – float for Armijo condition rule

  • c2 – float for curvature condition rule

Returns: float, float