Skip to content

Spinhalf

Representation of a block in a spin \(S=1/2\) Hilbert space.

Source spinhalf.hpp

Constructors

Spinhalf(n_sites::Integer)
Spinhalf(n_sites::Integer, n_up::Integer)
Spinhalf(n_sites::Integer, group::PermutationGroup, irrep::Representation)
Spinhalf(n_sites::Integer, n_up::Integer, group::PermutationGroup, 
         irrep::Representation)
Spinhalf(int64_t n_sites);
Spinhalf(int64_t n_sites, int64_t n_up);
Spinhalf(int64_t n_sites, PermutationGroup permutation_group,
         Representation irrep);
Spinhalf(int64_t n_sites, int64_t n_up, PermutationGroup group,
         Representation irrep);
Name Description
n_sites number of sites (integer)
n_up number of "up" spin setting spin (integer)
group PermutationGroup defining the permutation symmetries
irrep Irreducible Representation of the symmetry group

Iteration

An Spinhalf block can be iterated over, where at each iteration a ProductState representing the corresponding basis state is returned.

block = Spinhalf(4, 2)
for pstate in block
    @show pstate, index(block, pstate) 
end
auto block = Spinhalf(4, 2);
for (auto pstate : block) {
    Log("{} {}", to_string(pstate), block.index(pstate));
}

Methods

index

Returns the index of a given ProductState in the basis of the Spinhalf block.

index(block::Spinhalf, pstate::ProductState)
int64_t index(ProductState const &pstate) const;

1-indexing

In the C++ version, the index count starts from "0" whereas in Julia the index count starts from "1".

n_sites

Returns the number of sites of the block.

n_sites(block::Spinhalf)
int64_t n_sites() const;

n_up

Returns the number of "up" spins.

n_up(block::Spinhalf)
int64_t n_up() const;

permutation_group

Returns the PermutationGroup of the block, if defined.

permutation_group(block::Spinhalf)
PermutationGroup permutation_group() const;

irrep

Returns the Representation of the block, if defined.

irrep(block::Spinhalf)
Representation irrep() const;

size

Returns the size of the block, i.e. its dimension.

size(block::Spinhalf)
int64_t size() const;

dim

Returns the dimension of the block, same as "size" for non-distributed blocks.

dim(block::Spinhalf)
int64_tdim() const;

isreal

Returns whether the block can be used with real arithmetic. Complex arithmetic is needed when a Representation is genuinely complex.

isreal(block::Spinhalf; precision::Real=1e-12)
int64_t isreal(double precision = 1e-12) const;

Usage Example

N = 4
nup = 2

# without Sz conservation
block = Spinhalf(N)
@show block


# with Sz conservation
block_sz = Spinhalf(N, nup)
@show block_sz

# with symmetries, without Sz
p1 = Permutation([1, 2, 3, 4])
p2 = Permutation([2, 3, 4, 1])
p3 = Permutation([3, 4, 1, 2])
p4 = Permutation([4, 1, 2, 3])
group = PermutationGroup([p1, p2, p3, p4])
rep = Representation([1, -1, 1, -1])
block_sym = Spinhalf(N, group, rep)
@show block_sym

# with symmetries and Sz
block_sym_sz = Spinhalf(N, nup, group, rep)
@show block_sym_sz

@show n_sites(block_sym_sz)
@show size(block_sym_sz)

# Iteration
for pstate in block_sym_sz
    @show pstate, index(block_sym_sz, pstate)
end
@show permutation_group(block_sym_sz)
@show irrep(block_sym_sz)
int N = 4;
int nup = 2;

// without Sz conservation
auto block = Spinhalf(N);
XDIAG_SHOW(block);

// with Sz conservation
auto block_sz = Spinhalf(N, nup);
XDIAG_SHOW(block_sz);

// with symmetries, without Sz
Permutation p1 = {0, 1, 2, 3};
Permutation p2 = {1, 2, 3, 0};
Permutation p3 = {2, 3, 0, 1};
Permutation p4 = {3, 0, 1, 2};
auto group = PermutationGroup({p1, p2, p3, p4});
auto irrep = Representation({1, -1, 1, -1});
auto block_sym = Spinhalf(N, group, irrep);
XDIAG_SHOW(block_sym);

// with symmetries and Sz
auto block_sym_sz = Spinhalf(N, nup, group, irrep);
XDIAG_SHOW(block_sym_sz);

XDIAG_SHOW(block_sym_sz.n_sites());
XDIAG_SHOW(block_sym_sz.size());

// Iteration
for (auto pstate : block_sym_sz) {
  Log("{} {}", to_string(pstate), block_sym_sz.index(pstate));
}
XDIAG_SHOW(block_sym_sz.permutation_group());
XDIAG_SHOW(block_sym_sz.irrep());