Documentation
¶
Overview ¶
Package mps implements the Matrix Product State algorithm.
References:
- The density-matrix renormalization group in the age of matrix product states, Ulrich Schollwock
Example ¶
package main
import (
"fmt"
"log"
"math/cmplx"
"github.com/fumin/qising/mps"
"github.com/fumin/tensor"
)
func main() {
// Create an Ising chain of length n and transverse field strength h.
const n = 4
const h = 0.031623
mpo := mps.Ising([2]int{n, 1}, h)
// Buffers.
fs := make([]*tensor.Dense, 0, len(mpo))
for _ = range mpo {
fs = append(fs, tensor.Zeros(1))
}
var bufs [10]*tensor.Dense
for i := range len(bufs) {
bufs[i] = tensor.Zeros(1)
}
// Search for the ground state.
const bondDim = 2
state := mps.RandMPS(mpo, bondDim)
if err := mps.SearchGroundState(fs, mpo, state, bufs); err != nil {
log.Fatalf("%+v", err)
}
// Compute expectation values of the ground state.
bufs2 := [2]*tensor.Dense(bufs[:2])
norm2 := mps.InnerProduct(state, state, bufs2) // <state|state>
e0 := mps.LExpressions(fs, mpo, state, bufs2) / norm2 // ground energy
fmt.Printf("Ground energy %.4f\n", real(e0))
}
func abs(x complex64) float64 {
return cmplx.Abs(complex128(x))
}
Output: Ground energy -3.0015
Index ¶
- func H2(ws, ms []*tensor.Dense, bufs [2]*tensor.Dense) complex64
- func InnerProduct(x, y []*tensor.Dense, bufs [2]*tensor.Dense) complex64
- func Ising(n [2]int, h complex64) []*tensor.Dense
- func LExpressions(fs, ws, ms []*tensor.Dense, bufs [2]*tensor.Dense) complex64
- func MagnetizationZ(n [2]int) []*tensor.Dense
- func NewMPS(state *tensor.Dense, bufs [2]*tensor.Dense) []*tensor.Dense
- func RExpressions(fs, ws, ms []*tensor.Dense, bufs [2]*tensor.Dense) complex64
- func RandMPS(mpo []*tensor.Dense, maxD int) []*tensor.Dense
- func SearchGroundState(fs, ws, ms []*tensor.Dense, bufs [10]*tensor.Dense, ...) error
- type SearchGroundStateOptions
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func H2 ¶
H2 returns <psi|H^2|psi>. See Figure 44, Section 6.4 Conventional DMRG in MPS language: the subtle differences, Ulrich Schollwock for a graphical explanation.
func InnerProduct ¶
InnerProduct computes the inner product between x and y. See Section 4.2.1 Efficient evaluation of contractions, Ulrich Schollwock.
func Ising ¶
Ising returns the MPO hamiltonian of the Transverse Field Ising Model. n is the shape of the lattic, and h is the field strength.
func LExpressions ¶
LExpressions returns the L expressions defined in Equation 192, Section 6.2 Applying a Hamiltonian MPO to a mixed canonical state, Ulrich Schollwock. See Figure 38, Ulrich Schollwock for a graphical explanation.
func MagnetizationZ ¶
MagnetizationZ returns the MPO hamiltonian of the Z axis magnetization. The shape of the lattice is specified by n.
func RExpressions ¶
RExpressions returns the R expressions defined in Equation 193, Section 6.2 Applying a Hamiltonian MPO to a mixed canonical state, Ulrich Schollwock. See Figure 38, Ulrich Schollwock for a graphical explanation.
func RandMPS ¶
RandMPS creates a random matrix product state. maxD is the maximum bond dimension, which is D in the discussion below equation 71 in section 4.1.4, Ulrich Schollwock.
func SearchGroundState ¶
func SearchGroundState(fs, ws, ms []*tensor.Dense, bufs [10]*tensor.Dense, options ...SearchGroundStateOptions) error
SearchGroundState performs the MPS ground state search. See Section 6.3 Iterative ground state search, Ulrich Schollwock.
Types ¶
type SearchGroundStateOptions ¶
type SearchGroundStateOptions struct {
// contains filtered or unexported fields
}
SearchGroundStateOptions are options for the MPS ground state search algorithm.
func NewSearchGroundStateOptions ¶
func NewSearchGroundStateOptions() SearchGroundStateOptions
NewSearchGroundStateOptions returns the default MPS ground state search options.
func (SearchGroundStateOptions) MaxIterations ¶
func (opt SearchGroundStateOptions) MaxIterations(i int) SearchGroundStateOptions
MaxIterations sets the maximum iterations.
func (SearchGroundStateOptions) Tol ¶
func (opt SearchGroundStateOptions) Tol(tol float32) SearchGroundStateOptions
Tol sets the tolerance of the convergence criterion <H^2> - (<H>)^2.