Skip to content

ProductState

A product state of local configurations on a given number of sites. The local states are encoded using an integer. Each integer represents a certain local physical state which differs from block to block. Here is a summary for each one of the main 5 block types:

Fermion

Integer Configuration Symbol
0 empty
1 occupied fermion

Boson

The local configuration of a site is simply the occupation number, i.e. an integer in \(0, 1, \ldots, d-1\).

Spinhalf

Integer Configuration Symbol
0 down-spin
1 up-spin

tJ

Integer Configuration Symbol
0 empty
1 up-spin electron
2 down-spin electron

Electron

Integer Configuration Symbol
0 empty
1 up-spin electron
2 down-spin electron
3 doubly occupied

For the fermionic blocks, Fermion,tJ, Electron a sign convention for normal ordering is chosen as explained in normal ordering.

Sources: product_state.hpp · product_state.cpp

Constructors

ProductState(nsites::Int64)
ProductState(local_states::Vector{Int64})
ProductState(int64_t nsites);
ProductState(std::vector<int64_t> const &local_states);
Parameter Description
nsites construct a product state on nsites
local_states the local configurations of the product state

Iteration

A ProductState can be iterated over, where at each iteration the string of the local configuration is retured. Here is an example:

pstate = ProductState(["Up", "Dn", "Emp", "UpDn"])
for s in pstate
    @show s
end
auto pstate = ProductState({"Up", "Dn", "Emp", "UpDn"});
for (auto s : pstate) {
    Log("{}", s);
}

Methods

nsites

Returns the number of sites of the product state

nsites(p::ProductState)
int64_t nsites(ProductState const &p);

size

Returns the number of sites of the product state. Same as "nsites".

size(state::ProductState)
int64_t size(ProductState const &p);

setindex! / operator[]

Sets the local configuration at the given site index to the given string.

setindex!(state::ProductState, local_state::String, idx::Int64)
std::string &operator[](int64_t i);

getindex / operator[]

Returns the string of the local configuration at the given site index.

getindex(state::ProductState, idx::Int64)
std::string const &operator[](int64_t i) const;

push! / push_back

Adds a local configuration add the end of the product state.

push!(state::ProductState, local_state::String
void push_back(std::string l);

Usage Example

pstate = ProductState([1, 2, 0, 3])
for s in pstate
    @show s
end
@show pstate

pstate = ProductState([2, 1, 2])
@show nsites(pstate)
for s in pstate
    @show s
end
@show pstate
auto pstate = ProductState({1, 2, 0, 3});
for (auto s : pstate) {
  Log("{}", s);
}
XDIAG_SHOW(to_string(pstate));

pstate = ProductState();
pstate.push_back(2);
pstate.push_back(1);
pstate.push_back(2);
XDIAG_SHOW(pstate.nsites());
for (auto s : pstate) {
  Log("{}", s);
}
XDIAG_SHOW(to_string(pstate));