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_ODSLF.h 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: ABACUS_ODSLF.h
  6. Purpose: Declares lattice spinless fermion classes and functions.
  7. ***********************************************************/
  8. #ifndef ABACUS_ODSLF_H
  9. #define ABACUS_ODSLF_H
  10. #include "ABACUS.h"
  11. namespace ABACUS {
  12. //****************************************************************************
  13. // Objects in class ODSLF_Base are a checked vector containing the number of rapidities of allowable types for a given state
  14. class ODSLF_Base {
  15. public:
  16. int Mdown; // total number of down spins
  17. Vect<int> Nrap; // Nrap[i] contains the number of rapidities of type i, i = 0, Nstrings - 1.
  18. int Nraptot; // total number of strings in this state
  19. Vect<DP> Ix2_infty; // Ix2_infty[i] contains the max of BAE function for the (half-)integer I[i], i = 0, Nstrings - 1.
  20. Vect<int> Ix2_max; // Ix2_max[i] contains the integer part of 2*I_infty, with correct parity for base.
  21. long long int id; // identification number
  22. public:
  23. ODSLF_Base ();
  24. ODSLF_Base (const ODSLF_Base& RefBase); // copy constructor
  25. ODSLF_Base (const Heis_Chain& RefChain, int M); // constructs configuration with all Mdown in one-string of +1 parity
  26. ODSLF_Base (const Heis_Chain& RefChain, const Vect<int>& Nrapidities); // sets to Nrapidities vector, and checks consistency
  27. ODSLF_Base (const Heis_Chain& RefChain, long long int id_ref);
  28. inline int& operator[] (const int i);
  29. inline const int& operator[] (const int i) const;
  30. ODSLF_Base& operator= (const ODSLF_Base& RefBase);
  31. bool operator== (const ODSLF_Base& RefBase);
  32. bool operator!= (const ODSLF_Base& RefBase);
  33. void Compute_Ix2_limits(const Heis_Chain& RefChain); // computes the Ix2_infty and Ix2_max
  34. void Scan_for_Possible_Types (Vect<long long int>& possible_type_id, int& nfound, int base_level, Vect<int>& Nexcitations);
  35. Vect<long long int> Possible_Types (); // returns a vector of possible types
  36. };
  37. inline int& ODSLF_Base::operator[] (const int i)
  38. {
  39. return Nrap[i];
  40. }
  41. inline const int& ODSLF_Base::operator[] (const int i) const
  42. {
  43. return Nrap[i];
  44. }
  45. //****************************************************************************
  46. // Objects in class ODSLF_Ix2_Config carry all the I's of a given state
  47. class ODSLF_Ix2_Config {
  48. public:
  49. int Nstrings;
  50. Vect<int> Nrap;
  51. int Nraptot;
  52. int** Ix2;
  53. public:
  54. ODSLF_Ix2_Config ();
  55. ODSLF_Ix2_Config (const Heis_Chain& RefChain, int M); // constructor, puts I's to ground state
  56. ODSLF_Ix2_Config (const Heis_Chain& RefChain, const ODSLF_Base& base); // constructor, putting I's to lowest-energy config
  57. // consistent with Heis_Base configuration for chain RefChain
  58. ODSLF_Ix2_Config& operator= (const ODSLF_Ix2_Config& RefConfig);
  59. inline int* operator[] (const int i);
  60. inline const int* operator[] (const int i) const;
  61. ~ODSLF_Ix2_Config();
  62. };
  63. inline int* ODSLF_Ix2_Config::operator[] (const int i)
  64. {
  65. return Ix2[i];
  66. }
  67. inline const int* ODSLF_Ix2_Config::operator[] (const int i) const
  68. {
  69. return Ix2[i];
  70. }
  71. std::ostream& operator<< (std::ostream& s, const ODSLF_Ix2_Config& RefConfig);
  72. //****************************************************************************
  73. // Objects in class ODSLF_Lambda carry all rapidities of a state
  74. class ODSLF_Lambda {
  75. private:
  76. int Nstrings;
  77. Vect<int> Nrap;
  78. int Nraptot;
  79. DP** lambda;
  80. public:
  81. ODSLF_Lambda ();
  82. ODSLF_Lambda (const Heis_Chain& RefChain, int M); // constructor, puts all lambda's to zero
  83. ODSLF_Lambda (const Heis_Chain& RefChain, const ODSLF_Base& base); // constructor, putting I's to lowest-energy config
  84. // consistent with Heis_Base configuration for chain RefChain
  85. ODSLF_Lambda& operator= (const ODSLF_Lambda& RefConfig);
  86. inline DP* operator[] (const int i);
  87. inline const DP* operator[] (const int i) const;
  88. ~ODSLF_Lambda();
  89. };
  90. inline DP* ODSLF_Lambda::operator[] (const int i)
  91. {
  92. return lambda[i];
  93. }
  94. inline const DP* ODSLF_Lambda::operator[] (const int i) const
  95. {
  96. return lambda[i];
  97. }
  98. //****************************************************************************
  99. // Objects in class ODSLF_Ix2_Offsets carry Young tableau representations of the Ix2 configurations
  100. class ODSLF_Ix2_Offsets {
  101. public:
  102. ODSLF_Base base;
  103. Vect<Young_Tableau> Tableau; // vector of pointers to tableaux at each level
  104. long long int type_id;
  105. long long int id; // id number of offset
  106. long long int maxid; // max id number allowable
  107. public:
  108. ODSLF_Ix2_Offsets ();
  109. ODSLF_Ix2_Offsets (const ODSLF_Ix2_Offsets& RefOffset); // copy constructor
  110. ODSLF_Ix2_Offsets (const ODSLF_Base& RefBase, long long int req_type_id);
  111. ODSLF_Ix2_Offsets (const ODSLF_Base& RefBase, Vect<int> nparticles); // sets all tableaux to empty ones, with nparticles[] at each level
  112. ODSLF_Ix2_Offsets& operator= (const ODSLF_Ix2_Offsets& RefOffset);
  113. bool operator<= (const ODSLF_Ix2_Offsets& RefOffsets);
  114. bool operator>= (const ODSLF_Ix2_Offsets& RefOffsets);
  115. public:
  116. void Set_to_id (long long int idnr);
  117. void Compute_id ();
  118. void Compute_type_id ();
  119. public:
  120. bool Add_Boxes_From_Lowest (int Nboxes, bool odd_sectors); // adds Nboxes in minimal energy config, all boxes in either even or odd sectors
  121. };
  122. inline long long int ODSLF_Ix2_Offsets_type_id (Vect<int>& nparticles)
  123. {
  124. long long int type_id_here = 0ULL;
  125. for (int i = 0; i < nparticles.size(); ++i)
  126. type_id_here += nparticles[i] * pow_ulli(10ULL, i);
  127. return(type_id_here);
  128. }
  129. //****************************************************************************
  130. // Objects in class ODSLF_Ix2_Offsets_List carry a vector of used Ix2_Offsets
  131. class ODSLF_Ix2_Offsets_List {
  132. public:
  133. int ndef;
  134. Vect<ODSLF_Ix2_Offsets> Offsets;
  135. public:
  136. ODSLF_Ix2_Offsets_List ();
  137. ODSLF_Ix2_Offsets& Return_Offsets (ODSLF_Base& RefBase, Vect<int> nparticles); // returns the Ix2_Offsets corresponding to nparticles[]/base
  138. ODSLF_Ix2_Offsets& Return_Offsets (ODSLF_Base& RefBase, long long int req_type_id);
  139. };
  140. //****************************************************************************
  141. // Objects in class ODSLF_Bethe_State carry all information about an eigenstate
  142. // Derived classes include XXZ_Bethe_State, XXX_Bethe_State, XXZ_gpd_Bethe_State
  143. // These contain subclass-specific functions and data.
  144. class ODSLF_Bethe_State {
  145. public:
  146. Heis_Chain chain;
  147. ODSLF_Base base;
  148. ODSLF_Ix2_Offsets offsets;
  149. ODSLF_Ix2_Config Ix2;
  150. ODSLF_Lambda lambda;
  151. ODSLF_Lambda BE; // Bethe equation for relevant rapidity, in the form BE = theta - (1/N)\sum ... - \pi I/N = 0
  152. DP diffsq; // sum of squares of rapidity differences in last iteration
  153. int conv; // convergence status
  154. int iter; // number of iterations necessary for convergence
  155. int iter_Newton; // number of iterations necessary for convergence (Newton method)
  156. DP E; // total energy
  157. int iK; // K = 2.0*PI * iK/Nsites
  158. DP K; // total momentum
  159. DP lnnorm; // ln of norm of reduced Gaudin matrix
  160. long long int base_id;
  161. long long int type_id;
  162. long long int id;
  163. long long int maxid;
  164. int nparticles;
  165. public:
  166. ODSLF_Bethe_State ();
  167. ODSLF_Bethe_State (const ODSLF_Bethe_State& RefState); // copy constructor
  168. ODSLF_Bethe_State (const ODSLF_Bethe_State& RefState, long long int type_id_ref); // new state with requested type_id
  169. ODSLF_Bethe_State (const Heis_Chain& RefChain, int M); // constructor to ground-state configuration
  170. ODSLF_Bethe_State (const Heis_Chain& RefChain, const ODSLF_Base& base); // constructor to lowest-energy config with base
  171. ODSLF_Bethe_State (const Heis_Chain& RefChain, long long int base_id_ref, long long int type_id_ref);
  172. virtual ~ODSLF_Bethe_State () {};
  173. public:
  174. int Charge () { return(base.Mdown); };
  175. void Set_Ix2_Offsets (const ODSLF_Ix2_Offsets& RefOffset); // sets the Ix2 to given offsets
  176. void Set_to_id (long long int id_ref);
  177. void Set_to_id (long long int id_ref, ODSLF_Bethe_State& RefState);
  178. int Nparticles (); // counts the number of particles in state once Ix2 offsets set (so type_id is correctly set)
  179. bool Check_Symmetry (); // checks whether the I's are symmetrically distributed
  180. void Compute_diffsq (); // \sum BE[j][alpha]^2
  181. void Iterate_BAE (); // Finds new set of lambda[j][alpha] from previous one by simple iteration
  182. void Iterate_BAE_Newton (); // Finds new set of lambda[j][alpha] from previous one by a Newton step
  183. void Find_Rapidities (bool reset_rapidities); // Finds the rapidities
  184. void Find_Rapidities_Twisted (bool reset_rapidities, DP twist); // Finds the rapidities with twist added to RHS of logBE
  185. void BAE_smackdown (DP max_allowed);
  186. void Solve_BAE_smackdown (DP max_allowed, int maxruns);
  187. void Solve_BAE (int j, int alpha, DP req_prec, int itermax);
  188. void Solve_BAE_interp (DP interp_prec, int max_iter_interp);
  189. void Solve_BAE_straight_iter (DP interp_prec, int max_iter_interp);
  190. void Solve_BAE_Newton (DP Newton_prec, int max_iter_Newton);
  191. void Compute_lnnorm ();
  192. void Compute_Momentum ();
  193. void Compute_All (bool reset_rapidities); // solves BAE, computes E, K and lnnorm
  194. bool Boost_Momentum (int iKboost);
  195. // Virtual functions, all defined in the derived classes
  196. public:
  197. virtual void Set_Free_lambdas() { ABACUSerror("ODSLF_Bethe_State::..."); } // sets the rapidities to solutions of BAEs without scattering terms
  198. virtual bool Check_Admissibility(char option) { ABACUSerror("ODSLF_Bethe_State::..."); return(false); }
  199. // verifies that we don't have a symmetrical Ix2 config with a Ix2 == 0 for a string of even length >= 2.
  200. virtual void Compute_BE (int j, int alpha) { ABACUSerror("ODSLF_Bethe_State::..."); }
  201. virtual void Compute_BE () { ABACUSerror("ODSLF_Bethe_State::..."); }
  202. virtual DP Iterate_BAE(int i, int alpha) { ABACUSerror("ODSLF_Bethe_State::..."); return(0.0);}
  203. virtual bool Check_Rapidities() { ABACUSerror("ODSLF_Bethe_State::..."); return(false); }
  204. virtual void Compute_Energy () { ABACUSerror("ODSLF_Bethe_State::..."); }
  205. virtual void Build_Reduced_Gaudin_Matrix (SQMat<std::complex<DP> >& Gaudin_Red) { ABACUSerror("ODSLF_Bethe_State::..."); }
  206. };
  207. inline bool Force_Descent (char whichDSF, ODSLF_Bethe_State& ScanState, ODSLF_Bethe_State& RefState, int desc_type_required, int iKmod, DP Chem_Pot)
  208. {
  209. ABACUSerror("Need to implement Force_Descent properly for ODSLF.");
  210. bool force_descent = false;
  211. // Force descent if quantum nr distribution is symmetric:
  212. if (RefState.Check_Symmetry()) force_descent = true;
  213. return(force_descent);
  214. }
  215. std::ostream& operator<< (std::ostream& s, const ODSLF_Bethe_State& state);
  216. //****************************************************************************
  217. // Objects in class XXZ_Bethe_State carry all extra information pertaining to XXZ gapless
  218. class ODSLF_XXZ_Bethe_State : public ODSLF_Bethe_State {
  219. public:
  220. ODSLF_Lambda sinhlambda;
  221. ODSLF_Lambda coshlambda;
  222. ODSLF_Lambda tanhlambda;
  223. public:
  224. ODSLF_XXZ_Bethe_State ();
  225. ODSLF_XXZ_Bethe_State (const ODSLF_XXZ_Bethe_State& RefState); // copy constructor
  226. ODSLF_XXZ_Bethe_State (const Heis_Chain& RefChain, int M); // constructor to ground-state configuration
  227. ODSLF_XXZ_Bethe_State (const Heis_Chain& RefChain, const ODSLF_Base& base); // constructor to lowest-energy config with base
  228. ODSLF_XXZ_Bethe_State (const Heis_Chain& RefChain, long long int base_id_ref, long long int type_id_ref); // constructor to lowest-energy config with bas
  229. public:
  230. ODSLF_XXZ_Bethe_State& operator= (const ODSLF_XXZ_Bethe_State& RefState);
  231. public:
  232. void Set_Free_lambdas(); // sets the rapidities to solutions of BAEs without scattering terms
  233. void Compute_sinhlambda();
  234. void Compute_coshlambda();
  235. void Compute_tanhlambda();
  236. 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.
  237. void Compute_BE (int j, int alpha);
  238. void Compute_BE ();
  239. DP Iterate_BAE(int i, int j);
  240. bool Check_Rapidities(); // checks that all rapidities are not nan
  241. void Compute_Energy ();
  242. void Build_Reduced_Gaudin_Matrix (SQMat<std::complex<DP> >& Gaudin_Red);
  243. // XXZ specific functions:
  244. public:
  245. };
  246. //****************************************************************************
  247. /*
  248. // Objects in class ODSLF_XXX_Bethe_State carry all extra information pertaining to XXX antiferromagnet
  249. class ODSLF_XXX_Bethe_State : public ODSLF_Bethe_State {
  250. public:
  251. ODSLF_XXX_Bethe_State ();
  252. ODSLF_XXX_Bethe_State (const ODSLF_XXX_Bethe_State& RefState); // copy constructor
  253. ODSLF_XXX_Bethe_State (const Heis_Chain& RefChain, int M); // constructor to ground-state configuration
  254. ODSLF_XXX_Bethe_State (const Heis_Chain& RefChain, const ODSLF__Base& base); // constructor to lowest-energy config with base
  255. ODSLF_XXX_Bethe_State (const Heis_Chain& RefChain, long long int base_id_ref, long long int type_id_ref); // constructor to lowest-energy config with base
  256. public:
  257. ODSLF_XXX_Bethe_State& operator= (const ODSLF_XXX_Bethe_State& RefState);
  258. public:
  259. void Set_Free_lambdas(); // sets the rapidities to solutions of BAEs without scattering terms
  260. 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.
  261. void Compute_BE (int j, int alpha);
  262. void Compute_BE ();
  263. DP Iterate_BAE(int i, int j);
  264. bool Check_Rapidities(); // checks that all rapidities are not nan
  265. void Compute_Energy ();
  266. //void Compute_Momentum ();
  267. void Build_Reduced_Gaudin_Matrix (SQMat<std::complex<DP> >& Gaudin_Red);
  268. // XXX specific functions
  269. public:
  270. bool Check_Finite_rap ();
  271. };
  272. */
  273. //****************************************************************************
  274. /*
  275. // Objects in class ODSLF_XXZ_gpd_Bethe_State carry all extra information pertaining to XXZ gapped antiferromagnets
  276. class ODSLF_XXZ_gpd_Bethe_State : public ODSLF__Bethe_State {
  277. public:
  278. Lambda sinlambda;
  279. Lambda coslambda;
  280. Lambda tanlambda;
  281. public:
  282. ODSLF_XXZ_gpd_Bethe_State ();
  283. ODSLF_XXZ_gpd_Bethe_State (const ODSLF_XXZ_gpd_Bethe_State& RefState); // copy constructor
  284. ODSLF_XXZ_gpd_Bethe_State (const Heis_Chain& RefChain, int M); // constructor to ground-state configuration
  285. ODSLF_XXZ_gpd_Bethe_State (const Heis_Chain& RefChain, const ODSLF_Base& base); // constructor to lowest-energy config with base
  286. ODSLF_XXZ_gpd_Bethe_State (const Heis_Chain& RefChain, long long int base_id_ref, long long int type_id_ref); // constructor to lowest-energy config with base
  287. public:
  288. ODSLF_XXZ_gpd_Bethe_State& operator= (const ODSLF_XXZ_gpd_Bethe_State& RefState);
  289. public:
  290. void Set_Free_lambdas(); // sets the rapidities to solutions of BAEs without scattering terms
  291. void Compute_sinlambda();
  292. void Compute_coslambda();
  293. void Compute_tanlambda();
  294. int Weight(); // weight function for contributions cutoff
  295. 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.
  296. void Compute_BE (int j, int alpha);
  297. void Compute_BE ();
  298. DP Iterate_BAE(int i, int j);
  299. void Iterate_BAE_Newton();
  300. bool Check_Rapidities(); // checks that all rapidities are not nan and are in interval ]-PI/2, PI/2]
  301. void Compute_Energy ();
  302. //void Compute_Momentum ();
  303. void Build_Reduced_Gaudin_Matrix (SQMat<std::complex<DP> >& Gaudin_Red);
  304. // XXZ_gpd specific functions
  305. public:
  306. };
  307. */
  308. //***********************************************
  309. // Function declarations
  310. /*
  311. // in M_vs_H.cc
  312. DP Ezero (DP Delta, int N, int M);
  313. DP H_vs_M (DP Delta, int N, int M);
  314. DP HZmin (DP Delta, int N, int M, Vect_DP& Ezero_ref);
  315. int M_vs_H (DP Delta, int N, DP HZ);
  316. DP X_avg (char xyorz, DP Delta, int N, int M);
  317. */
  318. DP Chemical_Potential (const ODSLF_Bethe_State& RefState);
  319. DP Sumrule_Factor (char whichDSF, ODSLF_Bethe_State& RefState, DP Chem_Pot, int iKmin, int iKmax);
  320. void Evaluate_F_Sumrule (std::string prefix, char whichDSF, const ODSLF_Bethe_State& RefState, DP Chem_Pot, int iKmin, int iKmax);
  321. std::complex<DP> ln_Sz_ME (ODSLF_XXZ_Bethe_State& A, ODSLF_XXZ_Bethe_State& B);
  322. std::complex<DP> ln_Smin_ME (ODSLF_XXZ_Bethe_State& A, ODSLF_XXZ_Bethe_State& B);
  323. DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, ODSLF_XXZ_Bethe_State& LeftState,
  324. ODSLF_XXZ_Bethe_State& RefState, DP Chem_Pot, std::stringstream& DAT_outfile);
  325. } // namespace ABACUS
  326. #endif