From 1cbeefb2ea200a9294095ea3a91c1e0523a560c4 Mon Sep 17 00:00:00 2001 From: Logan Bishop-Van Horn Date: Thu, 27 Jun 2024 16:04:01 -0700 Subject: [PATCH 1/2] Fix bug when number of solve steps % save_every == 0 --- tdgl/solver/runner.py | 2 +- tdgl/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tdgl/solver/runner.py b/tdgl/solver/runner.py index 6515e0e..c276f59 100644 --- a/tdgl/solver/runner.py +++ b/tdgl/solver/runner.py @@ -449,6 +449,6 @@ def save_step(step): self.logger.warning(msg.format("Cancelling")) cancelled = True break - if save: + if save and (i % self.options.save_every): save_step(i) return not cancelled diff --git a/tdgl/version.py b/tdgl/version.py index 25223ef..7b0258d 100644 --- a/tdgl/version.py +++ b/tdgl/version.py @@ -1,4 +1,4 @@ -__version_info__ = (0, 8, 2) +__version_info__ = (0, 8, 3) __version__ = ".".join(map(str, __version_info__)) From 0562772d42fbb2f44453846512c589ca2625f62e Mon Sep 17 00:00:00 2001 From: Logan Bishop-Van Horn Date: Thu, 27 Jun 2024 16:04:29 -0700 Subject: [PATCH 2/2] Use xp.allclose() --- tdgl/solver/solver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tdgl/solver/solver.py b/tdgl/solver/solver.py index 73b0544..3425c23 100644 --- a/tdgl/solver/solver.py +++ b/tdgl/solver/solver.py @@ -632,7 +632,7 @@ def update( (current_A_applied - prev_A_applied) / dt, self.normalized_directions, ) - if xp.any(xp.absolute(dA_dt) > 0): + if not xp.allclose(current_A_applied, self.current_A_applied): # Update the link exponents only if the applied vector potential # has actually changed. operators.set_link_exponents(current_A_applied) @@ -642,10 +642,10 @@ def update( self.current_A_applied = current_A_applied # Update the value of epsilon - epsilon = self.epsilon if self.dynamic_epsilon: - epsilon = self.epsilon = self.update_epsilon(time) + self.epsilon = self.update_epsilon(time) + epsilon = self.epsilon old_sq_psi = xp.absolute(psi) ** 2 screening_error = np.inf A_induced_vals = [A_induced]