Пример #1
0
    def test_Attenuator10dB(self):

        cr = rf.Circuit('Example')
        src = rf.Source("Source")
        att = rf.Attenuator("Attenuator", Att=np.array([10]))
        sink = rf.Sink("Sink")

        src['out'] >> att['in']
        att['out'] >> sink['in']

        # create callback function
        def cb_src(self, f, p):
            return {'f': f, 'p': p, 'Tn': rf.RFMath.T0}

        src['out'].regCallback(cb_src)

        cr.finalise()

        sim = cr.simulate(network=cr.net,
                          start=cr['Source'],
                          end=cr['Sink'],
                          freq=[0],
                          power=[0])

        sim.setNoiseBandwidth(1)

        assert sim.extractLastValues('n', freq=0, power=0) == rf.RFMath.N0
        assert np.round(sim.extractLastValues('NF', freq=0, power=0),
                        decimals=4) == 10
Пример #2
0
    def test_SourceN0(self):

        cr = rf.Circuit('Example')
        src = rf.Source("Source")
        sink = rf.Sink("Sink")

        src['out'] >> sink['in']

        # create callback function
        def cb_src(self, f, p):
            return {'f': f, 'p': p, 'Tn': rf.RFMath.T0}

        src['out'].regCallback(cb_src)

        cr.finalise()

        sim = cr.simulate(network=cr.net,
                          start=cr['Source'],
                          end=cr['Sink'],
                          freq=[0],
                          power=[0])

        sim.setNoiseBandwidth(1)

        assert sim.extractValues('Tn', freq=0, power=0)[1][0] == rf.RFMath.T0
        assert sim.extractValues('Tn', freq=0, power=0)[1][1] == rf.RFMath.T0

        assert sim.extractValues('n', freq=0, power=0)[1][0] == rf.RFMath.N0
        assert sim.extractValues('n', freq=0, power=0)[1][1] == rf.RFMath.N0

        assert sim.extractValues('NF', freq=0, power=0)[1][0] == 0
        assert sim.extractValues('NF', freq=0, power=0)[1][1] == 0
Пример #3
0
    def test_Lna1dB(self):

        cr = rf.Circuit('Example')
        src = rf.Source("Source")
        lna = rf.Amplifier("LNA", Gain=20, NF=1, OP1dB=20, OIP3=40)
        sink = rf.Sink("Sink")

        src['out'] >> lna['in']
        lna['out'] >> sink['in']

        # create callback function
        def cb_src(self, f, p):
            return {'f': f, 'p': p, 'Tn': rf.RFMath.T0}

        src['out'].regCallback(cb_src)

        cr.finalise()

        sim = cr.simulate(network=cr.net,
                          start=cr['Source'],
                          end=cr['Sink'],
                          freq=[0],
                          power=[0])

        sim.setNoiseBandwidth(1)

        assert sim.extractLastValues('n', freq=0,
                                     power=0) == (rf.RFMath.N0 + 20 + 1)
        assert np.round(sim.extractLastValues('NF', freq=0, power=0),
                        decimals=4) == 1
Пример #4
0
cr = rf.Circuit('Mixer')

lna = rf.Amplifier("LNA TQL9066",
                   Gain=[(0, 18.2)],
                   NF=0.7,
                   OP1dB=21.5,
                   OIP3=40)

mix = rf.Mixer("MIY SYM-18+",
               Gain=[(0, -8.61), (100, -8.41), (200, -8.64)],
               OP1dB=14,
               OIP3=30)

src = rf.Source("Source")
sink = rf.Sink("Sink")

src['out'] >> lna['in']
lna['out'] >> mix['in']
mix['out'] >> sink['in']


# create callback function
def cb_src(self, f, p):
    return {'f': f, 'p': p, 'Tn': rf.RFMath.T0}


src['out'].regCallback(cb_src)  # connect callback to Port


