Exemplo n.º 1
0
    def test_transfer_square_symmetrical_lattice(self):
        '''
        Square symmetrical lattice
        '''

        # Compute the transfer function
        left_minus = 0
        left_plus = 1
        right_minus = 2
        right_plus = 3
        net = core._Network([
            core.R(left_minus, left_plus, 'Zs'),
            core.R(right_minus, right_plus, 'Zl'),
            core.Admittance(left_minus, right_plus, 0),
            core.Admittance(right_minus, left_plus, 0),
            core.R(left_minus, right_minus, 'Za'),
            core.R(right_plus, left_plus, 'Za')
        ])
        transfer = net.transfer(left_minus, left_plus, right_minus, right_plus)

        # What the tranfer function should be
        def transfer_theory(Zs, Zl, Za):
            return Zl / (2 * Za + Zl)

        # Define some numerical values
        # for the resistors
        test_parameters = {
            'Zs': 1,
            'Zl': 2,
            'Za': 3,
        }

        self.assertRelativelyClose(transfer.evalf(subs=test_parameters),
                                   transfer_theory(**test_parameters))
Exemplo n.º 2
0
    def test_transfer_wheatstone(self):
        '''
        Wheatstone bridge, see:
        https://en.wikipedia.org/wiki/Wheatstone_bridge
        Note that the correct definitions of the voltages V_G and V_S can be found here:
        http://www.ece.lsu.edu/ee4770/1999/lsli04.4up.pdf
        '''

        # Compute the bridge transfer function
        net = core._Network([
            core.R(0, 1, 'R_3'),
            core.R(1, 2, 'R_x'),
            core.R(2, 3, 'R_2'),
            core.R(3, 0, 'R_1'),
        ])
        transfer = net.transfer(0, 2, 3, 1)

        # What the tranfer function should be
        def transfer_theory(R_1, R_2, R_3, R_x):
            return R_2 / (R_1 + R_2) - R_x / (R_x + R_3)

        # Define some numerical values
        # for the bridge resistors
        test_parameters = {
            'R_1': 1,
            'R_2': 2,
            'R_3': 3,
            'R_x': 4,
        }

        self.assertRelativelyClose(transfer.evalf(subs=test_parameters),
                                   transfer_theory(**test_parameters))
Exemplo n.º 3
0
    def test_transfer_wheatstone_all_equal(self):
        '''
        Case where all resistors of the bridge are equal, and
        there is potential for these lines:
            A_lattice = (Ya + Yb)*(Yd + Yc)/(Ya*Yd-Yb*Yc)
            B_lattice = (Ya + Yb + Yc + Yd)/(Ya*Yd-Yb*Yc)
        to raise an error.
        Note: I made sure with a break-point that this code
        actually calls those two lines.
        '''

        # Compute the bridge transfer function
        net = core._Network([
            core.R(0, 1, 'R_3'),
            core.R(1, 2, 'R_x'),
            core.R(2, 3, 'R_2'),
            core.R(3, 0, 'R_1'),
        ])
        transfer = net.transfer(0, 2, 3, 1)

        # Define some numerical values
        # for the bridge resistors
        test_parameters = {
            'R_1': 1,
            'R_2': 1,
            'R_3': 1,
            'R_x': 1,
        }

        # We just run this to check wether it raises an error
        transfer.evalf(subs=test_parameters)
Exemplo n.º 4
0
    def test_transfer_voltage_divider(self):
        '''
        Voltage divider, see:
        https://en.wikipedia.org/wiki/Voltage_divider
        We add an extra resistor between Vin and ground
        '''

        # Compute the bridge transfer function
        net = core._Network([
            core.R(0, 1, 'Z2'),
            core.R(1, 2, 'Z1'),
            core.R(2, 0, 'Zg'),
        ])
        transfer = net.transfer(0, 2, 0, 1)

        # What the tranfer function should be
        def transfer_theory(Z1, Z2, Zg):
            return Z2 / (Z1 + Z2)

        # Define some numerical values
        # for the resistors
        test_parameters = {'Z1': 1, 'Z2': 2, 'Zg': 3}

        self.assertRelativelyClose(transfer.evalf(subs=test_parameters),
                                   transfer_theory(**test_parameters))
