API

QuantumHamiltonian.HilbertSpaceType
HilbertSpace{QN, TS}

Abstract Hilbert space with quantum number type QN.

Examples

julia> using QuantumHamiltonian

julia> spin_site = Site([State("Up", +1), State("Dn", -1)]);

julia> hs = HilbertSpace([spin_site, spin_site]);
source
QuantumHamiltonian.PureOperatorType
PureOperator{Scalar, BR}

Represents an operator $α (P₁ ⊗ P₂ ⊗ … ⊗ Pₙ)$ where $Pᵢ$ is either identity (when bitmask is set to zero), or projection $|rᵢ⟩⟨cᵢ|$ (when bitmask is set to one).

See also: pure_operator

Fields

bitmask   :: BR
bitrow    :: BR
bitcol    :: BR
amplitude :: Scalar
source
QuantumHamiltonian.SiteType
Site{QN}

A site with quantum number type QN.

Examples

julia> using QuantumHamiltonian

julia> site = Site([State("Up", 1), State("Dn", -1)]);
source
QuantumHamiltonian.StateType
State{QN}

State with quantum number type QN.

Examples

julia> using QuantumHamiltonian

julia> up = State("Up", 1)
State{Tuple{Int64}}("Up", (1,))

julia> State("Dn", (-1, 1))
State{Tuple{Int64, Int64}}("Dn", (-1, 1))
source
Base.valtypeMethod
valtype(lhs::Type{<:AbstractOperator{S}})

Returns the valtype (scalar type) of the given AbstractOperator.

source
LatticeTools.dimensionMethod
dimension(arg::ReducedHilbertSpaceRepresentation{HSR, BR, C}) -> Int

Dimension of the given reduced hilbert space representation, i.e. number of basis elements.

source
LatticeTools.numsitesMethod
numsites(hsr::AbstractHilbertSpaceRepresentation, args...;kwargs...)

Call numsites with basespace of hsr.

source
QuantumHamiltonian.apply!Method
apply!(out, opr, state)

Perform out += opr * state. Apply the operator representation opr to the row vector state and add it to the row vector out. Return sum of errors and sum of error-squared. Call apply_serial! if Threads.nthreads() == 1, and apply_parallel! otherwise.

source
QuantumHamiltonian.apply!Method
apply!(out, opr, state)

Perform out += opr * state. Apply the operator representation opr to the column vector state and add it to the column vector out. Return sum of errors and sum of error-squared. Call apply_serial! if Threads.nthreads() == 1, and apply_parallel! otherwise.

source
QuantumHamiltonian.apply_parallel!Method
apply_parallel!(out, state, opr)

Perform out += state * opr. Apply the operator representation opr to the matrix state, whose rows are vectors, and add it to the rows of the matrix out. Multi-threaded version.

source
QuantumHamiltonian.apply_parallel!Method
apply_parallel!(out, opr, state)

Perform out += opr * state. Apply the operator representation opr to the matrix state, whose columns are vectors, and add it to the columns of the matrix out. Multi-threaded version.

source
QuantumHamiltonian.apply_parallel!Method
apply_parallel!(out, opr, state)

Perform out += opr * state. Apply the operator representation opr to the column vector state and add it to the column vector out. Multi-threaded version.

source
QuantumHamiltonian.apply_parallel!Method
apply_parallel!(out, state, opr)

Perform out += state * opr. Apply the operator representation opr to the row vector state and add it to the row vector out. Return sum of errors and sum of error-squared. Multi-threaded version.

source
QuantumHamiltonian.apply_serial!Method
apply_serial!(out, state, opr)

Perform out += state * opr. Apply the operator representation opr to the matrix state, whose rows are vectors, and add it to the rows of the matrix out. Single-threaded version.

source
QuantumHamiltonian.apply_serial!Method
apply_serial!(out, opr, state)

Perform out += opr * state. Apply the operator representation opr to the matrix state, whose columns are vectors, and add it to the columns of the matrix out. Single-threaded version.

source
QuantumHamiltonian.apply_serial!Method
apply_serial!(out, opr, state)

Perform out += opr * state. Apply the operator representation opr to the column vector state and add it to the column vector out. Single-threaded version.

source
QuantumHamiltonian.apply_serial!Method
apply_serial!(out, state, opr)

Perform out += state * opr. Apply the operator representation opr to the row vector state and add it to the row vector out. Return sum of errors and sum of error-squared. Single-threaded version.

source
QuantumHamiltonian.basespaceFunction
basespace(x::AbstractHilbertSpaceRepresentation)
basespace(x::Type{T}) where {T<:AbstractHilbertSpaceRepresentation}

If the argument is an instance of AbstractHilbertSpaceRepresentation, return the underlying Hilbert space of the Hilbert space representation. If the argument is a subtype of AbstractHilbertSpaceRepresentation, return the type of the underlying Hilbert space. Subtypes of AbstractHilbertSpace must implement this method.

source
QuantumHamiltonian.bitwidthMethod
bitwidth(hs, [isite])

Total number of bits

julia> using QuantumHamiltonian

julia> spin_site = Site([State("Up", +1), State("Dn", -1)]);

julia> hs = HilbertSpace([spin_site, spin_site, spin_site,]);

julia> bitwidth(hs)
3
source
QuantumHamiltonian.compressMethod
compress(hs, indexarray::CartesianIndex, binary_type=UInt)

Convert a cartesian index (a of state) to its binary representation

Examples

julia> using QuantumHamiltonian

julia> spin_site = Site([State("Up", +1), State("Dn", -1)]);

