Skip to content

Commit

Permalink
fill _gauge_diffs error
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Nov 20, 2024
1 parent 58e5116 commit ff78328
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions quimb/tensor/tensor_arbgeom_tebd.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ def sweep(self, tau):

def _set_progbar_description(self, pbar):
desc = f"n={self._n}, tau={float(self.last_tau):.2g}"
if self._gauge_diffs:
desc += f", max|dS|={self._gauge_diffs[-1]:.2g}"
if getattr(self, "gauge_diffs", None):
desc += f", max|dS|={self.gauge_diffs[-1]:.2g}"
if self.energies:
desc += f", energy~{float(self.energies[-1]):.6g}"
pbar.set_description(desc)
Expand Down Expand Up @@ -836,8 +836,8 @@ def set_axis_color(ax, which, color):

x_en = np.array(self.its)
y_en = np.array(self.energies)
x_gd = np.arange(1, len(self._gauge_diffs) + 1)
y_gd = np.array(self._gauge_diffs)
x_gd = np.arange(1, len(self.gauge_diffs) + 1)
y_gd = np.array(self.gauge_diffs)

if zoom is not None:
if zoom == "auto":
Expand Down Expand Up @@ -1004,8 +1004,8 @@ def __init__(
self.equilibrate_opts.setdefault("max_iterations", 100)
self.equilibrate_opts.setdefault("tol", 1e-3)

self._gauges_prev = None
self._gauge_diffs = []
self.gauges_prev = None
self.gauge_diffs = []

return super().__init__(
psi0,
Expand Down Expand Up @@ -1063,10 +1063,10 @@ def postsweep(self, i):
self.equilibrate()

# check gauges for convergence / progbar
if self._gauges_prev is not None:
if self.gauges_prev is not None:
sdiffs = []
for k, g in self.gauges.items():
g_prev = self._gauges_prev[k]
g_prev = self.gauges_prev[k]
try:
sdiff = do("linalg.norm", g - g_prev)
except ValueError:
Expand All @@ -1075,12 +1075,12 @@ def postsweep(self, i):
sdiffs.append(sdiff)

max_sdiff = max(sdiffs)
self._gauge_diffs.append(max_sdiff)
self.gauge_diffs.append(max_sdiff)

if self.tol is not None and (max_sdiff < self.tol):
self.stop = True

self._gauges_prev = self.gauges.copy()
self.gauges_prev = self.gauges.copy()

def normalize(self):
"""Normalize the state and simple gauges."""
Expand Down

0 comments on commit ff78328

Please sign in to comment.