Skip to content

Commit

Permalink
Check commutation relations in hubbard_one_solver
Browse files Browse the repository at this point in the history
  • Loading branch information
j-otsuki committed Apr 4, 2018
1 parent ecf10a2 commit b007e1e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions python/hubbard_one_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, beta, gf_struct, n_iw, spin_orbit=False, verbose=True):
self.G0_iw = self.G_iw.copy()
self.Sigma_iw = self.G_iw.copy()

def solve(self, H_int, E_levels, const_of_motion=None, density_matrix_cutoff=1e-10, file_quantum_numbers="", file_eigenvalues=""):
def solve(self, H_int, E_levels, integrals_of_motion=None, density_matrix_cutoff=1e-10, file_quantum_numbers="", file_eigenvalues=""):

self.__copy_E_levels(E_levels)

Expand All @@ -58,19 +58,33 @@ def solve(self, H_int, E_levels, const_of_motion=None, density_matrix_cutoff=1e-
print "\n*** compute G_iw and Sigma_iw"
print "*** E_levels =", E_levels
print "*** H_0 =", H_0
print "*** const_of_motion =", const_of_motion
# print "*** integrals_of_motion =", integrals_of_motion

N_op = sum( c_dag(sn,on)*c(sn,on) for sn, on in product(self.spin_names, self.orb_names) )

if const_of_motion is None:
if integrals_of_motion is None:
if self.spin_orbit:
# use only N op as integrals_of_motion when spin-orbit coupling is included
self.__ed.diagonalize(H_0+H_int, integrals_of_motion=[N_op])
else:
# use N and S_z as integrals of motion by default
self.__ed.diagonalize(H_0+H_int)
else:
self.__ed.diagonalize(H_0+H_int, const_of_motion)
assert isinstance(integrals_of_motion, list)

# check commutation relation in advance (just for test)
if self.verbose and mpi.is_master_node():
print "*** Integrals of motion:"
for i, op in enumerate(integrals_of_motion):
print " op%d =" %i, op

print "*** commutation relations:"
is_commute = lambda h, op: h*op - op*h
str_if_commute = lambda h, op: "== 0" if is_commute(h, op).is_zero() else "!= 0"
for i, op in enumerate(integrals_of_motion):
print " [H_0, op%d]" %i, str_if_commute(H_0, op), " [H_int, op%d]" %i, str_if_commute(H_int, op)

self.__ed.diagonalize(H_0+H_int, integrals_of_motion)

# save data
if file_quantum_numbers:
Expand Down

0 comments on commit b007e1e

Please sign in to comment.