diff --git a/documentation/index.html b/documentation/index.html index ff278073..10c7b689 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -505,6 +505,11 @@

States

A generic state describing a quantum wave function + +ProductState +A product state of local configurations + +

Symmetries

diff --git a/documentation/states/product_state/index.html b/documentation/states/product_state/index.html new file mode 100644 index 00000000..202ff4c1 --- /dev/null +++ b/documentation/states/product_state/index.html @@ -0,0 +1,614 @@ + + + + + + + + + + + + + + + + + + + ProductState - XDiag Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + Skip to content + + +
+
+ +
+ + + + + + +
+ + +
+ +
+ + + + + + +
+
+ + + +
+
+
+ + + + + +
+
+
+ + + +
+
+
+ + + +
+
+
+ + + +
+
+ + + + +

ProductState

+ +

A product state of local configurations

+

Source product_state.hpp

+

Constructors

+
+
+
+
ProductState(n_sites::Int64)
+ProductState(local_states::Vector{String})
+
+
+
+
ProductState(int64_t n_sites);
+ProductState(std::vector<std::string> const &local_states);
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
ParameterDescription
n_sitesconstruct a product state on n_sites
local_statesthe local configurations of the product state
+

Iteration

+

A Product state can be iterated over, where at each iteration the string of the local configuration is retured. Here is an example:

+
+
+
+
pstate = ProductState(["Up", "Dn", "Emp", "UpDn"])
+for s in pstate
+    @show s
+end
+
+
+
+
auto pstate = ProductState({"Up", "Dn", "Emp", "UpDn"});
+for (auto s : pstate) {
+    Log("{}", s);
+}
+
+
+
+
+

Methods

+
+

n_sites

+

Returns the number of sites of the product state

+
+
+
+
n_sites(state::ProductState)
+
+
+
+
int64_t n_sites() const
+
+
+
+
+
+
+

size

+

Returns the number of sites of the product state. Same as "n_sites".

+
+
+
+
size(state::ProductState)
+
+
+
+
int64_t size() const
+
+
+
+
+
+
+

setindex! / operator[]

+

Sets the local configuration at the given site index to the given string.

+
+
+
+
setindex!(state::ProductState, local_state::String, idx::Int64)
+
+
+
+
std::string &operator[](int64_t i);
+
+
+
+
+
+
+

getindex / operator[]

+

Returns the string of the local configuration at the given site index.

+
+
+
+
getindex(state::ProductState, idx::Int64)
+
+
+
+
std::string const &operator[](int64_t i) const;
+
+
+
+
+
+
+

push! / push_back

+

Adds a local configuration add the end of the product state.

+
+
+
+
push!(state::ProductState, local_state::String
+
+
+
+
void push_back(std::string l);
+
+
+
+
+
+

Usage Example

+
+
+
+
pstate = ProductState(["Up", "Dn", "Emp", "UpDn"])
+for s in pstate
+    @show s
+end
+@show pstate
+
+pstate = ProductState()
+push!(pstate, "Dn")
+push!(pstate, "Up")
+push!(pstate, "Dn")
+@show n_sites(pstate)
+for s in pstate
+    @show s
+end
+@show pstate
+
+
+
+
auto pstate = ProductState({"Up", "Dn", "Emp", "UpDn"});
+for (auto s : pstate) {
+  Log("{}", s);
+}
+XDIAG_SHOW(to_string(pstate));
+
+pstate = ProductState();
+pstate.push_back("Dn");
+pstate.push_back("Up");
+pstate.push_back("Dn");
+XDIAG_SHOW(pstate.n_sites());
+for (auto s : pstate) {
+  Log("{}", s);
+}
+XDIAG_SHOW(to_string(pstate));
+
+
+
+
+ + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/search/search_index.json b/search/search_index.json index f64dafb8..0277b558 100644 --- a/search/search_index.json +++ b/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":"

Quick Start Code on GitHub

"},{"location":"#overview","title":"Overview","text":"

XDiag is a C++ library for performing Exact Diagonalizations of quantum many-body systems. Key features include optimized combinatorical algorithms for navigating Hilbert spaces, iterative linear algebra algorithms, shared and distributed memory parallelization.

"},{"location":"#gallery","title":"Gallery","text":""},{"location":"examples/","title":"Examples","text":""},{"location":"examples/#basic-examples","title":"Basic examples","text":""},{"location":"examples/#distributed-examples","title":"Distributed examples","text":""},{"location":"examples/#cmakeliststxt-for-applications","title":"CMakeLists.txt for applications","text":""},{"location":"installation/","title":"Installation","text":""},{"location":"installation/#julia-installation","title":"Julia Installation","text":"

Enter the package mode using ] in the Julia REPL and add the following two packages

add https://github.com/awietek/XDiag_jll.jl.git\nadd https://github.com/awietek/XDiag.jl.git\n

"},{"location":"installation/#c-compilation","title":"C++ Compilation","text":"

Using XDiag with C++ is a two-step process. First the xdiag library needs to be compiled and installed. Therafter, application codes are compiled in a second step. Here we explain how to compile the library.

"},{"location":"installation/#prerequisites","title":"Prerequisites","text":""},{"location":"installation/#basic-compilation","title":"Basic Compilation","text":""},{"location":"installation/#advanced-compilation","title":"Advanced Compilation","text":""},{"location":"installation/#building-documentation","title":"Building Documentation","text":"

The source files for the documentation can be found in the directory docs. The documentation is built using Material for MKDocs. To work on it locally, it can be served using

mkdocs serve\n

from the xdiag root source directory. A local build of the documentation can then be accessed in a webbrowser at the adress

127.0.0.1:8000\n
"},{"location":"quickstart/","title":"Quick start","text":""},{"location":"quickstart/#hello-world","title":"Hello World","text":"

Let us set up our first program using the xdiag library.

JuliaC++
using XDiag\nsay_hello()\n
#include <xdiag/all.hpp>\n\nusing namespace xdiag;\n\nint main() try {\n  say_hello();\n} catch (Error e) {\n  error_trace(e);\n}\n

The function say_hello() prints out a welcome message, which also contains information which exact XDiag version is used. In Julia this is all there is to it.

For the C++ code we need to create two files to compile the program. The first is the actual C++ code. What is maybe a bit unfamiliar is the try / catch block. XDiag implements a traceback mechanism for runtime errors, which is activated by this idiom. While not stricly necessary here, it is a good practice to make use of this.

Now that the application program is written, we next need to set up the compilation instructions using CMake. To do so we create a second file called CMakeLists.txt in the same directory.

