From 07c94617fefd5b5da72331958d1e48350601ba0d Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Wed, 7 Aug 2019 01:01:55 -0700 Subject: [PATCH] Operator-based soruce --- meanas/fdfd/waveguide_mode.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/meanas/fdfd/waveguide_mode.py b/meanas/fdfd/waveguide_mode.py index 1603547..1cce856 100644 --- a/meanas/fdfd/waveguide_mode.py +++ b/meanas/fdfd/waveguide_mode.py @@ -170,18 +170,25 @@ def compute_source(E: field_t, src_order = numpy.roll(range(3), -axis) exp_iphi = numpy.exp(1j * polarity * wavenumber * dxes[1][axis][slices[axis]]) - J[src_order[1]] = +exp_iphi * H[src_order[2]] * polarity - J[src_order[2]] = -exp_iphi * H[src_order[1]] * polarity rollby = -1 if polarity > 0 else 0 - M[src_order[1]] = +numpy.roll(E[src_order[2]], rollby, axis=axis) - M[src_order[2]] = -numpy.roll(E[src_order[1]], rollby, axis=axis) +# J[src_order[1]] = +exp_iphi * H[src_order[2]] * polarity / dxes[1][axis][slices[axis]] +# J[src_order[2]] = -exp_iphi * H[src_order[1]] * polarity / dxes[1][axis][slices[axis]] +# M[src_order[1]] = +numpy.roll(E[src_order[2]], rollby, axis=axis) / dxes[0][axis][slices[axis]] +# M[src_order[2]] = -numpy.roll(E[src_order[1]], rollby, axis=axis) / dxes[0][axis][slices[axis]] + + s2 = [slice(None), slice(None), slice(None)] + s2[axis] = slice(slices[axis].start, slices[axis].stop) + s2 = (src_order, *s2) + + J[s2] = numpy.roll(functional.curl_h(dxes=dxes)(H), rollby, axis=axis+1)[s2] * polarity * exp_iphi + M[s2] = numpy.roll(functional.curl_e(dxes=dxes)(E), -rollby, axis=axis+1)[s2] m2j = functional.m2j(omega, dxes, mu) Jm = m2j(M) Jtot = J + Jm - return Jtot + return Jtot.conj() def compute_overlap_e(E: field_t, @@ -332,7 +339,6 @@ def compute_source_q(E: field_t, Jm = m2j(M) Jtot = J + Jm - return Jtot, J, M