hqs_nmr.spin_dependent_clustering
Functions that can identify for a particular spin the most strongly coupled spins.
Used to construct spin-dependent clusters.
Functions
|
Create weight matrix according to perturbation theory. |
|
Identify for each spin the best cluster and group spins with the same cluster together. |
|
For one spin return sorted list with indices of spins its strongest coupled with. |
|
For one spin return sorted list with indices of spins its strongest coupled with. |
|
Identify clusters for each spin. |
- hqs_nmr.spin_dependent_clustering.get_weight_matrix(hJp: ndarray, Jz: ndarray, weight_offset: float) ndarray
Create weight matrix according to perturbation theory.
\[w_{x,y} = \frac{|J_{x,y}|^2}{|J^z_x - J^z_y| + d}\]- Parameters:
hJp – J-coupling matrix.
Jz – Jz vector.
weight_offset – Small factor to avoid division by zero.
- Returns:
Matrix with weights from perturbation theory.
- hqs_nmr.spin_dependent_clustering.spin_dependent_cluster_finder_prim(spin_index: int, weights: ndarray, max_cluster_size: int, epsilon: float = 1e-12) list[int]
For one spin return sorted list with indices of spins its strongest coupled with.
This uses something related to Prim’s algorithm (https://en.wikipedia.org/wiki/Prim%27s_algorithm).
- Parameters:
spin_index – Index of the spin for which to find the coupled spins.
weights – Weight matrix of the effective spin system.
max_cluster_size – Maximum number of spins the spin is allowed to couple to.
epsilon – Minimum weight for a spin to be considered.
- Returns:
Integer array with sorted indices that make up the cluster for the spin.
- hqs_nmr.spin_dependent_clustering.spin_dependent_cluster_finder_bfs(spin_index: int, weights: ndarray, max_cluster_size: int, epsilon: float = 1e-12) list[int]
For one spin return sorted list with indices of spins its strongest coupled with.
This uses the Breadth-first search (https://en.wikipedia.org/wiki/Breadth-first_search).
- Parameters:
spin_index – Index of the spin for which to find the coupled spins.
weights – Weight matrix of the effective spin system.
max_cluster_size – Maximum number of spins the spin is allowed to couple to.
epsilon – Small threshold for the weight of the bonds between spins.
- Returns:
Integer array with sorted indices that make up the cluster for the spin.
- hqs_nmr.spin_dependent_clustering.spin_dependent_cluster_list(weights: ndarray, J_coupling: ndarray, max_cluster_size: int, number_spins: int, verbose: int = 0, clustering_method: str = 'BFS', epsilon: float = 1e-12) tuple[list, list]
Identify clusters for each spin.
- Parameters:
weights – Weight matrix of the effective spin system.
J_coupling – Matrix with J-coupling values.
max_cluster_size – Maximum number of spins the spin is allowed to couple to.
number_spins – Number of spin half in the full system.
verbose – Verbosity level of output.
clustering_method (str) – The clustering method to use. Can be either “BFS” or “PRIM”. Defaults to BFS.
epsilon – Small threshold for the weight of the bonds between spins.
- Returns:
List of lists of spins that are associated with identical clusters. List of integer arrays with sorted indices that make up the clusters.
- hqs_nmr.spin_dependent_clustering.identify_spin_dependent_clusters(Jz: np.ndarray, hJp: np.ndarray, solver_settings: NMRSolverSettings) tuple[list, list]
Identify for each spin the best cluster and group spins with the same cluster together.
- Parameters:
Jz – Array with S^z terms. dim: (number_spins).
hJp – Array with the S^+ S^- coupling. dim: (number_spins x number_spins).
solver_settings – NMRSolverSettings object containing information on the cluster and solver method.
- Returns:
List of lists of spins that are associated with identical clusters. List of integer arrays with sorted indices that make up the clusters.