From 099966f2910e6fb115cc029b7eb9bdc3da547109 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Tue, 9 Jul 2019 20:20:49 -0700 Subject: [PATCH] Add poynting vector and divergence --- fdfd_tools/fdtd.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fdfd_tools/fdtd.py b/fdfd_tools/fdtd.py index f72c7a3..5279d22 100644 --- a/fdfd_tools/fdtd.py +++ b/fdfd_tools/fdtd.py @@ -241,3 +241,18 @@ def cpml(direction:int, return e, h return pml_e, pml_h, fields + + +def poynting(e, h): + s = [numpy.roll(e[1], -1, axis=0) * h[2] - numpy.roll(e[2], -1, axis=0) * h[1], + numpy.roll(e[2], -1, axis=1) * h[0] - numpy.roll(e[0], -1, axis=1) * h[2], + numpy.roll(e[0], -1, axis=2) * h[1] - numpy.roll(e[1], -1, axis=2) * h[0]] + return numpy.array(s) + + +def div_poyting(dt, dxes, e, h): + s = poynting(e, h) + ds = (s[0] - numpy.roll(s[0], 1, axis=0) + + s[1] - numpy.roll(s[1], 1, axis=1) + + s[2] - numpy.roll(s[2], 1, axis=2)) + return ds