Пример #1
0
    def test_abcd_lossy_line(self):
        '''
        Lossy transmission line of characteristic impedance Z0, length l
        and propagation constant gamma = alpha + j beta

        ○---------○

        ○---------○

        has ABCD matrix of the form:

        [ cosh(gamma l)       Z0 sinh(gamma l) ]
        [ 1/Z0 sinh(gamma l)  cosh(gamma l) ]
        '''
        l = 5.0
        z0 = 30.0
        alpha = 0.5
        beta = 2.0
        lossy_media = DefinedGammaZ0(frequency=Frequency(1, 100, 21, 'GHz'),
                                     gamma=alpha + 1j * beta,
                                     z0=z0)
        ntw = lossy_media.line(d=l, unit='m', z0=z0)
        gamma = lossy_media.gamma
        npy.testing.assert_array_almost_equal(ntw.a[:, 0, 0],
                                              npy.cosh(gamma * l))
        npy.testing.assert_array_almost_equal(ntw.a[:, 0, 1],
                                              z0 * npy.sinh(gamma * l))
        npy.testing.assert_array_almost_equal(ntw.a[:, 1, 0],
                                              1.0 / z0 * npy.sinh(gamma * l))
        npy.testing.assert_array_almost_equal(ntw.a[:, 1, 1],
                                              npy.cosh(gamma * l))
Пример #2
0
 def setUp(self):
     self.files_dir = os.path.join(
         os.path.dirname(os.path.abspath(__file__)), 'qucs_prj')
     self.dummy_media = DefinedGammaZ0(
         frequency=Frequency(1, 100, 21, 'ghz'),
         gamma=1j,
         z0=50,
     )
Пример #3
0
    def test_complex_ports(self):
        m = DefinedGammaZ0(
            frequency=Frequency(1, 1, 1, 'ghz'),
            gamma=1j,
            z0=50,
            Z0=10 + 20j,
        )
        self.assertTrue(m.Z0.imag != 0)

        # Powerwave short is -Z0.conj()/Z0
        short = m.short(z0=m.Z0, s_def='power')
        self.assertTrue(short.s != -1)
        # Should be -1 when converted to traveling s_def
        npy.testing.assert_allclose(short.s_traveling, -1)

        short = m.short(z0=m.Z0, s_def='traveling')
        npy.testing.assert_allclose(short.s, -1)

        short = m.short(z0=m.Z0, s_def='pseudo')
        npy.testing.assert_allclose(short.s, -1)

        # Mismatches agree with real port impedances
        mismatch_traveling = m.impedance_mismatch(z1=10,
                                                  z2=50,
                                                  s_def='traveling')
        mismatch_pseudo = m.impedance_mismatch(z1=10, z2=50, s_def='pseudo')
        mismatch_power = m.impedance_mismatch(z1=10, z2=50, s_def='power')
        npy.testing.assert_allclose(mismatch_traveling.s, mismatch_pseudo.s)
        npy.testing.assert_allclose(mismatch_traveling.s, mismatch_power.s)

        mismatch_traveling = m.impedance_mismatch(z1=10 + 10j,
                                                  z2=50 - 20j,
                                                  s_def='traveling')
        mismatch_pseudo = m.impedance_mismatch(z1=10 + 10j,
                                               z2=50 - 20j,
                                               s_def='pseudo')
        mismatch_power = m.impedance_mismatch(z1=10 + 10j,
                                              z2=50 - 20j,
                                              s_def='power')

        # Converting thru to new impedance should give impedance mismatch.
        # The problem is that thru Z-parameters have infinities
        # and renormalization goes through Z-parameters making
        # it very inaccurate.
        thru_traveling = m.thru(s_def='traveling')
        thru_traveling.renormalize(z_new=[10 + 10j, 50 - 20j])
        thru_pseudo = m.thru(s_def='pseudo')
        thru_pseudo.renormalize(z_new=[10 + 10j, 50 - 20j])
        thru_power = m.thru(s_def='power')
        thru_power.renormalize(z_new=[10 + 10j, 50 - 20j])

        npy.testing.assert_allclose(thru_traveling.s,
                                    mismatch_traveling.s,
                                    rtol=1e-3)
        npy.testing.assert_allclose(thru_pseudo.s,
                                    mismatch_pseudo.s,
                                    rtol=1e-3)
        npy.testing.assert_allclose(thru_power.s, mismatch_power.s, rtol=1e-3)
Пример #4
0
 def test_scalar_gamma_z0_media(self):
     """
     test ability to create a Media from scalar quantities for gamma/z0
     """
     freq = Frequency(1, 10, 101)
     a = DefinedGammaZ0(freq, gamma=1j, z0=50)
     self.assertEqual(len(freq), len(a))
     self.assertEqual(len(freq), len(a.gamma))
     self.assertEqual(len(freq), len(a.z0))
