Skip to content

Commit bbd6683

Browse files
committed
Do not ignore step count during first steps of CTMRG
1 parent 904cf17 commit bbd6683

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

varipeps/ctmrg/routine.py

+31-24
Original file line numberDiff line numberDiff line change
@@ -537,16 +537,19 @@ def calc_ctmrg_env(
537537
tmp_count = 0
538538
corner_singular_vals = None
539539

540-
while any(
541-
getattr(i, j).shape[0] != i.chi or getattr(i, j).shape[1] != i.chi
542-
for i in working_unitcell.get_unique_tensors()
543-
for j in ("C1", "C2", "C3", "C4")
544-
) or (
545-
hasattr(working_unitcell.get_unique_tensors()[0], "T4_ket")
546-
and any(
547-
getattr(i, j).shape[0] != i.interlayer_chi
540+
while tmp_count < varipeps_config.ctmrg_max_steps and (
541+
any(
542+
getattr(i, j).shape[0] != i.chi or getattr(i, j).shape[1] != i.chi
548543
for i in working_unitcell.get_unique_tensors()
549-
for j in ("T1_bra", "T2_ket", "T3_bra", "T4_ket")
544+
for j in ("C1", "C2", "C3", "C4")
545+
)
546+
or (
547+
hasattr(working_unitcell.get_unique_tensors()[0], "T4_ket")
548+
and any(
549+
getattr(i, j).shape[0] != i.interlayer_chi
550+
for i in working_unitcell.get_unique_tensors()
551+
for j in ("T1_bra", "T2_ket", "T3_bra", "T4_ket")
552+
)
550553
)
551554
):
552555
(
@@ -557,7 +560,7 @@ def calc_ctmrg_env(
557560
_,
558561
tmp_count,
559562
_,
560-
_,
563+
norm_smallest_S,
561564
_,
562565
_,
563566
) = _ctmrg_body_func(
@@ -575,24 +578,28 @@ def calc_ctmrg_env(
575578
)
576579
)
577580

578-
working_unitcell, converged, end_count, norm_smallest_S = _ctmrg_while_wrapper(
579-
(
580-
peps_tensors,
581-
working_unitcell,
582-
False,
581+
if tmp_count < varipeps_config.ctmrg_max_steps:
582+
working_unitcell, converged, end_count, norm_smallest_S = _ctmrg_while_wrapper(
583583
(
584-
corner_singular_vals
584+
peps_tensors,
585+
working_unitcell,
586+
False,
587+
(
588+
corner_singular_vals
585589
if corner_singular_vals is not None
586590
else init_corner_singular_vals
587-
),
588-
eps,
589-
tmp_count,
590-
enforce_elementwise_convergence,
591-
jnp.inf,
592-
varipeps_global_state,
593-
varipeps_config,
591+
),
592+
eps,
593+
tmp_count,
594+
enforce_elementwise_convergence,
595+
jnp.inf,
596+
varipeps_global_state,
597+
varipeps_config,
598+
)
594599
)
595-
)
600+
else:
601+
converged = False
602+
end_count = tmp_count
596603

597604
current_truncation_eps = (
598605
varipeps_config.ctmrg_truncation_eps

0 commit comments

Comments
 (0)