Guest User

Untitled

a guest
Dec 4th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. #include "./itensor/all.h"
  2. using namespace itensor;
  3. #include <iomanip>
  4.  
  5. void Sx_meas( MPS psi, SiteSet sites ) // Sx measurement and output
  6. {
  7.     int N = length(sites);  
  8.  
  9.     for( int j = 1; j <= N; j++ )
  10.     {            
  11.         psi.position(j);
  12.  
  13.         auto ket = psi(j);
  14.         auto bra = dag(prime(ket,"Site"));
  15.         auto Sxjop = sites.op("Sx",j);
  16.  
  17.         auto sxj = 2*eltC(bra*Sxjop*ket).real();
  18.  
  19.         std::cout << std::setprecision(3) << sxj << " ";
  20.     }
  21. }
  22.  
  23. MPO get_H( const SiteSet sites, double h, double hx )
  24. {
  25.     auto ampo = AutoMPO(sites);
  26.     int N = length(sites);
  27.     for (int i = 1; i < N; i++)
  28.     {
  29.         // produces correct GS
  30.         ampo += -0.5, "S+", i, "S+", i+1;
  31.         ampo += -0.5, "S-", i, "S-", i+1;
  32.         ampo += -0.5, "S+", i, "S-", i+1;
  33.         ampo += -0.5, "S-", i, "S+", i+1;
  34.        
  35.         // produces wrong GS
  36.         //ampo += -1, "Sx", i, "Sx", i+1;      
  37.     }
  38.     for (int i = 1; i <= N; i++)
  39.     {
  40.         ampo += -h, "Sz", i;
  41.         ampo += -hx, "Sx", i;
  42.     }
  43.  
  44.     MPO H_TI = toMPO(ampo);
  45.  
  46.     return H_TI;
  47. }
  48.  
  49. int main(int argc, char **argv)
  50. {
  51.     int N = 50;
  52.     double h = 0.5;
  53.  
  54.     auto sites = SpinHalf(N,{"ConserveQNs=",false});
  55.  
  56.     auto sweeps = Sweeps(10);
  57.     sweeps.maxdim() = 1000;
  58.     sweeps.cutoff() = 1E-10;
  59.  
  60.     std::vector<double> hxs = {1.0, 0.5, 0.4, 0.3, 0.2, 0.1, 0.01, 1e-3, 0};
  61.  
  62.     MPS psi_up = randomMPS(sites);
  63.     double energy_up;
  64.  
  65.     for( double hxk : hxs )
  66.     {
  67.         auto H_TI_up = get_H( sites, h, hxk); // Construct H with smaller and smaller hx to end up in the symmetry-broken GS
  68.         std::tie(energy_up,psi_up) = dmrg(H_TI_up,psi_up,sweeps,{"Quiet",true});
  69.         psi_up.normalize();
  70.  
  71.         Sx_meas( psi_up, sites );
  72.     }
  73. }
Add Comment
Please, Sign In to add comment