class MediaTestCase(unittest.TestCase):
    """

    """

    def setUp(self):
        """

        """
        self.files_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "qucs_prj")
        fname = os.path.join(self.files_dir, "distributedCircuit,line1mm.s2p")
        qucs_ntwk = Network(fname)
        self.a_media = DistributedCircuit(frequency=qucs_ntwk.frequency, R=1e5, G=1, L=1e-6, C=8e-12)

    def test_line(self):
        """
        """
        fname = os.path.join(self.files_dir, "distributedCircuit,line1mm.s2p")
        qucs_ntwk = Network(fname)

        a_media = DistributedCircuit(frequency=qucs_ntwk.frequency, R=1e5, G=1, L=1e-6, C=8e-12)
        skrf_ntwk = a_media.thru(z0=50) ** a_media.line(1e-3, "m") ** a_media.thru(z0=50)
        self.assertEqual(qucs_ntwk, skrf_ntwk)

    def test_write_csv(self):
        fname = os.path.join(self.files_dir, "out.csv")
        self.a_media.write_csv(fname)
        os.remove(fname)

    def test_from_csv(self):
        fname = os.path.join(self.files_dir, "out.csv")
        self.a_media.write_csv(fname)
        a_media = DistributedCircuit.from_csv(fname)
        self.assertEqual(a_media, self.a_media)
        os.remove(fname)
    def test_line(self):
        """
        """
        fname = os.path.join(self.files_dir, "distributedCircuit,line1mm.s2p")
        qucs_ntwk = Network(fname)

        a_media = DistributedCircuit(frequency=qucs_ntwk.frequency, R=1e5, G=1, L=1e-6, C=8e-12)
        skrf_ntwk = a_media.thru(z0=50) ** a_media.line(1e-3, "m") ** a_media.thru(z0=50)
        self.assertEqual(qucs_ntwk, skrf_ntwk)
Esempio n. 3
0
    def setUp(self):
        """

        """
        self.files_dir = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'qucs_prj')
        fname = os.path.join(self.files_dir,\
                'distributedCircuit,line1mm.s2p')
        qucs_ntwk = Network(fname)
        self.a_media = DistributedCircuit(frequency=qucs_ntwk.frequency,
                                          R=1e5,
                                          G=1,
                                          L=1e-6,
                                          C=8e-12)
Esempio n. 4
0
    def test_line(self):
        """
        """
        fname = os.path.join(self.files_dir,\
                'distributedCircuit,line1mm.s2p')
        qucs_ntwk = Network(fname)

        a_media = DistributedCircuit(frequency=qucs_ntwk.frequency,
                                     R=1e5,
                                     G=1,
                                     L=1e-6,
                                     C=8e-12)
        skrf_ntwk = a_media.thru(z0=50)**a_media.line(1e-3,'m')\
                    **a_media.thru(z0=50)
        self.assertEqual(qucs_ntwk, skrf_ntwk)
