Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Split the Fermi-Hubbard system into two subclasses, that return the G…

…reens function or the correlations as moments.
  • Loading branch information...
commit 823c8a95d09a4ba7318bcba964400e7a46116d35 1 parent 25fcd05
thisrod authored

Showing 2 changed files with 26 additions and 9 deletions. Show diff stats Hide diff stats

  1. +24 7 fermi_hubbard.py
  2. +2 2 fermi_tests.py
31 fermi_hubbard.py
@@ -11,6 +11,7 @@
11 11 class FermiHubbardSystem:
12 12
13 13 # I remember the physical parameters of the Fermi-Hubbard model, and compute the derivatives of the Greens' function and weight.
  14 + # Moments are a subclass responsibility.
14 15
15 16 """Parameters: sites, repulsion, hopping, chemical_potential
16 17
@@ -68,12 +69,7 @@ def noise_required(self, state):
68 69 return range(2*reduce(mul, self.sites))
69 70
70 71 def moments(self, state):
71   - # The moments to be collected are a 2x2 matrix of spin correlation functions, averaged over sites
72   - corr = zeros([2,2])
73   - for i in range(2):
74   - for j in range(2):
75   - corr[i,j] = (state.mean[i,::]*state.mean[j,::]).sum()
76   - return corr / corr.size
  72 + raise 'Subclass responsibility'
77 73
78 74 def initial(self, filling):
79 75 "Answer the state at infinite temperature for given filling"
@@ -81,10 +77,31 @@ def initial(self, filling):
81 77 for i in sites(self.sites):
82 78 id[i*2] = filling
83 79 return Weighting(array([id, id]))
  80 +
  81 +
  82 +class CorrelationFermiHubbard(FermiHubbardSystem):
84 83
85   -
  84 + def moments(self, state):
  85 + # The moments to be collected are a 2x2 matrix of spin correlation functions, averaged over sites
  86 + corr = zeros([2,2])
  87 + for i in range(2):
  88 + for j in range(2):
  89 + corr[i,j] = (state.mean[i,::]*state.mean[j,::]).sum()
  90 + return corr / corr.size
  91 +
  92 +
  93 +class GreensFermiHubbard(FermiHubbardSystem):
86 94
  95 + def moments(self, state):
  96 + return state.mean
  97 +
  98 +def figure_1_system():
  99 + return CorrelationFermiHubbard(sites = [2], repulsion = 2, hopping = 0, chemical_potential = 1)
87 100
  101 +def figure_1_system_g2(matrix):
  102 + return matrix[0,1]/matrix[0,0]**2
  103 +
  104 +
88 105 def noise(sites, timestep):
89 106 return make_diagonal(normal_deviates(sites))/sqrt(timestep)
90 107
4 fermi_tests.py
@@ -36,7 +36,7 @@ class OneDTest(TestCase):
36 36 def setUp(self):
37 37 self.moments = Record(timestep = 1)
38 38 self.noise = DiscreteNoise(timestep = 0.01)
39   - self.system = FermiHubbardSystem(sites = [2], repulsion = 0.5, hopping = 0, chemical_potential = 0)
  39 + self.system = GreensFermiHubbard(sites = [2], repulsion = 0.5, hopping = 0, chemical_potential = 0)
40 40 self.integrator = SemiImplicitIntegrator(self.system, self.noise, timestep = 0.01)
41 41
42 42 def testSolution(self):
@@ -54,7 +54,7 @@ def setUp(self):
54 54 self.sites = [2,2]
55 55 self.moments = Record(timestep = 1)
56 56 self.noise = DiscreteNoise(timestep = 0.01)
57   - self.system = FermiHubbardSystem(sites = self.sites, repulsion = 0.5, hopping = 0, chemical_potential = 0)
  57 + self.system = GreensFermiHubbard(sites = self.sites, repulsion = 0.5, hopping = 0, chemical_potential = 0)
58 58 self.integrator = SemiImplicitIntegrator(self.system, self.noise, timestep = 0.01)
59 59
60 60 def testFilling(self):

0 comments on commit 823c8a9

Please sign in to comment.
Something went wrong with that request. Please try again.