# AutoMPO

AutoMPO is a very powerful system for translating sums of local operators into an MPO (or IQMPO) tensor network. The notation for AutoMPO input is designed to be as close as possible to pencil-and-paper quantum mechanics notation.

The code for AutoMPO is located in the files "itensor/mps/autompo.h" and "itensor/mps/autompo.cc".

# Synopsis

// Make a chain of N spin 1/2's with QN information
auto Nx = 12, Ny = 6;
auto N = Nx*Ny;
auto sites = SpinHalf(N,{"ConserveQNs=",true});

//
// Use AutoMPO to create the
// next-neighbor Heisenberg model
//

auto ampo = AutoMPO(sites);
for(int j = 1; j < N; ++j)
{
ampo += 0.5,"S+",j,"S-",j+1;
ampo += 0.5,"S-",j,"S+",j+1;
ampo +=     "Sz",j,"Sz",j+1;
}

//Convert the AutoMPO object to an MPO
auto H = toMPO(ampo);

//....

//
// Create a model with further-range interactions
// capturing a 2D lattice (with a 1D ordering of sites)
//
auto ampo2D = AutoMPO(sites);
auto lattice = squareLattice(Nx,Ny);
for(auto b : lattice)
{
ampo2D += 0.5,"S+",b.s1,"S-",b.s2;
ampo2D += 0.5,"S-",b.s1,"S+",b.s2;
ampo2D +=     "Sz",b.s1,"Sz",b.s2;
}
auto H2D = toMPO(ampo2D);

//....

//
// Create the 1D Hubbard model
//
auto sitesElec = Electron(N);
auto ampoHub = AutoMPO(sitesElec);
for(int i = 1; i <= N; ++i)
{
ampoHub += U,"Nupdn",i;
}
for(int b = 1; b < N; ++b)
{
ampoHub += -t,"Cdagup",b,"Cup",b+1;
ampoHub += -t,"Cdagup",b+1,"Cup",b;
ampoHub += -t,"Cdagdn",b,"Cdn",b+1;
ampoHub += -t,"Cdagdn",b+1,"Cdn",b;
}
auto H = toMPO(ampoHub);

//....

//
// Create a spin model with four-site terms
//
auto ampo4 = AutoMPO(sites);
for(auto i : range1(N-4))
{
ampo4 += "Sz",i,"Sz",i+1,"Sz",i+2,"Sz",i+4;
}
for(auto i : range1(N-1))
{
ampo4 += 0.5,"S+",i,"S-",i+1;
ampo4 += 0.5,"S-",i,"S+",i+1;
}
auto H4 = toMPO(ampo4);


## AutoMPO Interface

• AutoMPO(SiteSet sites)

Construct an AutoMPO object.

• AutoMPO += op

The += operator of an AutoMPO object adds a operator product into the sum of operators represented by the AutoMPO.

Examples of valid input:

ampo += "Sz",i;
ampo += "Sz",i,"Sz",j;
ampo += 0.2,"Sz",i,"Sz",j;
ampo += 0.5,"S+",i,"S-",j;
ampo += 0.5,"S+",i,"S-",j,"S+",k,"S-",l;


The operator products on the right-hand side of the += operator begin with an optional real- or complex-valued coefficient, then continue with a comma separated list of string-integer pairs. The coefficient can be either a numeric literal or a variable of type Real (double) or Cplx (std::complex<double>).

The string-integer pairs, such as "Sz",i, represent an operator $S^z_i$ .

Which strings are acceptable as operator names are determined by the SiteSet used to construct the AutoMPO. All operator names must be valid input to the .op method of the SiteSet (which is used to construct local site operators as tensors).

• .sites() -> SiteSet const&

Retrieve the SiteSet used to construct the AutoMPO.

## Converting an AutoMPO to an MPO

### toMPO function

Call the toMPO function to create an MPO from an AutoMPO. You can pass various named arguments to control which backend is used to process the AutoMPO and to control the accuracy of this process.

Examples:

auto H1 = toMPO(ampo);
auto H2 = toMPO(ampo,{"Exact=",true});


Named arguments recognized:

• "Exact" — boolean (default: false). Set whether to use the 'exact' backend or the approximate backend. The approximate backend can handle operators acting on more than two sites, and compresses the resulting MPO by doing a series of singular value decompositions (SVDs). Normally these SVDs are very accurate but could become an issue if an important term has an unusually small coefficient. The exact backend makes no approximations whatsoever, but is limited to at most two-site operators and can sometimes result in larger MPO bond dimensions than the approximate backend.

• "MaxDim" — integer (default: 5000). Set the maximum bond dimension of the resulting MPO when using the approximate backend. If Exact=true, this has no effect.

• "Cutoff" — real. (default: 1E-13). Set the SVD truncation error cutoff used by the approximate backend. If Exact=true, this has no effect.

### toExpH function

The toExpH function converts an AutoMPO representing a sum of operators $H$ into an MPO which approximates the operator $e^{-t H}$ for a small time step t, making an error of order $t^2$ per time step. The time step t can be real or complex.

The method used to do the approximate exponentiation is based on the following article: Phys. Rev. B 91, 165112 (arxiv:1407.1832) using the $W^{I}$ method, and has the advantage that unlike naive approaches for exponentiating an MPO, the time-step error per site is independent of system size.

Note that the true amount of error per step, or the quality of the results can depend very highly on how short- or long-range the interactions are in the input Hamiltonian. It is recommended to test your results against a different method, such as Trotter gates, global Krylov, or TDVP to confirm that your results are accurate and controlled.

Examples:

auto ampo = AutoMPO(sites);
...
Real tau = 0.1;
//Real time evolution
auto expiH = toExpH(ampo,tau*Cplx_i);
//...
//Imaginary time evolution
auto expH = toExpH(ampo,tau); Back to Classes Back to Main
{"ft_lang_label":"__label__en","ft_lang_prob":0.77730906,"math_prob":0.955359,"size":5164,"snap":"2023-40-2023-50","text_gpt3_token_len":1539,"char_repetition_ratio":0.119573645,"word_repetition_ratio":0.022360248,"special_character_ratio":0.29841208,"punctuation_ratio":0.20480855,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98669034,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-01T13:21:52Z\",\"WARC-Record-ID\":\"<urn:uuid:b922d2e4-a751-42d3-a5c1-616f083df5a1>\",\"Content-Length\":\"25036\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:dacd31a7-ec92-436e-899b-f0fb69539eb9>\",\"WARC-Concurrent-To\":\"<urn:uuid:94b1026e-5f78-4f0c-8868-14cf63c92fc9>\",\"WARC-IP-Address\":\"52.14.254.137\",\"WARC-Target-URI\":\"https://itensor.org/docs.cgi?vers=cppv3&page=classes/autompo\",\"WARC-Payload-Digest\":\"sha1:ML5G2O4ZPKJS7IVOKD7X5NYBEEBFQTZQ\",\"WARC-Block-Digest\":\"sha1:LUVRXJSPXYR27KWR3RDE2QTQ2A77KH2I\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510888.64_warc_CC-MAIN-20231001105617-20231001135617-00311.warc.gz\"}"}