Exemplo n.º 5
0
 def test_connectivity_check_single_element_not_connected(self):
     with self.assertRaises(ValueError):
         net = core._Network([
             core.R(0, 1, 'Z'),
             core.C(1, 2, 'Z'),
             core.J(3, 4, 'Z'),
         ])
Exemplo n.º 6
0
 def test_open_or_series_check(self):
     with self.assertRaises(ValueError):
         net = core._Network([
             core.R(0, 1, 'Z'),
             core.C(1, 2, 'Z'),
             core.J(2, 3, 'Z'),
         ])
Exemplo n.º 7
0
 def test_q_zpf(self):
     Cj = 100e-15
     Lj = 10e-9
     junction = core.J(0, 1, Lj)
     circuit = core.Network([core.C(0, 1, Cj), junction, core.R(0, 1, 1e6)])
     Z = np.sqrt(Lj / Cj)
     q_zpf = np.sqrt(hbar / Z / 2)
     self.assertRelativelyClose(
         q_zpf / e, np.absolute(junction.zpf(mode=0, quantity='charge')))
Exemplo n.º 8
0
 def test_connectivity_check_subcircuit_not_connected(self):
     with self.assertRaises(ValueError):
         net = core._Network([
             core.R(0, 1, "Z"),
             core.C(1, 2, "Z"),
             core.J(3, 4, "Z"),
             core.J(3, 4, "Z"),
             core.J(4, 5, "Z"),
         ])
Exemplo n.º 9
0
 def test_sweeping_LJ_in_fkAchi(self):
     cir = core.Network([
         core.C(0, 1, 100e-15),
         core.J(0, 1, 'L_J'),
         core.C(1, 2, 1e-15),
         core.C(2, 0, 100e-15),
         core.L(2, 0, 10e-9),
         core.R(2, 0, 1e6)
     ])
     [cir.f_k_A_chi(L_J=x) for x in [1e-9, 2e-9]]
Exemplo n.º 10
0
 def test_phi_zpf(self):
     Cj = 100e-15
     Lj = 10e-9
     junction = core.J(0, 1, Lj)
     circuit = core.Network([core.C(0, 1, Cj), junction, core.R(0, 1, 1e6)])
     phi_0 = hbar / 2 / e
     Z = np.sqrt(Lj / Cj)
     phi_zpf = np.sqrt(hbar * Z / 2)
     self.assertRelativelyClose(phi_zpf / phi_0,
                                junction.zpf(mode=0, quantity='flux'))
Exemplo n.º 11
0
 def test_sweeping_CJ_array_in_zpf(self):
     C_comp = core.C(0, 1, 'C_J')
     cir = core.Network([
         C_comp,
         core.J(0, 1, 10e-9),
         core.C(1, 2, 1e-15),
         core.C(2, 0, 100e-15),
         core.L(2, 0, 10e-9),
         core.R(2, 0, 1e6)
     ])
     self.assertRelativelyClose(
         C_comp.zpf(mode=1, quantity='charge', C_J=1.5e-9),
         C_comp.zpf(mode=1, quantity='charge', C_J=[1e-9, 1.5e-9, 3e-9])[1])
Exemplo n.º 12
0
    def revaluing_labelled_valued_component_twice(self):
        '''
        Adressing last error appearing in issue #83
        '''
        cir = core.Network(
            [core.L(0, 1, 1),
             core.C(0, 1, 1),
             core.R(0, 1, 'R', 1)])
        try:
            cir.loss_rates(R=1)
        except Exception:
            pass

        with self.assertRaises(ValueError):
            cir.loss_rates(R=1)
Exemplo n.º 13
0
 def parameters(self, R, L, C):
     circuit = core.Network(
         [core.C(0, 1, C),
          core.L(1, 2, L),
          core.R(0, 2, R)])
     return circuit.f_k_A_chi()
Exemplo n.º 14
0
 def test_transfer_left_right_port_indentical_inverted(self):
     '''
     Trivial cases
     '''
     net = core._Network([core.R(0, 1, 'Z2')])
     self.assertEqual(net.transfer(0, 1, 1, 0), -1)
Exemplo n.º 15
0
 def test_transfer_left_right_port_indentical_inverted(self):
     """
     Trivial cases
     """
     net = core._Network([core.R(0, 1, "Z2")])
     self.assertEqual(net.transfer(0, 1, 1, 0), -1)