NMR functions

class nmrcryspy.nmr.ML_function(root: Optional[str] = None, data_file: Optional[str] = None)

Bases: object

Base class for the machine learning functions. Contains useful functions for the creation of the data files used by the ML function.

root
Type:

string filepath to data used for ML model

data_file
Type:

string name of initial data file for ML model

get_unique_atoms(structure)

Finds the symmetrically unique atoms of a structure object.

Parameters:

structure – pymatgen.Structure object to find symmetrically unique atoms.

Returns: int

make_file_from_structure(structure)

Takes a structure and creates the corresponding ML data file for that structure

Parameters:

structure – pymatgen.Structure object corresponding to the data file.

Return: string, string

remove_tmp_folder()

File to cleanup the generated scratch files.

class nmrcryspy.nmr.ShieldingTensor_Function(sigma_errors: Optional[dict] = None, regr_func: Callable = <function shielding_regr>, r_cut: float = 5, checkpoint: Optional[str] = None, root: Optional[str] = None, data_file: Optional[str] = None)

Bases: nmrcryspy.nmr.ML_function

ShieldingTensor_Function class for the prediction and residuals of the shielding tensor ML model.

sigma_errors

deviation of sigma_11, sigma_22, sigma_33 where the order of the sigma_ii’s follow the standard convention of sigma_11 > sigma_22 > sigma_33. Example: {‘sigma_11’: 0.4, ‘sigma_22’: 2.5, ‘sigma_33’: 0.7}

Type:

Dictionary containing the standard

regr_func

values to shift values

Type:

Callable Regression function used to convert shielding

r_cut

local neighborhood in the GNN

Type:

float representing cutoff radius used to define the

checkpoint

the GNN model

Type:

string containing name of the checkpoint file containing

root
Type:

string filepath to data used for ML model

data_file
Type:

string name of initial data file for ML model

assemble_residual_and_grad(structure, data_dictionary)

Function to package the Jacobian matrix and residual vector for the Gauss_Newton_Solver class.

Parameters:
  • structure – pymatgen.Structure object used to calculate the residual and Jacobian.

  • data_dictionary – Dict of the data_dictionary attribute from the Gauss_Newton_Solver which contains the ML data.

Returns: np.ndarray, np.array

calculate_grad_and_residual(root, data_file)

Function to calculate the gradient and residual for processing by the assemble_residual_and_grad function.

Parameters:
  • root – string containing the data file location for the calculation of the gradient and residual.

  • data_file – string contaning the name of the data file to be used for the gradient and residual.

Returns: list

class nmrcryspy.nmr.JTensor_Function(J_error: Optional[float] = None, regr_func: Callable = <function J_regr>, r_cut: float = 6, checkpoint: Optional[str] = None, root: Optional[str] = None, data_file: Optional[str] = None)

Bases: nmrcryspy.nmr.ML_function

JTensor_Function class for the prediction and residuals of the J tensor ML model.

J_error
Type:

The standard deviation of J coupling

regr_func

values to shift values

Type:

Callable Regression function used to convert shielding

r_cut

local neighborhood in the GNN

Type:

float representing cutoff radius used to define the

checkpoint

the GNN model

Type:

string containing name of the checkpoint file containing

root
Type:

string filepath to data used for ML model

data_file
Type:

string name of initial data file for ML model

assemble_residual_and_grad(structure, data_dictionary)

Function to package the Jacobian matrix and residual vector for the Gauss_Newton_Solver class.

Parameters:
  • structure – pymatgen.Structure object used to calculate the residual and Jacobian.

  • data_dictionary – Dict of the data_dictionary attribute from the Gauss_Newton_Solver which contains the ML data.

Returns: np.ndarray, np.array

calculate_grad_and_residual(root, data_file)

Function to calculate the gradient and residual for processing by the assemble_residual_and_grad function.

Parameters:
  • root – string containing the data file location for the calculation of the gradient and residual.

  • data_file – string containg the name of the data file to be used for the gradient and residual.

Returns: list