From c0a68c4bf9e4fb2218ae90d864e853d00bc2d193 Mon Sep 17 00:00:00 2001 From: nmannall Date: Wed, 15 May 2024 15:36:52 +0100 Subject: [PATCH] Move timewindow and interations to Model class --- gprMax/cmds_singleuse.py | 12 ++++++------ gprMax/grid/fdtd_grid.py | 4 ---- gprMax/model.py | 4 ++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gprMax/cmds_singleuse.py b/gprMax/cmds_singleuse.py index 616133ef..62ae51fd 100644 --- a/gprMax/cmds_singleuse.py +++ b/gprMax/cmds_singleuse.py @@ -226,27 +226,27 @@ class TimeWindow(UserObjectSingle): # the fact that the solver (iterations) loop runs from 0 to < G.iterations try: iterations = int(self.kwargs["iterations"]) - G.timewindow = (iterations - 1) * G.dt - G.iterations = iterations + model.timewindow = (iterations - 1) * model.G.dt + model.iterations = iterations except KeyError: pass try: tmp = float(self.kwargs["time"]) if tmp > 0: - G.timewindow = tmp - G.iterations = int(np.ceil(tmp / G.dt)) + 1 + model.timewindow = tmp + model.iterations = int(np.ceil(tmp / model.G.dt)) + 1 else: logger.exception(self.__str__() + " must have a value greater than zero") raise ValueError except KeyError: pass - if not G.timewindow: + if not model.timewindow: logger.exception(self.__str__() + " specify a time or number of iterations") raise ValueError - logger.info(f"Time window: {G.timewindow:g} secs ({G.iterations} iterations)") + logger.info(f"Time window: {model.timewindow:g} secs ({model.iterations} iterations)") class OMPThreads(UserObjectSingle): diff --git a/gprMax/grid/fdtd_grid.py b/gprMax/grid/fdtd_grid.py index 403f97f0..db22af42 100644 --- a/gprMax/grid/fdtd_grid.py +++ b/gprMax/grid/fdtd_grid.py @@ -59,10 +59,6 @@ class FDTDGrid: self.dl: np.ndarray[Any, np.dtype[np.single]] self.dt = 0.0 - self.iteration = 0 # Current iteration number - self.iterations = 0 # Total number of iterations - self.timewindow = 0 - # PML parameters - set some defaults to use if not user provided self.pmls = {} self.pmls["formulation"] = "HORIPML" diff --git a/gprMax/model.py b/gprMax/model.py index 06211c11..89a28d67 100644 --- a/gprMax/model.py +++ b/gprMax/model.py @@ -62,6 +62,10 @@ class Model: self.dt_mod = 1.0 # Time step stability factor + self.iteration = 0 # Current iteration number + self.iterations = 0 # Total number of iterations + self.timewindow = 0.0 + self.G = self._create_grid() # Monitor memory usage self.p = None