Sites

General

TensorMixedStates.AbstractSite — Type
abstract type AbstractSite

the supertype of all site types. A site type defines dim, declares its states and operators with @def_states and @def_operators, and, if fermionic, fermion_parities. It keeps the constructor taking the values of its fields in their order, which reading a state file and weaken use.

Examples

struct MySite <: AbstractSite
    conserve::Conservation
end
MySite(; conserve = ()) = conserving(MySite; conserve)
TensorMixedStates.dim(::MySite) = 2

Operators

Declared once for every site type, each of these holds on a site type that declares what it is made of, Sp and Sz, A, or Cup and Cdn, unless it declares the name itself:

  • Sm : dag(Sp)
  • Sx, Sy : (Sp + Sm) / 2 and (Sp - Sm) / 2im
  • S2 : (Sp * Sm + Sm * Sp) / 2 + Sz^2
  • Q, P : (A + dag(A)) / √2 and (A - dag(A)) / (im * √2)
  • Nup, Ndn, Ntot : dag(Cup) * Cup, dag(Cdn) * Cdn and Nup + Ndn
source
NDTensors.dim — Method
dim(site)

the dimension of the Hilbert space of a site, which every site type defines.

source

The state "FullyMixed" represents the infinite temperature mixed state, that is a density matrix proportional to the identity matrix.

TensorMixedStates.F — Constant
F

the fermionic parity of a site, $(-1)^p$ on a basis state of parity p, see fermion_parities: the identity on a site that is not fermionic.

source

There are eight predefined site types Qubit, Qudit, Spin, Boson, Fermion, Electron, Tj and Qboson.

Qubit

To use Qubit, call

using .Qubits
TensorMixedStates.Qubits — Module
using .Qubits

module giving access to the Qubit site type and the names it exports: graph_state, X, Y, Z, Sx, Sy, Sz, S2, N, Sp, Sm, thermal_relaxation_dissipator, thermal_relaxation_channel

source
TensorMixedStates.Qubit — Type
Qubit(; conserve = ())

the site type of a qubit, a two level system, whose basis is "Up", "Dn". Z is a charge of values ±1, so conserve = Z conserves the magnetization, as 2Sz does; its parity is parity(N).

Examples

Qubit()
Qubit(conserve = N)      # the number of excitations
Qubit(conserve = 2Sz)    # the same conservation, in spin language
Qubit(conserve = parity(N))

States

  • "Up", "Z+", "↑", "0" : the up state
  • "Dn", "Z-", "↓", "1" : the down state
  • "+", "X+" : the +1 eigenvector of X
  • "-", "X-" : the -1 eigenvector of X
  • "i", "Y+" : the +1 eigenvector of Y
  • "-i", "Y-" : the -1 eigenvector of Y

Operators

  • X, Y, Z : the Pauli operators
  • Sp, Sm : the $S^+$ and $S^-$ operators
  • Sx, Sy, Sz, S2 : the $S_x$, $S_y$, $S_z$ operators, half the Pauli operators, and $S^2$
  • N : the number of excitations, $(1 - Z)/2$: "Dn" is the occupied state and Sm creates an excitation

In the module Circuits, with Phase(t), the rotations and the controlled gates:

  • H : the Hadamard gate, $(X + Z)/\sqrt{2}$
  • S, T : the phase gates $\mathrm{diag}(1, i)$ and $\mathrm{diag}(1, e^{i\pi/4})$
source
TensorMixedStates.graph_state — Function
graph_state(system, graph; others, limits = Limits())

the graph state of graph, a list of edges between the qubits of system: the sites of its edges in "+", to which controlled(Z) is applied on every edge, truncated by limits. The sites in no edge take the local state others, one for all of them or a vector of one for each, which they then need: the qubits of the graph conserve nothing, the others may.

Examples

graph_state(System(10, Qubit()), complete_graph(10); limits = Limits(maxdim = 10))
graph_state(System([Qubit(), Qubit(), Fermion(conserve = N)]), [(1, 2)]; others = "Occ")
source
TensorMixedStates.thermal_relaxation_channel — Function
thermal_relaxation_channel(T1, T2, t)

the channel of the relaxation of a qubit of times T1 and T2 over a time t, exp(t * thermal_relaxation_dissipator(T1, T2)): the population of "Dn" decays by $e^{-t/T_1}$ and the coherences by $e^{-t/T_2}$. T2 cannot exceed 2T1.

Examples

prod(thermal_relaxation_channel(50., 30., 0.1)(i) for i in 1:10)
source
TensorMixedStates.thermal_relaxation_dissipator — Function
thermal_relaxation_dissipator(T1, T2)

