Commit 3bfe1f0d authored by Davison, Jacob's avatar Davison, Jacob
Browse files

updated occupation tensors and generator/flow to go faster (np.multiply occ...

updated occupation tensors and generator/flow to go faster (np.multiply occ tensors with relevant operators)
parent 5ad97d57
......@@ -36,7 +36,7 @@ from oop_imsrg.tests2B import *
sys.path.append('/mnt/home/daviso53/Research/')
from pyci.density_matrix.density_matrix import density_1b, density_2b
import pyci.imsrg_ci.pyci_p3h as pyci
import reference_state_ensemble.reference_ensemble as re
#import reference_state_ensemble.reference_ensemble as re
def get_vacuum_coeffs(E, f, G, basis, holes):
......@@ -509,7 +509,7 @@ if __name__ == '__main__':
#0,3,14,15,28,35
g = 0.5
pb = 0.0
pb = 0.1
hme = pyci.matrix(4,4,0.0,1.0,g,pb)
w,v = np.linalg.eigh(hme)
......@@ -531,7 +531,7 @@ if __name__ == '__main__':
#ref = pickle.load(open('reference_g2.00_pb0.01_4-4.p', 'rb'))
main(4,4, g=g, ref=ref, pb=pb, generator='white')
main(4,4, g=g, ref=ref, pb=pb, generator='wegner')
print('FCI ENERGY = {: .8f}'.format(w[0]))
data = pickle.load(open('expect_flow.p', 'rb'))
......
......@@ -115,9 +115,9 @@ def main3b(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0):
initi = time.time() # start instantiation timer
if ref == None:
if ref is None:
ha = PairingHamiltonian2B(n_holes, n_particles, d=d, g=g, pb=pb)
ref = [1,1,1,1,0,0,0,0] # this is just for printing
ref = ha.reference # this is just for printing
else:
ha = PairingHamiltonian2B(n_holes, n_particles, ref=ref, d=d, g=g, pb=pb)
print("Built Hamiltonian")
......@@ -138,7 +138,7 @@ def main3b(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0):
snapshot = tracemalloc.take_snapshot()
top_stats = snapshot.statistics('lineno')
total = sum(stat.size for stat in top_stats)
print("Total allocated size: %.1f GB" % (total / 1024**3))
print("Total allocated size: %.1f MB" % (total / 1024**2))
print("""Pairing model IM-SRG(3) flow:
......@@ -163,15 +163,31 @@ def main3b(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0):
solver.set_initial_value(y0, 0.)
sfinal = 50
ds = 0.1
ds = 0.01
s_vals = []
E_vals = []
iters = 0
convergence = 0
print_columns = ['iter',
's',
'E',
'||eta1b||',
'||eta2b||',
'||eta3b||']
column_string = '{: >6}, '
for i, string in enumerate(print_columns[1::]):
if i != len(print_columns)-2:
column_string += '{: >'+str(11)+'}, '
else:
column_string += '{: >'+str(11)+'}'
print(column_string.format(*print_columns))
while solver.successful() and solver.t < sfinal:
ys = solver.integrate(sfinal, step=True)
ys = solver.integrate(solver.t+ds, step=True)
Es, fs, Gs, Ws = ravel(ys, ha.n_sp_states)
s_vals.append(solver.t)
E_vals.append(Es)
......@@ -179,9 +195,34 @@ def main3b(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0):
iters += 1
# if iters == 1:
# break
if iters %10 == 0: print("iter: {:>6d} \t scale param: {:0.4f} \t E = {:0.9f}".format(iters, solver.t, Es))
if len(E_vals) > 100 and abs(E_vals[-1] - E_vals[-2]) < 10**-8 and E_vals[-1] != E_vals[0]:
if iters %10 == 0:
# print("iter: {:>6d} \t scale param: {:0.4f} \t E = {:0.9f}".format(iters, solver.t, Es))
norm_eta1B = np.linalg.norm(np.ravel(wg.eta1B))
norm_eta2B = np.linalg.norm(np.ravel(wg.eta2B))
norm_eta3B = np.linalg.norm(np.ravel(wg.eta3B))
data_columns = [iters,
solver.t,
Es,
norm_eta1B,
norm_eta2B,
norm_eta3B]
column_string = '{:>6d}, '
for i, string in enumerate(print_columns[1::]):
if i != len(print_columns)-2:
column_string += '{: .8f}, '
else:
column_string += '{: .8f}'
# print(column_string.format(*data_columns))
print(column_string.format(*data_columns))
if len(E_vals) > 100 and abs(E_vals[-1] - E_vals[-2]) < 10**-8:
print("---- Energy converged at iter {:>06d} with energy {:1.8f}\n".format(iters,E_vals[-1]))
convergence = 1
break
......@@ -259,7 +300,7 @@ def test_exact(plots_dir):
if __name__ == '__main__':
#test_exact("plots3b/")
main3b(4,4)
main3b(2,2,g=0.5,pb=0.1)
#test = main3b(4,4)
#tracemalloc.start()
......
......@@ -276,10 +276,8 @@ def main(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0, verbose=1, flow_d
'2bc_SS',
'||eta1b||',
'||eta2b||',
'commute1bd',
'commute1bod',
'commute2bd',
'commute2bod',
'f_full_trace',
'G_full_trace',
'commute',
'commutePairedBlock']
column_string = '{: >6}, '
......@@ -335,6 +333,15 @@ def main(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0, verbose=1, flow_d
norm_eta2B = np.linalg.norm(np.ravel(wg.eta2B))
num_sp = n_holes+n_particles
axes = (num_sp**2,num_sp**2)
Gnode = tn.Node(G_spins[np.ix_(ha.holes,ha.holes,ha.holes,ha.holes)])
Gnode[0] ^ Gnode[2]
Gnode[1] ^ Gnode[3]
result_ij = Gnode @ Gnode
#H1B = np.trace(Gs[np.ix_(ha.sp_basis,ha.holes,ha.sp_basis,ha.holes)], axis1=1,axis2=3)
f_full_trace = np.trace(SS1B[np.ix_(ha.holes,ha.holes)])
# SS2B_r = np.reshape(SS2B, (num_sp**2,num_sp**2))
# H2B_r = np.reshape(H2B, (num_sp**2, num_sp**2))
# commute1b = np.linalg.norm(SS1B.dot(H1B) - H1B.dot(SS1B))
......@@ -348,10 +355,6 @@ def main(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0, verbose=1, flow_d
hGd,hGod,sGd,sGod = np.reshape(hGd,axes),np.reshape(hGod,axes),np.reshape(sGd,axes),np.reshape(sGod,axes)
commute1bd = np.linalg.norm(hfd.dot(sfd) - sfd.dot(hfd))
commute1bod = np.linalg.norm(hfod.dot(sfod) - sfod.dot(hfod))
commute2bd = np.linalg.norm(hGd.dot(sGd) - sGd.dot(hGd))
commute2bod = np.linalg.norm(hGod.dot(sGod) - sGod.dot(hGod))
commute = np.linalg.norm(hme.dot(ssme) - ssme.dot(hme))
commutePairBlock = np.linalg.norm(hme[0:2,0:2].dot(ssme[0:2,0:2]) - ssme[0:2,0:2].dot(hme[0:2,0:2]))
data_columns = [iters,
......@@ -365,10 +368,8 @@ def main(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0, verbose=1, flow_d
contract_2b,
norm_eta1B,
norm_eta2B,
commute1bd,
commute1bod,
commute2bd,
commute2bod,
f_full_trace,
result_ij.tensor,
commute,
commutePairBlock]
column_string = '{:>6d}, '
......@@ -385,8 +386,14 @@ def main(n_holes, n_particles, ref=None, d=1.0, g=0.5, pb=0.0, verbose=1, flow_d
ws,vs = np.linalg.eigh(ssme)
with np.printoptions(linewidth=999,precision=4):
print(ssme)
print(ggme)
print(np.reshape(wg.eta2B, axes))
# print(np.reshape(G_spins[np.ix_(ha.holes,ha.holes,ha.holes,ha.holes)],(4,4)))
# print(SS1B[np.ix_(ha.holes,ha.holes)])
# print(ssme)
# print(ggme)
# for i in range(wg.eta1B.shape[0]):
# print("{d}".format(d=wg.eta1B[i,:]))
# for i in range(wg.eta1B.shape[0]):
......@@ -542,14 +549,14 @@ if __name__ == '__main__':
#ref = 0.8*basis[0,:] + 0.2*basis[1,:]
#ref = basis.T.dot(v0*v0)
ref = basis[1,:]
ref = basis[0,:]
# ref_input = sys.argv[1]
# ref = [int(x) for x in list(ref_input)]
#ref = pickle.load(open('reference_g2.00_pb0.01_4-4.p', 'rb'))
main(2,2, g=g, ref=ref, pb=pb, generator='white')
main(2,2, g=g, ref=ref, pb=pb, generator='wegner')
print('FCI ENERGY = {: .8f}'.format(w[0]))
data = pickle.load(open('expect_flow.p', 'rb'))
......
......@@ -272,6 +272,8 @@ class Flow_IMSRG3(Flow_IMSRG2):
W = gen.W
gen2b = WegnerGenerator(self._h, self._occ_t)
gen2b.f = f
gen2b.G = G
partition = super().flow(f,G,gen2b)
dE = partition[0]
......@@ -299,26 +301,34 @@ class Flow_IMSRG3(Flow_IMSRG2):
occJ = self._occJ
# Calculate 0B flow equation
sum3_0b_1 = np.matmul(eta3B, occE)
sum3_0b_1 = np.multiply(eta3B, occE)
sum3_0b = tn.ncon([sum3_0b_1, W], [(1,2,3,4,5,6), (4,5,6,1,2,3)])#.numpy()
dE += (1/18)*sum3_0b
# Calculate 1B flow equation
# fourth term
sum4_1b_1 = np.matmul(np.transpose(occD.tensor,[2,3,0,1]), G)
sum4_1b_2 = np.matmul(np.transpose(occD.tensor,[2,3,0,1]), eta2B)
sum4_1b_1 = np.multiply(np.transpose(occD.tensor,[2,3,0,1]), G)
sum4_1b_2 = np.multiply(np.transpose(occD.tensor,[2,3,0,1]), eta2B)
sum4_1b_3 = tn.ncon([eta3B, sum4_1b_1], [(1,2,-1,3,4,-2),(3,4,1,2)])#.numpy()
sum4_1b_4 = tn.ncon([W, sum4_1b_2], [(1,2,-1,3,4,-2),(3,4,1,2)])#.numpy()
sum4_1b_4 = tn.ncon([W, sum4_1b_2], [(1,2,-1,3,4,-2),(3,4,1,2)])#.numpy()
sum4_1b = sum4_1b_3 - sum4_1b_4
# fifth term
sum5_1b_1 = tn.ncon([eta3B, occF, W], [(6,7,-1,8,9,10),
(6,7,8,9,10,1,2,3,4,5),
(3,4,5,1,2,-2)])#.numpy()
sum5_1b_2 = tn.ncon([W, occF, eta3B], [(6,7,-1,8,9,10),
(6,7,8,9,10,1,2,3,4,5),
(3,4,5,1,2,-2)])#.numpy()
sum5_1b = sum5_1b_1 - sum5_1b_2
# sum5_1b_1 = tn.ncon([eta3B, occF, W], [(6,7,-1,8,9,10),
# (6,7,8,9,10,1,2,3,4,5),
# (3,4,5,1,2,-2)])#.numpy()
# sum5_1b_2 = tn.ncon([W, occF, eta3B], [(6,7,-1,8,9,10),
# (6,7,8,9,10,1,2,3,4,5),
# (3,4,5,1,2,-2)])#.numpy()
# sum5_1b = sum5_1b_1 - sum5_1b_2
sum5_1b_1 = np.multiply(np.transpose(occF.tensor,[0,1,5,2,3,4]), eta3B)
sum5_1b_2 = np.multiply(np.transpose(occF.tensor,[0,1,5,2,3,4]), W)
sum5_1b_3 = tn.ncon([sum5_1b_1, W],[(1,2,-1,3,4,5),(3,4,5,1,2,-2)])
sum5_1b_4 = tn.ncon([sum5_1b_2, eta3B],[(1,2,-1,3,4,5),(3,4,5,1,2,-2)])
sum5_1b = sum5_1b_3 - sum5_1b_4
# sum5_1b_1 = tn.ncon([occF, eta3B.astype(np.float32)],
# [(-1,-3,-4,-5,-6,0,1,2,3,4), (0,1,-2,2,3,4)])#.numpy()
......@@ -334,23 +344,36 @@ class Flow_IMSRG3(Flow_IMSRG2):
# Calculate 2B flow equation
# fourth term
sum4_2b_1 = np.matmul(-1.0*np.transpose(occA.tensor), f)
sum4_2b_2 = np.matmul(-1.0*np.transpose(occA.tensor), eta1B)
sum4_2b_1 = np.multiply(-1.0*np.transpose(occA.tensor), f)
sum4_2b_2 = np.multiply(-1.0*np.transpose(occA.tensor), eta1B)
sum4_2b_3 = tn.ncon([eta3B, sum4_2b_1], [(1,-1,-2,2,-3,-4), (2,1)])#.numpy()
sum4_2b_4 = tn.ncon([W, sum4_2b_2], [(1,-1,-2,2,-3,-4), (2,1)])#.numpy()
sum4_2b = sum4_2b_3 - sum4_2b_4
#fifth term
sum5_2b_1 = tn.ncon([eta3B, occG, G], [(4,-1,-2,5,6,-4),
(4,5,6,1,2,3),
(2,3,1,-3)])#.numpy()
sum5_2b_2 = tn.ncon([W, occG, eta2B], [(4,-1,-2,5,6,-4),
(4,5,6,1,2,3),
(2,3,1,-3)])#.numpy()
sum5_2b = sum5_2b_2 - np.transpose(sum5_2b_2, [3,2,0,1]) - \
np.transpose(sum5_2b_2, [0,1,3,2]) + \
np.transpose(sum5_2b_2, [2,3,0,1])
sum5_2b_1 = np.multiply(np.transpose(occG.tensor, [1,2,0,3]), G)
sum5_2b_2 = np.multiply(np.transpose(occG.tensor, [1,2,0,3]), eta2B)
sum5_2b_3 = tn.ncon([eta3B, sum5_2b_1],[(1,-1,-2,2,3,-4),(2,3,1,-3)])
sum5_2b_4 = tn.ncon([W, sum5_2b_2],[(1,-1,-2,2,3,-4),(2,3,1,-3)])
sum5_2b_5 = sum5_2b_3 - sum5_2b_4
sum5_2b = sum5_2b_5 - np.transpose(sum5_2b_5, [3,2,0,1]) - \
np.transpose(sum5_2b_5, [0,1,3,2]) + \
np.transpose(sum5_2b_5, [2,3,0,1])
# sum5_2b_1 = tn.ncon([eta3B, occG, G], [(4,-1,-2,5,6,-4),
# (4,5,6,1,2,3),
# (2,3,1,-3)])#.numpy()
# sum5_2b_2 = tn.ncon([W, occG, eta2B], [(4,-1,-2,5,6,-4),
# (4,5,6,1,2,3),
# (2,3,1,-3)])#.numpy()
# sum5_2b = sum5_2b_2 - np.transpose(sum5_2b_2, [3,2,0,1]) - \
# np.transpose(sum5_2b_2, [0,1,3,2]) + \
# np.transpose(sum5_2b_2, [2,3,0,1])
# sum5_2b_1 = tn.ncon([occG, G], [(-1,-2,-4,0,1,2), (1,2,0,-3)])#.numpy()
# sum5_2b_2 = tn.ncon([occG, eta2B], [(-1,-2,-4,0,1,2), (1,2,0,-3)])#.numpy()
......@@ -362,13 +385,20 @@ class Flow_IMSRG3(Flow_IMSRG2):
# np.transpose(sum5_2b_5, [2,3,0,1])
#sixth term
sum6_2b_1 = tn.ncon([eta3B, occH, W], [(5,-1,-2,6,7,8),
(5,6,7,8,1,2,3,4),
(2,3,4,1,-3,-4)])#.numpy()
sum6_2b_2 = tn.ncon([eta3B, occH, W], [(6,7,8,5,-3,-4),
(5,6,7,8,1,2,3,4),
(1,-1,-2,2,3,4)])#.numpy()
sum6_2b = sum6_2b_1 - sum6_2b_2
sum5_2b_1 = np.multiply(np.transpose(occH.tensor,[0,4,5,1,2,3]), eta3B)
sum5_2b_2 = np.multiply(np.transpose(occH.tensor,[0,4,5,1,2,3]), W)
sum5_2b_3 = tn.ncon([sum5_2b_1, W], [(1,-1,-2,2,3,4),(2,3,4,1,-3,-4)])
sum5_2b_4 = tn.ncon([eta3B, sum5_2b_2], [(1,-1,-2,2,3,4),(2,3,4,1,-3,-4)])
sum6_2b = sum5_2b_3 - sum5_2b_4
# sum6_2b_1 = tn.ncon([eta3B, occH, W], [(5,-1,-2,6,7,8),
# (5,6,7,8,1,2,3,4),
# (2,3,4,1,-3,-4)])#.numpy()
# sum6_2b_2 = tn.ncon([eta3B, occH, W], [(6,7,8,5,-3,-4),
# (5,6,7,8,1,2,3,4),
# (1,-1,-2,2,3,4)])#.numpy()
# sum6_2b = sum6_2b_1 - sum6_2b_2
# sum6_2b_1 = tn.ncon([occH, W], [(-1,-2,-3,-4,0,1,2,3),(1,2,3,0,-5,-6)])#.numpy()
# sum6_2b_2 = tn.ncon([occH, W], [(-3,-4,-5,-6,0,1,2,3),(0,-1,-2,1,2,3)])#.numpy()
......@@ -377,12 +407,18 @@ class Flow_IMSRG3(Flow_IMSRG2):
# sum6_2b = sum6_2b_3 - sum6_2b_4
#seventh term
sum7_2b_1 = tn.ncon([eta3B, occI, W], [(5,6,-1,7,8,-4),
(5,6,7,8,1,2,3,4),
(3,4,-2,1,2,-3)])#.numpy()
sum7_2b = sum7_2b_1 - np.transpose(sum7_2b_1,[1,0,2,3]) - \
np.transpose(sum7_2b_1,[0,1,3,2]) + \
np.transpose(sum7_2b_1,[1,0,3,2])
sum7_2b_1 = np.multiply(np.transpose(occI.tensor,[0,1,4,2,3,5]),eta3B)
sum7_2b_2 = tn.ncon([sum7_2b_1, W], [(1,2,-1,3,4,-4),(3,4,-2,1,2,-3)])
sum7_2b = sum7_2b_2 - np.transpose(sum7_2b_2,[1,0,2,3]) - \
np.transpose(sum7_2b_2,[0,1,3,2]) + \
np.transpose(sum7_2b_2,[1,0,3,2])
# sum7_2b_1 = tn.ncon([eta3B, occI, W], [(5,6,-1,7,8,-4),
# (5,6,7,8,1,2,3,4),
# (3,4,-2,1,2,-3)])#.numpy()
# sum7_2b = sum7_2b_1 - np.transpose(sum7_2b_1,[1,0,2,3]) - \
# np.transpose(sum7_2b_1,[0,1,3,2]) + \
# np.transpose(sum7_2b_1,[1,0,3,2])
# sum7_2b_1 = tn.ncon([occI, W], [(-1,-2,-3,-4,0,1,2,3), (2,3,-5,0,1,-6)])#.numpy()
# sum7_2b_2 = tn.ncon([eta3B, sum7_2b_1], [(0,1,-1,2,3,-4),(2,3,-2,0,1,-3)])#.numpy()
......@@ -421,41 +457,87 @@ class Flow_IMSRG3(Flow_IMSRG2):
sum1_3b = sum1_3b_4 + sum1_3b_8 + sum1_3b_13
#fourth term
sum4_3b_1 = tn.ncon([eta2B, occB4, W], [(-1,-2,3,4),(3,4,1,2),(1,2,-3,-4,-5,-6)])#.numpy()
sum4_3b_2 = tn.ncon([G, occB4, eta3B], [(-1,-2,3,4),(3,4,1,2),(1,2,-3,-4,-5,-6)])#.numpy()
sum4_3b_3 = sum4_3b_1 - sum4_3b_2
sum4_3b = sum4_3b_3 - np.transpose(sum4_3b_3, [1,0,2,3,4,5]) - \
np.transpose(sum4_3b_3, [2,1,0,3,4,5])
sum4_3b_1 = np.multiply(np.transpose(occB4.tensor,[2,3,0,1]), eta2B)
sum4_3b_2 = np.multiply(np.transpose(occB4.tensor,[2,3,0,1]), G)
sum4_3b_3 = tn.ncon([sum4_3b_1, W], [(-1,-2,1,2),(1,2,-3,-4,-5,-6)])
sum4_3b_4 = tn.ncon([sum4_3b_2, eta3B], [(-1,-2,1,2),(1,2,-3,-4,-5,-6)])
sum4_3b_5 = sum4_3b_3 - sum4_3b_4
sum4_3b = sum4_3b_5 - np.transpose(sum4_3b_5, [1,0,2,3,4,5]) - \
np.transpose(sum4_3b_5, [2,1,0,3,4,5])
# sum4_3b_1 = tn.ncon([eta2B, occB4, W], [(-1,-2,3,4),(3,4,1,2),(1,2,-3,-4,-5,-6)])#.numpy()
# sum4_3b_2 = tn.ncon([G, occB4, eta3B], [(-1,-2,3,4),(3,4,1,2),(1,2,-3,-4,-5,-6)])#.numpy()
# sum4_3b_3 = sum4_3b_1 - sum4_3b_2
# sum4_3b = sum4_3b_3 - np.transpose(sum4_3b_3, [1,0,2,3,4,5]) - \
# np.transpose(sum4_3b_3, [2,1,0,3,4,5])
#fifth term
sum5_3b_1 = tn.ncon([eta2B, occB4, W], [(3,4,-4,-5),(3,4,1,2),(-1,-2,-3,1,2,-6)])#.numpy()
sum5_3b_2 = tn.ncon([G, occB4, eta3B], [(3,4,-4,-5),(3,4,1,2),(-1,-2,-3,1,2,-6)])#.numpy()
sum5_3b_3 = sum5_3b_1 - sum5_3b_2
sum5_3b = sum5_3b_3 - np.transpose(sum5_3b_3, [0,1,2,5,4,3]) - \
np.transpose(sum5_3b_3, [0,1,2,3,5,4])
sum5_3b_1 = np.multiply(occB4.tensor, eta2B)
sum5_3b_2 = np.multiply(occB4.tensor, G)
sum5_3b_3 = tn.ncon([sum5_3b_1, W], [(1,2,-4,-5),(-1,-2,-3,1,2,-6)])
sum5_3b_4 = tn.ncon([sum5_3b_2, eta3B], [(1,2,-4,-5),(-1,-2,-3,1,2,-6)])
sum5_3b_5 = sum5_3b_3 - sum5_3b_4
sum5_3b = sum5_3b_5 - np.transpose(sum5_3b_5, [0,1,2,5,4,3]) - \
np.transpose(sum5_3b_5, [0,1,2,3,5,4])
# sum5_3b_1 = tn.ncon([eta2B, occB4, W], [(3,4,-4,-5),(3,4,1,2),(-1,-2,-3,1,2,-6)])#.numpy()
# sum5_3b_2 = tn.ncon([G, occB4, eta3B], [(3,4,-4,-5),(3,4,1,2),(-1,-2,-3,1,2,-6)])#.numpy()
# sum5_3b_3 = sum5_3b_1 - sum5_3b_2
# sum5_3b = sum5_3b_3 - np.transpose(sum5_3b_3, [0,1,2,5,4,3]) - \
# np.transpose(sum5_3b_3, [0,1,2,3,5,4])
#sixth term
sum6_3b_1 = tn.ncon([eta2B, occA4, W], [(4,-1,3,-4),(3,4,1,2),(1,-2,-3,2,-5,-6)])#.numpy()
sum6_3b_2 = tn.ncon([G, occA4, eta3B], [(4,-1,3,-4),(3,4,1,2),(1,-2,-3,2,-5,-6)])#.numpy()
sum6_3b_3 = sum6_3b_1 - sum6_3b_2
sum6_3b_4 = sum6_3b_3 - np.transpose(sum6_3b_3, [0,1,2,4,3,5]) - \
np.transpose(sum6_3b_3, [0,1,2,5,4,3])
sum6_3b = sum6_3b_4 - np.transpose(sum6_3b_4, [1,0,2,3,4,5]) - \
np.transpose(sum6_3b_4, [2,1,0,3,4,5])
sum6_3b_1 = np.multiply(np.transpose(occA4.tensor,[1,2,0,3]), eta2B)
sum6_3b_2 = np.multiply(np.transpose(occA4.tensor,[1,2,0,3]), G)
sum6_3b_3 = tn.ncon([sum6_3b_1, W], [(2,-1,1,-4),(1,-2,-3,2,-5,-6)])
sum6_3b_4 = tn.ncon([sum6_3b_2, eta3B], [(2,-1,1,-4),(1,-2,-3,2,-5,-6)])
sum6_3b_5 = sum6_3b_3 - sum6_3b_4
sum6_3b_6 = sum6_3b_5 - np.transpose(sum6_3b_5, [0,1,2,4,3,5]) - \
np.transpose(sum6_3b_5, [0,1,2,5,4,3])
sum6_3b = sum6_3b_6 - np.transpose(sum6_3b_6, [1,0,2,3,4,5]) - \
np.transpose(sum6_3b_6, [2,1,0,3,4,5])
# sum6_3b_1 = tn.ncon([eta2B, occA4, W], [(4,-1,3,-4),(3,4,1,2),(1,-2,-3,2,-5,-6)])#.numpy()
# sum6_3b_2 = tn.ncon([G, occA4, eta3B], [(4,-1,3,-4),(3,4,1,2),(1,-2,-3,2,-5,-6)])#.numpy()
# sum6_3b_3 = sum6_3b_1 - sum6_3b_2
# sum6_3b_4 = sum6_3b_3 - np.transpose(sum6_3b_3, [0,1,2,4,3,5]) - \
# np.transpose(sum6_3b_3, [0,1,2,5,4,3])
# sum6_3b = sum6_3b_4 - np.transpose(sum6_3b_4, [1,0,2,3,4,5]) - \
# np.transpose(sum6_3b_4, [2,1,0,3,4,5])
#seventh term
sum7_3b_1 = tn.ncon([eta3B, occJ, W], [(-1,-2,-3,4,5,6), (4,5,6,1,2,3), (1,2,3,-4,-5,-6)])#.numpy()
sum7_3b_2 = tn.ncon([W, occJ, eta3B], [(-1,-2,-3,4,5,6), (4,5,6,1,2,3), (1,2,3,-4,-5,-6)])#.numpy()
sum7_3b = sum7_3b_1 - sum7_3b_2
sum7_3b_1 = np.multiply(np.transpose(occJ.tensor,[3,4,5,0,1,2]), eta3B)
sum7_3b_2 = np.multiply(np.transpose(occJ.tensor,[3,4,5,0,1,2]), W)
sum7_3b_3 = tn.ncon([sum7_3b_1, W], [(-1,-2,-3,1,2,3),(1,2,3,-4,-5,-6)])
sum7_3b_4 = tn.ncon([sum7_3b_2, eta3B], [(-1,-2,-3,1,2,3),(1,2,3,-4,-5,-6)])
sum7_3b = sum7_3b_3 - sum7_3b_4
# sum7_3b_1 = tn.ncon([eta3B, occJ, W], [(-1,-2,-3,4,5,6), (4,5,6,1,2,3), (1,2,3,-4,-5,-6)])#.numpy()
# sum7_3b_2 = tn.ncon([W, occJ, eta3B], [(-1,-2,-3,4,5,6), (4,5,6,1,2,3), (1,2,3,-4,-5,-6)])#.numpy()
# sum7_3b = sum7_3b_1 - sum7_3b_2
#eighth term
sum8_3b_1 = tn.ncon([eta3B, occC6, W], [(4,5,-3,6,-5,-6), (4,5,6,1,2,3), (3,-1,-2,1,2,-4)])#.numpy()
sum8_3b_2 = tn.ncon([eta3B, occC6, W], [(6,-2,-3,4,5,-6), (4,5,6,1,2,3), (-1,1,2,-4,-5,3)])#.numpy()
sum8_3b_3 = sum8_3b_1 - sum8_3b_2
sum8_3b_4 = sum8_3b_3 - np.transpose(sum8_3b_3, [0,1,2,4,3,5]) - \
np.transpose(sum8_3b_3, [0,1,2,5,4,3])
sum8_3b = sum8_3b_4 - np.transpose(sum8_3b_4, [2,1,0,3,4,5]) - \
np.transpose(sum8_3b_4, [0,2,1,3,4,5])
sum8_3b_1 = np.multiply(np.transpose(occC6.tensor,[0,1,3,2,4,5]), eta3B)
sum8_3b_2 = np.multiply(np.transpose(occC6.tensor,[2,3,4,0,1,5]), eta3B)
sum8_3b_3 = tn.ncon([sum8_3b_1, W], [(1,2,-3,3,-5,-6),(3,-1,-2,1,2,-4)])
sum8_3b_4 = tn.ncon([sum8_3b_2, W], [(3,-2,-3,1,2,-6),(-1,1,2,-4,-5,3)])
sum8_3b_5 = sum8_3b_3 - sum8_3b_4
sum8_3b_6 = sum8_3b_5 - np.transpose(sum8_3b_5, [0,1,2,4,3,5]) - \
np.transpose(sum8_3b_5, [0,1,2,5,4,3])
sum8_3b = sum8_3b_6 - np.transpose(sum8_3b_6, [2,1,0,3,4,5]) - \
np.transpose(sum8_3b_6, [0,2,1,3,4,5])
# sum8_3b_1 = tn.ncon([eta3B, occC6, W], [(4,5,-3,6,-5,-6), (4,5,6,1,2,3), (3,-1,-2,1,2,-4)])#.numpy()
# sum8_3b_2 = tn.ncon([eta3B, occC6, W], [(6,-2,-3,4,5,-6), (4,5,6,1,2,3), (-1,1,2,-4,-5,3)])#.numpy()
# sum8_3b_3 = sum8_3b_1 - sum8_3b_2
# sum8_3b_4 = sum8_3b_3 - np.transpose(sum8_3b_3, [0,1,2,4,3,5]) - \
# np.transpose(sum8_3b_3, [0,1,2,5,4,3])
# sum8_3b = sum8_3b_4 - np.transpose(sum8_3b_4, [2,1,0,3,4,5]) - \
# np.transpose(sum8_3b_4, [0,2,1,3,4,5])
dW = sum1_3b + 0.5*sum4_3b + (-0.5)*sum5_3b + (-1.0)*sum6_3b + (1/6)*sum7_3b + 0.5*sum8_3b
......
......@@ -310,8 +310,30 @@ class WegnerGenerator3B(WegnerGenerator):
self._eta1B = np.zeros_like(self.f)
self._eta2B = np.zeros_like(self.G)
self._eta3B = np.zeros_like(self.W)
@property
def eta1B(self):
"""Returns:
eta1B -- one-body generator"""
return self._eta1B
@property
def eta2B(self):
"""Returns:
eta2B -- one-body generator"""
return self._eta2B
@property
def eta3B(self):
"""Returns:
eta3B -- one-body generator"""
return self._eta3B
@property
def W(self):
"""Returns:
......@@ -410,13 +432,22 @@ class WegnerGenerator3B(WegnerGenerator):
sum4_1b = sum4_1b_3 - sum4_1b_4
# fifth term
sum5_1b_1 = tn.ncon([Wd, occF, Wod], [(6,7,-1,8,9,10),
(6,7,8,9,10,1,2,3,4,5),
(3,4,5,1,2,-2)])#.numpy()
sum5_1b_2 = tn.ncon([Wod, occF, Wd], [(6,7,-1,8,9,10),
(6,7,8,9,10,1,2,3,4,5),
(3,4,5,1,2,-2)])#.numpy()
sum5_1b = sum5_1b_1 - sum5_1b_2
sum5_1b_1 = np.multiply(np.transpose(occF.tensor,[0,1,5,2,3,4]), Wd)
sum5_1b_2 = np.multiply(np.transpose(occF.tensor,[0,1,5,2,3,4]), Wod)
sum5_1b_3 = tn.ncon([sum5_1b_1, Wod],[(1,2,-1,3,4,5),(3,4,5,1,2,-2)])
sum5_1b_4 = tn.ncon([sum5_1b_2, Wd],[(1,2,-1,3,4,5),(3,4,5,1,2,-2)])
sum5_1b = sum5_1b_3 - sum5_1b_4
# sum5_1b_1 = tn.ncon([Wd, occF, Wod], [(6,7,-1,8,9,10),
# (6,7,8,9,10,1,2,3,4,5),
# (3,4,5,1,2,-2)])#.numpy()
# sum5_1b_2 = tn.ncon([Wod, occF, Wd], [(6,7,-1,8,9,10),
# (6,7,8,9,10,1,2,3,4,5),
# (3,4,5,1,2,-2)])#.numpy()
# sum5_1b = sum5_1b_1 - sum5_1b_2
# sum5_1b_1 = tn.ncon([occF, Wd.astype(np.float32)],
# [(-1,-3,-4,-5,-6,0,1,2,3,4), (0,1,-2,2,3,4)])#.numpy()
......@@ -439,15 +470,29 @@ class WegnerGenerator3B(WegnerGenerator):
sum4_2b = sum4_2b_3 - sum4_2b_4
#fifth term
sum5_2b_1 = tn.ncon([Wd, occG, God], [(4,-1,-2,5,6,-4),
(4,5,6,1,2,3),
(2,3,1,-3)])#.numpy()
sum5_2b_2 = tn.ncon([Wod, occG, Gd], [(4,-1,-2,5,6,-4),
(4,5,6,1,2,3),
(2,3,1,-3)])#.numpy()
sum5_2b = sum5_2b_2 - np.transpose(sum5_2b_2, [3,2,0,1]) - \
np.transpose(sum5_2b_2, [0,1,3,2]) + \
np.transpose(sum5_2b_2, [2,3,0,1])
sum5_2b_1 = np.multiply(np.transpose(occG.tensor, [1,2,0,3]), God)
sum5_2b_2 = np.multiply(np.transpose(occG.tensor, [1,2,0,3]), Gd)
sum5_2b_3 = tn.ncon([Wd, sum5_2b_1],[(1,-1,-2,2,3,-4),(2,3,1,-3)])
sum5_2b_4 = tn.ncon([Wod, sum5_2b_2],[(1,-1,-2,2,3,-4),(2,3,1,-3)])
sum5_2b_5 = sum5_2b_3 - sum5_2b_4
sum5_2b = sum5_2b_5 - np.transpose(sum5_2b_5, [3,2,0,1]) - \
np.transpose(sum5_2b_5, [0,1,3,2]) + \
np.transpose(sum5_2b_5, [2,3,0,1])
# sum5_2b_1 = tn.ncon([Wd, occG, God], [(4,-1,-2,5,6,-4),
# (4,5,6,1,2,3),
# (2,3,1,-3)])#.numpy()
# sum5_2b_2 = tn.ncon([Wod, occG, Gd], [(4,-1,-2,5,6,-4),
# (4,5,6,1,2,3),
# (2,3,1,-3)])#.numpy()
# sum5_2b = sum5_2b_2 - np.transpose(sum5_2b_2, [3,2,0,1]) - \
# np.transpose(sum5_2b_2, [0,1,3,2]) + \