From 223b202d03c8a5298732886bc8b368eca0487029 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Fri, 19 Jul 2019 00:19:47 -0700 Subject: [PATCH] More test cases --- fdfd_tools/test_fdtd.py | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/fdfd_tools/test_fdtd.py b/fdfd_tools/test_fdtd.py index 692cd61..bc995c1 100644 --- a/fdfd_tools/test_fdtd.py +++ b/fdfd_tools/test_fdtd.py @@ -126,17 +126,16 @@ class Basic2DNoDXOnlyVacuum(unittest.TestCase, BasicTests): self.hs.append(h) - class Basic3DUniformDXOnlyVacuum(unittest.TestCase, BasicTests): def setUp(self): shape = [3, 5, 5, 5] - self.dt = 0.33 + self.dt = 0.5 self.epsilon = numpy.ones(shape, 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, 0] = True + self.src_mask[1, 2, 2, 2] = True e = 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): def setUp(self): shape = [3, 5, 5, 5] self.dt = 0.33 - 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, 0] = True + self.src_mask = numpy.zeros(shape, dtype=bool) + 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) h = numpy.zeros_like(self.epsilon)