diff --git a/gprMax/subgrids/base.py b/gprMax/subgrids/base.py index 9ba9ee82..0b1364cd 100644 --- a/gprMax/subgrids/base.py +++ b/gprMax/subgrids/base.py @@ -17,19 +17,9 @@ # along with gprMax. If not, see . from ..grid import FDTDGrid -from ..materials import Material - -from scipy.constants import mu_0 -from scipy.constants import epsilon_0 from scipy.constants import c - import numpy as np -from colorama import init -from colorama import Fore -from colorama import Style -init() - class SubGridBase(FDTDGrid): @@ -64,6 +54,7 @@ class SubGridBase(FDTDGrid): # Number of sub cells to extend the sub grid beyond the IS boundary d_to_pml = self.s_is_os_sep + self.pml_separation + # index of the is self.n_boundary_cells = d_to_pml + self.pmlthickness['x0'] self.n_boundary_cells_x = d_to_pml + self.pmlthickness['x0'] self.n_boundary_cells_y = d_to_pml + self.pmlthickness['y0'] @@ -72,17 +63,17 @@ class SubGridBase(FDTDGrid): self.interpolation = kwargs['interpolation'] def calculate_dt(self): + """Calculate dt at the CFL limit.""" self.dt = (1 / (c * np.sqrt( - (1 / self.dx) * (1 / self.dx) + - (1 / self.dy) * (1 / self.dy) + - (1 / self.dz) * (1 / self.dz)))) - + (1 / self.dx) * (1 / self.dx) + + (1 / self.dy) * (1 / self.dy) + + (1 / self.dz) * (1 / self.dz)))) def main_grid_index_to_subgrid_index(self, i, j, k): + """Calculate local subgrid index from global main grid index.""" i_s = self.n_boundary_cells_x + (i - self.i0) * self.ratio j_s = self.n_boundary_cells_y + (j - self.j0) * self.ratio k_s = self.n_boundary_cells_z + (k - self.k0) * self.ratio - return (i_s, j_s, k_s) def initialise_geometry_arrays(self):