From 38cb10720f1b0c16e7286976e4ecb9e64932adee Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Wed, 6 Jan 2016 18:35:14 +0000 Subject: [PATCH] Corrected class name; added functions to calculate current at a grid point. --- gprMax/grid.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/gprMax/grid.py b/gprMax/grid.py index c2a44b48..beb3081d 100644 --- a/gprMax/grid.py +++ b/gprMax/grid.py @@ -22,7 +22,7 @@ from gprMax.constants import floattype, complextype from gprMax.materials import Material -class FDTDGrid(): +class FDTDGrid: """Holds attributes associated with the entire grid. A convenient way for accessing regularly used parameters.""" def __init__(self): @@ -51,6 +51,7 @@ class FDTDGrid(): self.voltagesources = [] self.hertziandipoles = [] self.magneticdipoles = [] + self.transmissionlines = [] self.txs = [] # Only used for converting old output files to HDF5 format self.srcstepx = 0 self.srcstepy = 0 @@ -98,5 +99,56 @@ class FDTDGrid(): self.updatecoeffsdispersive = np.zeros((nummaterials, 3 * Material.maxpoles), dtype=complextype) +def Ix(x, y, z, Hy, Hz, G): + """Calculates the x-component of current at a grid position. + + Args: + x, y, z (float): Coordinates of position in grid. + Hy, Hz (memory view): numpy array of magnetic field values. + G (class): Grid class instance - holds essential parameters describing the model. + """ + + if y == 0 or z == 0: + Ix = 0 + return Ix + + else: + Ix = G.dy * (Hy[x, y, z - 1] - Hy[x, y, z]) + G.dz * (Hz[x, y, z] - Hz[x, y - 1, z]) + return Ix + +def Iy(x, y, z, Hx, Hz, G): + """Calculates the y-component of current at a grid position. + + Args: + x, y, z (float): Coordinates of position in grid. + Hx, Hz (memory view): numpy array of magnetic field values. + G (class): Grid class instance - holds essential parameters describing the model. + """ + + if x == 0 or z == 0: + Iy = 0 + return Iy + + else: + Iy = G.dx * (Hx[x, y, z] - Hx[x, y, z - 1]) + G.dz * (Hz[x - 1, y, z] - Hz[x, y, z]) + return Iy + +def Iz(x, y, z, Hx, Hy, G): + """Calculates the z-component of current at a grid position. + + Args: + x, y, z (float): Coordinates of position in grid. + Hx, Hy (memory view): numpy array of magnetic field values. + G (class): Grid class instance - holds essential parameters describing the model. + """ + + if x == 0 or y == 0: + Iz = 0 + return Iz + + else: + Iz = G.dx * (Hx[x, y - 1, z] - Hx[x, y, z]) + G.dy * (Hy[x, y, z] - Hy[x - 1, y, z]) + return Iz +