Quantum operators (C code)¶
Symbolic operator chains¶
Symbolic operator chain data structure and utility functions.
Functions
-
void allocate_op_chain(const int length, struct op_chain *chain)¶
Allocate memory for an operator chain, and initialize coefficient by default value 1.
-
void copy_op_chain(const struct op_chain *src, struct op_chain *dst)¶
Copy an operator chain, allocating memory for the copy.
-
void op_chain_pad_identities(const struct op_chain *chain, const int new_length, struct op_chain *pad_chain)¶
Construct a new operator chain with identities padded on the left and right.
-
void op_chain_to_matrix(const struct op_chain *chain, const ct_long d, const int nsites, const struct dense_tensor *opmap, const void *coeffmap, const enum numeric_type dtype, struct dense_tensor *a)¶
Construct the full matrix representation of the operator chain.
-
struct op_chain¶
- #include <op_chain.h>
Symbolic operator chain
coeff op_i x op_{i+1} x ... x op_{i+n-1}, withop_iacting on lattice siteiA single bond quantum number is interleaved between each
op_iandop_{i+1}; set all quantum numbers to zero to effectively disable them.
Local operators¶
(Site-)local operators.
Enums
Functions
-
bool coefficient_map_is_valid(const enum numeric_type dtype, const void *coeffmap)¶
Test whether a coefficient map is valid, i.e., contains 0 and 1 as first two entries.
-
void construct_local_operator(const struct local_op_ref *opics, const int nopics, const struct dense_tensor *opmap, const void *coeffmap, struct dense_tensor *op)¶
Construct the local operator as dense matrix.
-
struct local_op_ref¶
- #include <local_op.h>
Local operator ID and corresponding coefficient.
Matrix product operators (MPOs)¶
MPO graph internal data structure for generating MPO representations.
Functions
-
void mpo_graph_vertex_add_edge(const int direction, const int eid, struct mpo_graph_vertex *vertex)¶
Add an edge reference to an MPO graph vertex.
-
int mpo_graph_from_opchains(const struct op_chain *chains, const int nchains, const int nsites, struct mpo_graph *mpo_graph)¶
Construct an MPO operator graph from a list of operator chains, implementing the algorithm in: Jiajun Ren, Weitang Li, Tong Jiang, Zhigang Shuai A general automatic method for optimal construction of matrix product operators using bipartite graph theory J. Chem. Phys. 153, 084118 (2020)
-
bool mpo_graph_is_consistent(const struct mpo_graph *mpo_graph)¶
Internal consistency check of an MPO graph.
-
void mpo_graph_to_matrix(const struct mpo_graph *mpo_graph, const struct dense_tensor *opmap, const void *coeffmap, const enum numeric_type dtype, struct dense_tensor *mat)¶
Construct the full matrix representation of the MPO graph.
-
struct mpo_graph_vertex¶
- #include <mpo_graph.h>
Operator graph vertex, corresponding to a virtual bond in an MPO.
-
struct mpo_graph_edge¶
- #include <mpo_graph.h>
MPO operator graph edge, representing a weighted sum of local operators which are indexed by their IDs.
Public Members
-
int vids[2]¶
indices of left- and right-connected vertices
-
struct local_op_ref *opics¶
weighted sum of local operators
-
int nopics¶
number of local operators in the sum
-
int vids[2]¶
-
struct mpo_graph¶
- #include <mpo_graph.h>
MPO graph internal data structure for generating MPO representations.
Public Members
-
struct mpo_graph_vertex **verts¶
list of vertices for each virtual bond
-
struct mpo_graph_edge **edges¶
list of edges for each site
-
int *num_verts¶
number of vertices for each virtual bond, i.e., virtual bond dimensions
-
int *num_edges¶
number of edges for each site
-
int nsites¶
number of sites
-
struct mpo_graph_vertex **verts¶
Matrix product operator (MPO) data structure and functions.
Functions
-
void delete_mpo_assembly(struct mpo_assembly *assembly)¶
Delete a matrix product operator assembly (free memory).
-
void allocate_mpo(const enum numeric_type dtype, const int nsites, const ct_long d, const qnumber *qsite, const ct_long *dim_bonds, const qnumber **qbonds, struct mpo *mpo)¶
Allocate memory for a matrix product operator. ‘dim_bonds’ and ‘qbonds’ must be arrays of length ‘nsites + 1’.
-
void mpo_from_assembly(const struct mpo_assembly *assembly, struct mpo *mpo)¶
Construct an MPO from an MPO assembly.
-
bool mpo_is_consistent(const struct mpo *mpo)¶
Internal consistency check of the MPO data structure.
-
static inline ct_long mpo_bond_dim(const struct mpo *mpo, const int i)¶
Dimension of i-th virtual bond of a matrix product operator, starting with the leftmost (dummy) bond.
-
void mpo_merge_tensor_pair(const struct block_sparse_tensor *a0, const struct block_sparse_tensor *a1, struct block_sparse_tensor *a)¶
Merge two neighboring MPO tensors.
-
void mpo_to_matrix(const struct mpo *mpo, struct block_sparse_tensor *mat)¶
Merge all tensors of an MPO to obtain the matrix representation on the full Hilbert space. The (dummy) virtual bonds are retained in the output tensor.
-
struct mpo_assembly¶
- #include <mpo.h>
Matrix product operator (MPO) assembly: structural description which can be used to construct an MPO.
Public Members
-
struct dense_tensor *opmap¶
local operator map (look-up table)
-
void *coeffmap¶
coefficient map (look-up table)
-
enum numeric_type dtype¶
data type of local operators and coefficients
-
int num_local_ops¶
number of local operators (length of ‘opmap’ array)
-
int num_coeffs¶
number of coefficients (length of ‘coeffmap’ array)
-
struct dense_tensor *opmap¶
-
struct mpo¶
- #include <mpo.h>
Matrix product operator (MPO) data structure.
Tree tensor network operators (TTNOs)¶
Tree tensor network operator (TTNO) graph internal data structure.
Vertices and hyperedges only depend on undirected tree topology and enumeration of physical sites.
Functions
-
void ttno_graph_vertex_add_edge(const int direction, const int eid, struct ttno_graph_vertex *vertex)¶
Add an edge reference to a TTNO graph vertex.
-
int ttno_graph_from_opchains(const struct op_chain *chains, const int nchains, const int nsites_physical, const struct abstract_graph *topology, struct ttno_graph *ttno_graph)¶
Construct a TTNO operator graph from a list of operator chains.
-
void delete_ttno_graph(struct ttno_graph *graph)¶
Delete a TTNO graph (free memory).
-
bool ttno_graph_is_consistent(const struct ttno_graph *graph)¶
Internal consistency check of a TTNO graph.
-
void ttno_graph_to_matrix(const struct ttno_graph *graph, const struct dense_tensor *opmap, const void *coeffmap, struct dense_tensor *mat)¶
Construct the full matrix representation of the TTNO graph.
-
struct ttno_graph_vertex¶
- #include <ttno_graph.h>
Operator graph vertex, corresponding to a virtual bond in a TTNO.
-
struct ttno_graph_hyperedge¶
- #include <ttno_graph.h>
TTNO graph hyperedge, representing a weighted sum of local operators which are indexed by their IDs.
Public Members
-
int *vids¶
indices of connected vertices, ordered by neighboring hyperedge site indices
-
int order¶
order (number of connected vertices)
-
struct local_op_ref *opics¶
weighted sum of local operators
-
int nopics¶
number of local operators in the sum
-
int *vids¶
-
struct ttno_graph¶
- #include <ttno_graph.h>
TTNO graph internal data structure for generating TTNO representations.
Sites are enumerated as physical sites first, then branching sites.
Public Members
-
struct abstract_graph topology¶
logical tree topology; nodes correspond to physical and branching sites
-
struct ttno_graph_hyperedge **edges¶
list of hyperedges for each physical and branching site
-
struct ttno_graph_vertex **verts¶
list of vertices for each virtual bond, indexed by corresponding hyperedge site indices (i, j) with i < j
-
int *num_edges¶
number of edges for each site
-
int *num_verts¶
number of vertices for each virtual bond, i.e., virtual bond dimensions, indexed by corresponding hyperedge site indices (i, j) with i < j
-
int nsites_physical¶
number of physical sites
-
int nsites_branching¶
number of branching sites
-
struct abstract_graph topology¶
Tree tensor network operator (TTNO) data structure and functions.
Enums
Functions
-
void delete_ttno_assembly(struct ttno_assembly *assembly)¶
Delete a tensor network operator assembly (free memory).
-
void allocate_ttno(const enum numeric_type dtype, const int nsites_physical, const struct abstract_graph *topology, const ct_long d, const qnumber *qsite, const ct_long *dim_bonds, const qnumber **qbonds, struct ttno *ttno)¶
Allocate memory for a tree tensor network operator. ‘dim_bonds’ and ‘qbonds’ are indexed by site index tuples (i, j) with i < j.
-
void ttno_from_assembly(const struct ttno_assembly *assembly, struct ttno *ttno)¶
Construct a TTNO from a TTNO assembly.
-
void construct_random_ttno(const enum numeric_type dtype, const int nsites_physical, const struct abstract_graph *topology, const ct_long d, const qnumber *qsite, const ct_long max_vdim, struct rng_state *rng_state, struct ttno *ttno)¶
Construct a tree tensor network operator with random normal tensor entries, given a maximum virtual bond dimension.
-
bool ttno_is_consistent(const struct ttno *ttno)¶
Internal consistency check of the TTNO data structure.
-
void ttno_tensor_get_axis_desc(const struct abstract_graph *topology, const int i_site, struct ttno_tensor_axis_desc *desc)¶
Fill the axis descriptions of a TTNO tensor; ‘desc’ must point to an array of the same length as the degree of the tensor at ‘i_site’.
-
void ttno_to_matrix(const struct ttno *ttno, struct block_sparse_tensor *mat)¶
Merge all tensors of a TTNO to obtain the matrix representation on the full Hilbert space.
-
struct ttno_assembly¶
- #include <ttno.h>
Tree tensor network operator (TTNO) assembly: structural description which can be used to construct a TTNO.
Public Members
-
struct ttno_graph graph¶
TTNO graph data structure.
-
struct dense_tensor *opmap¶
local operator map (look-up table)
-
void *coeffmap¶
coefficient map (look-up table)
-
enum numeric_type dtype¶
data type of local operators and coefficients
-
int num_local_ops¶
number of local operators (length of ‘opmap’ array)
-
int num_coeffs¶
number of coefficients (length of ‘coeffmap’ array)
-
struct ttno_graph graph¶
-
struct ttno¶
- #include <ttno.h>
Tree tensor network operator (TTNO) data structure.
Public Members
-
struct block_sparse_tensor *a¶
tensors associated with sites, with interleaved physical and virtual bond dimensions (ordered by site indices)
-
struct abstract_graph topology¶
logical tree topology; nodes correspond to physical and branching sites
-
int nsites_physical¶
number of physical sites
-
int nsites_branching¶
number of branching sites
-
struct block_sparse_tensor *a¶
-
struct ttno_tensor_axis_desc¶
- #include <ttno.h>
TTNO tensor axis description.
Public Members
-
enum ttno_tensor_axis_type type¶
tensor axis type
-
int index¶
local site index (for a physical axis), or neighbor site index (for a virtual bond)
-
enum ttno_tensor_axis_type type¶
Quantum Hamiltonians¶
Construction of common quantum Hamiltonians.
Functions
-
void construct_ising_1d_mpo_assembly(const int nsites, const double J, const double h, const double g, struct mpo_assembly *assembly)¶
Contruct an MPO assembly representation of the Ising Hamiltonian ‘sum J Z Z + h Z + g X’ on a one-dimensional lattice.
-
void construct_heisenberg_xxz_1d_mpo_assembly(const int nsites, const double J, const double D, const double h, struct mpo_assembly *assembly)¶
Construct an MPO assembly representation of the XXZ Heisenberg Hamiltonian ‘sum J (X X + Y Y + D Z Z) - h Z’ on a one-dimensional lattice.
-
void construct_bose_hubbard_1d_mpo_assembly(const int nsites, const ct_long d, const double t, const double u, const double mu, struct mpo_assembly *assembly)¶
Construct an MPO assembly representation of the Bose-Hubbard Hamiltonian with nearest-neighbor hopping on a one-dimensional lattice.
-
void construct_fermi_hubbard_1d_mpo_assembly(const int nsites, const double t, const double u, const double mu, struct mpo_assembly *assembly)¶
Construct an MPO assembly representation of the Fermi-Hubbard Hamiltonian with nearest-neighbor hopping on a one-dimensional lattice.
States for each spin and site are ‘|0>’ and ‘|1>’.
-
void construct_molecular_hamiltonian_mpo_assembly(const struct dense_tensor *tkin, const struct dense_tensor *vint, const bool optimize, struct mpo_assembly *assembly)¶
Construct a molecular Hamiltonian as MPO assembly, using physicists’ convention for the interaction term (note ordering of k and l):
\[ H = \sum_{i,j} t_{i,j} a^{\dagger}_i a_j + \frac{1}{2} \sum_{i,j,k,\ell} v_{i,j,k,\ell} a^{\dagger}_i a^{\dagger}_j a_{\ell} a_k \]If ‘optimize == true’, optimize the virtual bond dimensions via the automatic construction starting from operator chains. Can handle zero entries in ‘tkin’ and ‘vint’, but construction takes considerably longer for larger number of orbitals.
-
void construct_spin_molecular_hamiltonian_mpo_assembly(const struct dense_tensor *tkin, const struct dense_tensor *vint, const bool optimize, struct mpo_assembly *assembly)¶
Construct a molecular Hamiltonian as MPO assembly, assuming a spin orbital basis and using physicists’ convention for the interaction term (note ordering of k and l):
\[ H = \sum_{i,j} \sum_{\sigma \in \{\uparrow, \downarrow\}} t_{i,j} a^{\dagger}_{i,\sigma} a_{j,\sigma} + \frac{1}{2} \sum_{i,j,k,\ell} \sum_{\sigma, \tau \in \{\uparrow, \downarrow\}} v_{i,j,k,\ell} a^{\dagger}_{i,\sigma} a^{\dagger}_{j,\tau} a_{\ell,\tau} a_{k,\sigma} \]If ‘optimize == true’, optimize the virtual bond dimensions via the automatic construction starting from operator chains. Can handle zero entries in ‘tkin’ and ‘vint’, but construction takes considerably longer for larger number of orbitals.
-
void construct_quadratic_fermionic_mpo_assembly(const int nsites, const double *coeffc, const double *coeffa, struct mpo_assembly *assembly)¶
Represent a product of sums of fermionic creation and annihilation operators of the following form as MPO:
\[ H = \left(\sum_{i=1}^L \mathrm{coeffc}_i a^{\dagger}_i\right) \left(\sum_{j=1}^L \mathrm{coeffa}_j a_j\right) \]
-
void construct_quadratic_spin_fermionic_mpo_assembly(const int nsites, const double *coeffc, const double *coeffa, const int sigma, struct mpo_assembly *assembly)¶
Construct an MPO assembly representation of a product of sums of fermionic creation and annihilation operators, where sigma = 0 indicates spin-up and sigma = 1 indicates spin-down:
\[ H = \left(\sum_{i=1}^L \mathrm{coeffc}_i a^{\dagger}_{i,\sigma}\right) \left(\sum_{j=1}^L \mathrm{coeffa}_j a_{j,\sigma}\right) \]