runQED.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ######################################################
  2. #
  3. # Fock space Hamiltonian truncation for phi^4 theory in 2 dimensions
  4. # Authors: Slava Rychkov (slava.rychkov@lpt.ens.fr) and Lorenzo Vitale (lorenzo.vitale@epfl.ch)
  5. # December 2014
  6. #
  7. ######################################################
  8. import schwinger
  9. import sys
  10. import scipy
  11. import numpy as np
  12. import time
  13. from scipy.constants import pi
  14. from math import isclose
  15. import matplotlib.pyplot as plt
  16. def main(argv):
  17. #if there are too few arguments, print the right syntax and exit
  18. if len(argv) < 3:
  19. print("python runQED.py <R> <Emax>")
  20. sys.exit(-1)
  21. print("Beginning execution.")
  22. startTime = time.time()
  23. #circle circumference (p.5)
  24. R = float(argv[1])
  25. #maximum energy (compare Eq. 2.26)
  26. Emax = float(argv[2])
  27. #mass
  28. m = 0.
  29. verbose = False
  30. a = schwinger.Schwinger()
  31. a.buildFullBasis(2*pi*R, m, Emax, bcs="antiperiodic")
  32. print(f"Basis size: {a.fullBasis.size}")
  33. if verbose:
  34. print(f"Basis elements: {a.fullBasis}")
  35. #set the file name for saving the generated matrix
  36. fstr = "Emax="+str(a.fullBasis.Emax)+"_L="+str(a.L)
  37. a.buildMatrix()
  38. if verbose:
  39. print("Potential:")
  40. print(f"{a.potential.M.toarray()}")
  41. a.buildBasis(a.fullBasis.Emax)
  42. mass_gap = []
  43. for gval in [1]:# np.arange(1,15,0.5):
  44. computeVacuumEnergy(a,g=gval)
  45. spectrum = a.spectrum()
  46. #print(f"H: {a.H.toarray()}")
  47. print(f"Spectrum: {spectrum}")
  48. print(f"Normalized mass gap: {spectrum[1]/gval}")
  49. mass_gap.append(spectrum[1]/gval)
  50. # plt.xlabel("g")
  51. # plt.ylabel("m/g")
  52. # plt.title("R=1,lmax=5")
  53. # plt.plot(np.arange(1,15,0.5),mass_gap)
  54. # plt.savefig('normalized_mass_gap_vs_g.pdf')
  55. # plt.show()
  56. #for index in np.arange(1,len(spectrum),2):
  57. # assert(isclose(spectrum[index],spectrum[index+1])), f"{spectrum[index]} !={spectrum[index+1]}"
  58. #print(a.h0)
  59. #print(a.fullBasis)
  60. print("Runtime:",time.time()-startTime)
  61. #a.saveMatrix(fstr)
  62. def computeVacuumEnergy(schwinger, g):
  63. """
  64. Parameters
  65. ----------
  66. phi4 : Phi1234
  67. A Phi1234 object initialized with a suitable basis and the matrices
  68. for the various terms in the Hamiltonian.
  69. g : float
  70. Value of the coupling g.
  71. Returns
  72. -------
  73. A float representing the vacuum energy for this set of parameters.
  74. """
  75. sigma = -30.#-30.
  76. neigs = 10
  77. #print(schwinger.h0OffDiag.M.toarray())
  78. schwinger.setcouplings(g)
  79. print(f"Computing raw eigenvalues for g4 = {g}")
  80. schwinger.computeHamiltonian(ren=False)
  81. #print("Hamiltonian:")
  82. #print(schwinger.H.toarray())
  83. schwinger.computeEigval(sigma=sigma, n=neigs, ren=False)
  84. vacuumEnergy = schwinger.vacuumE(ren="raw")
  85. print("Raw vacuum energy: ", vacuumEnergy)
  86. return vacuumEnergy
  87. if __name__ == "__main__":
  88. main(sys.argv)