Пример #5
0
 def test_alpha_warning(self):
     """
     Test if alpha_conductor warns when t < 3 * skin_depth
     """
     # cpw line on 1.5mm FR-4 substrate
     freq = Frequency(1, 1, 1, 'MHz')
     with self.assertWarns(RuntimeWarning) as context:
         cpw = CPW(frequency = freq, z0 = 50., w = 3.0e-3, s = 0.3e-3, t = 35e-6,
                    ep_r = 4.5, rho = 1.7e-8)
         line = cpw.line(d = 25e-3, unit = 'm', embed = True, z0 = cpw.Z0)
Пример #6
0
 def test_alpha_warning(self):
     """
     Test if warns when t < 3 * skin_depth
     """
     freq = Frequency(1, 1, 1, 'MHz')
     with self.assertWarns(RuntimeWarning) as context:
         mline = MLine(frequency = freq, z0 = 50.,
                    w = self.w, h = self.h, t = self.t,
                    ep_r = self.ep_r, rho = self.rho,
                    tand = self.tand, rough = self.d,
                    diel = 'frequencyinvariant', disp = 'hammerstadjensen')
Пример #7
0
    def test_scalar_gamma_z0_media(self):
        '''
        test ability to create a Media from scalar quanties for gamma/z0
        and change frequency resolution
        '''
        a = DefinedGammaZ0(Frequency(1, 10, 101), gamma=1j, z0=50)
        self.assertEqual(a.line(1), a.line(1))

        # we should be able to re-sample the media
        a.npoints = 21
        self.assertEqual(len(a.gamma), len(a))
        self.assertEqual(len(a.z0), len(a))
        self.assertEqual(len(a.z0), len(a))
Пример #8
0
 def test_vector_gamma_z0_media(self):
     """
     test ability to create a Media from vector quantities for gamma/z0
     """
     freq = Frequency(1, 10, 101)
     a = DefinedGammaZ0(
         freq,
         gamma=1j * npy.ones(len(freq)),
         z0=50 * npy.ones(len(freq)),
     )
     self.assertEqual(len(freq), len(a))
     self.assertEqual(len(freq), len(a.gamma))
     self.assertEqual(len(freq), len(a.z0))
Пример #9
0
    def test_vector_gamma_z0_media(self):
        '''
        test ability to create a Media from vector quanties for gamma/z0
        '''
        freq = Frequency(1, 10, 101)
        a = DefinedGammaZ0(
            freq,
            gamma=1j * npy.ones(len(freq)),
            z0=50 * npy.ones(len(freq)),
        )

        self.assertEqual(a.line(1), a.line(1))
        with self.assertRaises(NotImplementedError):
            a.npoints = 4
Пример #10
0
 def test_Z0_ep_reff(self):
     """
     Test against characterisitc impedance from another calculator using
     Hammerstadt-Jensen model
     http://web.mit.edu/~geda/arch/i386_rhel3/versions/20050830/html/mcalc-1.5/
     """
     freq = Frequency(1, 1, 1, 'GHz')
     mline1 = MLine(frequency = freq, z0 = 50.,
                    w = self.w, h = self.h, t = self.t,
                    ep_r = self.ep_r, rho = self.rho,
                    tand = self.tand, rough = self.d,
                    diel = 'frequencyinvariant', disp = 'hammerstadjensen',
                    compatibility_mode = 'qucs')
     
     # without t (t = None)
     mline2 = MLine(frequency = freq, z0 = 50.,
                    w = self.w, h = self.h,
                    ep_r = self.ep_r, rho = self.rho,
                    tand = self.tand, rough = self.d,
                    diel = 'frequencyinvariant', disp = 'hammerstadjensen',
                    compatibility_mode = 'qucs')
     
     # with t = 0
     mline3 = MLine(frequency = freq, z0 = 50.,
                    w = self.w, h = self.h, t = 0,
                    ep_r = self.ep_r, rho = self.rho,
                    tand = self.tand, rough = self.d,
                    diel = 'frequencyinvariant', disp = 'hammerstadjensen',
                    compatibility_mode = 'qucs')
     
     self.assertTrue(npy.abs((mline1.Z0[0] - 49.142) / 49.142) < 0.01)
     self.assertTrue(npy.abs((mline1.ep_reff_f[0] - 3.324) / 3.324) < 0.01)
     self.assertTrue(npy.abs(mline2.w_eff - mline2.w) < 1e-16)
     self.assertTrue(npy.abs(mline2.alpha_conductor) < 1e-16)
     self.assertTrue(npy.abs(mline3.w_eff - mline3.w) < 1e-16)
     self.assertTrue(npy.abs(mline3.alpha_conductor) < 1e-16)
Пример #11
0
 def setUp(self):
     self.dummy_media = DefinedGammaZ0(
         frequency=Frequency(1, 100, 21, 'GHz'),
         gamma=1j,
         z0=50,
     )