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 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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())),
  21. Ix2_max(Vect<int>(RefBase.Ix2_max.size())), id(RefBase.id)
  22. {
  23. for (int i = 0; i < Nrap.size(); ++i) {
  24. Nrap[i] = RefBase.Nrap[i];
  25. Ix2_infty[i] = RefBase.Ix2_infty[i];
  26. Ix2_max[i] = RefBase.Ix2_max[i];
  27. }
  28. }
  29. Base::Base (const Heis_Chain& RefChain, const Vect<int>& Nrapidities)
  30. : Charge(0), Nrap(Nrapidities), Nraptot(0), Ix2_infty(Vect<DP>(RefChain.Nstrings)),
  31. Ix2_max(Vect<int>(RefChain.Nstrings)),
  32. id (0LL)
  33. {
  34. // Check consistency of Nrapidities vector with RefChain
  35. if (RefChain.Nstrings != Nrapidities.size())
  36. ABACUSerror("Incompatible Nrapidities vector used in Base constructor.");
  37. int Mcheck = 0;
  38. for (int i = 0; i < RefChain.Nstrings; ++i) Mcheck += RefChain.Str_L[i] * Nrap[i];
  39. Charge = Mcheck;
  40. Nraptot = 0;
  41. for (int i = 0; i < RefChain.Nstrings; ++i) Nraptot += Nrap[i];
  42. // Compute id
  43. id += Nrapidities[0];
  44. long long int factor = 100000LL;
  45. for (int i = 1; i < RefChain.Nstrings; ++i) {
  46. id += factor * Nrapidities[i];
  47. factor *= 100LL;
  48. }
  49. // Now compute the Ix2_infty numbers
  50. (*this).Compute_Ix2_limits(RefChain);
  51. }
  52. Base::Base (const Heis_Chain& RefChain, long long int id_ref)
  53. : Charge(0), Nrap(Vect<int>(RefChain.Nstrings)), Nraptot(0),
  54. Ix2_infty(Vect<DP>(RefChain.Nstrings)), Ix2_max(Vect<int>(RefChain.Nstrings)),
  55. id (id_ref)
  56. {
  57. // Build Nrapidities vector from id_ref
  58. long long int factor = pow_ulli (10LL, 2* RefChain.Nstrings + 1);
  59. long long int id_eff = id_ref;
  60. for (int i = 0; i < RefChain.Nstrings - 1; ++i) {
  61. Nrap[RefChain.Nstrings - 1 - i] = id_eff/factor;
  62. id_eff -= factor * Nrap[RefChain.Nstrings - 1 - i];
  63. factor /= 100LL;
  64. }
  65. Nrap[0] = id_eff;
  66. int Mcheck = 0;
  67. for (int i = 0; i < RefChain.Nstrings; ++i) Mcheck += RefChain.Str_L[i] * Nrap[i];
  68. Charge = Mcheck;
  69. Nraptot = 0;
  70. for (int i = 0; i < RefChain.Nstrings; ++i) Nraptot += Nrap[i];
  71. // Now compute the Ix2_infty numbers
  72. (*this).Compute_Ix2_limits(RefChain);
  73. }
  74. Base& Base::operator= (const Base& RefBase)
  75. {
  76. if (this != & RefBase) {
  77. Charge = RefBase.Charge;
  78. Nrap = RefBase.Nrap;
  79. Nraptot = RefBase.Nraptot;
  80. Ix2_infty = RefBase.Ix2_infty;
  81. Ix2_max = RefBase.Ix2_max;
  82. id = RefBase.id;
  83. }
  84. return(*this);
  85. }
  86. bool Base::operator== (const Base& RefBase)
  87. {
  88. bool answer = (Nrap == RefBase.Nrap);
  89. return (answer);
  90. }
  91. bool Base::operator!= (const Base& RefBase)
  92. {
  93. bool answer = (Nrap != RefBase.Nrap);
  94. return (answer);
  95. }
  96. void Base::Compute_Ix2_limits (const Heis_Chain& RefChain)
  97. {
  98. if ((RefChain.Delta > 0.0) && (RefChain.Delta < 1.0)) {
  99. // Compute the Ix2_infty numbers
  100. DP sum1 = 0.0;
  101. DP sum2 = 0.0;
  102. for (int j = 0; j < RefChain.Nstrings; ++j) {
  103. sum1 = 0.0;
  104. for (int k = 0; k < RefChain.Nstrings; ++k) {
  105. sum2 = 0.0;
  106. sum2 += (RefChain.Str_L[j] == RefChain.Str_L[k]) ? 0.0 :
  107. 2.0 * atan(tan(0.25 * PI * (1.0 + RefChain.par[j] * RefChain.par[k])
  108. - 0.5 * fabs(RefChain.Str_L[j] - RefChain.Str_L[k]) * RefChain.anis));
  109. sum2 += 2.0 * atan(tan(0.25 * PI * (1.0 + RefChain.par[j] * RefChain.par[k])
  110. - 0.5 * (RefChain.Str_L[j] + RefChain.Str_L[k]) * RefChain.anis));
  111. for (int a = 1; a < ABACUS::min(RefChain.Str_L[j], RefChain.Str_L[k]); ++a)
  112. sum2 += 2.0 * 2.0 * atan(tan(0.25 * PI * (1.0 + RefChain.par[j] * RefChain.par[k])
  113. - 0.5 * (fabs(RefChain.Str_L[j] - RefChain.Str_L[k])
  114. + 2.0*a) * RefChain.anis));
  115. sum1 += (Nrap[k] - ((j == k) ? 1 : 0)) * sum2;
  116. }
  117. Ix2_infty[j] = (1.0/PI) * fabs(RefChain.Nsites *
  118. 2.0 * atan(tan(0.25 * PI * (1.0 + RefChain.par[j])
  119. - 0.5 * RefChain.Str_L[j] * RefChain.anis)) - sum1);
  120. } // The Ix2_infty are now set.
  121. // Now compute the Ix2_max limits
  122. for (int j = 0; j < RefChain.Nstrings; ++j) {
  123. Ix2_max[j] = int(floor(Ix2_infty[j])); // sets basic integer
  124. // Reject formally infinite rapidities (i.e. if Delta is root of unity)
  125. //cout << "Ix2_infty - Ix2_max = " << Ix2_infty[j] - Ix2_max[j] << endl;
  126. //if (Ix2_infty[j] == Ix2_max[j]) {
  127. //Ix2_max[j] -= 2;
  128. //}
  129. // If Nrap is even, Ix2_max must be odd. If odd, then even.
  130. if (!((Nrap[j] + Ix2_max[j]) % 2)) Ix2_max[j] -= 1;
  131. while (Ix2_max[j] > RefChain.Nsites) {
  132. Ix2_max[j] -= 2;
  133. }
  134. }
  135. } // if XXZ gapless
  136. else if (RefChain.Delta == 1.0) {
  137. // Compute the Ix2_infty numbers
  138. int sum1 = 0;
  139. for (int j = 0; j < RefChain.Nstrings; ++j) {
  140. sum1 = 0;
  141. for (int k = 0; k < RefChain.Nstrings; ++k) {
  142. sum1 += Nrap[k] * (2 * ABACUS::min(RefChain.Str_L[j], RefChain.Str_L[k]) - ((j == k) ? 1 : 0));
  143. }
  144. //Ix2_infty[j] = (RefChain.Nsites - 1.0 + 2.0 * RefChain.Str_L[j] - sum1);
  145. Ix2_infty[j] = (RefChain.Nsites + 1.0 - sum1); // to get counting right...
  146. } // The Ix2_infty are now set.
  147. // Now compute the Ix2_max limits
  148. for (int j = 0; j < RefChain.Nstrings; ++j) {
  149. Ix2_max[j] = int(floor(Ix2_infty[j])); // sets basic integer
  150. // Give the correct parity to Ix2_max
  151. // If Nrap is even, Ix2_max must be odd. If odd, then even.
  152. if (!((Nrap[j] + Ix2_max[j]) % 2)) Ix2_max[j] -= 1;
  153. // If Ix2_max equals Ix2_infty, we reduce it by 2:
  154. if (Ix2_max[j] == int(Ix2_infty[j])) Ix2_max[j] -= 2;
  155. while (Ix2_max[j] > RefChain.Nsites) {
  156. Ix2_max[j] -= 2;
  157. }
  158. }
  159. } // if XXX AFM
  160. else if (RefChain.Delta > 1.0) {
  161. // Compute the Ix2_infty numbers
  162. int sum1 = 0;
  163. for (int j = 0; j < RefChain.Nstrings; ++j) {
  164. sum1 = 0;
  165. for (int k = 0; k < RefChain.Nstrings; ++k) {
  166. sum1 += Nrap[k] * (2 * ABACUS::min(RefChain.Str_L[j], RefChain.Str_L[k]) - ((j == k) ? 1 : 0));
  167. }
  168. Ix2_infty[j] = (RefChain.Nsites - 1 + 2 * RefChain.Str_L[j] - sum1);
  169. } // The Ix2_infty are now set.
  170. // Now compute the Ix2_max limits
  171. for (int j = 0; j < RefChain.Nstrings; ++j) {
  172. Ix2_max[j] = int(floor(Ix2_infty[j])); // sets basic integer
  173. // Give the correct parity to Ix2_max
  174. // If Nrap is even, Ix2_max must be odd. If odd, then even.
  175. if (!((Nrap[j] + Ix2_max[j]) % 2)) Ix2_max[j] -= 1;
  176. // If Ix2_max equals Ix2_infty, we reduce it by 2:
  177. //if (Ix2_max[j] == Ix2_infty[j]) Ix2_max[j] -= 2;
  178. while (Ix2_max[j] > RefChain.Nsites) {
  179. Ix2_max[j] -= 2;
  180. }
  181. }
  182. } // if XXZ_gpd
  183. }
  184. } // namespace ABACUS