State tensors
State tensors are full-rank tensorial objects for describing tensors of a many-body system, e.g., wavefunctions for lattice systems.
Vectors
Initiating a state vector
There are many ways to initialise a state. For variational methods, a popular choice is to initiate it randomly, which can be achieved using randomsv(dim, length) for physical dimension dim and length lattice sites.
TeNe.randomsv — Methodrandomsv(dim::Int, length::Int)
randomstatevector(dim::Int, length::Int)Create a random state vector with dimensions dim, size length.
Optional Keyword Arguments
- `T::Type=ComplexF64`: The element type for the tensors.Alternatively, you can initalise it as a mean field state.
TeNe.productsv — Methodproductsv(dim::Int, A::AbstractVector)
productstatevector(dim::Int, A::AbstractVector)Create a product state vector with length length and local state A.
Optional Keyword Arguments
- `T::Type=ComplexF64`: The element type for the tensors.Similarly, you can do this using the LatticeTypes feature. For example, initalise a lattice for Qubits, lt = Qubits() and then use ψ = productsv(lt, ["up" for _ = 1:6]).
TeNe.productsv — Methodproductsv(lt::LatticeTypes, states::AbstractVector{String})
productstatevector(lt::LatticeTypes, states::AbstractVector{String})Create a product state from a string of state names.
Example
julia> lt = Qubits();
julia> ψ = productsv(lt, ["up" for _ = 1:6]);Properties of state vectors
LinearAlgebra.rank — Methodrank(::GStateTensor)Returns the rank of a state tensor.
rank(::GMPS)Returns the rank of an MPS object.
TeNe.dim — Methoddim(ψ::GStateTensor, [which::Int, site::Int])Return the physical dimension of a StateTensor. The axis can be specified using which, and furthermore the site. Returns 0 for heterogeneous systems.
Base.length — MethodBase.length(::GStateTensor)The length of a state tensor.
LinearAlgebra.norm — Methodnorm(ψ::GStateTensor)Calculate the norm of a state tensor.
TeNe.entropy — Methodentropy(ψ::StateVector, site::Int)Calcualte the bipartition entanglement entropy between sites site and site+1 for a StateVector ψ.
TeNe.entropy — Methodentropy(ψ::StateVector, sites)Calcualte the bipartition entanglement entropy between two partitions, one with sites and the other with the remaining sites for StateVector ψ.
Manipulations of state vectors
Normalization
LinearAlgebra.normalize! — Methodnormalize!(ψ::GStateTensor)Normalize a state tensor.
Exponentiation
Base.exp — Methodexp(O::StateOperator; kwargs...)Exponentiate a StateOperator.
Optional Keyword Arguments
- `prefactor=1.0`: Multiply the StateOperator by some value before the exponetiation.Inner products
TeNe.inner — Methodinner(ψ::StateVector, ϕ::StateVector)
dot(ψ::StateVector, ϕ::StateVector)
*(ψ::StateVector, ϕ::StateVector)Calculate the inner product of two StateVectors ψ and ϕ.
Sampling a state vector
TeNe.sample — Methodsample(ψ::MPS)Sample the StateVector ψ with the interpretation that it is a wavefunction (or Born ansatz).
Operators
Operators, such as the Hamiltonian of a quantum many-body system, or more generally a matrix can be represented by a StateOperator.
Initiating an operator
Like a StateVector, we can initalise a StateOperator randomly or as a product state.
TeNe.randomso — Functionrandomso(dim::Int, length::Int; kwargs...)
randomstateoperator(dim::Int, length::Int; kwargs...)Create a state operator with physical dimensions dim and length sites.
Optional Keyword Arguments
- `T::Type=ComplexF64`: The element type for the tensor.Examples
julia> O = randomso(2, 10);TeNe.productso — Methodproductso(N::Int, A::AbstractMatrix; kwargs...)
productstateoperator(N::Int, A::AbstractMatrix; kwargs...)Create a state operator as a product state with size N, and composed of array A.
Optional Keyword Arguments
- `T::Type=ComplexF64`: The element type for the tensor.Examples
julia> O = productso(10, [1 0; 0 1]);Construct an operator from a list
We can also use the LatticeTypes interface to initalise as a product of a string of operators...
TeNe.StateOperator — MethodStateOperator(ops::OpList)Create a StateOperator from an OpList.
Examples
julia> lt = Qubits();
julia> H = OpList(lt, 10);
julia> for i = 1:10 add!(H, "x", i) end;
julia> for i = 1:9 add!(H, ["z", "z"], [i, i+1]) end;
julia> H = StateOperator(H);Products
A StateVector or a StateOperator can be multiplied by a StateOperator.
TeNe.applyso — Functionapplyso(O::StateOperator, ψ::StateVector)
applyso(ψ::StateVector, O::StateOperator)
*(O::StateOperator, ψ::StateVector)
*(ψ::StateVector, O::StateOperator)Multiply the StateOperator O to the StateVector ψ.
Examples
julia> O = productso(10, [0 1; 1 0]);
julia> ψ = productsv(10, [1, 0]);
julia> ϕ = O * ψ;applyso(O1::StateOperator, O2::StateOperator)Calculate the product of two StateOperators, O1 and O2.
Examples
julia> O1 = productso(10, [0 1; 1 0]);
julia> O2 = productso(10, [0 1im; -1im 0]);
julia> O = O1 * O2;This can be done in-place, either so store the result in an existing StateVector ϕ, or to replace ψ. In the case of a StateOperator-StateOperator multiplication, the StateOperator for the result must be specified.
TeNe.applyso! — Functionapplyso!(ϕ::StateVector, O::StateOperator, ψ::StateVector)
applyso!(ϕ::StateVector, ψ::StateVector, O::StateOperator)Multiply the StateOperator O to the StateVector ψ, and store the result in ϕ.
Examples
julia> O = productso(10, [0 1; 1 0]);
julia> ψ = productsv(10, [1, 0]);
julia> ϕ = StateVector(2, 10);
julia> applyso!(ϕ, O, ψ);applyso!(O::StateOperator, O1::StateOperator, O2::StateOperator)Calculate the product of two StateOperators, O1 and O2. Store the result in StateOperator O.
Examples
julia> O1 = productso(10, [0 1; 1 0]);
julia> O2 = productso(10, [0 1im; -1im 0]);
julia> O = StateOperator(2, 10);
julia> applyso!(O, O1, O2);The expectation value of operators (or a string of operators) can be calculated in the following way.
TeNe.inner — Methodinner(ψ::StateVector, O::StateOperator, ϕ::StateVector)
inner(ψ::StateVector, O1::StateOperator, O2::MPO, ϕ::StateVector)Calculate the expectation of a string of StateOperators Os with respect to StateVectors ψ and ϕ.
Examples
julia> ψ = randomsv(2, 10);
julia> O = productso(10, [0 1; 1 0]);
julia> inner(ψ, O, O, ψ)
1.0 + 0.0imThe trace of an operator (or a string of operators) can be computed in the following way.
TeNe.trace — Methodtrace(Os::StateOperator...)Compute the trace of a string of StateOperators.
Examples
julia> O = productso(10, [0 1; 1 0]);
julia> trace(O, O)
1024.0 + 0.0im