From 8e1d99dda332b5761ae6287124e470d47421fe35 Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Tue, 1 Mar 2016 15:37:34 +0000 Subject: [PATCH] Cleanup initialisation of coefficient arrays. --- gprMax/gprMax.py | 4 ++-- gprMax/grid.py | 22 +++++++--------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/gprMax/gprMax.py b/gprMax/gprMax.py index c0b20ebe..ec47c8fa 100644 --- a/gprMax/gprMax.py +++ b/gprMax/gprMax.py @@ -290,11 +290,11 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace): voltagesource.create_material(G) # Initialise arrays of update coefficients to pass to update functions - G.initialise_std_updatecoeff_arrays(len(G.materials)) + G.initialise_std_updatecoeff_arrays() # Initialise arrays of update coefficients and temporary values if there are any dispersive materials if Material.maxpoles != 0: - G.initialise_dispersive_arrays(len(G.materials)) + G.initialise_dispersive_arrays() # Calculate update coefficients, store in arrays, and list materials in model if G.messages: diff --git a/gprMax/grid.py b/gprMax/grid.py index 826953d9..bb21fb42 100644 --- a/gprMax/grid.py +++ b/gprMax/grid.py @@ -78,25 +78,17 @@ class FDTDGrid: self.Hy = np.zeros((self.nx, self.ny + 1, self.nz), dtype=floattype) self.Hz = np.zeros((self.nx, self.ny, self.nz + 1), dtype=floattype) - def initialise_std_updatecoeff_arrays(self, nummaterials): - """Initialise arrays for storing update coefficients. - - Args: - nummaterials (int): Number of materials present in the model. - """ - self.updatecoeffsE = np.zeros((nummaterials, 5), dtype=floattype) - self.updatecoeffsH = np.zeros((nummaterials, 5), dtype=floattype) + def initialise_std_updatecoeff_arrays(self): + """Initialise arrays for storing update coefficients.""" + self.updatecoeffsE = np.zeros((len(self.materials), 5), dtype=floattype) + self.updatecoeffsH = np.zeros((len(self.materials), 5), dtype=floattype) - def initialise_dispersive_arrays(self, nummaterials): - """Initialise arrays for storing coefficients when there are dispersive materials present. - - Args: - nummaterials (int): Number of materials present in the model. - """ + def initialise_dispersive_arrays(self): + """Initialise arrays for storing coefficients when there are dispersive materials present.""" self.Tx = np.zeros((Material.maxpoles, self.nx, self.ny + 1, self.nz + 1), dtype=complextype) self.Ty = np.zeros((Material.maxpoles, self.nx + 1, self.ny, self.nz + 1), dtype=complextype) self.Tz = np.zeros((Material.maxpoles, self.nx + 1, self.ny + 1, self.nz), dtype=complextype) - self.updatecoeffsdispersive = np.zeros((nummaterials, 3 * Material.maxpoles), dtype=complextype) + self.updatecoeffsdispersive = np.zeros((len(self.materials), 3 * Material.maxpoles), dtype=complextype) def dispersion_check(waveforms, materials, dx, dy, dz):