Esempio n. 5
0
    def test_noise(self):
        a = rf.Network(os.path.join(self.test_dir,'ntwk_noise.s2p'))

        nf = 10**(0.05)
        self.assertTrue(a.noisy)
        self.assertTrue(abs(a.nfmin[0] - nf) < 1.e-6, 'noise figure does not match original spec')
        self.assertTrue(abs(a.z_opt[0] - 50.) < 1.e-6, 'optimal resistance does not match original spec')
        self.assertTrue(abs(a.rn[0] - 0.1159*50.) < 1.e-6, 'equivalent resistance does not match original spec')
        self.assertTrue(npy.all(abs(a.g_opt) < 1.e-6), 'calculated optimal reflection coefficient does not match original coefficients')

        b = rf.Network(f=[1, 2],
                       s=[[[0, 1], [1, 0]], [[0, 1], [1, 0]]],
                       z0=50).interpolate(a.frequency)
        with self.assertRaises(ValueError) as context:
            b.n
        with self.assertRaises(ValueError) as context:
            b.f_noise
        self.assertEqual(str(context.exception), 'network does not have noise')

        c = a ** b
        self.assertTrue(a.noisy)
        self.assertTrue(abs(c.nfmin[0] - nf) < 1.e-6, 'noise figure does not match original spec')
        self.assertTrue(abs(c.z_opt[0] - 50.) < 1.e-6, 'optimal resistance does not match original spec')
        self.assertTrue(abs(c.rn[0] - 0.1159*50.) < 1.e-6, 'equivalent resistance does not match original spec')

        d = b ** a
        self.assertTrue(d.noisy)
        self.assertTrue(abs(d.nfmin[0] - nf) < 1.e-6, 'noise figure does not match original spec')
        self.assertTrue(abs(d.z_opt[0] - 50.) < 1.e-6, 'optimal resistance does not match original spec')
        self.assertTrue(abs(d.rn[0] - 0.1159*50.) < 1.e-6, 'equivalent resistance does not match original spec')

        e = a ** a
        self.assertTrue(abs(e.nfmin[0] - (nf + (nf-1)/(10**2))) < 1.e-6, 'noise figure does not match Friis formula')

        self.assertTrue(a.noisy)
        self.assertTrue(abs(a.nfmin[0] - nf) < 1.e-6, 'noise figure was altered')
        self.assertTrue(abs(a.z_opt[0] - 50.) < 1.e-6, 'optimal resistance was altered')
        self.assertTrue(abs(a.rn[0] - 0.1159*50.) < 1.e-6, 'equivalent resistance was altered')

        tem = DistributedCircuit(z0=50)
        inductor = tem.inductor(1e-9).interpolate(a.frequency)

        f = inductor ** a
        expected_zopt = 50 - 2j*npy.pi*1e+9*1e-9
        self.assertTrue(abs(f.z_opt[0] - expected_zopt) < 1.e-6, 'optimal resistance was not 50 ohms - inductor')


        return
Esempio n. 6
0
class MediaTestCase(unittest.TestCase):
    """

    """
    def setUp(self):
        """

        """
        self.files_dir = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'qucs_prj')
        fname = os.path.join(self.files_dir,\
                'distributedCircuit,line1mm.s2p')
        qucs_ntwk = Network(fname)
        self.a_media = DistributedCircuit(frequency=qucs_ntwk.frequency,
                                          R=1e5,
                                          G=1,
                                          L=1e-6,
                                          C=8e-12)

    def test_line(self):
        """
        """
        fname = os.path.join(self.files_dir,\
                'distributedCircuit,line1mm.s2p')
        qucs_ntwk = Network(fname)

        a_media = DistributedCircuit(frequency=qucs_ntwk.frequency,
                                     R=1e5,
                                     G=1,
                                     L=1e-6,
                                     C=8e-12)
        skrf_ntwk = a_media.thru(z0=50)**a_media.line(1e-3,'m')\
                    **a_media.thru(z0=50)
        self.assertEqual(qucs_ntwk, skrf_ntwk)

    def test_write_csv(self):
        fname = os.path.join(self.files_dir,\
                'out.csv')
        self.a_media.write_csv(fname)
        os.remove(fname)

    def test_from_csv(self):
        fname = os.path.join(self.files_dir,\
                'out.csv')
        self.a_media.write_csv(fname)
        a_media = DistributedCircuit.from_csv(fname)
        self.assertEqual(a_media, self.a_media)
        os.remove(fname)
Esempio n. 7
0
 def test_from_csv(self):
     fname = os.path.join(self.files_dir,\
             'out.csv')
     self.a_media.write_csv(fname)
     a_media = DistributedCircuit.from_csv(fname)
     self.assertEqual(a_media, self.a_media)
     os.remove(fname)
    def setUp(self):
        """

        """
        self.files_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "qucs_prj")
        fname = os.path.join(self.files_dir, "distributedCircuit,line1mm.s2p")
        qucs_ntwk = Network(fname)
        self.a_media = DistributedCircuit(frequency=qucs_ntwk.frequency, R=1e5, G=1, L=1e-6, C=8e-12)
