def delta(spin, r): def repulsion(site): "Compute |U|(sn_jj-n_jj+1/2)" # FIXME: I'm slow return self.repulsion * greens[(1 - spin,) + 2 * site] + abs(self.repulsion) * ( 0.5 - greens[(spin,) + 2 * site] ) f = 1 if spin == 1 else copysign(1, -self.repulsion) result = ndmat(zeros(2 * self.sites)) for i in sites(self.sites): result[2 * i] = ( -repulsion(i) - f * sqrt(2 * abs(self.repulsion)) * noise[(r,) + i] + self.chemical_potential ) for i, j in adjacencies(self.sites): assert i != j result[i + j] = self.hopping return result
def derivative(self, time, state, noise): greens = state.mean noise = array(noise).reshape((2,) + self.sites) def greens_dot(spin): n = greens[spin, ::] particles = ndmat(n) holes = ndmat(unit_like(n) - n) return 0.5 * (holes * delta(spin, 0) * particles + particles * delta(spin, 1) * holes) def delta(spin, r): def repulsion(site): "Compute |U|(sn_jj-n_jj+1/2)" # FIXME: I'm slow return self.repulsion * greens[(1 - spin,) + 2 * site] + abs(self.repulsion) * ( 0.5 - greens[(spin,) + 2 * site] ) f = 1 if spin == 1 else copysign(1, -self.repulsion) result = ndmat(zeros(2 * self.sites)) for i in sites(self.sites): result[2 * i] = ( -repulsion(i) - f * sqrt(2 * abs(self.repulsion)) * noise[(r,) + i] + self.chemical_potential ) for i, j in adjacencies(self.sites): assert i != j result[i + j] = self.hopping return result weight_log_dot = ( self.hopping * sum([greens[(0,) + i + j] + greens[(1,) + i + j] for i, j in adjacencies(self.sites)]) + self.repulsion * (greens[0, ::] * greens[1, ::]).sum() - self.chemical_potential * sum([greens[(0,) + i + i] + greens[(1,) + i + i] for i in sites(self.sites)]) ) return Weighting(array([greens_dot(0), greens_dot(1)]), weight=state.weight * weight_log_dot)