Input Functions
The high-level function mostly used is add_operator(…) that takes in an operator string and adds it to the Operator. While the function is capable of handling Hamiltonian terms and jump operators directly we have added the following wrapper to add a jump operator directly via add_jump_operator(…). New local operators can be added with define_operator(…). A diagonal shift is added with add_diagonal(…).
Warning
doxygenfunction: Unable to resolve function “danceq::internal::Operator::add_operator” with arguments (const ScalarType, const std::vector<uint64_t>, const std::vector<std::string>, const OperatorType, const bool) in doxygen xml output for project “DanceQ” from directory: /builds/DanceQ/danceq/docs/sphinx/../build/docs/doxygen/xml/. Potential matches:
- int32_t add_operator(const ScalarType coef, const std::vector<uint64_t> sites_to_act, const std::vector<std::string> operator_string, const OperatorType OT_term = Hamiltonian, const bool print_warning = true, const bool merge_terms_in_the_end = true)
Warning
doxygenfunction: Unable to resolve function “danceq::internal::Operator::add_jump_operator” with arguments (const ScalarType, const std::vector<uint64_t>, const std::vector<std::string>, const bool) in doxygen xml output for project “DanceQ” from directory: /builds/DanceQ/danceq/docs/sphinx/../build/docs/doxygen/xml/. Potential matches:
- int32_t add_jump_operator(const ScalarType coef, const std::vector<uint64_t> sites_to_act, const std::vector<std::string> operators_to_apply, const bool print_warning = true, const bool merge_terms_in_the_end = true)
-
int32_t danceq::internal::Operator::define_operator(std::string name, std::array<std::array<ScalarType, state_class::template_struct::template_Q>, state_class::template_struct::template_Q> matrix)
Adds an operator to the available operators.
Adds an operator to available_operators. If the name* already exists, it will be replaced.
\[\langle i \vert O \vert j \rangle = \delta_{i,j+1}\]- std::vector< std::vector<double>> matrix(Q,std::vector<double>(Q));
- for(uint64_t i_for = 0UL; i_for < Q; i_for++){
- for(uint64_t j_for = 0UL; j_for < Q; j_for++){
- if(i_for != j_for + 1){
matrix[i_for][j_for] = 0.; // two-dimensional array has to be set to zer
- } else {
matrix[i_for][j_for] = 1.;
}
}
} H.define_operator(“O”,matrix);
- Parameters:
name – Name of the operator
matrix – Interaction matrix of size Q times Q in form of an two-dimensional array
- Returns:
error_code
-
int32_t danceq::internal::Operator::add_diagonal(const ScalarType val)
Adds a diagonal shift.
Adds a constant to the diagonal of the operator:
\[O = O + \textbf{val} \cdot \mathbb{1}\otimes \dots \otimes \mathbb{1}\]The diagonal is initially set to zero.
- Parameters:
val – Adding val a diagonal contribution
- Returns:
error_code
-
int32_t danceq::internal::Operator::set_Ntensor_max(const uint64_t Ntensor_max_input)
Sets Ntensor_max.
Sets Ntensor_max.
- Parameters:
Ntensor_max_input – New value
- Returns:
error_code
-
int32_t danceq::internal::Operator::merge_terms(const bool transpose = false)
Identifies non-local subclusters to merge all operator strings that are fully supported on such a clusters.
The function groups sites into clusters to improve the performance and creates the
std::tuplein sparse_matrices_for_computation. Each term that is listed in operator_list will be assigned to a cluster in order to optimize the computation.An example*: In an one-dimensional spin chain with periodic boundary condition and nearest-neighbor terms of size \(L=30\) we can define three clusters containing sites \(C_0=\{0,\dots,10\}\), \(C_1=\{10,\dots,20\}\), and \(C_2=\{0,20,\dots,29\}\).
Hence, we only define three sparse matrices of size \(2^{11}\). For example, the terms \(S^x_3S^x_4\) and \(S^y_7S^y_8\) are assigned to the first cluster \(C_0\), and \(S^x_{16}S^x_{17}\) is assigned to the second cluster \(C_1\).
The maximal cluster size can is given by Ntensor_max and cane be set by calling set_Ntensor_max(…). Its default value is chosen such that the tensor matrix does not exceeds the dimension of 2028. However, if terms acting on more than Ntensor_max sites (e.g., long loop updates), Ntensor_max is increased. This function is called by add_operator(…).
The transposed problem will be encoded by setting transpose* to
true.- Parameters:
transpose – Sets the transposed problem
- Returns:
error_code
-
int32_t danceq::internal::Operator::add_default_operators(void)
Adds some local default operators.
The function adds the following local operator to available_operators:
{"Sx","Sy","Sz","S+","S-","n","R","Rdag","P"+std::to_string(k)}for \(k=0,\dots,\textbf{Q}-1`\).For spin operators, \(m,m^\prime =-S,-S+1,\dots,S\) with \(S = (\textbf{Q}-1)/2\):
\[\begin{split}\langle m^\prime \vert S^x \vert m \rangle &= \left( \delta_{m^\prime,m+1} + \delta_{m^\prime,m+1}\right)\frac{1}{2}\sqrt{S(S+1)-m^\prime m}\\ \langle m^\prime \vert S^y \vert m \rangle &= \left( \delta_{m^\prime,m+1} - \delta_{m^\prime,m+1}\right)\frac{1}{2i}\sqrt{S(S+1)-m^\prime m}\\ \langle m^\prime \vert S^z \vert m \rangle &= \delta_{m^\prime,m}m\\ \langle m^\prime \vert S^+ \vert m \rangle &= \delta_{m^\prime,m+1}\sqrt{S(S+1)-m^\prime m}\\ \langle m^\prime \vert S^- \vert m \rangle &= \delta_{m^\prime+1,m}\sqrt{S(S+1)-m^\prime m}\end{split}\]\(\vert m\rangle\) refer to qudit states: \(\vert 0\rangle, \dots,\vert \textbf{Q}-1\rangle\).
We further define more general qudit operators:
\[\begin{split}\langle i \vert n \vert j \rangle &= \delta_{i,j} i\\ \langle i \vert R \vert j \rangle &= \delta_{i,j+1}\\ \langle i \vert R^\dagger \vert j \rangle &= \delta_{i+1,j}\\ \langle i \vert P_k \vert j \rangle &= \delta_{i,k}\delta_{k,j}\end{split}\]- Returns:
error_code
-
int32_t danceq::internal::Operator::merge_given_terms(std::vector<uint64_t> &cluster, std::vector<std::pair<uint64_t, danceq::internal::ResolvedAction>> &list_of_terms, const bool transpose)
Merges given terms that are all defined on the given cluster.
This function is only called internally by merge_terms(…). It merges the terms given in list_of_terms* which refers to operator_list into a single entry in sparse_matrices_for_computation that is used in apply(…). All terms are fully supported on the given cluster*. The second argument in list_of_terms* refers to the precise action on the wavefunction or density matrix as specified in ResolvedAction.
The transposed problem will be encoded by setting transpose* to
true.- Parameters:
cluster – Sites on which the matrix is defined
list_of_terms – Terms that are included
transpose – Boolean to generate the transposed problem
- Returns:
error_code
-
enum danceq::internal::ResolvedAction
Defines the precise action of a term to the wavefunction or density matrix.
This is primarily used for the Lindbladian OperatorType where each jump operator \(l\) acts three times on a density matrix:
\[\frac{\text{d}\rho}{\text{d}t} = \gamma l\rho l^\dagger - \gamma\frac{1}{2}l^\dagger l\rho - \gamma\frac{1}{2}\rho l^\dagger l\]Each term in the Hamiltonian \(h\) acts two times on the density matrix \(\rho\) according von Neumann equation
\[\frac{\text{d}\rho}{\text{d}t} = -ih\rho +i\rho h\]Values:
-
enumerator wavefunction
Action of a term in Hamiltonian to the wavefunction.
-
enumerator density_matrix_commutator_left
Action of a term in the Hamiltonian from the left of the density matrix coming from the commutator.
-
enumerator density_matrix_commutator_right
Action of a term in the Hamiltonian from the right of the density matrix coming from the commutator.
-
enumerator density_matrix_jump_operator_both_sites
Action of a jump operator from both sides of the density matrix.
-
enumerator density_matrix_jump_operator_anti_commutator_left
Action of a jump operator from the left of the density matrix coming from the anti commutator.
-
enumerator density_matrix_jump_operator_anti_commutator_right
Action of a jump operator from the right of the density matrix coming from the anti commutator.
-
enumerator wavefunction