Skip to content

Commit

Permalink
TEBD: make sure queue always drains
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Nov 3, 2022
1 parent 6c312f6 commit dcd8cbc
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions quimb/tensor/tensor_1d_tebd.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def update_to(self, T, dt=None, tol=None, order=4, progbar=None):
Manually turn the progress bar off.
"""
if T < self.t - self.TARGET_TOL:
# can't go backwards yet
raise NotImplementedError

self._compute_sweep_dt_tol(T, dt, tol, order)
Expand All @@ -382,18 +383,12 @@ def update_to(self, T, dt=None, tol=None, order=4, progbar=None):
progbar = self.progbar if (progbar is None) else progbar
progbar = continuous_progbar(self.t, T) if progbar else None

while self.t < T - self.TARGET_TOL:
if (T - self.t < self._dt):
# set custom dt if within one step of final time
dt = T - self.t
# also make sure queued sweeps are drained
queue = False
else:
dt = None
queue = True
while self.t < T - self._dt:
# get closer until we can reach in a single step
self.step(order=order, progbar=progbar, dt=None, queue=True)

# perform a step!
self.step(order=order, progbar=progbar, dt=dt, queue=queue)
# always perform final sweep with queue draining
self.step(order=order, progbar=progbar, dt=T - self.t, queue=False)

if progbar:
progbar.close()
Expand Down

0 comments on commit dcd8cbc

Please sign in to comment.