julia> hs = HilbertSpace([spin_site, spin_site]);

julia> compress(hs, CartesianIndex(2,2))
0x0000000000000003
source
QuantumHamiltonian.compressMethod
compress(site, state_index, binary_type=UInt) -> binary_type

Get binary representation of the state specified by state_index. Check bounds 1 <= state_index <= dimension(site), and returns binary representation of state_index-1.

source
QuantumHamiltonian.extractMethod
extract(hs, binrep)

Convert binary representation to an array of indices (of states)

Examples

julia> using QuantumHamiltonian

julia> spin_site = Site([State("Up", +1), State("Dn", -1)]);

julia> hs = HilbertSpace([spin_site, spin_site]);

julia> extract(hs, 0x03)
CartesianIndex(2, 2)
source
QuantumHamiltonian.get_basis_index_amplitudeFunction
get_basis_index_amplitude(hsr::AbstractHilbertSpaceRepresentation, bin::Unsigned)

Return a tuple (index=index, amplitude=amplitude) that corresponds to the binary bin, i.e., the index of the basis state that overlaps with bin and the value of the overlap ⟨b|ϕᵢ⟩. Return (index=-1, amplitude=0) if bin is not in the representation. Subtypes of AbstractHilbertSpaceRepresentation must implement this method.

source
QuantumHamiltonian.get_basis_index_amplitudeMethod
get_basis_index_amplitude(hsr, bvec)

Get the index of the basis state that overlaps with bvec, and the value of the overlap. Currentiy it is guaranteed to be at most one. Returns (i, ⟨b|ϕᵢ⟩). For the unsymmetrized HilbertSpaceRepresentation, the amplitude is 1 of Int type. If no such basis vector exists, return (-1, 0).

source
QuantumHamiltonian.get_basis_iteratorFunction
get_basis_iterator(hsr::AbstractHilbertSpaceRepresentation)

Return an iterator of the list of basis binaries. Subtypes of AbstractHilbertSpaceRepresentation must implement this method.

source
QuantumHamiltonian.get_basis_listFunction
get_basis_list(hsr::AbstractHilbertSpaceRepresentation)

Return a Vector of the list of basis binaries. Subtypes of AbstractHilbertSpaceRepresentation must implement this method.

source
QuantumHamiltonian.get_basis_stateFunction
get_basis_state(hsr::AbstractHilbertSpaceRepresentation, index::Integer)

Return the state at index index. Subtypes of AbstractHilbertSpaceRepresentation must implement this method.

source
QuantumHamiltonian.get_column_iteratorMethod
get_column_iterator(opr, icol)

Returns an iterator which generates a list of elements of the column icol. Each element is represented as (irow, amplitude). May contain duplicates and invalid elements. Invalid elements are represented as (-1, amplitude).

source
QuantumHamiltonian.get_operatorFunction
get_operator(x::AbstractOperatorRepresentation)

Return the operator of the operator representation. Subclass of AbstractOperatorRepresentation must define this method.

source
QuantumHamiltonian.get_row_iteratorMethod
get_row_iterator(opr, irow)

Returns an iterator which generates a list of elements of the row irow. Each element is represented as (icol, amplitude). May contain duplicates and invalid elements. Invalid elements are represented as (-1, amplitude).

source
QuantumHamiltonian.get_spaceFunction
get_space(x::AbstractOperatorRepresentation)

Return the Hilbert Space representation on which the operator representation is defined. Subclass of AbstractOperatorRepresentation must define this method.

source
QuantumHamiltonian.get_stateMethod
get_state(hs, binrep, isite)

Get the local state at site isite for the basis state represented by binrep. Returns an object of type State

source
QuantumHamiltonian.operatortypeFunction
operatortype(x::AbstractOperatorRepresentation)

Return the type of the operator of the operator representation. Subclass of AbstractOperatorRepresentation must define this method.

source
QuantumHamiltonian.pure_operatorMethod
pure_operator(hilbert_space, isite, istate_row, istate_col, amplitude=1, [binary_type=UInt])

Creates a pure operator where projection is at one of the sites.

source
QuantumHamiltonian.representMethod
represent(hilbert_space_representation, operator)

Create an OperatorRepresentation of the operator in the hilbert_space_representation.

source
QuantumHamiltonian.spacetypeFunction
spacetype(x::AbstractOperatorRepresentation)
spacetype(x::Type{T}) where {T<:AbstractOperatorRepresentation}

Return the type of the Hilbert space representation on which the operator representation is defined. Subclass of AbstractOperatorRepresentation must define this method.

source
QuantumHamiltonian.symmetry_reduceMethod
symmetry_reduce(hsr, symops, amplitudes, bvec; tol=√ϵ)

Returns bᵢ => ⟨B|ϕᵢ⟩, i.e., the basis state (represented by bᵢ, and the amount of that basis state that overlaps with the input. Returns the same amplitude as the get_basis_index_amplitude of the reduced Hilbert space representation

Basis states: |ϕᵢ⟩ with a representative bᵢ input : |B⟩

source
QuantumHamiltonian.uncompressMethod
uncompress(hs, binrep)

Convert binary representation to an array of indices (of states)

Examples

julia> using QuantumHamiltonian

julia> spin_site = Site([State("Up", +1), State("Dn", -1)]);

julia> hs = HilbertSpace([spin_site, spin_site]);

julia> extract(hs, 0x03)
CartesianIndex(2, 2)
source
QuantumHamiltonian.updateMethod
update(hs, binrep, isite, new_state_index)

Update the binary representation of a basis state by changing the state at site isite to a new local state specified by new_state_index.

source