diff --git a/gprMax/cmds_singleuse.py b/gprMax/cmds_singleuse.py index ed722d37..ae451973 100644 --- a/gprMax/cmds_singleuse.py +++ b/gprMax/cmds_singleuse.py @@ -191,7 +191,7 @@ class TimeStepStabilityFactor(UserObjectSingle): raise ValueError G.dt_mod = f - G.dt = G.dt * G.dt_mod + G.calculate_dt() logger.info(f'Time step (modified): {G.dt:g} secs') diff --git a/gprMax/grid.py b/gprMax/grid.py index a4960727..069a8de2 100644 --- a/gprMax/grid.py +++ b/gprMax/grid.py @@ -46,7 +46,7 @@ class FDTDGrid: self.dy = 0 self.dz = 0 self.dt = 0 - self.dt_mod = None # Time step stability factor + self.dt_mod = 1 # Time step stability factor self.iteration = 0 # Current iteration number self.iterations = 0 # Total number of iterations self.timewindow = 0 @@ -299,6 +299,9 @@ class FDTDGrid: # binary representation of floating point number. self.dt = round_value(self.dt, decimalplaces=d.getcontext().prec - 1) + # Apply any time step stability factor + self.dt = self.dt * self.dt_mod + class CUDAGrid(FDTDGrid): """Additional grid methods for solving on GPU using CUDA.""" diff --git a/gprMax/subgrids/user_objects.py b/gprMax/subgrids/user_objects.py index 18421be7..d4e12dbd 100644 --- a/gprMax/subgrids/user_objects.py +++ b/gprMax/subgrids/user_objects.py @@ -91,11 +91,8 @@ class SubGridBase(UserObjectMulti): self.set_discretisation(sg, grid) - # Set temporal discretisation including inheriting any time step - # stability factor from the main grid + # Set temporal discretisation sg.calculate_dt() - if sg.dt_mod: - sg.dt = sg.dt * sg.dt_mod # Set the indices related to the subgrids main grid placement self.set_main_grid_indices(sg, uip, p1, p2)