Skip to content

Commit e6aaf60

Browse files
committed
Allow to reset maximum bond dimension while changing the enviroment dim
1 parent edf4120 commit e6aaf60

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

varipeps/peps/tensor.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ def change_chi(
399399
new_chi: int,
400400
*,
401401
reinitialize_env_as_identities: bool = True,
402+
reset_max_chi: bool = False,
402403
) -> T_PEPS_Tensor:
403404
"""
404405
Change the environment bond dimension and returns new object of the class.
@@ -409,6 +410,8 @@ def change_chi(
409410
Keyword args:
410411
reinitialize_env_as_identities (:obj:`bool`):
411412
Reinitialize the CTM tensors as identities if decreasing the dimension.
413+
reset_max_chi (:obj:`bool`):
414+
Set maximal bond dimension to the same new value.
412415
Returns:
413416
:obj:`~varipeps.peps.PEPS_Tensor`:
414417
New instance of the class with the increased value.
@@ -418,6 +421,8 @@ def change_chi(
418421
"Increase above the max value for environment bond dimension."
419422
)
420423

424+
new_max_chi = new_chi if reset_max_chi else self.max_chi
425+
421426
if new_chi < self.chi and reinitialize_env_as_identities:
422427
return type(self)(
423428
tensor=self.tensor,
@@ -440,7 +445,7 @@ def change_chi(
440445
d=self.d,
441446
D=self.D,
442447
chi=new_chi,
443-
max_chi=self.max_chi,
448+
max_chi=new_max_chi,
444449
)
445450
else:
446451
return type(self)(
@@ -456,7 +461,7 @@ def change_chi(
456461
d=self.d,
457462
D=self.D,
458463
chi=new_chi,
459-
max_chi=self.max_chi,
464+
max_chi=new_max_chi,
460465
)
461466

462467
def increase_max_chi(

varipeps/peps/unitcell.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,26 @@ def replace_unique_tensors(
450450
sanity_checks=False,
451451
)
452452

453-
def change_chi(self: T_PEPS_Unit_Cell, new_chi: int) -> T_PEPS_Unit_Cell:
453+
def change_chi(
454+
self: T_PEPS_Unit_Cell,
455+
new_chi: int,
456+
reset_max_chi: bool = False,
457+
) -> T_PEPS_Unit_Cell:
454458
"""
455459
Change environment bond dimension of all tensors in the unit cell.
456460
457461
Args:
458462
new_chi (:obj:`int`):
459463
New value for the environment bond dimension.
464+
reset_max_chi (:obj:`bool`):
465+
Set maximal bond dimension to the same new value.
460466
Returns:
461467
PEPS_Unit_Cell:
462468
New instance of PEPS unit cell with the new tensor list.
463469
"""
464470
new_unique_tensors = type(self.data.peps_tensors)(
465-
t.change_chi(new_chi) for t in self.data.peps_tensors
471+
t.change_chi(new_chi, reset_max_chi=reset_max_chi)
472+
for t in self.data.peps_tensors
466473
)
467474

468475
new_data = self.data.replace_peps_tensors(new_unique_tensors)

0 commit comments

Comments
 (0)