the generator of the relaxation of a qubit of times T1 and T2: its decay to "Up", of time T1, and the dephasing that brings the decay of its coherences to the time T2, amplitude_damping_dissipator(1 / T1) + dephasing_dissipator(1 / T2 - 1 / (2T1)). T2 cannot exceed 2T1. Evolving under it for a time t is thermal_relaxation_channel(T1, T2, t).

Examples

-im * H + sum(thermal_relaxation_dissipator(50., 30.)(i) for i in 1:10)
source

Spins

To use Spin, call

using .Spins
TensorMixedStates.Spins — Module
using .Spins

module giving access to the Spin site type and the names it exports: aklt_state, Sp, Sm, Sx, Sy, Sz, S2, N

source
TensorMixedStates.Spin — Type
Spin(s; conserve = ())

the site type of a spin s, integer or half integer, of dimension $2s + 1$, its basis going from $S_z = s$ down to $S_z = -s$.

Examples

Spin(3/2)
Spin(1, conserve = Sz)       # integer eigenvalues
Spin(1/2, conserve = 2Sz)    # half integer ones are written doubled
Spin(1/2, conserve = N)      # or counted from the top, which is integer for any spin

States

For m from s down to -s, written as an integer or a fraction, "1", "-1/2":

  • "m", "Zm" : the eigenstate of Sz of eigenvalue m
  • "Xm" : the eigenstate of Sx of eigenvalue m
  • "Ym" : the eigenstate of Sy of eigenvalue m

and "Up", "↑", "Dn", "↓" for $m = s$ and $m = -s$.

A name gives an eigenvalue: on Spin(1), "1" is $S_z = 1$, and Level => 1 the second basis state, $S_z = 0$.

Operators

  • Sp, Sm : the $S^+$ and $S^-$ operators
  • Sx, Sy, Sz, S2 : the $S_x$, $S_y$, $S_z$ operators and $S^2$
  • N : the number of excitations $s - S_z$, integer for every spin
source
TensorMixedStates.aklt_state — Function
aklt_state(system; left = "Up", right = "Up")

the AKLT state of a chain of spins one, Spin(1), the exact ground state of $\sum_i \vec S_i \cdot \vec S_{i+1} + \frac{1}{3} (\vec S_i \cdot \vec S_{i+1})^2$, as an MPS of bond dimension 2. left and right set the free virtual spins one half at the two ends, pure states as Spin(1/2) takes them: "Up", "Dn", "X1/2" or a vector of two components.

Examples

aklt_state(System(20, Spin(1)))
aklt_state(System(20, Spin(1, conserve = Sz)); right = "Dn")    # total Sz of 1
source

Boson

To use Boson, call

using .Bosons
TensorMixedStates.Boson — Type
Boson(dim; conserve = ())

the site type of a boson mode truncated to dim levels, the occupation going from 0 to dim - 1.

Examples

Boson(4)
Boson(4, conserve = N)
Boson(4, conserve = parity(N))

States

"0", "1", ..., "dim-1" : the state of that occupation

Operators

  • A : the annihilation operator
  • N : the number of bosons
  • Q, P : the position and momentum quadratures, $(A + A^\dagger)/\sqrt{2}$ and $(A - A^\dagger)/(i\sqrt{2})$
source

Fermion

To use Fermion, call

using .Fermions
TensorMixedStates.Fermion — Type
Fermion(; conserve = ())

the site type of a spinless fermion mode, of dimension 2.

Examples

Fermion()
Fermion(conserve = N)
Fermion(conserve = parity(N))
Fermion(conserve = strong(N))

States

  • "Emp", "0" : the empty state
  • "Occ", "1" : the occupied state

Operators

  • C : the annihilation operator
  • N : the number of fermions
  • F : the fermionic parity, $(-1)^N$
source

Electron

To use Electron, call

using .Electrons
TensorMixedStates.Electrons — Module
using .Electrons

module giving access to the Electron site type and the names it exports: Cup, Cdn, Nup, Ndn, Nupdn, Ntot, Sx, Sy, Sz, Sp, Sm, S2

source
TensorMixedStates.Electron — Type
Electron(; conserve = ())

the site type of an electron orbital, of dimension 4, whose basis is "Emp", "Up", "Dn", "UpDn", the doubly occupied state being $c^\dagger_\uparrow c^\dagger_\downarrow |0⟩$.

Examples

Electron()
Electron(conserve = (Ntot, 2Sz))
Electron(conserve = (strong(Ntot), 2Sz))

