Corrected class name; added functions to calculate current at a grid point.

这个提交包含在:
Craig Warren
2016-01-06 18:35:14 +00:00
父节点 2eec76aafa
当前提交 38cb10720f

查看文件

@@ -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