The core package provides fundamental data structures and classes to input systems to each component of colder.
core package
The colder.core.physics module provides the hamiltonian objects that describe spin systems.
Given the importance of this module, its documentation is provided within the main modules section. Click here for the documentation.
core backbone package
The core package requires additional modules that process the physics hamiltonian objects. These packages are listed here.
colder.core.quantum module
colder.core.pauli_algebra module
- colder.core.pauli_algebra.pauli_product(a: int, b: int) Tuple[complex, int][source]
Simplify the product between the Pauli operators sigma_a and sigma_b and compute the coefficient. The operators are ancoded using integer values: 1 -> sigma_x, 2 -> sigma_y, 3 -> sigma_z. 0 is the Identity.
- Parameters:
a (int) – first Pauli operator
b (int) – second Pauli operator (order matters)
- Returns:
coefficient and resulting operator
- Return type:
Tuple[complex, int]
- colder.core.pauli_algebra.pauli_sites_product(A: str, B: str, coeff: complex | None = None) Tuple[complex, str][source]
Given two input strings encoding Pauli operators in local sites, computes the local product of Pauli operators and returns the coefficient and resulting operator string.
- Parameters:
A (str) – String encoding Pauli operator (example: ‘IIXY’)
B (str) – _description_
coeff (complex, optional) – Global coefficient to be multiplied to the final result coefficient. Defaults to None.
- Returns:
The coefficient and the final operator string.
- Return type:
Tuple[complex, str]
- colder.core.pauli_algebra.operator_product(a: dict[str, complex], b: dict[str, complex], expr: dict | None = None, coeff: complex = 1, remove_null: bool = True) dict[str, complex][source]
Compute product between string prompted as dictionaries.
- Parameters:
a (dict[str, complex]) – First set of strings.
b (dict[str, complex]) – Second set of strings (order matters).
expr (dict, optional) – Dictionary to expand with terms. Defaults to None.
coeff (complex, optional) – Global coefficient for strings. Defaults to +1.
remove_null (bool, optional) – Remove null terms. Defaults to True.
- Returns:
Dictionary of string and associated coefficients.
- Return type:
dict[str, complex]
- colder.core.pauli_algebra.operator_commutator(a: dict[str, complex], b: dict[str, complex], coeff: complex = 1, remove_null: bool = True) dict[str, complex][source]
Compute commutator (ab-ba) between strings prompted as dictionaries.
- Parameters:
a (dict[str, complex]) – _description_
b (dict[str, complex]) – _description_
coeff (complex, optional) – _description_. Defaults to 1.
remove_null (bool, optional) – _description_. Defaults to True.
- Returns:
_description_
- Return type:
dict[str, complex]
colder.core.subroutines module
- colder.core.subroutines.remove_null_values_dictionary(expr: dict) dict[source]
Removes entries with null coefficients from expression dictionary.
- Parameters:
expr (dict) – Dictionary of strings and related coefficients.
- Returns:
Dictionary without null values.
- Return type:
dict
- colder.core.subroutines.build_string_from_operator_and_target(strlen: int, target: tuple, operator_sequence: str, default_op: str = 'I') str[source]
Create a string inserting the operator_sequence operators in target indices.
For instance, calling the function with arguments 5, (1,3), ‘XY’ will return ‘IXIYII’.
- Parameters:
strlen (int) – Total length of the string
target (tuple) – Indices of string to replace
operator_sequence (str) – Operators to replace (shoul have the same number of characters as target tuple elements)
default_op (str, optional) – default single site operator. Defaults to ‘I’ (identity in the algebra).
- Returns:
String with operator in target position.
- Return type:
str
- colder.core.subroutines.build_string_from_regular_pattern(N: int, pattern: str, default_op: str = 'I', coeff: complex = 1) dict[str, complex][source]
Given a string pattern, builds all the strings in which the pattern is repeated through all the N sites.
- Parameters:
N (int) – maximum length of string
pattern (str) – pattern (of length L) to be repeated
default_op (str, optional) – Default operator to fill the string. Defaults to ‘I’, for identity operator.
coeff (complex, optional) – Default coefficient to assign. Defaults to 1.
- Returns:
Dictionary of strings and related coefficients.
- Return type:
dict[str, complex]
- colder.core.subroutines.make_sum_expression(ops: dict[str, complex], global_coeff: complex = 1, symbol_prefix: str = 'sigma_')[source]
Sum the operators in input dictionary with related coefficients.
- Parameters:
ops (dict[str, complex]) – Strings to be cast as operators
coeff (complex, optional) – Global coefficient. Defaults to 1.
- Returns:
_description_
- Return type:
_type_
- colder.core.subroutines.expressions_to_linear_system_matrix(expressions: list, variables: list) <module 'sympy.matrices' from '/home/docs/checkouts/readthedocs.org/user_builds/colder/envs/latest/lib/python3.9/site-packages/sympy/matrices/__init__.py'>[source]
- colder.core.subroutines.make_linear_system(A: <module 'sympy.matrices' from '/home/docs/checkouts/readthedocs.org/user_builds/colder/envs/latest/lib/python3.9/site-packages/sympy/matrices/__init__.py'>, B: <module 'sympy.matrices' from '/home/docs/checkouts/readthedocs.org/user_builds/colder/envs/latest/lib/python3.9/site-packages/sympy/matrices/__init__.py'>, variables) Equality[source]
- colder.core.subroutines.get_operators_from_expr_with_prefix(expr, operator_prefix: str) List[source]
Returns a list of operators (as Sympy symbols) in expr starting with operator_prefix.