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_Usage_Example_Heis.cc 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS++ library.
  3. Copyright (c) J.-S. Caux
  4. -----------------------------------------------------------
  5. File: ABACUS_Usage_Example_Heis.cc
  6. Purpose: illustrates basic use of ABACUS for spin chains.
  7. ***********************************************************/
  8. #include "ABACUS.h"
  9. using namespace std;
  10. using namespace JSC;
  11. int main()
  12. {
  13. clock_t StartTime = clock();
  14. // Refer to include/ABACUS_Heis.h for all class definitions
  15. // and to src/HEIS/ for the actual implementations.
  16. // Set basic system parameters:
  17. DP Delta = 1.0; // anisotropy
  18. int N = 64; // chain length
  19. int M = 32; // number of downturned spins; must be <= N/2 (on or above equator)
  20. // Define the chain: J, Delta, h, Nsites
  21. Heis_Chain chain(1.0, Delta, 0.0, N);
  22. // The Heis_Chain class so constructed contains information about all types of strings:
  23. cout << "Delta = " << Delta << endl << "Possible string lengths and parities: ";
  24. for (int j = 0; j < chain.Nstrings; ++j)
  25. cout << "(" << chain.Str_L[j] << ", " << chain.par[j] << ")" << "\t";
  26. cout << endl;
  27. // Constructing a Bethe state: start with the ground state for simplicity.
  28. // Define the base: chain, Mdown
  29. // A base by definition represents a partition of the M down spins into different strings.
  30. Heis_Base gbase(chain, M); // This puts all the M down spins into one-strings.
  31. // Define the ground state
  32. //XXZ_Bethe_State gstate(chain, gbase); // Use this constructor for 0 < Delta < 1
  33. XXX_Bethe_State gstate(chain, gbase); // Use this constructor for Delta == 1
  34. //XXZ_gpd_Bethe_State gstate(chain, gbase); // Use this constructor for Delta > 1.
  35. // Anisotropies Delta < 0 are not separately implemented.
  36. // The assignment operator is overloaded for Bethe states:
  37. XXX_Bethe_State gstate2 = gstate; // copies all data of gstate into new object gstate2
  38. // Compute everything about the ground state
  39. gstate.Compute_All(true);
  40. // Output information about the state
  41. cout << gstate << endl;
  42. // Now define some excited state.
  43. // First method:
  44. // Start with defining a base using a base constructor with a vector of
  45. // numbers of rapidities of each type as argument:
  46. // First define Nrapidities vector:
  47. Vect<int> Nrapidities(0, chain.Nstrings);
  48. // Assigning the numbers that follow, you have to ensure (yourself!) that
  49. // the \sum_j M_j n_j = M (where n_j is the length of type j).
  50. Nrapidities[0] = M-2; // number of one-strings
  51. Nrapidities[1] = 1; // one two-string
  52. // Define the base:
  53. Heis_Base ebase(chain, Nrapidities);
  54. // Once the base is defined, the limiting quantum numbers are automatically computed:
  55. cout << "ebase defined, data is (Mdown, Nrap, Nraptot, Ix2_infty, Ix2_min, Ix2_max, baselabel):"
  56. << ebase.Mdown << endl << ebase.Nrap << endl << ebase.Nraptot << endl
  57. << ebase.Ix2_infty << endl
  58. << ebase.Ix2_min << endl << ebase.Ix2_max << endl << ebase.baselabel << endl;
  59. // An excited state can then be defined using this new base:
  60. XXX_Bethe_State estate(chain, ebase);
  61. // Individual quantum numbers can be manipulated: this will NOT update the
  62. // state label or verify range of Ix2
  63. estate.Ix2[0][0] = M+1;
  64. estate.Compute_All(true);
  65. cout << endl << "estate: " << estate << endl;
  66. // Second method of constructing a base:
  67. Heis_Base ebase2(chain, "31"); // This is another constructor for all rapidities in one-strings
  68. //Heis_Base ebase(chain, "29x1y1"); // one two-string (XXX)
  69. // Construct a new Bethe state
  70. XXX_Bethe_State estateref (chain, ebase2); // defaults to the lowest-energy state for this base
  71. XXX_Bethe_State estate2 (chain, ebase2); // yet another state
  72. // Setting a state to a given label:
  73. // The base of estate must coincide with the base in label. Label is relative to estateref.Ix2.
  74. estate2.Set_to_Label ("31_1_nh", estateref.Ix2);
  75. estate2.Compute_All(true);
  76. cout << "estate2: " << estate2 << endl;
  77. // Energy and momentum of the states:
  78. cout << "Energy and momentum of states:" << endl;
  79. cout << "gstate.E = " << gstate.E << "\testate.E = " << estate.E << endl;
  80. cout << "Excitation energy = estate.E - gstate.E = " << estate.E - gstate.E << endl;
  81. cout << "Excitation momentum (mod 2 pi) = estate.K - gstate.K = " << estate.K - gstate.K << endl;
  82. // Computing matrix elements:
  83. // CAREFUL: magnetizations must be consistent with operator (error is flagged).
  84. cout << "Matrix elements: " << endl;
  85. // The logarithm of the matrix elements are computed as complex numbers:
  86. cout << "ln_Sz (gstate, estate) = " << ln_Sz_ME (gstate, estate) << endl;
  87. // The other possible matrix element call is for the Smin matrix element,
  88. cout << "ln_Smin (gstate, estate2) = " << ln_Smin_ME (gstate, estate2) << endl;
  89. clock_t StopTime = clock();
  90. //cout << "Total time: " << (StopTime - StartTime)/*/CLOCKS_PER_SEC*/ << " hundreths of a second."
  91. cout << "Total time: " << DP(StopTime - StartTime)/CLOCKS_PER_SEC << " seconds."
  92. << endl;
  93. return(0);
  94. }