Esempio n. 9
0
    def setUp(self):
        global NPTS
        self.n_ports = 2
        self.wg = WG
        wg = self.wg

        r = npy.random.uniform(10, 100, NPTS)
        l = 1e-9 * npy.random.uniform(100, 200, NPTS)
        g = npy.zeros(NPTS)
        c = 1e-12 * npy.random.uniform(100, 200, NPTS)

        rlgc = DistributedCircuit(frequency=wg.frequency,
                                  z0=None,
                                  R=r,
                                  L=l,
                                  G=g,
                                  C=c)
        self.rlgc = rlgc

        self.X = wg.random(n_ports=2, name='X')
        self.Y = wg.random(n_ports=2, name='Y')
        self.gamma_f = wg.random(n_ports=1, name='gamma_f')
        self.gamma_r = wg.random(n_ports=1, name='gamma_r')

        actuals = [
            rlgc.thru(),
            rlgc.short(nports=2),
            rlgc.line(10, 'um'),
            rlgc.line(100, 'um'),
            rlgc.line(500, 'um'),
        ]

        self.actuals = actuals

        measured = [self.measure(k) for k in actuals]

        self.measured = measured

        self.cal = NISTMultilineTRL(measured=measured,
                                    Grefls=[-1],
                                    l=[0, 10e-6, 100e-6, 500e-6],
                                    switch_terms=(self.gamma_f, self.gamma_r),
                                    ref_plane=50e-6,
                                    c0=c,
                                    z0_ref=50,
                                    gamma_root_choice='real')
Esempio n. 10
0
 def setUp(self):
     self.frequency = rf.Frequency(75, 110, 101, 'ghz')
     self.media = DistributedCircuit(\
         frequency=self.frequency,
         L=1,C=1,R=0,G=0
         )
    c2 = 0
    d2 = a_abcd[:, 1, 0] / (a_abcd[:, 1, 0] + b_abcd[:, 1, 0])

    ee = (a1 * np.conj(a1) * an[:, 0, 0] + b1 * np.conj(b1) * bn[:, 1, 1] +
          a2 * np.conj(a2) * bn[:, 1, 1] + b2 * np.conj(b2) * bn[:, 1, 1] +
          a1 * np.conj(b1) * an[:, 0, 1] + b1 * np.conj(a1) * an[:, 1, 0] +
          a2 * np.conj(b2) * bn[:, 0, 1] + b2 * np.conj(a2) * bn[:, 1, 0])
    ii = (c1 * np.conj(c1) * an[:, 0, 0] + d1 * np.conj(d1) * an[:, 1, 1] +
          c2 * np.conj(c2) * bn[:, 0, 0] + d2 * np.conj(d2) * bn[:, 1, 1] +
          c1 * np.conj(d1) * an[:, 0, 1] + d1 * np.conj(c1) * an[:, 1, 0] +
          c2 * np.conj(d2) * bn[:, 0, 1] + d2 * np.conj(c2) * bn[:, 1, 0])
    ei = (a1 * np.conj(c1) * an[:, 0, 0] + b1 * np.conj(d1) * an[:, 1, 1] +
          a2 * np.conj(c2) * bn[:, 0, 0] + b2 * np.conj(d2) * bn[:, 1, 1] +
          a1 * np.conj(d1) * an[:, 0, 1] + b1 * np.conj(c1) * an[:, 1, 0] +
          a2 * np.conj(d2) * bn[:, 0, 1] + b2 * np.conj(c2) * bn[:, 1, 0])
    ie = np.conj(ei)

    ret.noise = np.moveaxis(np.array([[ee, ei], [ie, ii]]), 2, 0)
    ret.noise_freq = af
    return ret


f = freq.Frequency(0.4, 2, 1001)
tem = DistributedCircuit(f, z0=50)

bjt = net.Network(
    'BFU520_Spar_NF_400MHz-2GHz/BFU520_05V0_005mA_NF_SP.s2p').interpolate(f)
inductor = tem.shunt_inductor(1e-9)

print(series(bjt, inductor).n)
 def test_from_csv(self):
     fname = os.path.join(self.files_dir, "out.csv")
     self.a_media.write_csv(fname)
     a_media = DistributedCircuit.from_csv(fname)
     self.assertEqual(a_media, self.a_media)
     os.remove(fname)