# create callback function
Пример #5
0
def example():

    cr = rf.Circuit('Example')

    dup = rf.Attenuator("Duplexer", Att=[1.5])

    lim = rf.Attenuator("Limiter",
                        Att=np.array([0.5, 6.5, 12.5, 18.5]),
                        IIP3=60,
                        OP1dB=30)

    sw1 = rf.SPDT("SW 1", Att=0.3)

    lna = rf.Amplifier("LNA", Gain=[(0, 18.2)], NF=0.7, OP1dB=21.5, OIP3=40)

    sw2 = rf.SPDT("SW 2", Att=0.3)

    att_fix = rf.Attenuator("Att Fix1", Att=[1.5])

    rxfilt = rf.Filter("Rx Filter", Att=[(0, 2.0)])

    att_fix2 = rf.Attenuator("Att Fix2", Att=[1.5])

    driver = rf.Amplifier("Driver",
                          Gain=[(0, 14.9)],
                          NF=1.7,
                          OP1dB=21.4,
                          OIP3=40)

    dsa = rf.Attenuator("DSA", Att=np.arange(1.0, 29, 1.0))

    adc = rf.Amplifier("ADC", Gain=[(0, 0)], OP1dB=-1, OIP3=34, NF=19)

    src = rf.Source("Source")
    sink = rf.Sink("Sink")

    src['out'] >> dup['in']
    dup['out'] >> lim['in']
    lim['out'] >> sw1['S']

    sw1['S-1'] >> lna['in']
    lna['out'] >> sw2['S-1']
    sw1['S-2'] >> sw2['S-2']

    sw2['S'] >> att_fix['in']
    att_fix['out'] >> rxfilt['in']
    rxfilt['out'] >> att_fix2['in']
    att_fix2['out'] >> driver['in']
    driver['out'] >> dsa['in']
    dsa['out'] >> adc['in']
    adc['out'] >> sink['in']

    # create callback function
    def cb_src(self, f, p):
        return {'f': f, 'p': p, 'Tn': rf.RFMath.T0}

    src['out'].regCallback(cb_src)

    # create callback function
    def cb_lim(self, f, p):
        tb = {
            -31: 6,
            -30: 6,
            -29: 6,
            -28: 6,
            -27: 6,
            -26: 6,
            -25: 12,
            -24: 12,
            -23: 12,
            -22: 12,
            -21: 12,
            -20: 12,
            -19: 18,
            -18: 18,
            -17: 18,
            -16: 18,
            -15: 18,
            -14: 18,
            -13: 18,
            -12: 18,
            -11: 18,
            -10: 18,
        }
        if (p in tb):
            self.setAttenuation(tb[p])
        else:
            self.setAttenuation(0.0)
        return {}

    lim['in'].regCallback(cb_lim)

    # create callback function
    def cb_dsa(self, f, p):
        tb = {
            -37: 0,
            -36: 1,
            -35: 2,
            -34: 3,
            -33: 4,
            -32: 5,
            -31: 0,
            -30: 1,
            -29: 2,
            -28: 3,
            -27: 4,
            -26: 5,
            -25: 0,
            -24: 1,
            -23: 2,
            -22: 3,
            -21: 4,
            -20: 5,
            -19: 0,
            -18: 1,
            -17: 2,
            -16: 3,
            -15: 4,
            -14: 5,
            -13: 6,
            -12: 7,
            -11: 8,
            -10: 9,
        }
        if (p in tb):
            self.setAttenuation(tb[p])
        else:
            self.setAttenuation(0)
        return {}

    dsa['in'].regCallback(cb_dsa)

    # create callback function
    def cb_sw1(self, f, p):
        if (p > -11):
            self.setDirection('S-2')
        else:
            self.setDirection('S-1')
        return {}

    sw1['S'].regCallback(cb_sw1)
    sw2['S'].regCallback(cb_sw1)

    cr.finalise()

    return cr
Пример #6
0
 def test_Sink(self):
     rf.Sink("Sink")