# thisrod/cdprl

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

`…reens function or the correlations as moments.`
• Loading branch information...
1 parent 25fcd05 commit 823c8a95d09a4ba7318bcba964400e7a46116d35 committed Oct 25, 2011
Showing with 26 additions and 9 deletions.
1. +24 −7 fermi_hubbard.py
2. +2 −2 fermi_tests.py
31 fermi_hubbard.py
 @@ -11,6 +11,7 @@ class FermiHubbardSystem: # I remember the physical parameters of the Fermi-Hubbard model, and compute the derivatives of the Greens' function and weight. + # Moments are a subclass responsibility. """Parameters: sites, repulsion, hopping, chemical_potential @@ -68,23 +69,39 @@ def noise_required(self, state): return range(2*reduce(mul, self.sites)) def moments(self, state): - # The moments to be collected are a 2x2 matrix of spin correlation functions, averaged over sites - corr = zeros([2,2]) - for i in range(2): - for j in range(2): - corr[i,j] = (state.mean[i,::]*state.mean[j,::]).sum() - return corr / corr.size + raise 'Subclass responsibility' def initial(self, filling): "Answer the state at infinite temperature for given filling" id = zeros(self.sites*2) for i in sites(self.sites): id[i*2] = filling return Weighting(array([id, id])) + + +class CorrelationFermiHubbard(FermiHubbardSystem): - + def moments(self, state): + # The moments to be collected are a 2x2 matrix of spin correlation functions, averaged over sites + corr = zeros([2,2]) + for i in range(2): + for j in range(2): + corr[i,j] = (state.mean[i,::]*state.mean[j,::]).sum() + return corr / corr.size + + +class GreensFermiHubbard(FermiHubbardSystem): + def moments(self, state): + return state.mean + +def figure_1_system(): + return CorrelationFermiHubbard(sites = [2], repulsion = 2, hopping = 0, chemical_potential = 1) +def figure_1_system_g2(matrix): + return matrix[0,1]/matrix[0,0]**2 + + def noise(sites, timestep): return make_diagonal(normal_deviates(sites))/sqrt(timestep)
4 fermi_tests.py
 @@ -36,7 +36,7 @@ class OneDTest(TestCase): def setUp(self): self.moments = Record(timestep = 1) self.noise = DiscreteNoise(timestep = 0.01) - self.system = FermiHubbardSystem(sites = [2], repulsion = 0.5, hopping = 0, chemical_potential = 0) + self.system = GreensFermiHubbard(sites = [2], repulsion = 0.5, hopping = 0, chemical_potential = 0) self.integrator = SemiImplicitIntegrator(self.system, self.noise, timestep = 0.01) def testSolution(self): @@ -54,7 +54,7 @@ def setUp(self): self.sites = [2,2] self.moments = Record(timestep = 1) self.noise = DiscreteNoise(timestep = 0.01) - self.system = FermiHubbardSystem(sites = self.sites, repulsion = 0.5, hopping = 0, chemical_potential = 0) + self.system = GreensFermiHubbard(sites = self.sites, repulsion = 0.5, hopping = 0, chemical_potential = 0) self.integrator = SemiImplicitIntegrator(self.system, self.noise, timestep = 0.01) def testFilling(self):

#### 0 comments on commit `823c8a9`

Please sign in to comment.