States

  • "Emp", "0" : the empty state
  • "Up", "↑" : one electron of spin up
  • "Dn", "↓" : one electron of spin down
  • "UpDn", "↑↓" : two electrons
  • "MixedSpin", "↑|↓" : one electron of fully mixed spin, the density matrix $(|↑⟩⟨↑| + |↓⟩⟨↓|)/2$, which a strong conservation of Ntot allows where "FullyMixed" spreads over several numbers of electrons

Operators

  • Cup, Cdn : the annihilation operators
  • Nup, Ndn, Nupdn, Ntot : the numbers of electrons of spin up, of spin down, of pairs and in total
  • Sx, Sy, Sz, Sp, Sm : the spin operators
  • S2 : the total spin squared of the site, 3/4 (Ntot - 2 Nupdn)
  • F : the fermionic parity, $(-1)^{N_{tot}}$
source

Tj

To use Tj, call

using .Tjs
TensorMixedStates.Tjs — Module
using .Tjs

module giving access to the Tj site type and the names it exports: Cup, Cdn, Nup, Ndn, Ntot, Sx, Sy, Sz, Sp, Sm, S2

source
TensorMixedStates.Tj — Type
Tj(; conserve = ())

the site type of the t-J model, an electron orbital without double occupancy, of dimension 3, whose basis is "Emp", "Up", "Dn".

Examples

Tj()
Tj(conserve = (Ntot, 2Sz))

States

  • "Emp", "0" : the empty state
  • "Up", "↑" : one electron of spin up
  • "Dn", "↓" : one electron of spin down
  • "MixedSpin", "↑|↓" : one electron of fully mixed spin, the density matrix $(|↑⟩⟨↑| + |↓⟩⟨↓|)/2$

Operators

  • Cup, Cdn : the annihilation operators
  • Nup, Ndn, Ntot : the numbers of electrons of spin up, of spin down and in total
  • Sx, Sy, Sz, Sp, Sm : the spin operators
  • S2 : the total spin squared of the site, 3/4 Ntot
  • F : the fermionic parity, $(-1)^{N_{tot}}$
source

Qboson

To use Qboson, call

using .Qbosons
TensorMixedStates.Qboson — Type
Qboson(q, dim; conserve = ())

the site type of a q-boson mode truncated to dim levels, the occupation going from 0 to dim - 1, on which $a|n\rangle = \sqrt{1-q^n} |n-1\rangle$ and $a^\dagger |n\rangle = \sqrt{1 - q^{n+1}} |n+1\rangle$.

Examples

Qboson(0.1, 4)
Qboson(0.1, 4, conserve = N)

States

"0", "1", ..., "dim-1" : the state of that occupation

Operators

  • A : the annihilation operator $a$, $a a^\dagger - q a^\dagger a = 1 - q$ except on the last level, which the truncation cuts
  • N : the number of q-bosons
  • Q, P : the position and momentum quadratures, $(a + a^\dagger)/\sqrt{2}$ and $(a - a^\dagger)/(i\sqrt{2})$
source

Qudit

To use Qudit, call

using .Qudits
TensorMixedStates.Qudit — Type
Qudit(dim; conserve = ())

the site type of a qudit, a dim level system carrying the generalized Pauli operators.

Writing $d$ for the dimension and $\omega = e^{2i\pi/d}$, the clock operator acts as $Z|n\rangle = \omega^n |n\rangle$ and the shift operator as $X|n\rangle = |n+1 \mod d\rangle$. H, S and Sum generate the Clifford group. X, Z, H and S are those of Qubit for $d = 2$.

Examples

Qudit(3)
Qudit(3, conserve = Z)      # the Z3 symmetry of the clock model

States

"0", "1", ..., "dim-1" : the state of that level

Operators

  • N : the level operator, diag(0, 1, ..., d-1)
  • Z : the clock operator, mod(N, d)
  • X : the shift operator, $ZX = \omega XZ$

In the module Circuits:

  • H : the Fourier operator, or generalized Hadamard gate
  • S : the phase operator, of order $d$ for odd $d$ and $2d$ for even $d$
  • Sum : the generalized controlled not of two qudits, see Sum
source

Conservation

What conserving a quantity means and costs is explained in Conserving a quantity.

TensorMixedStates.Conservation — Type
Conservation(quantities = Quantity[])
Conservation(site, spec)

what a site conserves, its quantities sorted by name, as ITensors sorts the components of a charge: built from the operators spec, one or a tuple of them, each possibly marked strong, whose charges are read on site. A site type fills its field with conserving.

source
TensorMixedStates.conserving — Method
conserving(T, params...; conserve)

