More test cases

This commit is contained in:
Jan Petykiewicz 2019-07-19 00:19:47 -07:00
parent fb3c88a78d
commit 223b202d03

View File

@ -126,17 +126,16 @@ class Basic2DNoDXOnlyVacuum(unittest.TestCase, BasicTests):
self.hs.append(h) self.hs.append(h)
class Basic3DUniformDXOnlyVacuum(unittest.TestCase, BasicTests): class Basic3DUniformDXOnlyVacuum(unittest.TestCase, BasicTests):
def setUp(self): def setUp(self):
shape = [3, 5, 5, 5] shape = [3, 5, 5, 5]
self.dt = 0.33 self.dt = 0.5
self.epsilon = numpy.ones(shape, dtype=float) self.epsilon = numpy.ones(shape, dtype=float)
self.j_mag = 32 self.j_mag = 32
self.dxes = tuple(tuple(numpy.ones(s) for s in shape[1:]) for _ in range(2)) self.dxes = tuple(tuple(numpy.ones(s) for s in shape[1:]) for _ in range(2))
self.src_mask = numpy.zeros_like(self.epsilon, dtype=bool) self.src_mask = numpy.zeros_like(self.epsilon, dtype=bool)
self.src_mask[1, 2, 2, 0] = True self.src_mask[1, 2, 2, 2] = True
e = numpy.zeros_like(self.epsilon) e = numpy.zeros_like(self.epsilon)
h = numpy.zeros_like(self.epsilon) h = numpy.zeros_like(self.epsilon)
@ -156,16 +155,46 @@ class Basic3DUniformDXOnlyVacuum(unittest.TestCase, BasicTests):
class Basic3DUniformDXUniformN(unittest.TestCase, BasicTests):
def setUp(self):
shape = [3, 5, 5, 5]
self.dt = 0.5
self.epsilon = numpy.full(shape, 2, dtype=float)
self.j_mag = 32
self.dxes = tuple(tuple(numpy.ones(s) for s in shape[1:]) for _ in range(2))
self.src_mask = numpy.zeros_like(self.epsilon, dtype=bool)
self.src_mask[1, 2, 2, 2] = True
e = numpy.zeros_like(self.epsilon)
h = numpy.zeros_like(self.epsilon)
e[self.src_mask] = self.j_mag / self.epsilon[self.src_mask]
self.es = [e]
self.hs = [h]
eh2h = fdtd.maxwell_h(dt=self.dt, dxes=self.dxes)
eh2e = fdtd.maxwell_e(dt=self.dt, dxes=self.dxes)
for _ in range(9):
e = e.copy()
h = h.copy()
eh2h(e, h)
eh2e(e, h, self.epsilon)
self.es.append(e)
self.hs.append(h)
class Basic3DUniformDX(unittest.TestCase, BasicTests): class Basic3DUniformDX(unittest.TestCase, BasicTests):
def setUp(self): def setUp(self):
shape = [3, 5, 5, 5] shape = [3, 5, 5, 5]
self.dt = 0.33 self.dt = 0.33
self.epsilon = numpy.full(shape, 2, dtype=float)
self.j_mag = 32 self.j_mag = 32
self.dxes = tuple(tuple(numpy.ones(s) for s in shape[1:]) for _ in range(2)) self.dxes = tuple(tuple(numpy.ones(s) for s in shape[1:]) for _ in range(2))
self.src_mask = numpy.zeros_like(self.epsilon, dtype=bool) self.src_mask = numpy.zeros(shape, dtype=bool)
self.src_mask[1, 2, 2, 0] = True self.src_mask[1, 2, 2, 2] = True
self.epsilon = numpy.full(shape, 1, dtype=float)
self.epsilon[self.src_mask] = 2
e = numpy.zeros_like(self.epsilon) e = numpy.zeros_like(self.epsilon)
h = numpy.zeros_like(self.epsilon) h = numpy.zeros_like(self.epsilon)