Skip to content

Commit 43cd801

Browse files
committed
change default ttno construction algo to QR
1 parent 394ad22 commit 43cd801

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

renormalizer/mps/mpo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def __init__(self, model: Model = None, terms: Union[Op, List[Op]] = None, offse
275275

276276
self.dtype = factor.dtype
277277

278-
mpo_symbol, self.qn, self.qntot, self.qnidx, self.symbolic_out_ops_list, self.primary_ops \
278+
self.symbolic_mpo, self.qn, self.qntot, self.qnidx, self.symbolic_out_ops_list, self.primary_ops \
279279
= construct_symbolic_mpo(table, factor, algo=algo)
280280
# from renormalizer.mps.symbolic_mpo import _format_symbolic_mpo
281281
# print(_format_symbolic_mpo(mpo_symbol))
@@ -285,7 +285,7 @@ def __init__(self, model: Model = None, terms: Union[Op, List[Op]] = None, offse
285285
# evaluate the symbolic mpo
286286
assert model.basis is not None
287287

288-
for impo, mo in enumerate(mpo_symbol):
288+
for impo, mo in enumerate(self.symbolic_mpo):
289289
mo_mat = symbolic_mo_to_numeric_mo(model.basis[impo], mo, self.dtype)
290290
self.append(mo_mat)
291291

renormalizer/mps/symbolic_mpo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def _decompose_qr(term_row, term_col, non_red, in_ops_list, factor, primary_ops,
308308
309309
"""
310310
assert non_red.shape == (len(term_row), len(term_col))
311-
assert k == 1
311+
312312
non_red.data = factor[non_red.data - 1]
313313
gamma = non_red.todense()
314314

renormalizer/tn/symbolic_mpo.py renamed to renormalizer/tn/symbolic_ttno.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def symbolic_mo_to_numeric_mo_general(basis_sets: List[BasisSet], mo, dtype):
5252
return np.moveaxis(mo_tensor, mo.ndim - 1, -1)
5353

5454

55-
def construct_symbolic_mpo(tn: BasisTree, terms: List[Op], const: float = 0):
56-
algo = "Hopcroft-Karp"
55+
def construct_symbolic_ttno(tn: BasisTree, terms: List[Op], const: float = 0, algo: str = "qr"):
5756
nodes = tn.postorder_list()
5857
basis = list(chain(*[n.basis_sets for n in nodes]))
5958
model = Model(basis, [])

renormalizer/tn/tree.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from renormalizer.utils import calc_vn_entropy, calc_vn_entropy_dm
1717
from renormalizer.tn.node import TreeNodeTensor, TreeNodeBasis, copy_connection, TreeNodeEnviron
1818
from renormalizer.tn.treebase import Tree, BasisTree
19-
from renormalizer.tn.symbolic_mpo import construct_symbolic_mpo, symbolic_mo_to_numeric_mo_general
19+
from renormalizer.tn.symbolic_ttno import construct_symbolic_ttno, symbolic_mo_to_numeric_mo_general
2020

2121

2222
logger = logging.getLogger(__name__)
@@ -138,19 +138,19 @@ def dummy(cls, basis: BasisTree):
138138
basis.dummy_ttno = cls(new_basis, [new_basis.identity_op])
139139
return basis.dummy_ttno
140140

141-
def __init__(self, basis: BasisTree, terms: Union[List[Op], Op], root: TreeNodeTensor = None):
141+
def __init__(self, basis: BasisTree, terms: Union[List[Op], Op], root: TreeNodeTensor = None, algo: str = "qr"):
142142
self.basis: BasisTree = basis
143143
if isinstance(terms, Op):
144144
terms = [terms]
145145
self.terms: List[Op] = terms
146146

147147
if not root:
148-
symbolic_mpo, mpoqn = construct_symbolic_mpo(basis, terms)
148+
self.symbolic_ttno, mpoqn = construct_symbolic_ttno(basis, terms, algo=algo)
149149
# from renormalizer.mps.symbolic_mpo import _format_symbolic_mpo
150150
# print(_format_symbolic_mpo(symbolic_mpo))
151151
node_list_basis = self.basis.postorder_list()
152152
node_list_op = []
153-
for impo, (mo, qn) in enumerate(zip(symbolic_mpo, mpoqn)):
153+
for impo, (mo, qn) in enumerate(zip(self.symbolic_ttno, mpoqn)):
154154
node_basis: TreeNodeBasis = node_list_basis[impo]
155155
mo_mat = symbolic_mo_to_numeric_mo_general(node_basis.basis_sets, mo, backend.real_dtype)
156156
node_list_op.append(TreeNodeTensor(mo_mat, qn))

0 commit comments

Comments
 (0)