cmake_minimum_required(VERSION 3.19)\n\nproject(\n  hello_world\n)\n\nfind_package(xdiag REQUIRED HINTS \"../../install\")\nadd_executable(main main.cpp)\ntarget_link_libraries(main PRIVATE xdiag::xdiag)\n

You should replace \"/path/to/xdiag/install\" with the appropriate directory where your XDiag library is installed after compilation. This exact CMakeLists.txt file can be used to compile any XDiag application.

Info

For using the distributed XDiag library the last line of the above CMakeLists.txt should be changed to

target_link_libraries(main PUBLIC xdiag::xdiag_distributed)\n

We then compile the application code,

cmake -S . -B build\ncmake --build build\n

and finally run our first xdiag application.

./build/main\n
"},{"location":"quickstart/#computing-the-ground-state-energy-of-a-spin-chain","title":"Computing the ground state energy of a spin chain","text":"

We compute the ground state energy of the \\(S=1/2\\) Heisenberg chain on a periodic chain lattice in one dimension. The Hamiltonian is given by

\\[ H = J\\sum_{\\langle i,j \\rangle} \\mathbf{S}_i \\cdot \\mathbf{S}_j\\]

where \\(\\mathbf{S}_i = (S_i^x, S_i^y, S_i^z)\\) are the spin \\(S=1/2\\) operators and \\(\\langle i,j \\rangle\\) denotes summation over nearest-meighbor sites \\(i\\) and \\(j\\).

The following code, sets up the Hilbert space, defines the Hamiltonian and finally calls an iterative eigenvalue solver to compute the ground state energy.

JuliaC++
using XDiag\n\nlet \n    N = 16;\n    nup = N \u00f7 2;\n    block = Spinhalf(N, nup);\n\n    # Define the nearest-neighbor Heisenberg model\n    bonds = BondList()\n    for i in 1:N\n        bonds += Bond(\"HB\", \"J\", [i-1, i % N])\n    end\n    bonds[\"J\"] = 1.0;\n\n    set_verbosity(2);             # set verbosity for monitoring progress\n    e0 = eigval0(bonds, block);   # compute ground state energy\n\n    println(\"Ground state energy: $e0\");\nend\n
#include <xdiag/all.hpp>\n\nusing namespace xdiag;\n\nint main() try {\n  int N = 16;\n  int nup = N / 2;\n  Spinhalf block(N, nup);\n\n  // Define the nearest-neighbor Heisenberg model\n  OpSum ops;\n  for (int i = 0; i < N; ++i) {\n    ops += Op(\"HB\", \"J\", {i, (i + 1) % N});\n  }\n  ops[\"J\"] = 1.0;\n\n  set_verbosity(2);                  // set verbosity for monitoring progress\n  double e0 = eigval0(ops, block); // compute ground state energy\n\n  Log(\"Ground state energy: {:.12f}\", e0);\n\n} catch (Error e) {\n  error_trace(e);\n}\n
"},{"location":"documentation/","title":"Documentation","text":""},{"location":"documentation/#algorithms","title":"Algorithms","text":"Name Description Language eigval0 Computes the lowest lying eigenvalue of an operator eig0 Computes the lowest lying eigenvalue and eigenvector of an operator"},{"location":"documentation/#algebra","title":"Algebra","text":"matrix Creates the full matrix representation of an operator on a block"},{"location":"documentation/#blocks","title":"Blocks","text":"Spinhalf Block of a spin \\(S=1/2\\) type Hilbert space tJ Block of a \\(t-J\\) type Hilbert space Electron Block of a Electron type Hilbert space"},{"location":"documentation/#operators","title":"Operators","text":"Op A local operator acting on several lattice sites OpSum Sum of local operators Coupling Describes the coupling of a local operator"},{"location":"documentation/#states","title":"States","text":"State A generic state describing a quantum wave function"},{"location":"documentation/#symmetries","title":"Symmetries","text":"Permutation Permutations of indices or lattice sites PermutationGroup A group of permutations Representation A (1D) irreducible representation of a finite group"},{"location":"documentation/#utilities","title":"Utilities","text":"Logging Controling what is written to standard output Timing Measurng wall time straightforwardly XDIAG_SHOW Macro for printing debugging information"},{"location":"documentation/algebra/matrix/","title":"matrix","text":"
matrix(bondlist, block; force_complex=false)\nmatrixC(bondlist, block)  # c++ only\n

Creates the full matrix representation of a given BondList on a block.

In Julia, depending on whether a real/complex matrix is generated also a real/complex matrix is returned. The C++ version has to return a fixed type. If a real matrix is desired, use the function matrix. If a complex matrix is desired, use the function matrixC.

Source matrix.hpp

"},{"location":"documentation/algebra/matrix/#parameters","title":"Parameters","text":"Name Description bondlist BondList defining the bonds of the operator block block on which the operator is defined force_complex flag to determine if returned matrix is forced to be complex (Julia only)"},{"location":"documentation/algebra/matrix/#returns","title":"Returns","text":"Type Description matrix matrix representation of bondlist on block"},{"location":"documentation/algebra/matrix/#definition","title":"Definition","text":"JuliaC++
matrix(bonds::BondList, block::Block; force_complex::Bool=false)\n
template <typename block_t>\narma::mat matrix(BondList const &bond, block_t const &block);\n\ntemplate <typename block_t>\narma::cx_mat matrixC(BondList const &bond, block_t const &block);\n
"},{"location":"documentation/algebra/matrix/#usage-example","title":"Usage Example","text":"JuliaC++
let\n    # Creates matrix H_{k=2} in Eq (18.23) of https://link.springer.com/content/pdf/10.1007/978-3-540-74686-7_18.pdf\n    N = 4\n    nup = 3\n    ndn = 2\n\n    # Define a Hubbard chain model\n    ops = OpSum()\n    for i in 1:N\n        ops += Op(\"HOP\", \"T\", [i-1, i % N])\n    end\n    ops[\"T\"] = 1.0;\n    ops[\"U\"] = 5.0;\n\n    # Create the a permutation group\n    p1 = Permutation([0, 1, 2, 3])\n    p2 = Permutation([1, 2, 3, 0])\n    p3 = Permutation([2, 3, 0, 1])\n    p4 = Permutation([3, 0, 1, 2])\n    group = PermutationGroup([p1, p2, p3, p4])\n    irrep = Representation([1, -1, 1, -1])\n    block = Electron(N, nup, ndn, group, irrep)\n\n    H = matrix(ops, block)\n    display(H)\nend\n
// Creates matrix H_{k=2} in Eq (18.23) of https://link.springer.com/content/pdf/10.1007/978-3-540-74686-7_18.pdf\nint N = 4;\nint nup = 3;\nint ndn = 2;\n\n// Define a Hubbard chain model\nauto ops = OpSum();\nfor (int i=0; i< N; ++i){\n  ops += Op(\"HOP\", \"T\", {i, (i+1) % N});\n}\nops[\"T\"] = 1.0;\nops[\"U\"] = 5.0;\n\n// Create the a permutation group\nauto p1 = Permutation({0, 1, 2, 3});\nauto p2 = Permutation({1, 2, 3, 0});\nauto p3 = Permutation({2, 3, 0, 1});\nauto p4 = Permutation({3, 0, 1, 2});\nauto group = PermutationGroup({p1, p2, p3, p4});\nauto irrep = Representation({1, -1, 1, -1});\nauto block = Electron(N, nup, ndn, group, irrep);\n\nauto H = matrix(ops, block);\nH.print();\n
"},{"location":"documentation/algorithms/eig0/","title":"eig0","text":"
eig0(bondlist, block; precision, max_iterations, force_complex, random_seed)\n

Computes the groud state energy and the ground state of an operator on a block.

Source sparse_diag.hpp

"},{"location":"documentation/algorithms/eig0/#parameters","title":"Parameters","text":"Name Description Default bondlist BondList defining the bonds of the operator block block on which the operator is defined precision accuracy of the computed ground state 1e-12 max_iterations maximum number of iterations 1000 force_complex whether or not computation should be forced to have complex arithmetic false random_seed random seed for setting up the initial vector 42"},{"location":"documentation/algorithms/eig0/#returns","title":"Returns","text":"Type Description real number lowest lying eigenvalue State groundstate"},{"location":"documentation/algorithms/eig0/#definition","title":"Definition","text":"JuliaC++
eig0(bonds::BondList, block::Spinhalf;\n     precision::Real=1e-12, maxiter::Integer=1000,\n     force_complex::Bool=false, seed::Integer=42)\n
std::tuple<double, State>\neig0(BondList const &bondlist, block_variant_t const &block,\n     double precision = 1e-12, int64_t max_iterations = 1000,\n     bool force_complex = false, int64_t random_seed = 42);\n
"},{"location":"documentation/algorithms/eig0/#usage-example","title":"Usage Example","text":"JuliaC++
let \n    N = 8;\n    nup = N \u00f7 2;\n    block = Spinhalf(N, nup);\n\n    # Define the nearest-neighbor Heisenberg model\n    ops = OpSum()\n    for i in 1:N\n        ops += Op(\"HB\", \"J\", [i-1, i % N])\n    end\n    ops[\"J\"] = 1.0;\n\n    e0, gs = eig0(ops, block);\nend\n
int N = 8;\nint nup = N / 2;\nauto block = Spinhalf(N, nup);\n\n// Define the nearest-neighbor Heisenberg model\nauto ops = OpSum();\nfor (int i=0; i<N; ++i) {\n  ops += Op(\"HB\", \"J\", {i, (i+1) % N});\n}\nops[\"J\"] = 1.0;\nauto [e0, gs] = eig0(ops, block);\n
"},{"location":"documentation/algorithms/eigval0/","title":"eigval0","text":"
eigval0(bondlist, block; precision, max_iterations, force_complex, random_seed)\n

Computes the groud state energy of an operator on a block.

Source sparse_diag.hpp

"},{"location":"documentation/algorithms/eigval0/#parameters","title":"Parameters","text":"Name Description Default bondlist BondList defining the bonds of the operator block block on which the operator is defined precision accuracy of the computed ground state 1e-12 max_iterations maximum number of iterations 1000 force_complex whether or not computation should be forced to have complex arithmetic false random_seed random seed for setting up the initial vector 42"},{"location":"documentation/algorithms/eigval0/#returns","title":"Returns","text":"Type Description real number lowest lying eigenvalue"},{"location":"documentation/algorithms/eigval0/#definition","title":"Definition","text":"JuliaC++
eig0(bonds::BondList, block::Union{Spinhalf,Electron,tJ};\n     precision::Real=1e-12, maxiter::Integer=1000,\n     force_complex::Bool=false, seed::Integer=42)\n
double eigval0(BondList const &bondlist, block_variant_t const &block,\n               double precision = 1e-12, int64_t max_iterations = 1000,\n               bool force_complex = false, int64_t random_seed = 42);\n
"},{"location":"documentation/algorithms/eigval0/#usage-example","title":"Usage Example","text":"JuliaC++
let \n    N = 8;\n    nup = N \u00f7 2;\n    block = Spinhalf(N, nup);\n\n    # Define the nearest-neighbor Heisenberg model\n    ops = OpSum()\n    for i in 1:N\n        ops += Op(\"HB\", \"J\", [i-1, i % N])\n    end\n    ops[\"J\"] = 1.0;\n\n    e0 = eigval0(ops, block);\nend\n
int N = 8;\nint nup = N / 2;\nauto block = Spinhalf(N, nup);\n\n// Define the nearest-neighbor Heisenberg model\nauto ops = OpSum();\nfor (int i=0; i<N; ++i) {\n  ops += Op(\"HB\", \"J\", {i, (i+1) % N});\n}\nops[\"J\"] = 1.0;\ndouble e0 = eigval0(ops, block);\n
"},{"location":"documentation/blocks/electron/","title":"Electron","text":"

Representation of a block in a Electron (spinful fermion) Hilbert space.

Source electron.hpp

"},{"location":"documentation/blocks/electron/#constructors","title":"Constructors","text":"JuliaC++
Electron(n_sites::Integer)\nElectron(n_sites::Integer, n_up::Integer, n_dn::Integer)\nElectron(n_sites::Integer, group::PermutationGroup, irrep::Representation)\nElectron(n_sites::Integer, n_up::Integer, n_dn::Integer, \n         group::PermutationGroup, irrep::Representation)\n
Electron(int64_t n_sites);\nElectron(int64_t n_sites, int64_t n_up, int64_t n_dn);\nElectron(int64_t n_sites, PermutationGroup permutation_group,\n         Representation irrep);\nElectron(int64_t n_sites, int64_t n_up, int64_t n_dn, \n         PermutationGroup group, Representation irrep);\n
Name Description n_sites number of sites (integer) n_up number of \"up\" electrons (integer) n_dn number of \"dn\" electrons (integer) group PermutationGroup defining the permutation symmetries irrep Irreducible Representation of the symmetry group"},{"location":"documentation/blocks/electron/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the block.

JuliaC++
n_sites(block::Electron)\n
int64_t n_sites() const\n

size

Returns the size of the block, i.e. its dimension.

JuliaC++
size(block::Electron)\n
int64_t size() const;\n

isreal

Returns whether the block can be used with real arithmetic. Complex arithmetic is needed when a Representation is genuinely complex.

JuliaC++
isreal(block::Electron; precision::Real=1e-12)\n
int64_t isreal(double precision = 1e-12) const;\n
"},{"location":"documentation/blocks/electron/#usage-example","title":"Usage Example","text":"JuliaC++
N = 4\nnup = 2\nndn = 1\n\n# without number conservation\nblock = Electron(N)\n@show block\n\n# with number conservation\nblock_np = Electron(N, nup, ndn)\n@show block_np\n\n# with symmetries, without number conservation\np1 = Permutation([0, 1, 2, 3])\np2 = Permutation([1, 2, 3, 0])\np3 = Permutation([2, 3, 0, 1])\np4 = Permutation([3, 0, 1, 2])\ngroup = PermutationGroup([p1, p2, p3, p4])\nirrep = Representation([1, -1, 1, -1])\nblock_sym = Electron(N, group, irrep)\n@show block_sym\n\n# with symmetries and number conservation\nblock_sym_np = Electron(N, nup, ndn, group, irrep)\n@show block_sym_np\n\n@show n_sites(block_sym_np)\n@show size(block_sym_np)\n
int N = 4;\nint nup = 2;\nint ndn = 1;\n\n// without number conservation\nauto block = Electron(N);\nXDIAG_SHOW(block);\n\n// with number conservation\nauto block_np = Electron(N, nup, ndn);\nXDIAG_SHOW(block_np);\n\n// with symmetries, without number conservation\nauto p1 = Permutation({0, 1, 2, 3});\nauto p2 = Permutation({1, 2, 3, 0});\nauto p3 = Permutation({2, 3, 0, 1});\nauto p4 = Permutation({3, 0, 1, 2});\nauto group = PermutationGroup({p1, p2, p3, p4});\nauto irrep = Representation({1, -1, 1, -1});\nauto block_sym = Electron(N, group, irrep);\nXDIAG_SHOW(block_sym);\n\n// with symmetries and number conservation\nauto block_sym_np = Electron(N, nup, ndn, group, irrep);\nXDIAG_SHOW(block_sym_np);\n\nXDIAG_SHOW(block_sym_np.n_sites());\nXDIAG_SHOW(block_sym_np.size());\n
"},{"location":"documentation/blocks/spinhalf/","title":"Spinhalf","text":"

Representation of a block in a spin \\(S=1/2\\) Hilbert space.

Source spinhalf.hpp

"},{"location":"documentation/blocks/spinhalf/#constructors","title":"Constructors","text":"JuliaC++
Spinhalf(n_sites::Integer)\nSpinhalf(n_sites::Integer, n_up::Integer)\nSpinhalf(n_sites::Integer, group::PermutationGroup, irrep::Representation)\nSpinhalf(n_sites::Integer, n_up::Integer, group::PermutationGroup, \n         irrep::Representation)\n
Spinhalf(int64_t n_sites);\nSpinhalf(int64_t n_sites, int64_t n_up);\nSpinhalf(int64_t n_sites, PermutationGroup permutation_group,\n         Representation irrep);\nSpinhalf(int64_t n_sites, int64_t n_up, PermutationGroup group,\n         Representation irrep);\n
Name Description n_sites number of sites (integer) n_up number of \"up\" spin setting spin (integer) group PermutationGroup defining the permutation symmetries irrep Irreducible Representation of the symmetry group"},{"location":"documentation/blocks/spinhalf/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the block.

JuliaC++
n_sites(block::Spinhalf)\n
int64_t n_sites() const\n

dim

Returns the dimension of the block.

JuliaC++
dim(block::Spinhalf)\n
int64_t dim() const;\n

size

Returns the size of the block locally. Same as \"dim\" for non-distributed Blocks but different for distributed blocks.

JuliaC++
size(block::Spinhalf)\n
int64_t size() const;\n

isreal

Returns whether the block can be used with real arithmetic. Complex arithmetic is needed when a Representation is genuinely complex.

JuliaC++
isreal(block::Spinhalf; precision::Real=1e-12)\n
int64_t isreal(double precision = 1e-12) const;\n
"},{"location":"documentation/blocks/spinhalf/#usage-example","title":"Usage Example","text":"JuliaC++
N = 4\nnup = 2\n\n# without Sz conservation\nblock = Spinhalf(N)\n@show block\n\n\n# with Sz conservation\nblock_sz = Spinhalf(N, nup)\n@show block_sz\n\n# with symmetries, without Sz\np1 = Permutation([0, 1, 2, 3])\np2 = Permutation([1, 2, 3, 0])\np3 = Permutation([2, 3, 0, 1])\np4 = Permutation([3, 0, 1, 2])\ngroup = PermutationGroup([p1, p2, p3, p4])\nirrep = Representation([1, -1, 1, -1])\nblock_sym = Spinhalf(N, group, irrep)\n@show block_sym\n\n# with symmetries and Sz\nblock_sym_sz = Spinhalf(N, nup, group, irrep)\n@show block_sym_sz\n\n@show n_sites(block_sym_sz)\n@show size(block_sym_sz)\n
int N = 4;\nint nup = 2;\n\n// without Sz conservation\nauto block = Spinhalf(N);\nXDIAG_SHOW(block);\n\n// with Sz conservation\nauto block_sz = Spinhalf(N, nup);\nXDIAG_SHOW(block_sz);\n\n// with symmetries, without Sz\nPermutation p1 = {0, 1, 2, 3};\nPermutation p2 = {1, 2, 3, 0};\nPermutation p3 = {2, 3, 0, 1};\nPermutation p4 = {3, 0, 1, 2};\nauto group = PermutationGroup({p1, p2, p3, p4});\nauto irrep = Representation({1, -1, 1, -1});\nauto block_sym = Spinhalf(N, group, irrep);\nXDIAG_SHOW(block_sym);\n\n// with symmetries and Sz\nauto block_sym_sz = Spinhalf(N, nup, group, irrep);\nXDIAG_SHOW(block_sym_sz);\n\nXDIAG_SHOW(block_sym_sz.n_sites());\nXDIAG_SHOW(block_sym_sz.size());\n
"},{"location":"documentation/blocks/tJ/","title":"tJ","text":"

Representation of a block in a \\(t-J\\) type Hilbert space.

Source tj.hpp

"},{"location":"documentation/blocks/tJ/#constructors","title":"Constructors","text":"JuliaC++
tJ(n_sites::Integer, n_up::Integer, n_dn::Integer)\ntJ(n_sites::Integer, n_up::Integer, n_dn::Integer, \n   group::PermutationGroup, irrep::Representation)\n
tJ(int64_t n_sites, int64_t n_up, int64_t n_dn);\ntJ(int64_t n_sites, int64_t n_up, int64_t n_dn, \n   PermutationGroup group, Representation irrep);\n
Name Description n_sites number of sites (integer) n_up number of \"up\" electrons (integer) n_dn number of \"dn\" electrons (integer) group PermutationGroup defining the permutation symmetries irrep Irreducible Representation of the symmetry group"},{"location":"documentation/blocks/tJ/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the block.

JuliaC++
n_sites(block::tJ)\n
int64_t n_sites() const\n

size

Returns the size of the block, i.e. its dimension.

JuliaC++
size(block::tJ)\n
int64_t size() const;\n

isreal

Returns whether the block can be used with real arithmetic. Complex arithmetic is needed when a Representation is genuinely complex.

JuliaC++
isreal(block::tJ; precision::Real=1e-12)\n
int64_t isreal(double precision = 1e-12) const;\n
"},{"location":"documentation/blocks/tJ/#usage-example","title":"Usage Example","text":"JuliaC++
N = 4\nnup = 2\nndn = 1\n\n# without permutation symmetries\nblock = tJ(N, nup, ndn)\n@show block\n\n# with permutation symmetries\np1 = Permutation([0, 1, 2, 3])\np2 = Permutation([1, 2, 3, 0])\np3 = Permutation([2, 3, 0, 1])\np4 = Permutation([3, 0, 1, 2])\ngroup = PermutationGroup([p1, p2, p3, p4])\nirrep = Representation([1, -1, 1, -1])\nblock_sym = tJ(N, nup, ndn, group, irrep)\n@show block_sym\n\n@show n_sites(block_sym)\n@show size(block_sym)\n
int N = 4;\nint nup = 2;\nint ndn = 1;\n\n// without permutation symmetries\nauto block = tJ(N, nup, ndn);\nXDIAG_SHOW(block);\n\n// with permutation symmetries\nauto p1 = Permutation({0, 1, 2, 3});\nauto p2 = Permutation({1, 2, 3, 0});\nauto p3 = Permutation({2, 3, 0, 1});\nauto p4 = Permutation({3, 0, 1, 2});\nauto group = PermutationGroup({p1, p2, p3, p4});\nauto irrep = Representation({1, -1, 1, -1});\nauto block_sym = tJ(N, nup, ndn, group, irrep);\nXDIAG_SHOW(block_sym);\n\nXDIAG_SHOW(block_sym.n_sites());\nXDIAG_SHOW(block_sym.size());\n
"},{"location":"documentation/operators/coupling/","title":"Coupling","text":"

Describes the coupling of a local operator. A coupling can either be a string, a real/complex number or even a real/complex matrix. It allows for converting to real/complex numbers or matrices as well as strings, whenever this conversion is sensible.

Source coupling.hpp

"},{"location":"documentation/operators/coupling/#constructors","title":"Constructors","text":"JuliaC++
Coupling(name::String)\nCoupling(val::Float64)\nCoupling(val::ComplexF64)\nCoupling(mat::Matrix{Float64})\nCoupling(mat::Matrix{ComplexF64})\n
Coupling(std::string value);\nCoupling(double value);\nCoupling(complex value);\nCoupling(arma::mat const &value);\nCoupling(arma::cx_mat const &value);\n
"},{"location":"documentation/operators/coupling/#methods","title":"Methods","text":"

type

Returns the type of the Coupling, i.e. a string which either reads \"string\", \"double\", \"complex\", \"mat\", or \"cx_mat\"

JuliaC++
type(cpl::Coupling)\n
std::string type() const;\n

isreal

Returns whether or not the coupling is real. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

JuliaC++
isreal(cpl::Coupling)\n
bool isreal() const;\n

ismatrix

Returns whether or not the coupling is defined as a matrix. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

JuliaC++
ismatrix(cpl::Coupling)\n
bool ismatrix() const;\n

isexplicit

Returns false if the coupling is defined as a string, otherwise true

JuliaC++
isexplicit(cpl::Coupling)\n
bool isexplicit() const;\n
"},{"location":"documentation/operators/coupling/#conversions","title":"Conversions","text":"

A Coupling can be converted to the values it represents, so a string, real/complex number or a real/complex matrix. Initially real values can be cast to complex.

JuliaC++
convert(::Type{String}, cpl::Coupling)\nconvert(::Type{Float64}, cpl::Coupling)\nconvert(::Type{ComplexF64}, cpl::Coupling)\nconvert(::Type{Matrix{Float64}}, cpl::Coupling)\nconvert(::Type{Matrix{ComplexF64}}, cpl::Coupling)\n
template <typename coeff_t> coeff_t as() const;\n
"},{"location":"documentation/operators/coupling/#usage-example","title":"Usage Example","text":"JuliaC++
cpl = Coupling(\"J\")\n@show type(cpl)\n@show isexplicit(cpl)\n\ncpl = Coupling(1.23)\n@show ismatrix(cpl)\n@show convert(Float64, cpl)\n@show convert(ComplexF64, cpl)\n\ncpl = Coupling([1 2; -2 1])\n@show ismatrix(cpl)\n@show isreal(cpl)\n@show convert(Matrix{Float64}, cpl)\n@show convert(Matrix{ComplexF64}, cpl)\n
auto cpl = Coupling(\"J\");\nXDIAG_SHOW(cpl.type());\nXDIAG_SHOW(cpl.isexplicit());\n\ncpl = Coupling(1.23);\nXDIAG_SHOW(cpl.ismatrix());\nXDIAG_SHOW(cpl.as<double>());\nXDIAG_SHOW(cpl.as<complex>());\n\ncpl = Coupling(arma::mat(\"1 2; -2 1\"));\nXDIAG_SHOW(cpl.ismatrix());\nXDIAG_SHOW(cpl.isreal());\nXDIAG_SHOW(cpl.as<arma::mat>());\nXDIAG_SHOW(cpl.as<arma::cx_mat>());\n
"},{"location":"documentation/operators/op/","title":"Op","text":"

A local operator acting on several lattice sites.

Source op.hpp

"},{"location":"documentation/operators/op/#constructors","title":"Constructors","text":"JuliaC++
Op(type::String, coupling::String, sites::Vector{Int64})\nOp(type::String, coupling::String, site::Int64)\n\nOp(type::String, coupling::Float64, sites::Vector{Int64})\nOp(type::String, coupling::Float64, site::Int64)\n\nOp(type::String, coupling::ComplexF64, sites::Vector{Int64})\nOp(type::String, coupling::ComplexF64, site::Int64)\n\nOp(type::String, coupling::Matrix{Float64}, sites::Vector{Int64})\nOp(type::String, coupling::Matrix{Float64}, site::Int64)\n\nOp(type::String, coupling::Matrix{ComplexF64}, sites::Vector{Int64})\nOp(type::String, coupling::Matrix{ComplexF64}, site::Int64)\n
Op(std::string type, std::string coupling, std::vector<int64_t> const &sites)\nOp(std::string type, std::string coupling, int64_t site)\n\nOp(std::string type, double coupling, std::vector<int64_t> const &sites)\nOp(std::string type, double coupling, int64_t site)\n\nOp(std::string type, complex coupling, std::vector<int64_t> const &sites)\nOp(std::string type, complex coupling, int64_t site)\n\nOp(std::string type, arma::mat const &coupling, std::vector<int64_t> const &sites)\nOp(std::string type, arma::mat const &coupling, int64_t site)\n\nOp(std::string type, arma::cx_mat const &coupling, std::vector<int64_t> const &sites)\nOp(std::string type, arma::cx_mat const &coupling, int64_t site)\n
Parameter Description type a string which denotes what kind of operator is represented coupling sets the coefficients neded to specify the coupling. Further details below sites defines on which site(s) of the lattice the operator acts on.

The coupling can take on several types and allow some flexibility in defining operators.

type Description string the coupling is represented as a string, e.g. \"\\(t\\)\" or \"\\(J\\)\" in a \\(t-J\\) model real/cplx number the actual numerical value of the coupling real/cplx matrix more generic interactions can be specified as matrices"},{"location":"documentation/operators/op/#methods","title":"Methods","text":"

type

Returns the type of the operator

JuliaC++
type(op::Op)\n
std::string type() const;\n

coupling

Returns the coupling of the operator

JuliaC++
coupling(op::Op)\n
Coupling const &coupling() const;\n

This returns an object of type Coupling, which can then be converted to an appropriate type.

size

Returns how many sites the operator is defined on

JuliaC++
size(op::Op)\n
int64_t size() const;\n

getindex / operator[]

Returns the site with the given index.

JuliaC++
getindex(op::Op, idx::Int64)\n
int64_t operator[](int64_t idx) const;\n

sites

Returns all the sites the operator is defined on

JuliaC++
sites(op::Op)\n
std::vector<int64_t> const &sites() const;\n

isreal

Returns whether or not the coupling is real. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

JuliaC++
isreal(op::Op)\n
bool isreal() const;\n

ismatrix

Returns whether or not the coupling is defined as a matrix. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

JuliaC++
ismatrix(op::Op)\n
bool ismatrix() const;\n

isexplicit

Returns false if the coupling is defined as a string, otherwise true

JuliaC++
isexplicit(op::Op)\n
bool isexplicit() const;\n
"},{"location":"documentation/operators/op/#usage-example","title":"Usage Example","text":"JuliaC++
op = Op(\"HOP\", \"T\", [1, 2])\n@show op\n@show type(op)\n@show convert(String, coupling(op))\n@show size(op), op[1], op[2]\n@show sites(op) == [1, 2]\n@show isexplicit(op)\n\nop = Op(\"HOP\", 1.23, [1, 2])\n@show op\n@show isreal(op)\n@show ismatrix(op)\n@show isexplicit(op)\n\nop = Op(\"SY\", [0 -im; im 0], 1)\n@show op\n@show isreal(op)\n@show ismatrix(op)\n@show isexplicit(op)\n
auto op = Op(\"HOP\", \"T\", {1, 2});\nXDIAG_SHOW(op);\nXDIAG_SHOW(op.type());\nXDIAG_SHOW(op.coupling().as<std::string>());\nXDIAG_SHOW(op.size());\nXDIAG_SHOW(op[0]);\nXDIAG_SHOW(op[1]);\nXDIAG_SHOW(op.isexplicit());\n\n op = Op(\"HOP\", 1.23, {1, 2});\nXDIAG_SHOW(op);\nXDIAG_SHOW(op.isreal());\nXDIAG_SHOW(op.ismatrix());\nXDIAG_SHOW(op.isexplicit());\n\narma::cx_mat m(arma::mat(\"0 0; 0 0\"), arma::mat(\"0 -1; 1 0\"));\nop = Op(\"SY\", m, 1);\nXDIAG_SHOW(op);\nXDIAG_SHOW(op.isreal());\nXDIAG_SHOW(op.ismatrix());\nXDIAG_SHOW(op.isexplicit());\n
"},{"location":"documentation/operators/opsum/","title":"OpSum","text":"

A sum of local operators acting on several lattice sites.

Source opsum.hpp

"},{"location":"documentation/operators/opsum/#constructor","title":"Constructor","text":"JuliaC++
OpSum()\nOpSum(ops::Vector{Op})\n
OpSum() = default;\nOpSum(std::vector<Op> const &ops);\n
Parameter Description ops a vector of Op objects describing the operators summed over"},{"location":"documentation/operators/opsum/#methods","title":"Methods","text":"

size

Returns the number of local Op operators.

JuliaC++
size(ops::OpSum)\n
int64_t size() const;\n

defined

Returns bool whether a coupling (of type string) is defined

JuliaC++
defined(ops::OpSum, name::String)\n
bool defined(std::string name) const;\n

setindex! / operator[]

Sets a coupling given as a string to a certain numerical value or matrix

JuliaC++
Base.setindex!(ops::OpSum, cpl, name::String)\n
Coupling &operator[](std::string name);\n

getindex / operator[]

Returns the value of a Coupling defined as a string.

JuliaC++
getindex(ops::OpSum, name::String)\n
Coupling const &operator[](std::string name) const;\n

couplings

Returns all the possible names of Coupling as a vector of strings

JuliaC++
couplings(ops::OpSum)\n
std::vector<std::string> couplings() const;\n

isreal

Returns whether or not the OpSum is real. This will throw an error if some Coupling are only defined as a string.

JuliaC++
isreal(ops::OpSum)\n
bool isreal() const;\n

isexplicit

Returns false if there exist a Coupling which is defined as a string, otherwise true.

JuliaC++
isexplicit(ops::OpSum)\n
bool isexplicit() const;\n

operator +

Adds a single Op or a full OpSum

JuliaC++
+(ops::OpSum, op2::Op) = OpSum(ops.cxx_opsum + op2.cxx_op)\n+(ops::OpSum, ops2::OpSum) = OpSum(ops.cxx_opsum + ops2.cxx_opsum)\n
void operator+=(Op const &op);\nvoid operator+=(OpSum const &ops);\nOpSum operator+(Op const &op) const;\nOpSum operator+(OpSum const &ops) const;\n
"},{"location":"documentation/operators/opsum/#usage-example","title":"Usage Example","text":"JuliaC++
# Define the 1D transverse-field Ising chain\nlet \n    N = 12\n    J = 1.0\n    h = 0.5\n    Sx = [0 1; 1 0]\n\n    ops = OpSum()\n    for i in 1:N\n        ops += Op(\"ISING\", \"J\", [i-1, i % N])\n        ops += Op(\"SX\", h * Sx, i-1)\n    end\n\n    ops[\"J\"] = 1.0;\n    @show ops\n    @show defined(ops, \"J\")\n    @show isreal(ops)\n    @show isexplicit(ops)\nend\n
// Define the 1D transverse-field Ising chain\nint N = 12;\ndouble J = 1.0;\ndouble h = 0.5;\nauto Sx = arma::mat(\"0 1; 1 0\");\n\nauto ops = OpSum();\nfor (int i = 0; i<N; ++i) {\n  ops += Op(\"ISING\", \"J\", {i, (i+1)%N});\n  ops += Op(\"SX\", arma::mat(h*Sx), i);\n}\nops[\"J\"] = 1.0;\nXDIAG_SHOW(ops);\nXDIAG_SHOW(ops.defined(\"J\"));\nXDIAG_SHOW(ops.isreal());\nXDIAG_SHOW(ops.isexplicit());\n
"},{"location":"documentation/states/state/","title":"State","text":"

A generic state describing a quantum wave function

Source state.hpp

"},{"location":"documentation/states/state/#constructors","title":"Constructors","text":"JuliaC++
State(block::Block; real::Bool = true, n_cols::Int64 = 1)\nState(block::Block, vec::Vector{Float64})\nState(block::Block, vec::Vector{ComplexF64})\nState(block::Block, mat::Matrix{Float64})\nState(block::Block, mat::Matrix{ComplexF64})\n
State(Block const &block, bool real = true, int64_t n_cols = 1);\n\ntemplate <typename block_t, typename coeff_t>\nState(block_t const &block, arma::Col<coeff_t> const &vector);\n\ntemplate <typename block_t, typename coeff_t>\nState(block_t const &block, arma::Mat<coeff_t> const &matrix);\n
Parameter Description block The block of a Hilbertspace on which the state is defined real Flag whether or not the state has real coefficients n_cols Number of columns of the state (default 1) vector A vector containing the coefficients of the state. Must be same size as block. matrix A matrix containing the coefficients of the state. Number of rows must be same as block size ."},{"location":"documentation/states/state/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the block the state is defined on.

JuliaC++
n_sites(state::State)\n
int64_t n_sites() const\n

isreal

Returns whether the state is real.

JuliaC++
isreal(state::State)\n
int64_t isreal() const;\n

real

Returns whether the real part of the State.

JuliaC++
real(state::State)\n
State real() const;\n

imag

Returns whether the imaginary part of the State.

JuliaC++
imag(state::State)\n
State imag() const;\n

make_complex! / make_complex

Turns a real State into a complex State. Does nothing if the state is already complex

JuliaC++
make_complex!(state::State)\n
void make_complex();\n

dim

Returns the dimension of the block the state is defined on.

JuliaC++
dim(block::Spinhalf)\n
int64_t dim() const;\n

size

Returns the size of the block the state is defined on. locally. Same as \"dim\" for non-distributed Blocks but different for distributed blocks.

JuliaC++
size(block::Spinhalf)\n
int64_t size() const;\n

n_rows

Returns number of rows of the local storage. Same as \"size\"

JuliaC++
n_rows(block::Spinhalf)\n
int64_t n_rows() const;\n

n_cols

Returns number of columns of the local storage.

JuliaC++
n_cols(block::Spinhalf)\n
int64_t n_cols() const;\n

col

Returns a state created from the n-th column of the storage. Whether or not the storage is copied can be specified by setting the flag \"copy\".

JuliaC++
col(state::State, n::Int64 = 1; copy::Bool = true)\n
State col(int64_t n, bool copy = true) const;\n

vector/vectorC

Returns a vector from the n-th column of the storage. In C++ use \"vector\"/\"vectorC\" to either get a real or complex vector.

JuliaC++
vector(state::State; n::Int64 = 1)\n# no vectorC method in julia\n
arma::vec vector(int64_t n = 0, bool copy = true) const;\narma::cx_vec vectorC(int64_t n = 0, bool copy = true) const;\n

matrix/matrixC

Returns matrix representing the storage. In C++ use \"matrix\"/\"matrixC\" to either get a real or complex matrix.

JuliaC++
matrix(state::State)\n# no matrixC method in julia\n
arma::vec matrix(bool copy = true) const;\narma::cx_vec matrixC(bool copy = true) const;\n
"},{"location":"documentation/states/state/#usage-example","title":"Usage Example","text":"JuliaC++
block = Spinhalf(2)\npsi1 = State(block, [1.0, 2.0, 3.0, 4.0])\n@show psi1\ndisplay(vector(psi1))\nmake_complex!(psi1)\ndisplay(vector(psi1))\n\npsi2 = State(block, real=false, n_cols=3)\n@show psi2\ndisplay(matrix(psi2))\n\npsi3 = State(block, [1.0+4.0im, 2.0+3.0im, 3.0+2.0im, 4.0+1.0im])\ndisplay(vector(psi3))\ndisplay(vector(real(psi3)))\ndisplay(vector(imag(psi3)))\n
auto block = Spinhalf(2);\nauto psi1 = State(block, arma::vec(\"1.0 2.0 3.0 4.0\"));\nXDIAG_SHOW(psi1);\nXDIAG_SHOW(psi1.vector());\npsi1.make_complex();\nXDIAG_SHOW(psi1.vectorC());\n\nauto psi2 = State(block, false, 3);\nXDIAG_SHOW(psi2);\nXDIAG_SHOW(psi2.matrixC());\n\nauto psi3 = State(block, arma::cx_vec(arma::vec(\"1.0 2.0 3.0 4.0\"),\n                      arma::vec(\"4.0 3.0 2.0 1.0\")));\nXDIAG_SHOW(psi3.vectorC());\nXDIAG_SHOW(psi3.real().vector());\nXDIAG_SHOW(psi3.imag().vector());\n
"},{"location":"documentation/symmetries/permutation/","title":"Permutation","text":"

Permutations of indices or lattice sites

Source permutation.hpp

"},{"location":"documentation/symmetries/permutation/#constructors","title":"Constructors","text":"

Creates an Permutation out of an array of integers, e.g. [0, 2, 1, 3]. If the input array is of size N then every number between 0 and N-1 must occur exactly once, otherwise the Permutation is invalid.

JuliaC++
Permutation(array::Vector{Int64})\n
Permutation(std::vector<int64_t> const &array);\n
"},{"location":"documentation/symmetries/permutation/#methods","title":"Methods","text":"

inverse

Computes the inverse permutation.

JuliaC++
inverse(perm::Permutation)\n
// As a member function\nPermutation inverse() const;\n\n// As a non-member function\nPermutation inverse(Permutation const &p);\n

\"*\" operator

Concatenates two permutations by overloading the * operator.

JuliaC++
Base.:*(p1::Permutation, p2::Permutation)\n
Permutation operator*(Permutation const &p1, Permutation const &p2);\n

size

Returns the size of the permutation, i.e. the number of indices being permuted.

JuliaC++
size(perm::Permutation)\n
// As a member function\nint64_t size() const;\n\n// As a non-member function\nint64_t size(Permutation const &p);\n
"},{"location":"documentation/symmetries/permutation/#usage-example","title":"Usage Example","text":"JuliaC++
p1 = Permutation([0, 2, 1, 3])\np2 = Permutation([2, 0, 1, 3])\n\n@show inverse(p1)\n@show p1 * p2\n
Permutation p1 = {0, 2, 1, 3};\nPermutation p2 = {2, 0, 1, 3};\n\nXDIAG_SHOW(inverse(p1));\nXDIAG_SHOW(p1*p2);\n
"},{"location":"documentation/symmetries/permutation_group/","title":"Permutation","text":"

A group of permutations

Source permutation_group.hpp

"},{"location":"documentation/symmetries/permutation_group/#constructor","title":"Constructor","text":"

Creates an PermutationGroup out of a vector of Permutation objects.

JuliaC++
PermutationGroup(permutations::Vector{Permutation})\n
PermutationGroup(std::vector<Permutation> const &permutations);\n
"},{"location":"documentation/symmetries/permutation_group/#methods","title":"Methods","text":"

n_sites

Returns the number of sites on which the permutations of the group acts.

JuliaC++
n_sites(group::PermutationGroup)\n
int64_t n_sites() const\n

size

Returns the size of the permutation group, i.e. the number permutations

JuliaC++
size(group::PermutationGroup)\n
int64_t size() const;\n

inverse

Given an index of a permutation, it returns the index of the inverse permutation.

JuliaC++
inverse(group::PermutationGroup, idx::Integer)\n
// As a member function\nint64_t inverse(int64_t sym) const;\n
"},{"location":"documentation/symmetries/permutation_group/#usage-example","title":"Usage Example","text":"JuliaC++
# Define a cyclic group of order 3\np1 = Permutation([0, 1, 2])\np2 = Permutation([1, 2, 0])\np3 = Permutation([2, 0, 1])\nC3 = PermutationGroup([p1, p2, p3])\n\n@show size(C3)\n@show n_sites(C3)\n@show inverse(C3, 1) # = 2\n
// Define a cyclic group of order 3\nPermutation p1 = {0, 1, 2};\nPermutation p2 = {1, 2, 0};\nPermutation p3 = {2, 0, 1};\nauto C3 = PermutationGroup({p1, p2, p3});\n\nXDIAG_SHOW(C3.size());\nXDIAG_SHOW(C3.n_sites());\nXDIAG_SHOW(C3.inverse(1)); // = 2\n
"},{"location":"documentation/symmetries/representation/","title":"Representation","text":"

A (1D) irreducible representation of a finite group.

Source representation.hpp

"},{"location":"documentation/symmetries/representation/#constructors","title":"Constructors","text":"

Creates a Representation from a vector of complex numbers

JuliaC++
Representation(characters::Vector{<:Number})\n
Representation(std::vector<complex> const &characters);\n
"},{"location":"documentation/symmetries/representation/#methods","title":"Methods","text":"

size

Returns the size of the Representation, i.e. the number of characters.

JuliaC++
size(irrep::Representation)\n
int64_t size() const;\n

isreal

Returns the whether or not the Representation is real, I.E. the characters are real numbers and do not have an imaginary part.

JuliaC++
isreal(irrep::Representation; precision::Real=1e-12)\n
bool isreal(double precision = 1e-12) const;\n

\"*\" operator

Multiplies two Representations by overloading the * operator.

JuliaC++
Base.:*(p1::Representation, p2::Representation)\n
Representation operator*(Representation const &p1, Representation const &p2);\n
"},{"location":"documentation/symmetries/representation/#usage-example","title":"Usage Example","text":"JuliaC++
r1 = Representation([1, -1, 1, -1])\nr2 = Representation([1, 1im, -1, -1im])\n\n@show r1 * r2\n
Representation r1 = {1, -1, 1, -1};\nRepresentation r2 = {1, 1i, -1, -1i};\n\nXDIAG_SHOW(r1 * r2);\n
"},{"location":"documentation/utilities/logging/","title":"Logging","text":""},{"location":"documentation/utilities/logging/#setting-the-verbosity","title":"Setting the verbosity","text":"

Algorithms implemented in XDiag do not output anything during their execution by default. However, it is typically useful to get some information on how the code is performing and even intermediary results at runtime. For this, the verbosity of the internal XDiag logging can be set using the function set_verbosity, which is defined as

JuliaC++
set_verbosity(level::Integer);\n
void set_verbosity(int64_t level);\n

There are several levels of verbosity, defining how much information is shown.

level outputed information 0 no information 1 some information 2 detailed information

For example, when computing a ground state energy using the eigval0 function, we can set a higher verbosity level using

JuliaC++
set_verbosity(2);\ne0 = eigval0(bonds, block);\n
set_verbosity(2);\ndouble e0 = eigval0(bonds, block);\n

This will print detailed information, which can look like this

Lanczos iteration 1\nMVM: 0.00289 secs\nalpha: -0.2756971549998545\nbeta: 1.7639347562074059\neigs: -0.2756971549998545\nLanczos iteration 2\nMVM: 0.00244 secs\nalpha: -0.7116140394927443\nbeta: 2.3044797637130743\neigs: -2.2710052270892791 1.2836940325966804\nLanczos iteration 3\nMVM: 0.00210 secs\nalpha: -1.2772539678430306\nbeta: 2.6627870395174456\neigs: -3.7522788386927637 -0.6474957945455240 2.1352094709026579\n
"},{"location":"documentation/utilities/logging/#log-mechanism-c-only","title":"Log mechanism (C++ only)","text":"

Producing nicely formatted output is unfortunately a bit cumbersome in standard C++. For this, the Log mechanism in XDiag can help. To simply write out a line of information you can call,

Log(\"hello from the logger\");\n

By default, a new line is added. It is also possible to set verbosity by handing the level as the first argument,

Log(2, \"hello from the logger only if global verbosity is set to >= 2\");\n

This message will only appear if the global verbosity level is set to a value \\(\\geq 2\\). Finally, XDiag also supports formatted output by using the fmtlib. For example, numbers can be formated this way

Log(\"pi is around {:.4f} and the answer is {}\", 3.141592, 42);\n
"},{"location":"documentation/utilities/logging/#source","title":"Source","text":"

logger.hpp

"},{"location":"documentation/utilities/timing/","title":"Timing","text":"

In standard C++ measuring time is a bit awkward. To quickly monitor the CPU time spent by XDiag by simple functions.

"},{"location":"documentation/utilities/timing/#simple-timing-using-tic-toc","title":"Simple timing using tic() / toc()","text":"

Similar as in Matlab one can use tic() and toc() to measure the time spent between two points in the code.

tic();\ndouble e0 = eigval0(bonds, block);\ntoc();\n

toc() will output the time spent since the last time tic() has been called.

"},{"location":"documentation/utilities/timing/#detailed-timing","title":"Detailed timing","text":"

To get the present time, simply call

auto time = rightnow();\n

A timing (in second) between two time points can be written to output using

timing(begin, end);\n

This can even be accompanied by a message about what is being timed and a verbosity level (see Logging) can also be set. The full call signature is

timing(begin, end, message, level);\n
Name Description Default begin starting time computed using rightnow() end end time computed using rightnow() message message string to be prepended to timing \"\" level verbosity level at which timing is printed 0"},{"location":"documentation/utilities/xdiag_show/","title":"Debug printing","text":"

For quick debugging in C++, XDiag features a simple macro which outputs the name and content of a variable calles XDIAG_SHOW(x). For example

Spinhalf block(16, 8);\nXDIAG_SHOW(block);\n

will write an output similar to

block:\n  n_sites  : 16\n  n_up     : 8\n  dimension: 12,870\n  ID       : 0xa9127434d66b9878\n

The XDIAG_SHOW(x) macro can be used on any XDiag object and several other standard C++ objects as well.

"},{"location":"examples/cmake_distributed/","title":"CMakeLists.txt for the distributed XDiag library","text":"
cmake_minimum_required(VERSION 3.19)\n\nproject(\n  tj_distributed_time_evolve\n)\n\nfind_package(xdiag_distributed REQUIRED HINTS ../../../install)\nadd_executable(main main.cpp)\ntarget_link_libraries(main PUBLIC xdiag::xdiag_distributed)\n
"},{"location":"examples/cmake_normal/","title":"CMakeLists.txt for the normal XDiag library","text":"
cmake_minimum_required(VERSION 3.19)\n\nproject(\n  hello_world\n)\n\nfind_package(xdiag REQUIRED HINTS \"../../install\")\nadd_executable(main main.cpp)\ntarget_link_libraries(main PRIVATE xdiag::xdiag)\n
"},{"location":"examples/hello_world/","title":"Hello world!","text":"JuliaC++
   using XDiag\n   say_hello()\n
   #include <xdiag/all.hpp>\n\n   using namespace xdiag;\n\n   int main() try {\n     say_hello();\n   } catch (Error e) {\n     error_trace(e);\n   }\n
"},{"location":"examples/spinhalf_chain_e0/","title":"Groundstate energy","text":"JuliaC++
using XDiag\n\nlet \n    N = 16;\n    nup = N \u00f7 2;\n    block = Spinhalf(N, nup);\n\n    # Define the nearest-neighbor Heisenberg model\n    bonds = BondList()\n    for i in 1:N\n        bonds += Bond(\"HB\", \"J\", [i-1, i % N])\n    end\n    bonds[\"J\"] = 1.0;\n\n    set_verbosity(2);             # set verbosity for monitoring progress\n    e0 = eigval0(bonds, block);   # compute ground state energy\n\n    println(\"Ground state energy: $e0\");\nend\n
#include <xdiag/all.hpp>\n\nusing namespace xdiag;\n\nint main() try {\n  int N = 16;\n  int nup = N / 2;\n  Spinhalf block(N, nup);\n\n  // Define the nearest-neighbor Heisenberg model\n  OpSum ops;\n  for (int i = 0; i < N; ++i) {\n    ops += Op(\"HB\", \"J\", {i, (i + 1) % N});\n  }\n  ops[\"J\"] = 1.0;\n\n  set_verbosity(2);                  // set verbosity for monitoring progress\n  double e0 = eigval0(ops, block); // compute ground state energy\n\n  Log(\"Ground state energy: {:.12f}\", e0);\n\n} catch (Error e) {\n  error_trace(e);\n}\n
"},{"location":"examples/tj_distributed_time_evolve/","title":"\\(t\\)-\\(J\\) distributed time evolution","text":"
#include <xdiag/all.hpp>\n\nusing namespace xdiag;\n\nvoid measure_density(int n_sites, State const &v) {\n  int rank;\n  MPI_Comm_rank(MPI_COMM_WORLD, &rank);\n  for (int i = 0; i < n_sites; ++i) {\n    complex sz = innerC(Bond(\"NUMBER\", i), v);\n    if (rank == 0) {\n      printf(\"%.6f \", std::real(sz));\n    }\n  }\n  if (rank == 0) {\n    printf(\"\\n\");\n  }\n}\n\nint main(int argc, char **argv) try {\n  MPI_Init(&argc, &argv);\n\n  int L = 6;\n  int W = 4;\n  double t = 1.0;\n  double J = 0.1;\n  double mu_0 = 10;\n\n  int n_sites = L * W;\n  double precision = 1e-12;\n\n  // Create square lattice t-J model\n  OpSum ops;\n  for (int x = 0; x < L-1; ++x) {\n    for (int y = 0; y < W; ++y) {\n      int nx = (x + 1) % L;\n      int ny = (y + 1) % W;\n\n      int site = x * W + y;\n      int right = nx * W + y;\n      int top = x * W + ny;\n      ops += Op(\"HOP\", \"T\", {site, right});\n      ops += Op(\"EXCHANGE\", \"J\", {site, right});\n      ops += Op(\"HOP\", \"T\", {site, top});\n      ops += Op(\"EXCHANGE\", \"J\", {site, top});\n\n\n\n      if (x < L / 2) {\n    Log(\"x {} y {} site {} t {} r {} +\", x, y, site, top, right);\n        ops += Op(\"NUMBER\", \"MUPLUS\", site);\n      } else {\n    Log(\"x {} y {} site {} t {} r {} -\", x, y, site, top, right);\n        ops += Op(\"NUMBER\", \"MUNEG\", site);\n      }\n    }\n  }\n  ops[\"T\"] = t;\n  ops[\"J\"] = J;\n  ops[\"MUPLUS\"] = mu_0;\n  ops[\"MUNEG\"] = mu_0;\n\n  auto block = tJDistributed(n_sites, n_sites / 2 - 1, n_sites / 2 - 1);\n\n  XDIAG_SHOW(block);\n\n  Log.set_verbosity(2);\n  tic();\n  auto [e0, v] = eig0(ops, block);\n  toc(\"gs\");\n\n  ops[\"MUPLUS\"] = 0;\n  ops[\"MUNEG\"] = 0;\n\n  measure_density(n_sites, v);\n\n  // Do the time evolution with a step size tau\n  double tau = 0.1;\n  for (int i = 0; i < 40; ++i) {\n    tic();\n    v = time_evolve(ops, v, tau, precision);\n    toc(\"time evolve\");\n    tic();\n    measure_density(n_sites, v);\n    toc(\"measure\");\n  }\n\n  MPI_Finalize();\n  return EXIT_SUCCESS;\n} catch (std::exception const &e) {\n  traceback(e);\n}\n
"}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":"

Quick Start Code on GitHub

"},{"location":"#overview","title":"Overview","text":"

XDiag is a C++ library for performing Exact Diagonalizations of quantum many-body systems. Key features include optimized combinatorical algorithms for navigating Hilbert spaces, iterative linear algebra algorithms, shared and distributed memory parallelization.

"},{"location":"#gallery","title":"Gallery","text":""},{"location":"examples/","title":"Examples","text":""},{"location":"examples/#basic-examples","title":"Basic examples","text":""},{"location":"examples/#distributed-examples","title":"Distributed examples","text":""},{"location":"examples/#cmakeliststxt-for-applications","title":"CMakeLists.txt for applications","text":""},{"location":"installation/","title":"Installation","text":""},{"location":"installation/#julia-installation","title":"Julia Installation","text":"

Enter the package mode using ] in the Julia REPL and add the following two packages

add https://github.com/awietek/XDiag_jll.jl.git\nadd https://github.com/awietek/XDiag.jl.git\n

"},{"location":"installation/#c-compilation","title":"C++ Compilation","text":"

Using XDiag with C++ is a two-step process. First the xdiag library needs to be compiled and installed. Therafter, application codes are compiled in a second step. Here we explain how to compile the library.

"},{"location":"installation/#prerequisites","title":"Prerequisites","text":""},{"location":"installation/#basic-compilation","title":"Basic Compilation","text":""},{"location":"installation/#advanced-compilation","title":"Advanced Compilation","text":""},{"location":"installation/#building-documentation","title":"Building Documentation","text":"

The source files for the documentation can be found in the directory docs. The documentation is built using Material for MKDocs. To work on it locally, it can be served using

mkdocs serve\n

from the xdiag root source directory. A local build of the documentation can then be accessed in a webbrowser at the adress

127.0.0.1:8000\n
"},{"location":"quickstart/","title":"Quick start","text":""},{"location":"quickstart/#hello-world","title":"Hello World","text":"

Let us set up our first program using the xdiag library.

JuliaC++
using XDiag\nsay_hello()\n
#include <xdiag/all.hpp>\n\nusing namespace xdiag;\n\nint main() try {\n  say_hello();\n} catch (Error e) {\n  error_trace(e);\n}\n

The function say_hello() prints out a welcome message, which also contains information which exact XDiag version is used. In Julia this is all there is to it.

For the C++ code we need to create two files to compile the program. The first is the actual C++ code. What is maybe a bit unfamiliar is the try / catch block. XDiag implements a traceback mechanism for runtime errors, which is activated by this idiom. While not stricly necessary here, it is a good practice to make use of this.

Now that the application program is written, we next need to set up the compilation instructions using CMake. To do so we create a second file called CMakeLists.txt in the same directory.

cmake_minimum_required(VERSION 3.19)\n\nproject(\n  hello_world\n)\n\nfind_package(xdiag REQUIRED HINTS \"../../install\")\nadd_executable(main main.cpp)\ntarget_link_libraries(main PRIVATE xdiag::xdiag)\n

You should replace \"/path/to/xdiag/install\" with the appropriate directory where your XDiag library is installed after compilation. This exact CMakeLists.txt file can be used to compile any XDiag application.

Info

For using the distributed XDiag library the last line of the above CMakeLists.txt should be changed to

target_link_libraries(main PUBLIC xdiag::xdiag_distributed)\n

We then compile the application code,

cmake -S . -B build\ncmake --build build\n

and finally run our first xdiag application.

./build/main\n
"},{"location":"quickstart/#computing-the-ground-state-energy-of-a-spin-chain","title":"Computing the ground state energy of a spin chain","text":"

We compute the ground state energy of the \\(S=1/2\\) Heisenberg chain on a periodic chain lattice in one dimension. The Hamiltonian is given by

\\[ H = J\\sum_{\\langle i,j \\rangle} \\mathbf{S}_i \\cdot \\mathbf{S}_j\\]

where \\(\\mathbf{S}_i = (S_i^x, S_i^y, S_i^z)\\) are the spin \\(S=1/2\\) operators and \\(\\langle i,j \\rangle\\) denotes summation over nearest-meighbor sites \\(i\\) and \\(j\\).

The following code, sets up the Hilbert space, defines the Hamiltonian and finally calls an iterative eigenvalue solver to compute the ground state energy.

JuliaC++
using XDiag\n\nlet \n    N = 16;\n    nup = N \u00f7 2;\n    block = Spinhalf(N, nup);\n\n    # Define the nearest-neighbor Heisenberg model\n    bonds = BondList()\n    for i in 1:N\n        bonds += Bond(\"HB\", \"J\", [i-1, i % N])\n    end\n    bonds[\"J\"] = 1.0;\n\n    set_verbosity(2);             # set verbosity for monitoring progress\n    e0 = eigval0(bonds, block);   # compute ground state energy\n\n    println(\"Ground state energy: $e0\");\nend\n
#include <xdiag/all.hpp>\n\nusing namespace xdiag;\n\nint main() try {\n  int N = 16;\n  int nup = N / 2;\n  Spinhalf block(N, nup);\n\n  // Define the nearest-neighbor Heisenberg model\n  OpSum ops;\n  for (int i = 0; i < N; ++i) {\n    ops += Op(\"HB\", \"J\", {i, (i + 1) % N});\n  }\n  ops[\"J\"] = 1.0;\n\n  set_verbosity(2);                  // set verbosity for monitoring progress\n  double e0 = eigval0(ops, block); // compute ground state energy\n\n  Log(\"Ground state energy: {:.12f}\", e0);\n\n} catch (Error e) {\n  error_trace(e);\n}\n
"},{"location":"documentation/","title":"Documentation","text":""},{"location":"documentation/#algorithms","title":"Algorithms","text":"Name Description Language eigval0 Computes the lowest lying eigenvalue of an operator eig0 Computes the lowest lying eigenvalue and eigenvector of an operator"},{"location":"documentation/#algebra","title":"Algebra","text":"matrix Creates the full matrix representation of an operator on a block"},{"location":"documentation/#blocks","title":"Blocks","text":"Spinhalf Block of a spin \\(S=1/2\\) type Hilbert space tJ Block of a \\(t-J\\) type Hilbert space Electron Block of a Electron type Hilbert space"},{"location":"documentation/#operators","title":"Operators","text":"Op A local operator acting on several lattice sites OpSum Sum of local operators Coupling Describes the coupling of a local operator"},{"location":"documentation/#states","title":"States","text":"State A generic state describing a quantum wave function ProductState A product state of local configurations"},{"location":"documentation/#symmetries","title":"Symmetries","text":"Permutation Permutations of indices or lattice sites PermutationGroup A group of permutations Representation A (1D) irreducible representation of a finite group"},{"location":"documentation/#utilities","title":"Utilities","text":"Logging Controling what is written to standard output Timing Measurng wall time straightforwardly XDIAG_SHOW Macro for printing debugging information"},{"location":"documentation/algebra/matrix/","title":"matrix","text":"
matrix(bondlist, block; force_complex=false)\nmatrixC(bondlist, block)  # c++ only\n

Creates the full matrix representation of a given BondList on a block.

In Julia, depending on whether a real/complex matrix is generated also a real/complex matrix is returned. The C++ version has to return a fixed type. If a real matrix is desired, use the function matrix. If a complex matrix is desired, use the function matrixC.

Source matrix.hpp

"},{"location":"documentation/algebra/matrix/#parameters","title":"Parameters","text":"Name Description bondlist BondList defining the bonds of the operator block block on which the operator is defined force_complex flag to determine if returned matrix is forced to be complex (Julia only)"},{"location":"documentation/algebra/matrix/#returns","title":"Returns","text":"Type Description matrix matrix representation of bondlist on block"},{"location":"documentation/algebra/matrix/#definition","title":"Definition","text":"JuliaC++
matrix(bonds::BondList, block::Block; force_complex::Bool=false)\n
template <typename block_t>\narma::mat matrix(BondList const &bond, block_t const &block);\n\ntemplate <typename block_t>\narma::cx_mat matrixC(BondList const &bond, block_t const &block);\n
"},{"location":"documentation/algebra/matrix/#usage-example","title":"Usage Example","text":"JuliaC++
let\n    # Creates matrix H_{k=2} in Eq (18.23) of https://link.springer.com/content/pdf/10.1007/978-3-540-74686-7_18.pdf\n    N = 4\n    nup = 3\n    ndn = 2\n\n    # Define a Hubbard chain model\n    ops = OpSum()\n    for i in 1:N\n        ops += Op(\"HOP\", \"T\", [i-1, i % N])\n    end\n    ops[\"T\"] = 1.0;\n    ops[\"U\"] = 5.0;\n\n    # Create the a permutation group\n    p1 = Permutation([0, 1, 2, 3])\n    p2 = Permutation([1, 2, 3, 0])\n    p3 = Permutation([2, 3, 0, 1])\n    p4 = Permutation([3, 0, 1, 2])\n    group = PermutationGroup([p1, p2, p3, p4])\n    irrep = Representation([1, -1, 1, -1])\n    block = Electron(N, nup, ndn, group, irrep)\n\n    H = matrix(ops, block)\n    display(H)\nend\n
// Creates matrix H_{k=2} in Eq (18.23) of https://link.springer.com/content/pdf/10.1007/978-3-540-74686-7_18.pdf\nint N = 4;\nint nup = 3;\nint ndn = 2;\n\n// Define a Hubbard chain model\nauto ops = OpSum();\nfor (int i=0; i< N; ++i){\n  ops += Op(\"HOP\", \"T\", {i, (i+1) % N});\n}\nops[\"T\"] = 1.0;\nops[\"U\"] = 5.0;\n\n// Create the a permutation group\nauto p1 = Permutation({0, 1, 2, 3});\nauto p2 = Permutation({1, 2, 3, 0});\nauto p3 = Permutation({2, 3, 0, 1});\nauto p4 = Permutation({3, 0, 1, 2});\nauto group = PermutationGroup({p1, p2, p3, p4});\nauto irrep = Representation({1, -1, 1, -1});\nauto block = Electron(N, nup, ndn, group, irrep);\n\nauto H = matrix(ops, block);\nH.print();\n
"},{"location":"documentation/algorithms/eig0/","title":"eig0","text":"
eig0(bondlist, block; precision, max_iterations, force_complex, random_seed)\n

Computes the groud state energy and the ground state of an operator on a block.

Source sparse_diag.hpp

"},{"location":"documentation/algorithms/eig0/#parameters","title":"Parameters","text":"Name Description Default bondlist BondList defining the bonds of the operator block block on which the operator is defined precision accuracy of the computed ground state 1e-12 max_iterations maximum number of iterations 1000 force_complex whether or not computation should be forced to have complex arithmetic false random_seed random seed for setting up the initial vector 42"},{"location":"documentation/algorithms/eig0/#returns","title":"Returns","text":"Type Description real number lowest lying eigenvalue State groundstate"},{"location":"documentation/algorithms/eig0/#definition","title":"Definition","text":"JuliaC++
eig0(bonds::BondList, block::Spinhalf;\n     precision::Real=1e-12, maxiter::Integer=1000,\n     force_complex::Bool=false, seed::Integer=42)\n
std::tuple<double, State>\neig0(BondList const &bondlist, block_variant_t const &block,\n     double precision = 1e-12, int64_t max_iterations = 1000,\n     bool force_complex = false, int64_t random_seed = 42);\n
"},{"location":"documentation/algorithms/eig0/#usage-example","title":"Usage Example","text":"JuliaC++
let \n    N = 8;\n    nup = N \u00f7 2;\n    block = Spinhalf(N, nup);\n\n    # Define the nearest-neighbor Heisenberg model\n    ops = OpSum()\n    for i in 1:N\n        ops += Op(\"HB\", \"J\", [i-1, i % N])\n    end\n    ops[\"J\"] = 1.0;\n\n    e0, gs = eig0(ops, block);\nend\n
int N = 8;\nint nup = N / 2;\nauto block = Spinhalf(N, nup);\n\n// Define the nearest-neighbor Heisenberg model\nauto ops = OpSum();\nfor (int i=0; i<N; ++i) {\n  ops += Op(\"HB\", \"J\", {i, (i+1) % N});\n}\nops[\"J\"] = 1.0;\nauto [e0, gs] = eig0(ops, block);\n
"},{"location":"documentation/algorithms/eigval0/","title":"eigval0","text":"
eigval0(bondlist, block; precision, max_iterations, force_complex, random_seed)\n

Computes the groud state energy of an operator on a block.

Source sparse_diag.hpp

"},{"location":"documentation/algorithms/eigval0/#parameters","title":"Parameters","text":"Name Description Default bondlist BondList defining the bonds of the operator block block on which the operator is defined precision accuracy of the computed ground state 1e-12 max_iterations maximum number of iterations 1000 force_complex whether or not computation should be forced to have complex arithmetic false random_seed random seed for setting up the initial vector 42"},{"location":"documentation/algorithms/eigval0/#returns","title":"Returns","text":"Type Description real number lowest lying eigenvalue"},{"location":"documentation/algorithms/eigval0/#definition","title":"Definition","text":"JuliaC++
eig0(bonds::BondList, block::Union{Spinhalf,Electron,tJ};\n     precision::Real=1e-12, maxiter::Integer=1000,\n     force_complex::Bool=false, seed::Integer=42)\n
double eigval0(BondList const &bondlist, block_variant_t const &block,\n               double precision = 1e-12, int64_t max_iterations = 1000,\n               bool force_complex = false, int64_t random_seed = 42);\n
"},{"location":"documentation/algorithms/eigval0/#usage-example","title":"Usage Example","text":"JuliaC++
let \n    N = 8;\n    nup = N \u00f7 2;\n    block = Spinhalf(N, nup);\n\n    # Define the nearest-neighbor Heisenberg model\n    ops = OpSum()\n    for i in 1:N\n        ops += Op(\"HB\", \"J\", [i-1, i % N])\n    end\n    ops[\"J\"] = 1.0;\n\n    e0 = eigval0(ops, block);\nend\n
int N = 8;\nint nup = N / 2;\nauto block = Spinhalf(N, nup);\n\n// Define the nearest-neighbor Heisenberg model\nauto ops = OpSum();\nfor (int i=0; i<N; ++i) {\n  ops += Op(\"HB\", \"J\", {i, (i+1) % N});\n}\nops[\"J\"] = 1.0;\ndouble e0 = eigval0(ops, block);\n
"},{"location":"documentation/blocks/electron/","title":"Electron","text":"

Representation of a block in a Electron (spinful fermion) Hilbert space.

Source electron.hpp

"},{"location":"documentation/blocks/electron/#constructors","title":"Constructors","text":"JuliaC++
Electron(n_sites::Integer)\nElectron(n_sites::Integer, n_up::Integer, n_dn::Integer)\nElectron(n_sites::Integer, group::PermutationGroup, irrep::Representation)\nElectron(n_sites::Integer, n_up::Integer, n_dn::Integer, \n         group::PermutationGroup, irrep::Representation)\n
Electron(int64_t n_sites);\nElectron(int64_t n_sites, int64_t n_up, int64_t n_dn);\nElectron(int64_t n_sites, PermutationGroup permutation_group,\n         Representation irrep);\nElectron(int64_t n_sites, int64_t n_up, int64_t n_dn, \n         PermutationGroup group, Representation irrep);\n
Name Description n_sites number of sites (integer) n_up number of \"up\" electrons (integer) n_dn number of \"dn\" electrons (integer) group PermutationGroup defining the permutation symmetries irrep Irreducible Representation of the symmetry group"},{"location":"documentation/blocks/electron/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the block.

JuliaC++
n_sites(block::Electron)\n
int64_t n_sites() const\n

size

Returns the size of the block, i.e. its dimension.

JuliaC++
size(block::Electron)\n
int64_t size() const;\n

isreal

Returns whether the block can be used with real arithmetic. Complex arithmetic is needed when a Representation is genuinely complex.

JuliaC++
isreal(block::Electron; precision::Real=1e-12)\n
int64_t isreal(double precision = 1e-12) const;\n
"},{"location":"documentation/blocks/electron/#usage-example","title":"Usage Example","text":"JuliaC++
N = 4\nnup = 2\nndn = 1\n\n# without number conservation\nblock = Electron(N)\n@show block\n\n# with number conservation\nblock_np = Electron(N, nup, ndn)\n@show block_np\n\n# with symmetries, without number conservation\np1 = Permutation([0, 1, 2, 3])\np2 = Permutation([1, 2, 3, 0])\np3 = Permutation([2, 3, 0, 1])\np4 = Permutation([3, 0, 1, 2])\ngroup = PermutationGroup([p1, p2, p3, p4])\nirrep = Representation([1, -1, 1, -1])\nblock_sym = Electron(N, group, irrep)\n@show block_sym\n\n# with symmetries and number conservation\nblock_sym_np = Electron(N, nup, ndn, group, irrep)\n@show block_sym_np\n\n@show n_sites(block_sym_np)\n@show size(block_sym_np)\n
int N = 4;\nint nup = 2;\nint ndn = 1;\n\n// without number conservation\nauto block = Electron(N);\nXDIAG_SHOW(block);\n\n// with number conservation\nauto block_np = Electron(N, nup, ndn);\nXDIAG_SHOW(block_np);\n\n// with symmetries, without number conservation\nauto p1 = Permutation({0, 1, 2, 3});\nauto p2 = Permutation({1, 2, 3, 0});\nauto p3 = Permutation({2, 3, 0, 1});\nauto p4 = Permutation({3, 0, 1, 2});\nauto group = PermutationGroup({p1, p2, p3, p4});\nauto irrep = Representation({1, -1, 1, -1});\nauto block_sym = Electron(N, group, irrep);\nXDIAG_SHOW(block_sym);\n\n// with symmetries and number conservation\nauto block_sym_np = Electron(N, nup, ndn, group, irrep);\nXDIAG_SHOW(block_sym_np);\n\nXDIAG_SHOW(block_sym_np.n_sites());\nXDIAG_SHOW(block_sym_np.size());\n
"},{"location":"documentation/blocks/spinhalf/","title":"Spinhalf","text":"

Representation of a block in a spin \\(S=1/2\\) Hilbert space.

Source spinhalf.hpp

"},{"location":"documentation/blocks/spinhalf/#constructors","title":"Constructors","text":"JuliaC++
Spinhalf(n_sites::Integer)\nSpinhalf(n_sites::Integer, n_up::Integer)\nSpinhalf(n_sites::Integer, group::PermutationGroup, irrep::Representation)\nSpinhalf(n_sites::Integer, n_up::Integer, group::PermutationGroup, \n         irrep::Representation)\n
Spinhalf(int64_t n_sites);\nSpinhalf(int64_t n_sites, int64_t n_up);\nSpinhalf(int64_t n_sites, PermutationGroup permutation_group,\n         Representation irrep);\nSpinhalf(int64_t n_sites, int64_t n_up, PermutationGroup group,\n         Representation irrep);\n
Name Description n_sites number of sites (integer) n_up number of \"up\" spin setting spin (integer) group PermutationGroup defining the permutation symmetries irrep Irreducible Representation of the symmetry group"},{"location":"documentation/blocks/spinhalf/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the block.

JuliaC++
n_sites(block::Spinhalf)\n
int64_t n_sites() const\n

dim

Returns the dimension of the block.

JuliaC++
dim(block::Spinhalf)\n
int64_t dim() const;\n

size

Returns the size of the block locally. Same as \"dim\" for non-distributed Blocks but different for distributed blocks.

JuliaC++
size(block::Spinhalf)\n
int64_t size() const;\n

isreal

Returns whether the block can be used with real arithmetic. Complex arithmetic is needed when a Representation is genuinely complex.

JuliaC++
isreal(block::Spinhalf; precision::Real=1e-12)\n
int64_t isreal(double precision = 1e-12) const;\n
"},{"location":"documentation/blocks/spinhalf/#usage-example","title":"Usage Example","text":"JuliaC++
N = 4\nnup = 2\n\n# without Sz conservation\nblock = Spinhalf(N)\n@show block\n\n\n# with Sz conservation\nblock_sz = Spinhalf(N, nup)\n@show block_sz\n\n# with symmetries, without Sz\np1 = Permutation([0, 1, 2, 3])\np2 = Permutation([1, 2, 3, 0])\np3 = Permutation([2, 3, 0, 1])\np4 = Permutation([3, 0, 1, 2])\ngroup = PermutationGroup([p1, p2, p3, p4])\nirrep = Representation([1, -1, 1, -1])\nblock_sym = Spinhalf(N, group, irrep)\n@show block_sym\n\n# with symmetries and Sz\nblock_sym_sz = Spinhalf(N, nup, group, irrep)\n@show block_sym_sz\n\n@show n_sites(block_sym_sz)\n@show size(block_sym_sz)\n
int N = 4;\nint nup = 2;\n\n// without Sz conservation\nauto block = Spinhalf(N);\nXDIAG_SHOW(block);\n\n// with Sz conservation\nauto block_sz = Spinhalf(N, nup);\nXDIAG_SHOW(block_sz);\n\n// with symmetries, without Sz\nPermutation p1 = {0, 1, 2, 3};\nPermutation p2 = {1, 2, 3, 0};\nPermutation p3 = {2, 3, 0, 1};\nPermutation p4 = {3, 0, 1, 2};\nauto group = PermutationGroup({p1, p2, p3, p4});\nauto irrep = Representation({1, -1, 1, -1});\nauto block_sym = Spinhalf(N, group, irrep);\nXDIAG_SHOW(block_sym);\n\n// with symmetries and Sz\nauto block_sym_sz = Spinhalf(N, nup, group, irrep);\nXDIAG_SHOW(block_sym_sz);\n\nXDIAG_SHOW(block_sym_sz.n_sites());\nXDIAG_SHOW(block_sym_sz.size());\n
"},{"location":"documentation/blocks/tJ/","title":"tJ","text":"

Representation of a block in a \\(t-J\\) type Hilbert space.

Source tj.hpp

"},{"location":"documentation/blocks/tJ/#constructors","title":"Constructors","text":"JuliaC++
tJ(n_sites::Integer, n_up::Integer, n_dn::Integer)\ntJ(n_sites::Integer, n_up::Integer, n_dn::Integer, \n   group::PermutationGroup, irrep::Representation)\n
tJ(int64_t n_sites, int64_t n_up, int64_t n_dn);\ntJ(int64_t n_sites, int64_t n_up, int64_t n_dn, \n   PermutationGroup group, Representation irrep);\n
Name Description n_sites number of sites (integer) n_up number of \"up\" electrons (integer) n_dn number of \"dn\" electrons (integer) group PermutationGroup defining the permutation symmetries irrep Irreducible Representation of the symmetry group"},{"location":"documentation/blocks/tJ/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the block.

JuliaC++
n_sites(block::tJ)\n
int64_t n_sites() const\n

size

Returns the size of the block, i.e. its dimension.

JuliaC++
size(block::tJ)\n
int64_t size() const;\n

isreal

Returns whether the block can be used with real arithmetic. Complex arithmetic is needed when a Representation is genuinely complex.

JuliaC++
isreal(block::tJ; precision::Real=1e-12)\n
int64_t isreal(double precision = 1e-12) const;\n
"},{"location":"documentation/blocks/tJ/#usage-example","title":"Usage Example","text":"JuliaC++
N = 4\nnup = 2\nndn = 1\n\n# without permutation symmetries\nblock = tJ(N, nup, ndn)\n@show block\n\n# with permutation symmetries\np1 = Permutation([0, 1, 2, 3])\np2 = Permutation([1, 2, 3, 0])\np3 = Permutation([2, 3, 0, 1])\np4 = Permutation([3, 0, 1, 2])\ngroup = PermutationGroup([p1, p2, p3, p4])\nirrep = Representation([1, -1, 1, -1])\nblock_sym = tJ(N, nup, ndn, group, irrep)\n@show block_sym\n\n@show n_sites(block_sym)\n@show size(block_sym)\n
int N = 4;\nint nup = 2;\nint ndn = 1;\n\n// without permutation symmetries\nauto block = tJ(N, nup, ndn);\nXDIAG_SHOW(block);\n\n// with permutation symmetries\nauto p1 = Permutation({0, 1, 2, 3});\nauto p2 = Permutation({1, 2, 3, 0});\nauto p3 = Permutation({2, 3, 0, 1});\nauto p4 = Permutation({3, 0, 1, 2});\nauto group = PermutationGroup({p1, p2, p3, p4});\nauto irrep = Representation({1, -1, 1, -1});\nauto block_sym = tJ(N, nup, ndn, group, irrep);\nXDIAG_SHOW(block_sym);\n\nXDIAG_SHOW(block_sym.n_sites());\nXDIAG_SHOW(block_sym.size());\n
"},{"location":"documentation/operators/coupling/","title":"Coupling","text":"

Describes the coupling of a local operator. A coupling can either be a string, a real/complex number or even a real/complex matrix. It allows for converting to real/complex numbers or matrices as well as strings, whenever this conversion is sensible.

Source coupling.hpp

"},{"location":"documentation/operators/coupling/#constructors","title":"Constructors","text":"JuliaC++
Coupling(name::String)\nCoupling(val::Float64)\nCoupling(val::ComplexF64)\nCoupling(mat::Matrix{Float64})\nCoupling(mat::Matrix{ComplexF64})\n
Coupling(std::string value);\nCoupling(double value);\nCoupling(complex value);\nCoupling(arma::mat const &value);\nCoupling(arma::cx_mat const &value);\n
"},{"location":"documentation/operators/coupling/#methods","title":"Methods","text":"

type

Returns the type of the Coupling, i.e. a string which either reads \"string\", \"double\", \"complex\", \"mat\", or \"cx_mat\"

JuliaC++
type(cpl::Coupling)\n
std::string type() const;\n

isreal

Returns whether or not the coupling is real. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

JuliaC++
isreal(cpl::Coupling)\n
bool isreal() const;\n

ismatrix

Returns whether or not the coupling is defined as a matrix. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

JuliaC++
ismatrix(cpl::Coupling)\n
bool ismatrix() const;\n

isexplicit

Returns false if the coupling is defined as a string, otherwise true

JuliaC++
isexplicit(cpl::Coupling)\n
bool isexplicit() const;\n
"},{"location":"documentation/operators/coupling/#conversions","title":"Conversions","text":"

A Coupling can be converted to the values it represents, so a string, real/complex number or a real/complex matrix. Initially real values can be cast to complex.

JuliaC++
convert(::Type{String}, cpl::Coupling)\nconvert(::Type{Float64}, cpl::Coupling)\nconvert(::Type{ComplexF64}, cpl::Coupling)\nconvert(::Type{Matrix{Float64}}, cpl::Coupling)\nconvert(::Type{Matrix{ComplexF64}}, cpl::Coupling)\n
template <typename coeff_t> coeff_t as() const;\n
"},{"location":"documentation/operators/coupling/#usage-example","title":"Usage Example","text":"JuliaC++
cpl = Coupling(\"J\")\n@show type(cpl)\n@show isexplicit(cpl)\n\ncpl = Coupling(1.23)\n@show ismatrix(cpl)\n@show convert(Float64, cpl)\n@show convert(ComplexF64, cpl)\n\ncpl = Coupling([1 2; -2 1])\n@show ismatrix(cpl)\n@show isreal(cpl)\n@show convert(Matrix{Float64}, cpl)\n@show convert(Matrix{ComplexF64}, cpl)\n
auto cpl = Coupling(\"J\");\nXDIAG_SHOW(cpl.type());\nXDIAG_SHOW(cpl.isexplicit());\n\ncpl = Coupling(1.23);\nXDIAG_SHOW(cpl.ismatrix());\nXDIAG_SHOW(cpl.as<double>());\nXDIAG_SHOW(cpl.as<complex>());\n\ncpl = Coupling(arma::mat(\"1 2; -2 1\"));\nXDIAG_SHOW(cpl.ismatrix());\nXDIAG_SHOW(cpl.isreal());\nXDIAG_SHOW(cpl.as<arma::mat>());\nXDIAG_SHOW(cpl.as<arma::cx_mat>());\n
"},{"location":"documentation/operators/op/","title":"Op","text":"

A local operator acting on several lattice sites.

Source op.hpp

"},{"location":"documentation/operators/op/#constructors","title":"Constructors","text":"JuliaC++
Op(type::String, coupling::String, sites::Vector{Int64})\nOp(type::String, coupling::String, site::Int64)\n\nOp(type::String, coupling::Float64, sites::Vector{Int64})\nOp(type::String, coupling::Float64, site::Int64)\n\nOp(type::String, coupling::ComplexF64, sites::Vector{Int64})\nOp(type::String, coupling::ComplexF64, site::Int64)\n\nOp(type::String, coupling::Matrix{Float64}, sites::Vector{Int64})\nOp(type::String, coupling::Matrix{Float64}, site::Int64)\n\nOp(type::String, coupling::Matrix{ComplexF64}, sites::Vector{Int64})\nOp(type::String, coupling::Matrix{ComplexF64}, site::Int64)\n
Op(std::string type, std::string coupling, std::vector<int64_t> const &sites)\nOp(std::string type, std::string coupling, int64_t site)\n\nOp(std::string type, double coupling, std::vector<int64_t> const &sites)\nOp(std::string type, double coupling, int64_t site)\n\nOp(std::string type, complex coupling, std::vector<int64_t> const &sites)\nOp(std::string type, complex coupling, int64_t site)\n\nOp(std::string type, arma::mat const &coupling, std::vector<int64_t> const &sites)\nOp(std::string type, arma::mat const &coupling, int64_t site)\n\nOp(std::string type, arma::cx_mat const &coupling, std::vector<int64_t> const &sites)\nOp(std::string type, arma::cx_mat const &coupling, int64_t site)\n
Parameter Description type a string which denotes what kind of operator is represented coupling sets the coefficients neded to specify the coupling. Further details below sites defines on which site(s) of the lattice the operator acts on.

The coupling can take on several types and allow some flexibility in defining operators.

type Description string the coupling is represented as a string, e.g. \"\\(t\\)\" or \"\\(J\\)\" in a \\(t-J\\) model real/cplx number the actual numerical value of the coupling real/cplx matrix more generic interactions can be specified as matrices"},{"location":"documentation/operators/op/#methods","title":"Methods","text":"

type

Returns the type of the operator

JuliaC++
type(op::Op)\n
std::string type() const;\n

coupling

Returns the coupling of the operator

JuliaC++
coupling(op::Op)\n
Coupling const &coupling() const;\n

This returns an object of type Coupling, which can then be converted to an appropriate type.

size

Returns how many sites the operator is defined on

JuliaC++
size(op::Op)\n
int64_t size() const;\n

getindex / operator[]

Returns the site with the given index.

JuliaC++
getindex(op::Op, idx::Int64)\n
int64_t operator[](int64_t idx) const;\n

sites

Returns all the sites the operator is defined on

JuliaC++
sites(op::Op)\n
std::vector<int64_t> const &sites() const;\n

isreal

Returns whether or not the coupling is real. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

JuliaC++
isreal(op::Op)\n
bool isreal() const;\n

ismatrix

Returns whether or not the coupling is defined as a matrix. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

JuliaC++
ismatrix(op::Op)\n
bool ismatrix() const;\n

isexplicit

Returns false if the coupling is defined as a string, otherwise true

JuliaC++
isexplicit(op::Op)\n
bool isexplicit() const;\n
"},{"location":"documentation/operators/op/#usage-example","title":"Usage Example","text":"JuliaC++
op = Op(\"HOP\", \"T\", [1, 2])\n@show op\n@show type(op)\n@show convert(String, coupling(op))\n@show size(op), op[1], op[2]\n@show sites(op) == [1, 2]\n@show isexplicit(op)\n\nop = Op(\"HOP\", 1.23, [1, 2])\n@show op\n@show isreal(op)\n@show ismatrix(op)\n@show isexplicit(op)\n\nop = Op(\"SY\", [0 -im; im 0], 1)\n@show op\n@show isreal(op)\n@show ismatrix(op)\n@show isexplicit(op)\n
auto op = Op(\"HOP\", \"T\", {1, 2});\nXDIAG_SHOW(op);\nXDIAG_SHOW(op.type());\nXDIAG_SHOW(op.coupling().as<std::string>());\nXDIAG_SHOW(op.size());\nXDIAG_SHOW(op[0]);\nXDIAG_SHOW(op[1]);\nXDIAG_SHOW(op.isexplicit());\n\n op = Op(\"HOP\", 1.23, {1, 2});\nXDIAG_SHOW(op);\nXDIAG_SHOW(op.isreal());\nXDIAG_SHOW(op.ismatrix());\nXDIAG_SHOW(op.isexplicit());\n\narma::cx_mat m(arma::mat(\"0 0; 0 0\"), arma::mat(\"0 -1; 1 0\"));\nop = Op(\"SY\", m, 1);\nXDIAG_SHOW(op);\nXDIAG_SHOW(op.isreal());\nXDIAG_SHOW(op.ismatrix());\nXDIAG_SHOW(op.isexplicit());\n
"},{"location":"documentation/operators/opsum/","title":"OpSum","text":"

A sum of local operators acting on several lattice sites.

Source opsum.hpp

"},{"location":"documentation/operators/opsum/#constructor","title":"Constructor","text":"JuliaC++
OpSum()\nOpSum(ops::Vector{Op})\n
OpSum() = default;\nOpSum(std::vector<Op> const &ops);\n
Parameter Description ops a vector of Op objects describing the operators summed over"},{"location":"documentation/operators/opsum/#methods","title":"Methods","text":"

size

Returns the number of local Op operators.

JuliaC++
size(ops::OpSum)\n
int64_t size() const;\n

defined

Returns bool whether a coupling (of type string) is defined

JuliaC++
defined(ops::OpSum, name::String)\n
bool defined(std::string name) const;\n

setindex! / operator[]

Sets a coupling given as a string to a certain numerical value or matrix

JuliaC++
Base.setindex!(ops::OpSum, cpl, name::String)\n
Coupling &operator[](std::string name);\n

getindex / operator[]

Returns the value of a Coupling defined as a string.

JuliaC++
getindex(ops::OpSum, name::String)\n
Coupling const &operator[](std::string name) const;\n

couplings

Returns all the possible names of Coupling as a vector of strings

JuliaC++
couplings(ops::OpSum)\n
std::vector<std::string> couplings() const;\n

isreal

Returns whether or not the OpSum is real. This will throw an error if some Coupling are only defined as a string.

JuliaC++
isreal(ops::OpSum)\n
bool isreal() const;\n

isexplicit

Returns false if there exist a Coupling which is defined as a string, otherwise true.

JuliaC++
isexplicit(ops::OpSum)\n
bool isexplicit() const;\n

operator +

Adds a single Op or a full OpSum

JuliaC++
+(ops::OpSum, op2::Op) = OpSum(ops.cxx_opsum + op2.cxx_op)\n+(ops::OpSum, ops2::OpSum) = OpSum(ops.cxx_opsum + ops2.cxx_opsum)\n
void operator+=(Op const &op);\nvoid operator+=(OpSum const &ops);\nOpSum operator+(Op const &op) const;\nOpSum operator+(OpSum const &ops) const;\n
"},{"location":"documentation/operators/opsum/#usage-example","title":"Usage Example","text":"JuliaC++
# Define the 1D transverse-field Ising chain\nlet \n    N = 12\n    J = 1.0\n    h = 0.5\n    Sx = [0 1; 1 0]\n\n    ops = OpSum()\n    for i in 1:N\n        ops += Op(\"ISING\", \"J\", [i-1, i % N])\n        ops += Op(\"SX\", h * Sx, i-1)\n    end\n\n    ops[\"J\"] = 1.0;\n    @show ops\n    @show defined(ops, \"J\")\n    @show isreal(ops)\n    @show isexplicit(ops)\nend\n
// Define the 1D transverse-field Ising chain\nint N = 12;\ndouble J = 1.0;\ndouble h = 0.5;\nauto Sx = arma::mat(\"0 1; 1 0\");\n\nauto ops = OpSum();\nfor (int i = 0; i<N; ++i) {\n  ops += Op(\"ISING\", \"J\", {i, (i+1)%N});\n  ops += Op(\"SX\", arma::mat(h*Sx), i);\n}\nops[\"J\"] = 1.0;\nXDIAG_SHOW(ops);\nXDIAG_SHOW(ops.defined(\"J\"));\nXDIAG_SHOW(ops.isreal());\nXDIAG_SHOW(ops.isexplicit());\n
"},{"location":"documentation/states/product_state/","title":"ProductState","text":"

A product state of local configurations

Source product_state.hpp

"},{"location":"documentation/states/product_state/#constructors","title":"Constructors","text":"JuliaC++
ProductState(n_sites::Int64)\nProductState(local_states::Vector{String})\n
ProductState(int64_t n_sites);\nProductState(std::vector<std::string> const &local_states);\n
Parameter Description n_sites construct a product state on n_sites local_states the local configurations of the product state"},{"location":"documentation/states/product_state/#iteration","title":"Iteration","text":"

A Product state can be iterated over, where at each iteration the string of the local configuration is retured. Here is an example:

JuliaC++
pstate = ProductState([\"Up\", \"Dn\", \"Emp\", \"UpDn\"])\nfor s in pstate\n    @show s\nend\n
auto pstate = ProductState({\"Up\", \"Dn\", \"Emp\", \"UpDn\"});\nfor (auto s : pstate) {\n    Log(\"{}\", s);\n}\n
"},{"location":"documentation/states/product_state/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the product state

JuliaC++
n_sites(state::ProductState)\n
int64_t n_sites() const\n

size

Returns the number of sites of the product state. Same as \"n_sites\".

JuliaC++
size(state::ProductState)\n
int64_t size() const\n

setindex! / operator[]

Sets the local configuration at the given site index to the given string.

JuliaC++
setindex!(state::ProductState, local_state::String, idx::Int64)\n
std::string &operator[](int64_t i);\n

getindex / operator[]

Returns the string of the local configuration at the given site index.

JuliaC++
getindex(state::ProductState, idx::Int64)\n
std::string const &operator[](int64_t i) const;\n

push! / push_back

Adds a local configuration add the end of the product state.

JuliaC++
push!(state::ProductState, local_state::String\n
void push_back(std::string l);\n
"},{"location":"documentation/states/product_state/#usage-example","title":"Usage Example","text":"JuliaC++
pstate = ProductState([\"Up\", \"Dn\", \"Emp\", \"UpDn\"])\nfor s in pstate\n    @show s\nend\n@show pstate\n\npstate = ProductState()\npush!(pstate, \"Dn\")\npush!(pstate, \"Up\")\npush!(pstate, \"Dn\")\n@show n_sites(pstate)\nfor s in pstate\n    @show s\nend\n@show pstate\n
auto pstate = ProductState({\"Up\", \"Dn\", \"Emp\", \"UpDn\"});\nfor (auto s : pstate) {\n  Log(\"{}\", s);\n}\nXDIAG_SHOW(to_string(pstate));\n\npstate = ProductState();\npstate.push_back(\"Dn\");\npstate.push_back(\"Up\");\npstate.push_back(\"Dn\");\nXDIAG_SHOW(pstate.n_sites());\nfor (auto s : pstate) {\n  Log(\"{}\", s);\n}\nXDIAG_SHOW(to_string(pstate));\n
"},{"location":"documentation/states/state/","title":"State","text":"

A generic state describing a quantum wave function

Source state.hpp

"},{"location":"documentation/states/state/#constructors","title":"Constructors","text":"JuliaC++
State(block::Block; real::Bool = true, n_cols::Int64 = 1)\nState(block::Block, vec::Vector{Float64})\nState(block::Block, vec::Vector{ComplexF64})\nState(block::Block, mat::Matrix{Float64})\nState(block::Block, mat::Matrix{ComplexF64})\n
State(Block const &block, bool real = true, int64_t n_cols = 1);\n\ntemplate <typename block_t, typename coeff_t>\nState(block_t const &block, arma::Col<coeff_t> const &vector);\n\ntemplate <typename block_t, typename coeff_t>\nState(block_t const &block, arma::Mat<coeff_t> const &matrix);\n
Parameter Description block The block of a Hilbertspace on which the state is defined real Flag whether or not the state has real coefficients n_cols Number of columns of the state (default 1) vector A vector containing the coefficients of the state. Must be same size as block. matrix A matrix containing the coefficients of the state. Number of rows must be same as block size ."},{"location":"documentation/states/state/#methods","title":"Methods","text":"

n_sites

Returns the number of sites of the block the state is defined on.

JuliaC++
n_sites(state::State)\n
int64_t n_sites() const\n

isreal

Returns whether the state is real.

JuliaC++
isreal(state::State)\n
int64_t isreal() const;\n

real

Returns whether the real part of the State.

JuliaC++
real(state::State)\n
State real() const;\n

imag

Returns whether the imaginary part of the State.

JuliaC++
imag(state::State)\n
State imag() const;\n

make_complex! / make_complex

Turns a real State into a complex State. Does nothing if the state is already complex

JuliaC++
make_complex!(state::State)\n
void make_complex();\n

dim

Returns the dimension of the block the state is defined on.

JuliaC++
dim(block::Spinhalf)\n
int64_t dim() const;\n

size

Returns the size of the block the state is defined on. locally. Same as \"dim\" for non-distributed Blocks but different for distributed blocks.

JuliaC++
size(block::Spinhalf)\n
int64_t size() const;\n

n_rows

Returns number of rows of the local storage. Same as \"size\"

JuliaC++
n_rows(block::Spinhalf)\n
int64_t n_rows() const;\n

n_cols

Returns number of columns of the local storage.

JuliaC++
n_cols(block::Spinhalf)\n
int64_t n_cols() const;\n

col

Returns a state created from the n-th column of the storage. Whether or not the storage is copied can be specified by setting the flag \"copy\".

JuliaC++
col(state::State, n::Int64 = 1; copy::Bool = true)\n
State col(int64_t n, bool copy = true) const;\n

vector/vectorC

Returns a vector from the n-th column of the storage. In C++ use \"vector\"/\"vectorC\" to either get a real or complex vector.

JuliaC++
vector(state::State; n::Int64 = 1)\n# no vectorC method in julia\n
arma::vec vector(int64_t n = 0, bool copy = true) const;\narma::cx_vec vectorC(int64_t n = 0, bool copy = true) const;\n

matrix/matrixC

Returns matrix representing the storage. In C++ use \"matrix\"/\"matrixC\" to either get a real or complex matrix.

JuliaC++
matrix(state::State)\n# no matrixC method in julia\n
arma::vec matrix(bool copy = true) const;\narma::cx_vec matrixC(bool copy = true) const;\n
"},{"location":"documentation/states/state/#usage-example","title":"Usage Example","text":"JuliaC++
block = Spinhalf(2)\npsi1 = State(block, [1.0, 2.0, 3.0, 4.0])\n@show psi1\ndisplay(vector(psi1))\nmake_complex!(psi1)\ndisplay(vector(psi1))\n\npsi2 = State(block, real=false, n_cols=3)\n@show psi2\ndisplay(matrix(psi2))\n\npsi3 = State(block, [1.0+4.0im, 2.0+3.0im, 3.0+2.0im, 4.0+1.0im])\ndisplay(vector(psi3))\ndisplay(vector(real(psi3)))\ndisplay(vector(imag(psi3)))\n
auto block = Spinhalf(2);\nauto psi1 = State(block, arma::vec(\"1.0 2.0 3.0 4.0\"));\nXDIAG_SHOW(psi1);\nXDIAG_SHOW(psi1.vector());\npsi1.make_complex();\nXDIAG_SHOW(psi1.vectorC());\n\nauto psi2 = State(block, false, 3);\nXDIAG_SHOW(psi2);\nXDIAG_SHOW(psi2.matrixC());\n\nauto psi3 = State(block, arma::cx_vec(arma::vec(\"1.0 2.0 3.0 4.0\"),\n                      arma::vec(\"4.0 3.0 2.0 1.0\")));\nXDIAG_SHOW(psi3.vectorC());\nXDIAG_SHOW(psi3.real().vector());\nXDIAG_SHOW(psi3.imag().vector());\n
"},{"location":"documentation/symmetries/permutation/","title":"Permutation","text":"

Permutations of indices or lattice sites

Source permutation.hpp

"},{"location":"documentation/symmetries/permutation/#constructors","title":"Constructors","text":"

Creates an Permutation out of an array of integers, e.g. [0, 2, 1, 3]. If the input array is of size N then every number between 0 and N-1 must occur exactly once, otherwise the Permutation is invalid.

JuliaC++
Permutation(array::Vector{Int64})\n
Permutation(std::vector<int64_t> const &array);\n
"},{"location":"documentation/symmetries/permutation/#methods","title":"Methods","text":"

inverse

Computes the inverse permutation.

JuliaC++
inverse(perm::Permutation)\n
// As a member function\nPermutation inverse() const;\n\n// As a non-member function\nPermutation inverse(Permutation const &p);\n

\"*\" operator

Concatenates two permutations by overloading the * operator.

JuliaC++
Base.:*(p1::Permutation, p2::Permutation)\n
Permutation operator*(Permutation const &p1, Permutation const &p2);\n

size

Returns the size of the permutation, i.e. the number of indices being permuted.

JuliaC++
size(perm::Permutation)\n
// As a member function\nint64_t size() const;\n\n// As a non-member function\nint64_t size(Permutation const &p);\n
"},{"location":"documentation/symmetries/permutation/#usage-example","title":"Usage Example","text":"JuliaC++
p1 = Permutation([0, 2, 1, 3])\np2 = Permutation([2, 0, 1, 3])\n\n@show inverse(p1)\n@show p1 * p2\n
Permutation p1 = {0, 2, 1, 3};\nPermutation p2 = {2, 0, 1, 3};\n\nXDIAG_SHOW(inverse(p1));\nXDIAG_SHOW(p1*p2);\n
"},{"location":"documentation/symmetries/permutation_group/","title":"Permutation","text":"

A group of permutations

Source permutation_group.hpp

"},{"location":"documentation/symmetries/permutation_group/#constructor","title":"Constructor","text":"

Creates an PermutationGroup out of a vector of Permutation objects.

JuliaC++
PermutationGroup(permutations::Vector{Permutation})\n
PermutationGroup(std::vector<Permutation> const &permutations);\n
"},{"location":"documentation/symmetries/permutation_group/#methods","title":"Methods","text":"

n_sites

Returns the number of sites on which the permutations of the group acts.

JuliaC++
n_sites(group::PermutationGroup)\n
int64_t n_sites() const\n

size

Returns the size of the permutation group, i.e. the number permutations

JuliaC++
size(group::PermutationGroup)\n
int64_t size() const;\n

inverse

Given an index of a permutation, it returns the index of the inverse permutation.

JuliaC++
inverse(group::PermutationGroup, idx::Integer)\n
// As a member function\nint64_t inverse(int64_t sym) const;\n
"},{"location":"documentation/symmetries/permutation_group/#usage-example","title":"Usage Example","text":"JuliaC++
# Define a cyclic group of order 3\np1 = Permutation([0, 1, 2])\np2 = Permutation([1, 2, 0])\np3 = Permutation([2, 0, 1])\nC3 = PermutationGroup([p1, p2, p3])\n\n@show size(C3)\n@show n_sites(C3)\n@show inverse(C3, 1) # = 2\n
// Define a cyclic group of order 3\nPermutation p1 = {0, 1, 2};\nPermutation p2 = {1, 2, 0};\nPermutation p3 = {2, 0, 1};\nauto C3 = PermutationGroup({p1, p2, p3});\n\nXDIAG_SHOW(C3.size());\nXDIAG_SHOW(C3.n_sites());\nXDIAG_SHOW(C3.inverse(1)); // = 2\n
"},{"location":"documentation/symmetries/representation/","title":"Representation","text":"

A (1D) irreducible representation of a finite group.

Source representation.hpp

"},{"location":"documentation/symmetries/representation/#constructors","title":"Constructors","text":"

Creates a Representation from a vector of complex numbers

JuliaC++
Representation(characters::Vector{<:Number})\n
Representation(std::vector<complex> const &characters);\n
"},{"location":"documentation/symmetries/representation/#methods","title":"Methods","text":"

size

Returns the size of the Representation, i.e. the number of characters.

JuliaC++
size(irrep::Representation)\n
int64_t size() const;\n

isreal

Returns the whether or not the Representation is real, I.E. the characters are real numbers and do not have an imaginary part.

JuliaC++
isreal(irrep::Representation; precision::Real=1e-12)\n
bool isreal(double precision = 1e-12) const;\n

\"*\" operator

Multiplies two Representations by overloading the * operator.

JuliaC++
Base.:*(p1::Representation, p2::Representation)\n
Representation operator*(Representation const &p1, Representation const &p2);\n
"},{"location":"documentation/symmetries/representation/#usage-example","title":"Usage Example","text":"JuliaC++
r1 = Representation([1, -1, 1, -1])\nr2 = Representation([1, 1im, -1, -1im])\n\n@show r1 * r2\n
Representation r1 = {1, -1, 1, -1};\nRepresentation r2 = {1, 1i, -1, -1i};\n\nXDIAG_SHOW(r1 * r2);\n
"},{"location":"documentation/utilities/logging/","title":"Logging","text":""},{"location":"documentation/utilities/logging/#setting-the-verbosity","title":"Setting the verbosity","text":"

Algorithms implemented in XDiag do not output anything during their execution by default. However, it is typically useful to get some information on how the code is performing and even intermediary results at runtime. For this, the verbosity of the internal XDiag logging can be set using the function set_verbosity, which is defined as

JuliaC++
set_verbosity(level::Integer);\n
void set_verbosity(int64_t level);\n

There are several levels of verbosity, defining how much information is shown.

level outputed information 0 no information 1 some information 2 detailed information

For example, when computing a ground state energy using the eigval0 function, we can set a higher verbosity level using

JuliaC++
set_verbosity(2);\ne0 = eigval0(bonds, block);\n
set_verbosity(2);\ndouble e0 = eigval0(bonds, block);\n

This will print detailed information, which can look like this

Lanczos iteration 1\nMVM: 0.00289 secs\nalpha: -0.2756971549998545\nbeta: 1.7639347562074059\neigs: -0.2756971549998545\nLanczos iteration 2\nMVM: 0.00244 secs\nalpha: -0.7116140394927443\nbeta: 2.3044797637130743\neigs: -2.2710052270892791 1.2836940325966804\nLanczos iteration 3\nMVM: 0.00210 secs\nalpha: -1.2772539678430306\nbeta: 2.6627870395174456\neigs: -3.7522788386927637 -0.6474957945455240 2.1352094709026579\n
"},{"location":"documentation/utilities/logging/#log-mechanism-c-only","title":"Log mechanism (C++ only)","text":"

Producing nicely formatted output is unfortunately a bit cumbersome in standard C++. For this, the Log mechanism in XDiag can help. To simply write out a line of information you can call,

Log(\"hello from the logger\");\n

By default, a new line is added. It is also possible to set verbosity by handing the level as the first argument,

Log(2, \"hello from the logger only if global verbosity is set to >= 2\");\n

This message will only appear if the global verbosity level is set to a value \\(\\geq 2\\). Finally, XDiag also supports formatted output by using the fmtlib. For example, numbers can be formated this way

Log(\"pi is around {:.4f} and the answer is {}\", 3.141592, 42);\n
"},{"location":"documentation/utilities/logging/#source","title":"Source","text":"

logger.hpp

"},{"location":"documentation/utilities/timing/","title":"Timing","text":"

In standard C++ measuring time is a bit awkward. To quickly monitor the CPU time spent by XDiag by simple functions.

"},{"location":"documentation/utilities/timing/#simple-timing-using-tic-toc","title":"Simple timing using tic() / toc()","text":"

Similar as in Matlab one can use tic() and toc() to measure the time spent between two points in the code.

tic();\ndouble e0 = eigval0(bonds, block);\ntoc();\n

toc() will output the time spent since the last time tic() has been called.

"},{"location":"documentation/utilities/timing/#detailed-timing","title":"Detailed timing","text":"

To get the present time, simply call

auto time = rightnow();\n

A timing (in second) between two time points can be written to output using

timing(begin, end);\n

This can even be accompanied by a message about what is being timed and a verbosity level (see Logging) can also be set. The full call signature is

timing(begin, end, message, level);\n
Name Description Default begin starting time computed using rightnow() end end time computed using rightnow() message message string to be prepended to timing \"\" level verbosity level at which timing is printed 0"},{"location":"documentation/utilities/xdiag_show/","title":"Debug printing","text":"

For quick debugging in C++, XDiag features a simple macro which outputs the name and content of a variable calles XDIAG_SHOW(x). For example

Spinhalf block(16, 8);\nXDIAG_SHOW(block);\n

will write an output similar to

block:\n  n_sites  : 16\n  n_up     : 8\n  dimension: 12,870\n  ID       : 0xa9127434d66b9878\n

The XDIAG_SHOW(x) macro can be used on any XDiag object and several other standard C++ objects as well.

"},{"location":"examples/cmake_distributed/","title":"CMakeLists.txt for the distributed XDiag library","text":"
cmake_minimum_required(VERSION 3.19)\n\nproject(\n  tj_distributed_time_evolve\n)\n\nfind_package(xdiag_distributed REQUIRED HINTS ../../../install)\nadd_executable(main main.cpp)\ntarget_link_libraries(main PUBLIC xdiag::xdiag_distributed)\n
"},{"location":"examples/cmake_normal/","title":"CMakeLists.txt for the normal XDiag library","text":"
cmake_minimum_required(VERSION 3.19)\n\nproject(\n  hello_world\n)\n\nfind_package(xdiag REQUIRED HINTS \"../../install\")\nadd_executable(main main.cpp)\ntarget_link_libraries(main PRIVATE xdiag::xdiag)\n
"},{"location":"examples/hello_world/","title":"Hello world!","text":"JuliaC++
   using XDiag\n   say_hello()\n
   #include <xdiag/all.hpp>\n\n   using namespace xdiag;\n\n   int main() try {\n     say_hello();\n   } catch (Error e) {\n     error_trace(e);\n   }\n
"},{"location":"examples/spinhalf_chain_e0/","title":"Groundstate energy","text":"JuliaC++
using XDiag\n\nlet \n    N = 16;\n    nup = N \u00f7 2;\n    block = Spinhalf(N, nup);\n\n    # Define the nearest-neighbor Heisenberg model\n    bonds = BondList()\n    for i in 1:N\n        bonds += Bond(\"HB\", \"J\", [i-1, i % N])\n    end\n    bonds[\"J\"] = 1.0;\n\n    set_verbosity(2);             # set verbosity for monitoring progress\n    e0 = eigval0(bonds, block);   # compute ground state energy\n\n    println(\"Ground state energy: $e0\");\nend\n
#include <xdiag/all.hpp>\n\nusing namespace xdiag;\n\nint main() try {\n  int N = 16;\n  int nup = N / 2;\n  Spinhalf block(N, nup);\n\n  // Define the nearest-neighbor Heisenberg model\n  OpSum ops;\n  for (int i = 0; i < N; ++i) {\n    ops += Op(\"HB\", \"J\", {i, (i + 1) % N});\n  }\n  ops[\"J\"] = 1.0;\n\n  set_verbosity(2);                  // set verbosity for monitoring progress\n  double e0 = eigval0(ops, block); // compute ground state energy\n\n  Log(\"Ground state energy: {:.12f}\", e0);\n\n} catch (Error e) {\n  error_trace(e);\n}\n
"},{"location":"examples/tj_distributed_time_evolve/","title":"\\(t\\)-\\(J\\) distributed time evolution","text":"
#include <xdiag/all.hpp>\n\nusing namespace xdiag;\n\nvoid measure_density(int n_sites, State const &v) {\n  int rank;\n  MPI_Comm_rank(MPI_COMM_WORLD, &rank);\n  for (int i = 0; i < n_sites; ++i) {\n    complex sz = innerC(Bond(\"NUMBER\", i), v);\n    if (rank == 0) {\n      printf(\"%.6f \", std::real(sz));\n    }\n  }\n  if (rank == 0) {\n    printf(\"\\n\");\n  }\n}\n\nint main(int argc, char **argv) try {\n  MPI_Init(&argc, &argv);\n\n  int L = 6;\n  int W = 4;\n  double t = 1.0;\n  double J = 0.1;\n  double mu_0 = 10;\n\n  int n_sites = L * W;\n  double precision = 1e-12;\n\n  // Create square lattice t-J model\n  OpSum ops;\n  for (int x = 0; x < L-1; ++x) {\n    for (int y = 0; y < W; ++y) {\n      int nx = (x + 1) % L;\n      int ny = (y + 1) % W;\n\n      int site = x * W + y;\n      int right = nx * W + y;\n      int top = x * W + ny;\n      ops += Op(\"HOP\", \"T\", {site, right});\n      ops += Op(\"EXCHANGE\", \"J\", {site, right});\n      ops += Op(\"HOP\", \"T\", {site, top});\n      ops += Op(\"EXCHANGE\", \"J\", {site, top});\n\n\n\n      if (x < L / 2) {\n    Log(\"x {} y {} site {} t {} r {} +\", x, y, site, top, right);\n        ops += Op(\"NUMBER\", \"MUPLUS\", site);\n      } else {\n    Log(\"x {} y {} site {} t {} r {} -\", x, y, site, top, right);\n        ops += Op(\"NUMBER\", \"MUNEG\", site);\n      }\n    }\n  }\n  ops[\"T\"] = t;\n  ops[\"J\"] = J;\n  ops[\"MUPLUS\"] = mu_0;\n  ops[\"MUNEG\"] = mu_0;\n\n  auto block = tJDistributed(n_sites, n_sites / 2 - 1, n_sites / 2 - 1);\n\n  XDIAG_SHOW(block);\n\n  Log.set_verbosity(2);\n  tic();\n  auto [e0, v] = eig0(ops, block);\n  toc(\"gs\");\n\n  ops[\"MUPLUS\"] = 0;\n  ops[\"MUNEG\"] = 0;\n\n  measure_density(n_sites, v);\n\n  // Do the time evolution with a step size tau\n  double tau = 0.1;\n  for (int i = 0; i < 40; ++i) {\n    tic();\n    v = time_evolve(ops, v, tau, precision);\n    toc(\"time evolve\");\n    tic();\n    measure_density(n_sites, v);\n    toc(\"measure\");\n  }\n\n  MPI_Finalize();\n  return EXIT_SUCCESS;\n} catch (std::exception const &e) {\n  traceback(e);\n}\n
"}]} \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index 19983be9..ae42d86f 100644 Binary files a/sitemap.xml.gz and b/sitemap.xml.gz differ