Skip to content

Quantum operator definitions for ITensor (ITensors.jl, ITensorMPS.jl, ITensorNetworks.jl, etc.).

License

Notifications You must be signed in to change notification settings

ITensor/ITensorQuantumOperatorDefinitions.jl

Repository files navigation

ITensorQuantumOperatorDefinitions.jl

Stable Dev Build Status Coverage Code Style: Blue Aqua

Installation instructions

This package resides in the ITensor/ITensorRegistry local registry. In order to install, simply add that registry through your package manager. This step is only required once.

julia> using Pkg: Pkg

julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")

or:

julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")

if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.

Then, the package can be added as usual through the package manager:

julia> Pkg.add("ITensorQuantumOperatorDefinitions")

Examples

using ITensorBase: ITensor, Index, tags
using ITensorQuantumOperatorDefinitions:
  OpName, SiteType, StateName, ValName, op, siteind, siteinds, state, val
using Test: @test

States and operators as Julia arrays

@test val(ValName("Up"), SiteType("S=1/2")) == 1
@test val(ValName("Dn"), SiteType("S=1/2")) == 2
@test state(StateName("Up"), SiteType("S=1/2")) == [1, 0]
@test state(StateName("Dn"), SiteType("S=1/2")) == [0, 1]
@test op(OpName("X"), SiteType("S=1/2")) == [0 1; 1 0]
@test op(OpName("Z"), SiteType("S=1/2")) == [1 0; 0 -1]

Index constructors

@test siteind("S=1/2") isa Index
@test Int(length(siteind("S=1/2"))) == 2
@test "S=1/2" in tags(siteind("S=1/2"))
@test siteinds("S=1/2", 4) isa Vector{<:Index}
@test length(siteinds("S=1/2", 4)) == 4
@test all(s -> "S=1/2" in tags(s), siteinds("S=1/2", 4))

States and operators as ITensors

s = Index(2, "S=1/2")
@test val(s, "Up") == 1
@test val(s, "Dn") == 2
@test state("Up", s) == ITensor([1, 0], (s,))
@test state("Dn", s) == ITensor([0, 1], (s,))
@test op("X", s) == ITensor([0 1; 1 0], (s', s))
@test op("Z", s) == ITensor([1 0; 0 -1], (s', s))

This page was generated using Literate.jl.

About

Quantum operator definitions for ITensor (ITensors.jl, ITensorMPS.jl, ITensorNetworks.jl, etc.).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages