コード例 #1
0
        public void TransmissionCoefficientAtZerroFrequencyTestTest()
        {
            const double fd = 1000;
            const double dt = 1 / fd;
            const double f0 = 30;
            const double Df = 10;

            var rlc = new BandPassRLC(f0, Df, dt);

            var c = rlc.GetTransmissionCoefficient(0, dt);

            Assert.AreEqual(0, c.Abs, $"delta:{Abs(0 - c.Abs):e2}");
        }
コード例 #2
0
        public void TransmissionCoefficientAtCentralFrequencyTestTest()
        {
            const double fd = 1000;
            const double dt = 1 / fd;
            const double f0 = 30;
            const double Df = 10;

            var rlc = new BandPassRLC(f0, Df, dt);

            var c = rlc.GetTransmissionCoefficient(f0, dt);

            const double eps = 1.12e-15;

            Assert.AreEqual(1, c.Abs, eps, $"delta:{Abs(1 - c.Abs):e2}");
        }
コード例 #3
0
        public void SpectrumPassTest()
        {
            const double fd = 1000;
            const double dt = 1 / fd;
            const double f0 = 30;
            const double Df = 10;

            var rlc = new BandPassRLC(f0, Df, dt);

            const int samples_count = 1000;
            var       s0            = new SamplesDigitalSignal(dt, Enumerable.Repeat(1, samples_count));
            var       s1            = new SamplesDigitalSignal(dt, samples_count, t => 1 * Cos(2 * PI * (f0 - Df / 2) * t));
            var       s2            = new SamplesDigitalSignal(dt, samples_count, t => 1 * Cos(2 * PI * f0 * t));
            var       s3            = new SamplesDigitalSignal(dt, samples_count, t => 1 * Cos(2 * PI * (f0 + Df / 2) * t));

            var s = s0 + s1 + s2 + s3;

            s.FourierTransform().ToAbsArg(out var abs_S, out var arg_S);
            var abs_S_25 = abs_S[25];
            var abs_S_30 = abs_S[30];
            var abs_S_35 = abs_S[35];

            var arg_S_25 = arg_S[25];
            var arg_S_30 = arg_S[30];
            var arg_S_35 = arg_S[35];

            var y = rlc.ProcessIndividual(s);

            y.FourierTransform().ToAbsArg(out var abs_Y, out var arg_Y);
            Assert.That.Value(abs_Y[0]).IsEqual(0, 1.68e-3);
            var abs_Y_25 = abs_Y[25];
            var abs_Y_30 = abs_Y[30];
            var abs_Y_35 = abs_Y[35];

            var H_25 = rlc.GetTransmissionCoefficient(f0 - Df / 2, dt);
            var H_30 = rlc.GetTransmissionCoefficient(f0, dt);
            var H_35 = rlc.GetTransmissionCoefficient(f0 + Df / 2, dt);

            var H_25_abs = H_25.Abs;
            var H_30_abs = H_30.Abs;
            var H_35_abs = H_35.Abs;

            var K25 = abs_Y_25 / abs_S_25;
            var K30 = abs_Y_30 / abs_S_30;
            var K35 = abs_Y_35 / abs_S_35;

            Assert.That.Value(K25).IsEqual(H_25_abs, 0.042);
            Assert.That.Value(K30).IsEqual(H_30_abs, 0.062);
            Assert.That.Value(K35).IsEqual(H_35_abs, 0.045);

            var arg_Y_25 = arg_Y[25];
            var arg_Y_30 = arg_Y[30];
            var arg_Y_35 = arg_Y[35];

            var H_25_arg = H_25.Arg;
            var H_30_arg = H_30.Arg;
            var H_35_arg = H_35.Arg;

            var Arg25 = arg_S_25 - arg_Y_25;
            var Arg30 = arg_S_30 - arg_Y_30;
            var Arg35 = arg_S_35 - arg_Y_35;

            Assert.That.Value(Arg25).IsEqual(H_25_arg, 1.82e-2);
            Assert.That.Value(Arg30).IsEqual(H_30_arg, 1.71e-2);
            Assert.That.Value(Arg35).IsEqual(H_35_arg, 1.66e-2);
        }