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.

Base.cc 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: src/BETHE/Base.cc
  6. Purpose: defines functions in Base class,
  7. providing a unified base object for all
  8. Bethe Ansatz integrable models.
  9. ***********************************************************/
  10. #include "ABACUS.h"
  11. using namespace std;
  12. namespace ABACUS {
  13. // Function definitions: class Base
  14. Base::Base () : Charge(0), Nrap(Vect<int>()), Nraptot(0), Ix2_infty(Vect<DP>()),
  15. Ix2_max(Vect<int>()), id(0LL) {}
  16. Base::Base (int N) : Charge(N), Nrap(Vect<int>(N,1)), Nraptot(N), Ix2_infty(Vect<DP>(1.0e+100,1)),
  17. Ix2_max(Vect<int>(LONG_LONG_MAX, 1)), id(N) {}
  18. Base::Base (const Base& RefBase) // copy constructor
  19. : Charge(RefBase.Charge), Nrap(Vect<int>(RefBase.Nrap.size())), Nraptot(RefBase.Nraptot),
  20. Ix2_infty(Vect<DP>(RefBase.Ix2_infty.size())), Ix2_max(Vect<int>(RefBase.Ix2_max.size())), id(RefBase.id)
  21. {
  22. for (int i = 0; i < Nrap.size(); ++i) {
  23. Nrap[i] = RefBase.Nrap[i];
  24. Ix2_infty[i] = RefBase.Ix2_infty[i];
  25. Ix2_max[i] = RefBase.Ix2_max[i];
  26. }
  27. }
  28. /*
  29. // DEPRECATED
  30. Base::Base (const Heis_Chain& RefChain, int M)
  31. : Charge(M), Nrap(Vect<int>(RefChain.Nstrings)), Nraptot(0), Ix2_infty(Vect<DP>(RefChain.Nstrings)), Ix2_max(Vect<int>(RefChain.Nstrings))
  32. {
  33. for (int i = 0; i < RefChain.Nstrings; ++i) Nrap[i] = 0;
  34. Nrap[0] = M;
  35. Nraptot = 0;
  36. for (int i = 0; i < RefChain.Nstrings; ++i) Nraptot += Nrap[i];
  37. // The id of this is zero by definition
  38. id = 0LL;
  39. // Now compute the Ix2_infty numbers
  40. (*this).Compute_Ix2_limits(RefChain);
  41. }
  42. */
  43. Base::Base (const Heis_Chain& RefChain, const Vect<int>& Nrapidities)
  44. : Charge(0), Nrap(Nrapidities), Nraptot(0), Ix2_infty(Vect<DP>(RefChain.Nstrings)), Ix2_max(Vect<int>(RefChain.Nstrings)),
  45. id (0LL)
  46. {
  47. // Check consistency of Nrapidities vector with RefChain
  48. //if (RefChain.Nstrings != Nrapidities.size()) cout << "error: Nstrings = " << RefChain.Nstrings << "\tNrap.size = " << Nrapidities.size() << endl;
  49. if (RefChain.Nstrings != Nrapidities.size()) ABACUSerror("Incompatible Nrapidities vector used in Base constructor.");
  50. int Mcheck = 0;
  51. for (int i = 0; i < RefChain.Nstrings; ++i) Mcheck += RefChain.Str_L[i] * Nrap[i];
  52. Charge = Mcheck;
  53. Nraptot = 0;
  54. for (int i = 0; i < RefChain.Nstrings; ++i) Nraptot += Nrap[i];
  55. // Compute id
  56. id += Nrapidities[0];
  57. long long int factor = 100000LL;
  58. for (int i = 1; i < RefChain.Nstrings; ++i) {
  59. id += factor * Nrapidities[i];
  60. factor *= 100LL;
  61. }
  62. // Now compute the Ix2_infty numbers
  63. (*this).Compute_Ix2_limits(RefChain);
  64. }
  65. Base::Base (const Heis_Chain& RefChain, long long int id_ref)
  66. : Charge(0), Nrap(Vect<int>(RefChain.Nstrings)), Nraptot(0), Ix2_infty(Vect<DP>(RefChain.Nstrings)), Ix2_max(Vect<int>(RefChain.Nstrings)),
  67. id (id_ref)
  68. {
  69. // Build Nrapidities vector from id_ref
  70. long long int factor = pow_ulli (10LL, 2* RefChain.Nstrings + 1);
  71. long long int id_eff = id_ref;
  72. for (int i = 0; i < RefChain.Nstrings - 1; ++i) {
  73. Nrap[RefChain.Nstrings - 1 - i] = id_eff/factor;
  74. id_eff -= factor * Nrap[RefChain.Nstrings - 1 - i];
  75. factor /= 100LL;
  76. }
  77. Nrap[0] = id_eff;
  78. //id = id_ref;
  79. //cout << "In Base constructor: id_ref = " << id_ref << " and Nrapidities = " << Nrap << endl;
  80. // Check consistency of Nrapidities vector with RefChain
  81. //if (RefChain.Nstrings != Nrap.size()) ABACUSerror("Incompatible Nrapidities vector used in Base constructor.");
  82. int Mcheck = 0;
  83. for (int i = 0; i < RefChain.Nstrings; ++i) Mcheck += RefChain.Str_L[i] * Nrap[i];
  84. Charge = Mcheck;
  85. Nraptot = 0;
  86. for (int i = 0; i < RefChain.Nstrings; ++i) Nraptot += Nrap[i];
  87. // Now compute the Ix2_infty numbers
  88. (*this).Compute_Ix2_limits(RefChain);
  89. }
  90. Base& Base::operator= (const Base& RefBase)
  91. {
  92. if (this != & RefBase) {
  93. Charge = RefBase.Charge;
  94. Nrap = RefBase.Nrap;
  95. Nraptot = RefBase.Nraptot;
  96. Ix2_infty = RefBase.Ix2_infty;
  97. Ix2_max = RefBase.Ix2_max;
  98. id = RefBase.id;
  99. }
  100. return(*this);
  101. }
  102. bool Base::operator== (const Base& RefBase)
  103. {
  104. bool answer = (Nrap == RefBase.Nrap);
  105. return (answer);
  106. }
  107. bool Base::operator!= (const Base& RefBase)
  108. {
  109. bool answer = (Nrap != RefBase.Nrap);
  110. return (answer);
  111. }
  112. void Base::Compute_Ix2_limits (const Heis_Chain& RefChain)
  113. {
  114. if ((RefChain.Delta > 0.0) && (RefChain.Delta < 1.0)) {
  115. // Compute the Ix2_infty numbers
  116. DP sum1 = 0.0;
  117. DP sum2 = 0.0;
  118. for (int j = 0; j < RefChain.Nstrings; ++j) {
  119. sum1 = 0.0;
  120. for (int k = 0; k < RefChain.Nstrings; ++k) {
  121. sum2 = 0.0;
  122. sum2 += (RefChain.Str_L[j] == RefChain.Str_L[k]) ? 0.0 : 2.0 * atan(tan(0.25 * PI * (1.0 + RefChain.par[j] * RefChain.par[k])
  123. - 0.5 * fabs(RefChain.Str_L[j] - RefChain.Str_L[k]) * RefChain.anis));
  124. sum2 += 2.0 * atan(tan(0.25 * PI * (1.0 + RefChain.par[j] * RefChain.par[k])
  125. - 0.5 * (RefChain.Str_L[j] + RefChain.Str_L[k]) * RefChain.anis));
  126. for (int a = 1; a < ABACUS::min(RefChain.Str_L[j], RefChain.Str_L[k]); ++a)
  127. sum2 += 2.0 * 2.0 * atan(tan(0.25 * PI * (1.0 + RefChain.par[j] * RefChain.par[k])
  128. - 0.5 * (fabs(RefChain.Str_L[j] - RefChain.Str_L[k]) + 2.0*a) * RefChain.anis));
  129. sum1 += (Nrap[k] - ((j == k) ? 1 : 0)) * sum2;
  130. }
  131. Ix2_infty[j] = (1.0/PI) * fabs(RefChain.Nsites * 2.0 * atan(tan(0.25 * PI * (1.0 + RefChain.par[j])
  132. - 0.5 * RefChain.Str_L[j] * RefChain.anis)) - sum1);
  133. } // The Ix2_infty are now set.
  134. // Now compute the Ix2_max limits
  135. for (int j = 0; j < RefChain.Nstrings; ++j) {
  136. Ix2_max[j] = int(floor(Ix2_infty[j])); // sets basic integer
  137. // Reject formally infinite rapidities (i.e. if Delta is root of unity)
  138. //cout << "Ix2_infty - Ix2_max = " << Ix2_infty[j] - Ix2_max[j] << endl;
  139. //if (Ix2_infty[j] == Ix2_max[j]) {
  140. //Ix2_max[j] -= 2;
  141. //}
  142. // If Nrap is even, Ix2_max must be odd. If odd, then even.
  143. if (!((Nrap[j] + Ix2_max[j]) % 2)) Ix2_max[j] -= 1;
  144. while (Ix2_max[j] > RefChain.Nsites) {
  145. Ix2_max[j] -= 2;
  146. }
  147. }
  148. } // if XXZ gapless
  149. else if (RefChain.Delta == 1.0) {
  150. // Compute the Ix2_infty numbers
  151. int sum1 = 0;
  152. for (int j = 0; j < RefChain.Nstrings; ++j) {
  153. sum1 = 0;
  154. for (int k = 0; k < RefChain.Nstrings; ++k) {
  155. sum1 += Nrap[k] * (2 * ABACUS::min(RefChain.Str_L[j], RefChain.Str_L[k]) - ((j == k) ? 1 : 0));
  156. }
  157. //Ix2_infty[j] = (RefChain.Nsites - 1.0 + 2.0 * RefChain.Str_L[j] - sum1);
  158. Ix2_infty[j] = (RefChain.Nsites + 1.0 - sum1); // to get counting right...
  159. } // The Ix2_infty are now set.
  160. // Now compute the Ix2_max limits
  161. for (int j = 0; j < RefChain.Nstrings; ++j) {
  162. Ix2_max[j] = int(floor(Ix2_infty[j])); // sets basic integer
  163. // Give the correct parity to Ix2_max
  164. // If Nrap is even, Ix2_max must be odd. If odd, then even.
  165. if (!((Nrap[j] + Ix2_max[j]) % 2)) Ix2_max[j] -= 1;
  166. // If Ix2_max equals Ix2_infty, we reduce it by 2:
  167. if (Ix2_max[j] == int(Ix2_infty[j])) Ix2_max[j] -= 2;
  168. while (Ix2_max[j] > RefChain.Nsites) {
  169. Ix2_max[j] -= 2;
  170. }
  171. }
  172. } // if XXX AFM
  173. else if (RefChain.Delta > 1.0) {
  174. // Compute the Ix2_infty numbers
  175. int sum1 = 0;
  176. for (int j = 0; j < RefChain.Nstrings; ++j) {
  177. sum1 = 0;
  178. for (int k = 0; k < RefChain.Nstrings; ++k) {
  179. sum1 += Nrap[k] * (2 * ABACUS::min(RefChain.Str_L[j], RefChain.Str_L[k]) - ((j == k) ? 1 : 0));
  180. }
  181. Ix2_infty[j] = (RefChain.Nsites - 1 + 2 * RefChain.Str_L[j] - sum1);
  182. } // The Ix2_infty are now set.
  183. // Now compute the Ix2_max limits
  184. for (int j = 0; j < RefChain.Nstrings; ++j) {
  185. Ix2_max[j] = int(floor(Ix2_infty[j])); // sets basic integer
  186. // Give the correct parity to Ix2_max
  187. // If Nrap is even, Ix2_max must be odd. If odd, then even.
  188. if (!((Nrap[j] + Ix2_max[j]) % 2)) Ix2_max[j] -= 1;
  189. // If Ix2_max equals Ix2_infty, we reduce it by 2:
  190. //if (Ix2_max[j] == Ix2_infty[j]) Ix2_max[j] -= 2;
  191. while (Ix2_max[j] > RefChain.Nsites) {
  192. Ix2_max[j] -= 2;
  193. }
  194. // Fudge, for strings:
  195. //if (RefChain.Str_L[j] >= 1) Ix2_max[j] += 2;
  196. //Ix2_max[j] += 2;
  197. }
  198. } // if XXZ_gpd
  199. }
  200. } // namespace ABACUS