You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ABACUS_Heis.h 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: ABACUS_Heis.h
  6. Purpose: Declares Heisenberg chain classes and functions.
  7. ***********************************************************/
  8. #ifndef ABACUS_HEIS_H
  9. #define ABACUS_HEIS_H
  10. #include "ABACUS.h"
  11. namespace ABACUS {
  12. // First, some global constants...
  13. const long long int ID_UPPER_LIMIT = 10000000LL; // max size we can define without seg fault
  14. const int INTERVALS_SIZE = 100000; // size of Scan_Intervals arrays
  15. const int NBASESMAX = 1000; // max number of bases kept
  16. const DP ITER_REQ_PREC = 100.0 * MACHINE_EPS_SQ;
  17. // Cutoffs on particle numbers
  18. const int MAXSTRINGS = 20; // maximal number of particle types we allow in bases
  19. const int NEXC_MAX_HEIS = 16; // max nr of excitations (string binding/unbinding, particle-hole) considered
  20. //***********************************************************************
  21. class Heis_Chain {
  22. public:
  23. DP J;
  24. DP Delta;
  25. DP anis; // acos(Delta) if Delta < 1.0, 0 if Delta == 1.0, acosh(Delta) if Delta > 1.0
  26. DP hz;
  27. int Nsites;
  28. int Nstrings; // how many possible strings. The following two arrays have Nstrings nonzero elements.
  29. int* Str_L; // vector (length M) containing the allowed string lengths. Elements that are 0 have no meaning.
  30. int* par; // vector (length M) containing the parities of the strings. Elements that are 0 have no meaning.
  31. // Parities are all +1 except for gapless XXZ subcases
  32. DP* si_n_anis_over_2; // for optimization: sin for XXZ, sinh for XXZ_gpd
  33. DP* co_n_anis_over_2; // for optimization
  34. DP* ta_n_anis_over_2; // for optimization
  35. DP prec; // precision required for computations, always put to ITER_REQ_PREC
  36. public:
  37. Heis_Chain ();
  38. Heis_Chain (DP JJ, DP DD, DP hh, int NN); // contructor: simply initializes
  39. Heis_Chain (const Heis_Chain& RefChain); // copy constructor;
  40. Heis_Chain& operator= (const Heis_Chain& RefChain);
  41. bool operator== (const Heis_Chain& RefChain);
  42. bool operator!= (const Heis_Chain& RefChain);
  43. ~Heis_Chain(); // destructor
  44. };
  45. //****************************************************************************
  46. // Objects in class Heis_Base are a checked vector containing the number of rapidities
  47. // of allowable types for a given state
  48. class Heis_Base {
  49. public:
  50. int Mdown; // total number of down spins
  51. Vect<int> Nrap; // Nrap[i] contains the number of rapidities of type i, i = 0, Nstrings - 1.
  52. int Nraptot; // total number of strings in this state
  53. Vect<DP> Ix2_infty; // Ix2_infty[i] contains the max of BAE function for the (half-)integer I[i], i = 0, Nstrings - 1.
  54. Vect<int> Ix2_min;
  55. Vect<int> Ix2_max; // Ix2_max[i] contains the integer part of 2*I_infty, with correct parity for base.
  56. double dimH; // dimension of sub Hilbert space associated to this base; use double to avoid max int problems.
  57. std::string baselabel; // base label
  58. public:
  59. Heis_Base ();
  60. Heis_Base (const Heis_Base& RefBase); // copy constructor
  61. Heis_Base (const Heis_Chain& RefChain, int M); // constructs configuration with all Mdown in one-string of +1 parity
  62. Heis_Base (const Heis_Chain& RefChain, const Vect<int>& Nrapidities); // sets to Nrapidities vector, and checks consistency
  63. Heis_Base (const Heis_Chain& RefChain, std::string baselabel_ref);
  64. inline int& operator[] (const int i);
  65. inline const int& operator[] (const int i) const;
  66. Heis_Base& operator= (const Heis_Base& RefBase);
  67. bool operator== (const Heis_Base& RefBase);
  68. bool operator!= (const Heis_Base& RefBase);
  69. void Compute_Ix2_limits(const Heis_Chain& RefChain); // computes the Ix2_infty and Ix2_max
  70. };
  71. inline int& Heis_Base::operator[] (const int i)
  72. {
  73. return Nrap[i];
  74. }
  75. inline const int& Heis_Base::operator[] (const int i) const
  76. {
  77. return Nrap[i];
  78. }
  79. //****************************************************************************
  80. // Objects in class Lambda carry all rapidities of a state
  81. class Lambda {
  82. private:
  83. int Nstrings;
  84. Vect<int> Nrap;
  85. int Nraptot;
  86. DP** lambda;
  87. public:
  88. Lambda ();
  89. Lambda (const Heis_Chain& RefChain, int M); // constructor, puts all lambda's to zero
  90. Lambda (const Heis_Chain& RefChain, const Heis_Base& base); // constructor, putting I's to lowest-energy config
  91. // consistent with Heis_Base configuration for chain RefChain
  92. Lambda& operator= (const Lambda& RefConfig);
  93. inline DP* operator[] (const int i);
  94. inline const DP* operator[] (const int i) const;
  95. ~Lambda();
  96. };
  97. inline DP* Lambda::operator[] (const int i)
  98. {
  99. return lambda[i];
  100. }
  101. inline const DP* Lambda::operator[] (const int i) const
  102. {
  103. return lambda[i];
  104. }
  105. //****************************************************************************
  106. // Objects in class Heis_Bethe_State carry all information about an eigenstate
  107. // Derived classes include XXZ_Bethe_State, XXX_Bethe_State, XXZ_gpd_Bethe_State
  108. // These contain subclass-specific functions and data.
  109. class Heis_Bethe_State {
  110. public:
  111. Heis_Chain chain;
  112. Heis_Base base;
  113. Vect<Vect<int> > Ix2;
  114. Lambda lambda;
  115. Lambda deviation; // string deviations
  116. Lambda BE; // Bethe equation for relevant rapidity, in the form BE = theta - (1/N)\sum ... - \pi I/N = 0
  117. DP diffsq; // sum of squares of rapidity differences in last iteration
  118. int conv; // convergence status
  119. DP dev; // sum of absolute values of string deviations
  120. int iter; // number of iterations necessary for convergence
  121. int iter_Newton; // number of iterations necessary for convergence (Newton method)
  122. DP E; // total energy
  123. int iK; // K = 2.0*PI * iK/Nsites
  124. DP K; // total momentum
  125. DP lnnorm; // ln of norm of reduced Gaudin matrix
  126. std::string label;
  127. public:
  128. Heis_Bethe_State ();
  129. Heis_Bethe_State (const Heis_Bethe_State& RefState); // copy constructor
  130. Heis_Bethe_State (const Heis_Chain& RefChain, int M); // constructor to ground-state configuration
  131. Heis_Bethe_State (const Heis_Chain& RefChain, const Heis_Base& base); // constructor to lowest-energy config with base
  132. virtual ~Heis_Bethe_State () {};
  133. public:
  134. int Charge () { return(base.Mdown); };
  135. void Set_to_Label (std::string label_ref, const Vect<Vect<int> >& OriginIx2);
  136. void Set_Label_from_Ix2 (const Vect<Vect<int> >& OriginIx2);
  137. bool Check_Symmetry (); // checks whether the I's are symmetrically distributed
  138. void Compute_diffsq (); // \sum BE[j][alpha]^2
  139. void Find_Rapidities (bool reset_rapidities); // Finds the rapidities
  140. void Find_Rapidities_Twisted (bool reset_rapidities, DP twist); // Finds the rapidities with twist added to RHS of logBE
  141. void Solve_BAE_bisect (int j, int alpha, DP req_prec, int itermax);
  142. void Iterate_BAE (DP iter_factor); // Finds new set of lambda[j][alpha] from previous one by simple iteration
  143. void Solve_BAE_straight_iter (DP straight_prec, int max_iter_interp, DP iter_factor);
  144. void Solve_BAE_extrap (DP extrap_prec, int max_iter_extrap, DP iter_factor);
  145. void Iterate_BAE_Newton (); // Finds new set of lambda[j][alpha] from previous one by a Newton step
  146. void Solve_BAE_Newton (DP Newton_prec, int max_iter_Newton);
  147. void Solve_BAE_with_silk_gloves (DP silk_prec, int max_iter_silk, DP iter_factor);
  148. void Compute_lnnorm ();
  149. void Compute_Momentum ();
  150. void Compute_All (bool reset_rapidities); // solves BAE, computes E, K and lnnorm
  151. inline bool Set_to_Inner_Skeleton (int iKneeded, const Vect<Vect<int> >& OriginStateIx2)
  152. {
  153. Ix2[0][0] = Ix2[0][1] - 2;
  154. Ix2[0][base.Nrap[0] - 1] = Ix2[0][base.Nrap[0] - 2] + 2;
  155. (*this).Compute_Momentum();
  156. if (base.Nrap[0] == 0) return(false);
  157. if (iKneeded >= iK) Ix2[0][base.Nrap[0]-1] += 2*(iKneeded - iK);
  158. else Ix2[0][0] += 2*(iKneeded - iK);
  159. if (Ix2[0][0] < base.Ix2_min[0] || Ix2[0][base.Nrap[0]-1] > base.Ix2_max[0]) return(false);
  160. (*this).Set_Label_from_Ix2 (OriginStateIx2);
  161. return(true);
  162. }
  163. void Set_to_Outer_Skeleton (const Vect<Vect<int> >& OriginStateIx2) {
  164. Ix2[0][0] = base.Ix2_min[0] - 4;
  165. Ix2[0][base.Nrap[0]-1] = base.Ix2_max[0] + 4;
  166. (*this).Set_Label_from_Ix2 (OriginStateIx2);
  167. };
  168. void Set_to_Closest_Matching_Ix2_fixed_Base (const Heis_Bethe_State& StateToMatch); // defined in Heis.cc
  169. // Virtual functions, all defined in the derived classes
  170. public:
  171. virtual void Set_Free_lambdas() { ABACUSerror("Heis_Bethe_State::..."); } // sets the rapidities to solutions of BAEs without scattering terms
  172. virtual bool Check_Admissibility(char option) { ABACUSerror("Heis_Bethe_State::..."); return(false); }
  173. // verifies that we don't have a symmetrical Ix2 config with a Ix2 == 0 for a string of even length >= 2.
  174. virtual void Compute_BE (int j, int alpha) { ABACUSerror("Heis_Bethe_State::..."); }
  175. virtual void Compute_BE () { ABACUSerror("Heis_Bethe_State::..."); }
  176. virtual DP Iterate_BAE(int i, int alpha) { ABACUSerror("Heis_Bethe_State::..."); return(0.0);}
  177. virtual bool Check_Rapidities() { ABACUSerror("Heis_Bethe_State::..."); return(false); }
  178. virtual DP String_delta () { ABACUSerror("Heis_Bethe_State::..."); return(0.0); }
  179. virtual void Compute_Energy () { ABACUSerror("Heis_Bethe_State::..."); }
  180. virtual void Build_Reduced_Gaudin_Matrix (SQMat<std::complex<DP> >& Gaudin_Red) { ABACUSerror("Heis_Bethe_State::..."); }
  181. };
  182. inline bool Is_Inner_Skeleton (Heis_Bethe_State& State) {
  183. return (State.base.Nrap[0] >= 2 && (State.Ix2[0][0] == State.Ix2[0][1] - 2 || State.Ix2[0][State.base.Nrap[0]-1] == State.Ix2[0][State.base.Nrap[0]-2] + 2));
  184. };
  185. inline bool Is_Outer_Skeleton (Heis_Bethe_State& State) {
  186. return (State.Ix2[0][0] == State.base.Ix2_min[0] - 4 && State.Ix2[0][State.base.Nrap[0]-1] == State.base.Ix2_max[0] + 4);
  187. };
  188. inline bool Force_Descent (char whichDSF, Heis_Bethe_State& ScanState, Heis_Bethe_State& RefState, int desc_type_required, int iKmod, DP Chem_Pot)
  189. {
  190. bool force_descent = false;
  191. // Force descent for all DSFs if we're at K = 0 or PI and not conserving momentum upon descent:
  192. if (desc_type_required > 8 && (2*(ScanState.iK - RefState.iK) % iKmod == 0)) force_descent = true; // type_req > 8 means that we don't conserve momentum
  193. return(force_descent);
  194. }
  195. std::ostream& operator<< (std::ostream& s, const Heis_Bethe_State& state);
  196. //****************************************************************************
  197. // Objects in class XXZ_Bethe_State carry all extra information pertaining to XXZ gapless
  198. class XXZ_Bethe_State : public Heis_Bethe_State {
  199. public:
  200. Lambda sinhlambda;
  201. Lambda coshlambda;
  202. Lambda tanhlambda;
  203. public:
  204. XXZ_Bethe_State ();
  205. XXZ_Bethe_State (const XXZ_Bethe_State& RefState); // copy constructor
  206. XXZ_Bethe_State (const Heis_Chain& RefChain, int M); // constructor to ground-state configuration
  207. XXZ_Bethe_State (const Heis_Chain& RefChain, const Heis_Base& base); // constructor to lowest-energy config with base
  208. public:
  209. XXZ_Bethe_State& operator= (const XXZ_Bethe_State& RefState);
  210. public:
  211. void Set_Free_lambdas(); // sets the rapidities to solutions of BAEs without scattering terms
  212. void Compute_sinhlambda();
  213. void Compute_coshlambda();
  214. void Compute_tanhlambda();
  215. bool Check_Admissibility(char option); // verifies that we don't have a symmetrical Ix2 config with a Ix2 == 0 for a string of even length >= 2.
  216. void Compute_BE (int j, int alpha);
  217. void Compute_BE ();
  218. DP Iterate_BAE(int i, int j);
  219. bool Check_Rapidities(); // checks that all rapidities are not nan
  220. DP String_delta ();
  221. void Compute_Energy ();
  222. void Build_Reduced_Gaudin_Matrix (SQMat<std::complex<DP> >& Gaudin_Red);
  223. // XXZ specific functions:
  224. public:
  225. };
  226. XXZ_Bethe_State Add_Particle_at_Center (const XXZ_Bethe_State& RefState);
  227. XXZ_Bethe_State Remove_Particle_at_Center (const XXZ_Bethe_State& RefState);
  228. // Defined in XXZ_Bethe_State.cc
  229. inline DP fbar_XXZ (DP lambda, int par, DP tannzetaover2);
  230. DP Theta_XXZ (DP lambda, int nj, int nk, int parj, int park, DP* tannzetaover2);
  231. DP hbar_XXZ (DP lambda, int n, int par, DP* si_n_anis_over_2);
  232. DP ddlambda_Theta_XXZ (DP lambda, int nj, int nk, int parj, int park, DP* si_n_anis_over_2);
  233. //****************************************************************************
  234. // Objects in class XXX_Bethe_State carry all extra information pertaining to XXX antiferromagnet
  235. class XXX_Bethe_State : public Heis_Bethe_State {
  236. public:
  237. XXX_Bethe_State ();
  238. XXX_Bethe_State (const XXX_Bethe_State& RefState); // copy constructor
  239. XXX_Bethe_State (const Heis_Chain& RefChain, int M); // constructor to ground-state configuration
  240. XXX_Bethe_State (const Heis_Chain& RefChain, const Heis_Base& base); // constructor to lowest-energy config with base
  241. public:
  242. XXX_Bethe_State& operator= (const XXX_Bethe_State& RefState);
  243. public:
  244. void Set_Free_lambdas(); // sets the rapidities to solutions of BAEs without scattering terms
  245. bool Check_Admissibility(char option); // verifies that we don't have a symmetrical Ix2 config with a Ix2 == 0 for a string of even length >= 2.
  246. void Compute_BE (int j, int alpha);
  247. void Compute_BE ();
  248. DP Iterate_BAE(int i, int j);
  249. bool Check_Rapidities(); // checks that all rapidities are not nan
  250. DP String_delta ();
  251. void Compute_Energy ();
  252. void Build_Reduced_Gaudin_Matrix (SQMat<std::complex<DP> >& Gaudin_Red);
  253. // XXX specific functions
  254. public:
  255. bool Check_Finite_rap ();
  256. };
  257. XXX_Bethe_State Add_Particle_at_Center (const XXX_Bethe_State& RefState);
  258. XXX_Bethe_State Remove_Particle_at_Center (const XXX_Bethe_State& RefState);
  259. //****************************************************************************
  260. // Objects in class XXZ_gpd_Bethe_State carry all extra information pertaining to XXZ gapped antiferromagnets
  261. class XXZ_gpd_Bethe_State : public Heis_Bethe_State {
  262. public:
  263. Lambda sinlambda;
  264. Lambda coslambda;
  265. Lambda tanlambda;
  266. public:
  267. XXZ_gpd_Bethe_State ();
  268. XXZ_gpd_Bethe_State (const XXZ_gpd_Bethe_State& RefState); // copy constructor
  269. XXZ_gpd_Bethe_State (const Heis_Chain& RefChain, int M); // constructor to ground-state configuration
  270. XXZ_gpd_Bethe_State (const Heis_Chain& RefChain, const Heis_Base& base); // constructor to lowest-energy config with base
  271. public:
  272. XXZ_gpd_Bethe_State& operator= (const XXZ_gpd_Bethe_State& RefState);
  273. public:
  274. void Set_Free_lambdas(); // sets the rapidities to solutions of BAEs without scattering terms
  275. void Compute_sinlambda();
  276. void Compute_coslambda();
  277. void Compute_tanlambda();
  278. int Weight(); // weight function for contributions cutoff
  279. bool Check_Admissibility(char option); // verifies that we don't have a symmetrical Ix2 config with a Ix2 == 0 for a string of even length >= 2.
  280. void Compute_BE (int j, int alpha);
  281. void Compute_BE ();
  282. DP Iterate_BAE(int i, int j);
  283. void Iterate_BAE_Newton();
  284. bool Check_Rapidities(); // checks that all rapidities are not nan and are in interval ]-PI/2, PI/2]
  285. DP String_delta ();
  286. void Compute_Energy ();
  287. void Build_Reduced_Gaudin_Matrix (SQMat<std::complex<DP> >& Gaudin_Red);
  288. // XXZ_gpd specific functions
  289. public:
  290. };
  291. XXZ_gpd_Bethe_State Add_Particle_at_Center (const XXZ_gpd_Bethe_State& RefState);
  292. XXZ_gpd_Bethe_State Remove_Particle_at_Center (const XXZ_gpd_Bethe_State& RefState);
  293. //***********************************************
  294. // Function declarations
  295. // in M_vs_H.cc
  296. DP Ezero (DP Delta, int N, int M);
  297. DP H_vs_M (DP Delta, int N, int M);
  298. DP HZmin (DP Delta, int N, int M, Vect_DP& Ezero_ref);
  299. int M_vs_H (DP Delta, int N, DP HZ);
  300. DP X_avg (char xyorz, DP Delta, int N, int M);
  301. DP Chemical_Potential (const Heis_Bethe_State& RefState);
  302. DP Particle_Hole_Excitation_Cost (char whichDSF, Heis_Bethe_State& AveragingState);
  303. //DP Sumrule_Factor (char whichDSF, Heis_Bethe_State& RefState, DP Chem_Pot, bool fixed_iK, int iKneeded);
  304. DP Sumrule_Factor (char whichDSF, Heis_Bethe_State& RefState, DP Chem_Pot, int iKmin, int iKmax);
  305. void Evaluate_F_Sumrule (std::string prefix, char whichDSF, const Heis_Bethe_State& RefState, DP Chem_Pot, int iKmin, int iKmax);
  306. std::complex<DP> ln_Sz_ME (XXZ_Bethe_State& A, XXZ_Bethe_State& B);
  307. std::complex<DP> ln_Smin_ME (XXZ_Bethe_State& A, XXZ_Bethe_State& B);
  308. std::complex<DP> ln_Sz_ME (XXX_Bethe_State& A, XXX_Bethe_State& B);
  309. std::complex<DP> ln_Smin_ME (XXX_Bethe_State& A, XXX_Bethe_State& B);
  310. // From Antoine Klauser:
  311. std::complex<DP> ln_Szz_ME (XXX_Bethe_State& A, XXX_Bethe_State& B);
  312. std::complex<DP> ln_Szm_p_Smz_ME (XXX_Bethe_State& A, XXX_Bethe_State& B);
  313. std::complex<DP> ln_Smm_ME (XXX_Bethe_State& A, XXX_Bethe_State& B);
  314. std::complex<DP> ln_Sz_ME (XXZ_gpd_Bethe_State& A, XXZ_gpd_Bethe_State& B);
  315. std::complex<DP> ln_Smin_ME (XXZ_gpd_Bethe_State& A, XXZ_gpd_Bethe_State& B);
  316. DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_Bethe_State& LeftState,
  317. XXZ_Bethe_State& RefState, DP Chem_Pot, std::stringstream& DAT_outfile);
  318. DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXX_Bethe_State& LeftState,
  319. XXX_Bethe_State& RefState, DP Chem_Pot, std::stringstream& DAT_outfile);
  320. DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_gpd_Bethe_State& LeftState,
  321. XXZ_gpd_Bethe_State& RefState, DP Chem_Pot, std::stringstream& DAT_outfile);
  322. // For geometric quench:
  323. std::complex<DP> ln_Overlap (XXX_Bethe_State& A, XXX_Bethe_State& B);
  324. void Scan_Heis_Geometric_Quench (DP Delta, int N_1, int M, long long int base_id_1, long long int type_id_1, long long int id_1,
  325. int N_2, int iKmin, int iKmax, int Max_Secs, bool refine);
  326. } // namespace ABACUS
  327. #endif