Beispiel #1
0
def test_power_by_near_field_poynting_vector(source, rtol):
    """Check that the power is correct by integrating the near field Poynting vector in the xy plane"""
    E = source.E_field(X, Y, Z, k)
    H = source.H_field(X, Y, Z, k)
    S = 0.5 / Z0 * np.cross(E, np.conjugate(H), axis=0)[2]
    P = trapz_2d(x, y, S).real

    assert np.allclose(P, power, rtol=rtol)
Beispiel #2
0
    def test_power_spherically_ingoing_waves(self):
        """power by far-field integration of spherically ingoing waves"""
        lmax = 6
        radius = 1e6 * (2 * np.pi / k)

        p_src = self.source.structure([0, 0, 0], k, lmax)
        theta = np.linspace(np.pi / 2, np.pi, 20)
        phi = np.linspace(0, 2 * np.pi, 20)
        THETA, PHI = np.meshgrid(theta, phi)
        R = radius * np.ones_like(THETA)

        Efunc = miepy.expand_E(p_src / 2, k, miepy.vsh_mode.ingoing)
        E = Efunc(R, THETA, PHI)
        S = 0.5 / Z0 * np.sum(np.abs(E)**2, axis=0) * np.sin(THETA)
        P = radius**2 * trapz_2d(theta, phi, S.T).real

        assert np.allclose(P, self.power, rtol=.04)
Beispiel #3
0
    def test_power_2d_integration(self):
        """power by  integrating Poynting vector in 2D plane"""
        lmax = 6
        p_src = self.source.structure([0, 0, 0], k, lmax)
        a = 3000 * nm
        x = np.linspace(-a, a, 20)
        y = np.linspace(-a, a, 20)
        X, Y = np.meshgrid(x, y)
        R, THETA, PHI = miepy.coordinates.cart_to_sph(X, Y, 0)
        Efunc = miepy.expand_E(p_src, k, miepy.vsh_mode.incident)
        Hfunc = miepy.expand_H(p_src, k, miepy.vsh_mode.incident, 1, 1)
        E = Efunc(R, THETA, PHI)
        H = Hfunc(R, THETA, PHI)
        E = miepy.coordinates.vec_sph_to_cart(E, THETA, PHI)
        H = miepy.coordinates.vec_sph_to_cart(H, THETA, PHI) / Z0

        S = 0.5 * np.linalg.norm(np.cross(E, np.conjugate(H), axis=0), axis=0)
        S = 0.5 * np.cross(E, np.conjugate(H), axis=0)[2]
        # S = 0.5*np.sum(np.abs(E)**2, axis=0)

        P = trapz_2d(x, y, S).real

        assert np.allclose(P, self.power, rtol=.04)