State enumeration with number conservation
All functions have the name tag _conserve which means that the total particle number is conserved. The particle number within the range can be obtained by get_particle_number(start,end). The number of possible states is given by Eq. (2) which is returned by get_dim_U1(…). The constructor can be found in Constructors with indexing. We provide functions for forward and backward iteration as well as mappings from indices to the physical state and vice versa.
Example code:
using State = danceq::internal::State<5,4,uint64_t>; uint64_t start = 1; uint64_t end = 4; uint64_t number = 3; State state(0UL, number, start, end); uint64_t dim = state.get_dim_U1(number,end-start); std::cout << "[main] - dim = " << dim << std::endl; for(uint64_t i = 0; i < dim; i++){ std::cout << "[main] - |Psi_" << i << "> = " << state << std::endl; state.increment_U1(start,end); }
Output:
[main] - dim = 10 [main] - |Psi_0> = |0;3;0;0;0> [main] - |Psi_1> = |0;2;1;0;0> [main] - |Psi_2> = |0;1;2;0;0> [main] - |Psi_3> = |0;0;3;0;0> [main] - |Psi_4> = |0;2;0;1;0> [main] - |Psi_5> = |0;1;1;1;0> [main] - |Psi_6> = |0;0;2;1;0> [main] - |Psi_7> = |0;1;0;2;0> [main] - |Psi_8> = |0;0;1;2;0> [main] - |Psi_9> = |0;0;0;3;0>
-
uint64_t danceq::internal::State::get_particle_number(const uint64_t start = 0, const uint64_t end = MaxSites) const
Returns the total particle number within a given range.
The particle number within the range start and end is defined by
\[\textbf{particle_number} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \sigma_i\,.\]- Parameters:
start – Start of range
end – End of range
- Returns:
Particle number
-
static uint64_t danceq::internal::State::get_dim_U1(const uint64_t number, const uint64_t length = MaxSites, const uint64_t Q_ = Q)
Returns the dimension of a specific sector with number conservation.
The dimension of a particle number sector for a system of size length and a local Hilbert space dimension Q__ with a total of number excitations is obtained by the Eq. (2).
Warning
The method produces overflow errors due the alternating sign in the equation for large values.
- Parameters:
number – Number sector
length – Size of the system
Q_ – Local Hilbert space dimension
- Returns:
Dimension
-
int32_t danceq::internal::State::set_state_from_index_U1(const uint64_t index, const IntType num = -1, const uint64_t start = 0, const uint64_t end = MaxSites)
Sets a State defined by an index with number conservation.
The state refers to the index with number conservation in the range start to end. This is the inverse function of get_index_U1. The particle number can be set by num. Its default value is -1 which takes the current particle number, get_particle_number(start, end), as an input.
- Parameters:
index – Index to be set
num – Particle number sector
start – Start of range
end – End of range
- Returns:
error_code
-
uint64_t danceq::internal::State::get_index_U1(const uint64_t start = 0, const uint64_t end = MaxSites) const
Retrieves index from the State.
The index is obtained by the integer counting in the range start to end with additional number conservation. This is the inverse function of set_state_from_index_U1.
- Parameters:
start – Start of range
end – End of range
- Returns:
error_code
-
int32_t danceq::internal::State::increment_U1(uint64_t start = 0, uint64_t end = MaxSites, bool *overflow = nullptr)
Incrementing the State with number conservation.
The state is set to its increment defined by integer counting in the range start to end and the current particle number.
If overflow is given, it is set to
true
if the state jumps from its maximal index to the minimal index.- Parameters:
start – Start of range
end – End of range
overflow – Pointer to register overflow
- Returns:
error_code
-
int32_t danceq::internal::State::decrement_U1(uint64_t start = 0, uint64_t end = MaxSites, bool *underflow = nullptr)
Decrementing the State with number conservation.
The state is set to its decrement defined by integer counting in the range start to end and the current particle number.
If underflow is given, it is set to
true
if the state jumps from its minimal index to the maximal index.- Parameters:
start – Start of range
end – End of range
underflow – Pointer to register underflow
- Returns:
error_code