Exemple #1
0
    def test_get_layer_s_matrix_phase(self):
        """
        Test phase propagation through vacuum.

          0   1   2    3        4     5   layer-index
            |  |    |      |        |
            |  |    |      |        |
             thickness:  1 quarter wavelength
                         2 half wavelength
                         3 three quarter wavelength
                         4 one wavelength
        With N = (1.-0*j) for all layers we expect s_tilde(p) to be
            s_tilde(p) = | phi  0  |
                         | 0   phi |
        with phi = exp(-j q h).
        """
        k_v = 2. * np.pi / 1.
        k_t = 0.
        Ns = np.ones((6,), dtype="complex64")
        qs = np.sqrt((k_v * Ns)**2 - k_t**2)
        qs = np.where(qs.imag <= 0, qs, -qs)        # here: qs = k_v
        mus = np.ones((6,), dtype="complex64")
        hs = np.array([0., 0.25, 0.5, 0.75, 1., 0.], dtype="float32")
        identity = np.identity(2, dtype="complex64")
        expected_stildes = [identity,
                            complex(0, -1) * identity,
                            complex(-1, 0) * identity,
                            complex(0, 1) * identity,
                            identity]
        for pol in ['TE', 'TM']:
            for p in range(5):
                s_tilde = smatrix.get_layer_s_matrix(p, qs, Ns, mus, hs,
                                                     k_v, pol)
                numpy.testing.assert_allclose(s_tilde, expected_stildes[p],
                                              rtol=3e-07, atol=1e-16)
Exemple #2
0
    def test_get_layer_s_matrix_absorption(self):
        """
        Test s_tilde(p) for absorption in stack of equal materials.

        rtol=3e-7 apparantly is needed because we use float32 and complex64.
        """
        conf_1 = TestConfExtinctiveAir(k_extinction=0.01)

        for pol in ['TE', 'TM']:
            for p in range(5):
                s_tilde = smatrix.get_layer_s_matrix(
                    p, conf_1.qs, conf_1.Ns, conf_1.mus,
                    conf_1.hs, conf_1.k_v, pol)
                numpy.testing.assert_allclose(s_tilde,
                                              conf_1.expected_stildes[p],
                                              rtol=3e-07, atol=1e-16)