common_utils
Useful helper functions for several files in the ACE library.
- check_triangle(l1, l2, l3)[source]
Check if three quantum angular momenta obey triangle conditions.
Note that the order matters.
- Parameters:
l1 (int) – angular momentum quantum number 1
l2 (int) – angular momentum quantum number 2
l3 (int) – angular momentum quantum number 3
- Returns:
condition – If True, a triangle can be formed.
- Return type:
bool
- filled_perm(tuples, rank)[source]
Return sympy Permutation object for permutations tabulated from GAP. This function uses rank to fill in missing permutation indices from GAP.
For example tuples = [(0,1)], rank=4 would yeild Permutation(3)(0,1) corresponding to the cycles (0,1)(2)(3).
- Parameters:
tuples (List) – list of touples indicating the partitions of N (e.g., for the (2,2) partition of 4, tuples should be [(0,1),(2,3)]
rank (int) – Rank of the descriptor (N)
- Returns:
Permutation – Permutation object for the permutations.
- Return type:
sympy.combinatorics.Permutation
- flatten(list_of_lists)[source]
Flatten a list of lists.
Returns input, if input is not a list of lists.
- Parameters:
list_of_lists (List) – List of lists.
- Returns:
list – Flattened list.
- Return type:
List
- get_ms(l_vector, M_R=0)[source]
Retrieve the set of m_i combination with sum_i m_i = M_R.
These combinations are retrieved for an arbitrary l multiset.
- Parameters:
l_vector (List) – collection of angular momentum quantum numbers corresponding to spherical harmonics l1,l2…lN
M_R (int) – Sum to which combinations sum.
- Returns:
m_strs – Set of all combinations of m quantum numbers, obeying appropriate -li <= mi <= li
- Return type:
List
- group_vector_by_nodes(vector, nodes, remainder=None)[source]
Group a vector according to the mapping given in nodes.
If there is a remainder, it is added to the end of the list.
- Parameters:
vector (List) – Vector to be grouped.
nodes (List) – List of nodes.
remainder (int) – Remainder to be added to the end of the list.
- Returns:
vector_by_tuples – Grouped vector.
- Return type:
List
- group_vector_by_nodes_pairwise(vector, nodes, remainder=None)[source]
Group a vector of l quantum numbers pairwise.
- Parameters:
vector (List) – vector of l quantum numbers.
nodes (List) – List of nodes by which to pair vector.
remainder – Remainder node for binary trees with odd numbers of leaves.
- Returns:
vector_by_tuples
- Return type:
List
- group_vector_by_orbits(vector, partition)[source]
Group vector by orbits.
The partition is a list of integers that sum to the length of the vector.
- Parameters:
vector (List) – Vector to be grouped.
partition (List) – Partition to be grouped by.
- Returns:
vector_by_orbits – Grouped vector.
- Return type:
List