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.

LiebLin_Tgt0.cc 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: LiebLin_Tgt0.cc
  6. Purpose: Finite temperature correlations for Lieb-Liniger
  7. ***********************************************************/
  8. #include "ABACUS.h"
  9. using namespace std;
  10. using namespace ABACUS;
  11. namespace ABACUS {
  12. DP Entropy_Fixed_Delta (LiebLin_Bethe_State& RefState, int Delta)
  13. {
  14. // This function calculates the discrete entropy of a finite Lieb-Liniger state,
  15. // counting the possible permutations within windows of fixed width.
  16. // We assume that the quantum numbers are ordered.
  17. // Fill in vector of occupancies:
  18. // assume Ix2 are ordered, leave space of Delta on both sides
  19. int nrIs = (RefState.Ix2[RefState.N-1] - RefState.Ix2[0])/2 + 1 + 2*Delta;
  20. Vect<int> occupancy(0, nrIs); // leave space of Delta on both sides
  21. for (int i = 0; i < RefState.N; ++i) occupancy[Delta + (RefState.Ix2[i] -RefState.Ix2[0])/2] = 1;
  22. // Check:
  23. int ncheck = 0;
  24. for (int i = 0; i < nrIs; ++i) if(occupancy[i] == 1) ncheck++;
  25. if (ncheck != RefState.N) {
  26. cout << ncheck << "\t" << RefState.N << endl;
  27. ABACUSerror("Counting q numbers incorrectly in Entropy.");
  28. }
  29. // Define some useful numbers:
  30. Vect_DP oneoverDeltalnchoose(Delta + 1);
  31. for (int i = 0; i <= Delta; ++i) oneoverDeltalnchoose[i] = ln_choose(Delta, i)/Delta;
  32. // Compute entropy:
  33. DP entropy = 0.0;
  34. int np;
  35. for (int i = 0; i < nrIs - Delta; ++i) {
  36. np = 0;
  37. for (int iD = 0; iD < Delta; ++iD) if (occupancy[i + iD] == 1) np++;
  38. entropy += oneoverDeltalnchoose[np];
  39. }
  40. return(entropy);
  41. }
  42. DP Entropy (LiebLin_Bethe_State& RefState, int Delta)
  43. {
  44. // Perform an average of entropies for regulators from Delta to 2Delta:
  45. DP entropysum = 0.0;
  46. for (int ie = 0; ie < Delta; ++ie) entropysum += Entropy_Fixed_Delta (RefState, Delta + ie);
  47. return(entropysum/Delta);
  48. }
  49. DP Entropy (LiebLin_Bethe_State& RefState)
  50. {
  51. int Delta = int(log(RefState.L));
  52. return(Entropy (RefState, Delta));
  53. }
  54. DP Canonical_Free_Energy (LiebLin_Bethe_State& RefState, DP kBT)
  55. {
  56. return(RefState.E - kBT * Entropy (RefState));
  57. }
  58. DP rho_of_lambdaoc_1 (LiebLin_Bethe_State& RefState, DP lambdaoc, DP delta)
  59. {
  60. DP answer = 0.0;
  61. for (int i = 0; i < RefState.N; ++i)
  62. answer += atan((lambdaoc - RefState.lambdaoc[i])/delta + 0.5)
  63. - atan((lambdaoc - RefState.lambdaoc[i])/delta - 0.5);
  64. answer *= 1.0/(PI * delta * RefState.L);
  65. return(answer);
  66. }
  67. DP rho_of_lambdaoc_2 (LiebLin_Bethe_State& RefState, DP lambdaoc, DP delta)
  68. {
  69. DP answer = 0.0;
  70. for (int i = 0; i < RefState.N; ++i)
  71. answer += 1.0/(pow(lambdaoc - RefState.lambdaoc[i], 2.0) + delta*delta);
  72. answer *= delta/(PI * RefState.L);
  73. return(answer);
  74. }
  75. // Better implementation: making use of rediscretized TBA state.
  76. LiebLin_Bethe_State Canonical_Saddle_Point_State (DP c_int, DP L, int N, DP kBT)
  77. {
  78. // This function returns the discretized state minimizing the canonical free energy
  79. // F = E - T S.
  80. // This is obtained by rediscretizing the solution coming from TBA.
  81. // ASSUMPTIONS:
  82. // Periodic boundary conditions (the state which is output is forced to be symmetric Ix2 == -Ix2).
  83. // For zero temperature, return the ground state:
  84. if (fabs(kBT) < 1.0e-4) return(LiebLin_Bethe_State(c_int, L, N));
  85. // Otherwise, return the discretized TBA saddle-point state:
  86. LiebLin_TBA_Solution TBAsol = LiebLin_TBA_Solution_fixed_nbar (c_int, N/L, kBT, 1.0e-4, ABACUS::max(N/10, 10));
  87. LiebLin_Bethe_State spstate = Discretized_LiebLin_Bethe_State (c_int, L, N, TBAsol.rho);
  88. // Explicitly symmetrize:
  89. for (int i = 0; i < N/2; ++i) spstate.Ix2[i] = -spstate.Ix2[N-1-i];
  90. spstate.Compute_All(false);
  91. return(spstate);
  92. }
  93. LiebLin_Bethe_State Add_Particle_at_Center (const LiebLin_Bethe_State& RefState)
  94. {
  95. LiebLin_Bethe_State ReturnState (RefState.c_int, RefState.L, RefState.N + 1);
  96. // Add a quantum number in middle (explicitly: to right of index N/2)
  97. // and shift quantum numbers by half-integer away from added one:
  98. ReturnState.Ix2[RefState.N/2] = RefState.Ix2[RefState.N/2] - 1;
  99. for (int i = 0; i < RefState.N+1; ++i)
  100. ReturnState.Ix2[i + (i >= RefState.N/2)] = RefState.Ix2[i] - 1 + 2*(i >= RefState.N/2);
  101. return(ReturnState);
  102. }
  103. LiebLin_Bethe_State Remove_Particle_at_Center (const LiebLin_Bethe_State& RefState)
  104. {
  105. LiebLin_Bethe_State ReturnState (RefState.c_int, RefState.L, RefState.N - 1);
  106. // Remove midmost and shift quantum numbers by half-integer towards removed one:
  107. for (int i = 0; i < RefState.N-1; ++i)
  108. ReturnState.Ix2[i] = RefState.Ix2[i + (i >= RefState.N/2)] + 1 - 2*(i >= RefState.N/2);
  109. return(ReturnState);
  110. }
  111. } // namespace ABACUS