From ccdb423ba2091ff911fcecd48494cb0e123122cf Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 26 Aug 2019 00:15:34 -0700 Subject: [PATCH] add e_tfsf_source --- meanas/fdfd/functional.py | 17 +++++++++++++++++ meanas/fdfd/operators.py | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/meanas/fdfd/functional.py b/meanas/fdfd/functional.py index 655d9b8..fe11e51 100644 --- a/meanas/fdfd/functional.py +++ b/meanas/fdfd/functional.py @@ -187,3 +187,20 @@ def m2j(omega: complex, return m2j_mu +def e_tfsf_source(TF_region: field_t, + omega: complex, + dxes: dx_lists_t, + epsilon: field_t, + mu: field_t = None, + ) -> functional_matrix: + """ + Operator that turuns an E-field distribution into a total-field/scattered-field + (TFSF) source. + """ + # TODO documentation + A = e_full(omega, dxes, epsilon, mu) + + def op(e): + neg_iwj = A(TF_region * e) - TF_region * A(e) + return neg_iwj / (-1j * omega) + diff --git a/meanas/fdfd/operators.py b/meanas/fdfd/operators.py index 774c3d9..3042af4 100644 --- a/meanas/fdfd/operators.py +++ b/meanas/fdfd/operators.py @@ -501,3 +501,21 @@ def poynting_h_cross(h: vfield_t, dxes: dx_lists_t) -> sparse.spmatrix: [ bx @ Hz @ fy @ dagx, zero, -bz @ Hx @ fy @ dagz], [-bx @ Hy @ fz @ dagx, by @ Hx @ fz @ dagy, zero]]) return P + + +def e_tfsf_source(TF_region: vfield_t, + omega: complex, + dxes: dx_lists_t, + epsilon: vfield_t, + mu: vfield_t = None, + ) -> sparse.spmatrix: + """ + Operator that turns an E-field distribution into a total-field/scattered-field + (TFSF) source. + """ + # TODO documentation + A = e_full(omega, dxes, epsilon, mu) + Q = sparse.diags(TF_region) + return (A @ Q - Q @ A) / (-1j * omega) + +