the site of type T and parameters params conserving conserve, one operator or a tuple of them, each possibly marked strong: the charges are read on the site built conserving nothing. A site type writes its keyword constructor with it.

Examples

Qudit(dim::Int; conserve = ()) = conserving(Qudit, dim; conserve)
source
TensorMixedStates.strong — Function
strong(op)

declare a conserved quantity as a strong symmetry rather than the weak one conserve assumes. Under a strong symmetry every jump operator commutes with the charge: ket and bra are conserved separately, which gives finer blocks, and a state lives in a single sector.

Examples

Fermion(conserve = strong(N))
Electron(conserve = (strong(Ntot), 2Sz))
source
ITensors.flux — Function
flux(op, site)

the charge the one site operator op carries on site, as a QN: the difference between the charges of the states it connects. An operator connecting states whose charges differ in more than one way is refused.

Examples

flux(N, Fermion(conserve = N))        # QN("N",0)
flux(X, Qudit(3, conserve = Z))       # QN("Z",1,3)
source
TensorMixedStates.symmetries — Function
symmetries(::AbstractSite)
symmetries(::System)
symmetries(::State)

what a site, a system or the system of a state conserves, and whether strongly or weakly, as a Conserved, which prints as conserve is given and can be given back to weaken.

Examples

symmetries(System(4, Electron(conserve = (strong(Ntot), 2Sz))))   # (2Sz, strong(Ntot))
source
TensorMixedStates.weaken — Function
weaken(::System)
weaken(::System, target)

the same sites, each keeping of what it conserves only what target names, as strongly as target asks, written as conserve is given or as symmetries returns it. Without a target, one level down: strong quantities made weak, or, when none is strong, all dropped.

Examples

s = System(4, Electron(conserve = (strong(Ntot), 2Sz)))
weaken(s)          # conserves (2Sz, Ntot)
weaken(s, 2Sz)     # conserves 2Sz only
weaken(s, ())      # conserves nothing
source
weaken(::State)
weaken(::State, target)

the same state on a system conserving less, target naming what it must still conserve, as conserve is given. Without a target, every strong quantity becomes weak or, when none is strong, every quantity is dropped. There is no way back.

Examples

weaken(state)                          # one level down
weaken(state, (strong(Ntot), 2Sz))     # exactly these
weaken(state, ())                      # no charges at all
source

Defining new site types

How to define a site type of your own, its states and its operators is explained in Site types of one's own.

TensorMixedStates.string_state — Function
string_state(site, name)

the local state a name gives by a rule of the site rather than by a declaration, or nothing when the name is not one of its forms. By default "0" gives the first basis state, "1" the second, and so on. A site type overloads it to read names of its own, as Spin reads "1/2", or to read none.

Examples

TensorMixedStates.string_state(::MySite, ::String) = nothing
source
TensorMixedStates.fermion_parities — Method
fermion_parities(site)

the fermionic parity, 0 or 1, of each basis state of site, all 0 on a site that is not fermionic. A fermionic site type defines it, F being derived from it.

Examples

TensorMixedStates.fermion_parities(::MySite) = (0, 1)
source
TensorMixedStates.fermion_species — Method
fermion_species(site)

the annihilation operators of the fermion species of a site, as (C,) or (Cup, Cdn), for slater_state and fermi_sea; nothing when the site type declares none.

source
Base.show — Method
show(io, ::AbstractSite)

print a site as the call that builds it, Qubit() or Fermion(conserve = N), the trailing fields holding nothing left out

source
TensorMixedStates.@def_states — Macro
@def_states(T, [name => def, ...])

declare states for the site type T. A name is a string, or a vector of strings naming the same state. A definition is a vector (a pure state in the basis of the site), a matrix (a density matrix), a function of the site returning either, or the name of another state.

Examples

@def_states MySite [
    ["Emp", "0"] => [1, 0],
    "Occ" => [0, 1],
]
source
TensorMixedStates.@def_operators — Macro
@def_operators(T, [name = def, ...])

declare operators for the site type T. A definition is a matrix, an expression of operators of one site, or a function of the site returning either. Each name becomes a const of the calling module the first time it is seen, so the macro is used at the top level; a name already standing for the operator of that name is shared between site types.

Examples

@def_operators MySite [
    C = [0 1 ; 0 0],
    N = dag(C) * C,
]
source
TensorMixedStates.@create_site_module — Macro
@create_site_module(name, symbols)

define a submodule name importing the given symbols from the module the macro is called in and exporting them, so that using .name brings a site type and its operators into scope.

Examples

@create_site_module(Spins, [Spin, Sp, Sm, Sx, Sy, Sz, S2, N])
source