Basic Types
Basis
Basis is a useful object when describing a Hilbert space. In quantum physics, there are many kind of basis in different problems, including qubits, lattice site, infinity basis, etc.
The basis we mention here and implemented in this package is the tagged part. If you need to use Dirac ket expression, you can simply do it by hands with dot
function in Julia's linear algebra stdlib. We will not be able to help you to figure out which one is left ket and which one is the right at the moment. To be specific, the basis here means what is inside you ket expression.
$|basis\rangle$ or $\langle basis|$
Label
All the labels are subtype of SiteLabel
, label type is used to provide information about the content in a AbstractSites
instance.
QMTK offers three kind of labels: Bit, Spin, Half for binary configurations.
QMTK.Bit
— Type.Bit <: BitSiteLabel
Binary State, Bit. Has two state: 0, 1
QMTK.Spin
— Type.Spin <: BitSiteLabel
Binary State, Spin. Has two state: -1, 1
QMTK.Half
— Type.Half <: BitSiteLabel
Binary State, Half. Has two state: -0.5, 0.5
Sites
The abstract hierachy for site is defined as any subtype of AbstractArray
with label.
QMTK.AbstractSites
— Type.AbstractSites{Label, T, N} <: AbstractArray{T, N}
Sites are arrays with certain labels
Sites
is a Julia native array with certain label that tells the program which kind of site it is.
QMTK.Sites
— Type.Sites{L <: SiteLabel, T, N} <: AbstractSites{L, T, N}
Lattice Sites are Julia Arrays with certain Label, it is able to use array interface.
TODO: type promote to normal arrays when mixed with normal arrays.
And naive example of Sites
could be the Bit
configuration on a Chain lattice (a 1-D Array of Bits on the memory)
$0\quad 1\quad 0\quad 1\quad 1\quad 0$
You can declare it by
julia> Sites(Bit, [0, 1, 0, 1, 1, 0])
6-element QMTK.Sites{QMTK.Bit,Int64,1}:
0
1
0
1
1
0
Sites
is implemented to support most of Julia array interface, but since Julia do not have inherit of interface, not all operations is overloaded, please use method data
, when you need to access its content in calculatoin.
QMTK.data
— Function.data(sites)
get data of this sites
data(space::AbstractSpace{T, S}) -> T
get the current data of this space
SubSites
For small sites, it usually contains only a few configuration, and when we try to use a subset of Sites
, it would be a waste to create a new Sites
, SubSites
offer a way to do this efficiently by telling the compiler how large it is in compile time (by Tuple
).
QMTK.SubSites
— Type.SubSites{Label, T, Length} <: AbstractSites{Label, T, 1}
Sub-sites is usually derived from Sites
. It contains several sites in a tuple for local operations.
NOTE: SubSites should be designed faster for bitwise operations, cause this will be a temperory type for traversing through lattice.
Or to be simple, you can just interpret SubSites
to be a Tuple
with certain SiteLabel
. Use it like a native Tuple
.
julia> SubSites(Bit, 1, 0)
2-element QMTK.SubSites{QMTK.Bit,Int64,2}:
1
0
and just like tuple
julia> a, b = SubSites(Bit, 1, 0);
julia> a
1
julia> b
0
Space
Space are math objects contains a set of objects with certain structure. In QMTK
we present it as AbstractSpace
.
QMTK.AbstractSpace
— Type.AbstractSpace{T, S}
General abstract type for space with T
as its content in state S
.
In fact, an instance of a space should be a type with a temporary memory to store an element of the space in type T
.
There are currently two kinds of state for a space.
SpaceState
Randomized
Initialized
There are two kind of space currently
QMTK.RealSpace
— Type.RealSpace{T, DType, S} <: AbstractSpace{T, S}
A real space contains element of type DType
(e.g Array or a Number), the numeric content of each element has type T
(eltype(DType) = T
)
A naive example is the 1-D real space
julia> RealSpace(min=-1, max=1)
QMTK.RealSpace{Float64,Float64,QMTK.Randomized}(-1.0, 1.0, -0.04293376352914002)
QMTK.SiteSpace
— Type.SiteSpace{NFlips, S} <: AbstractSpace{Sites, S}
A space of sites contains all possible configurations of the sites. NFlips
indicated how many site will flip according to certain rules when shake!
is called.
SiteSpace(label, shape; nflips)
constructs a SiteSpace
with label in type SiteLabel
, and shape
with an optional keyword nflips
(default to be 1).
julia> SiteSpace(Bit, 2, 2)
QMTK.SiteSpace{1,QMTK.Randomized}(Int8[1 1; 0 0])
Interface
A space object has the following interface
method | description |
---|---|
data | property, required |
reset! | required |
copy | required |
acquire | required |
shake! | required |
randomized | required |
traverse | optional |
QMTK.data
— Method.data(space::AbstractSpace{T, S}) -> T
get the current data of this space
QMTK.reset!
— Function.reset!(space) -> space # with initilized state
reset the temporary data of this space to initial position be careful that the state of the space will also be changed assign it to your variable manually.
space = reset!(space)
Base.copy
— Function.copy(space) -> space
copy the space instance
QMTK.acquire
— Function.acquire(space) -> element
get a copy of current element of the space
QMTK.shake!
— Function.shake!(space) -> space
shake the space and move current element to a random position. the space has to be a space with Randomized
state. or it will an UnRandomizedError
.
QMTK.randomize!
— Function.randomize!(space) -> space
randomized the space, move current element to a random position and change the state of this space to Initialized
QMTK.traverse
— Function.traverse(space) -> iterator
get an iterator that traverses the whole space.