From 79e14af4db371d82bfb4c2eec084d06af7ed827b Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Wed, 17 Jul 2019 00:50:49 -0700 Subject: [PATCH] poynting divergence doesn't use dt, and can have default dxes --- fdfd_tools/fdtd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fdfd_tools/fdtd.py b/fdfd_tools/fdtd.py index 0cdec0d..bc52e45 100644 --- a/fdfd_tools/fdtd.py +++ b/fdfd_tools/fdtd.py @@ -263,9 +263,13 @@ def poynting(e, h): return numpy.array(s) -def poynting_divergence(dt, dxes, s=None, *, e=None, h=None): # TODO dxes +def poynting_divergence(s=None, *, e=None, h=None, dxes=None): # TODO dxes + if dxes is None: + dxes = tuple(tuple(numpy.ones(1) for _ in range(3)) for _ in range(2)) + if s is None: s = poynting(e, h) + ds = ((s[0] - numpy.roll(s[0], 1, axis=0)) / numpy.sqrt(dxes[0][0] * dxes[1][0])[:, None, None] + (s[1] - numpy.roll(s[1], 1, axis=1)) / numpy.sqrt(dxes[0][1] * dxes[1][1])[None, :, None] + (s[2] - numpy.roll(s[2], 1, axis=2)) / numpy.sqrt(dxes[0][2] * dxes[1][2])[None, None, :] )