OpSum
A sum of local operators acting on several lattice sites.
Source opsum.hpp
Constructor
Parameter | Description | |
---|---|---|
ops | a vector of Op objects describing the operators summed over |
Methods
defined
Returns bool whether a coupling (of type string) is defined
setindex! / operator[]
Sets a coupling given as a string to a certain numerical value or matrix
getindex / operator[]
Returns the value of a Coupling defined as a string.
couplings
Returns all the possible names of Coupling as a vector of strings
isreal
Returns whether or not the OpSum is real. This will throw an error if some Coupling are only defined as a string.
isexplicit
Returns false if there exist a Coupling which is defined as a string, otherwise true.
operator +
Adds a single Op or a full OpSum
Usage Example
// Define the 1D transverse-field Ising chain
int N = 12;
double J = 1.0;
double h = 0.5;
auto Sx = arma::mat("0 1; 1 0");
auto ops = OpSum();
for (int i = 0; i<N; ++i) {
ops += Op("ISING", "J", {i, (i+1)%N});
ops += Op("SX", arma::mat(h*Sx), i);
}
ops["J"] = 1.0;
XDIAG_SHOW(ops);
XDIAG_SHOW(ops.defined("J"));
XDIAG_SHOW(ops.isreal());
XDIAG_SHOW(ops.isexplicit());