Пример #1
0
        public void When_ResistorNoise_Expect_Reference()
        {
            var ckt = new Circuit(
                new CurrentSource("I1", "in", "0", 1).SetParameter("acmag", 1.0),
                new Resistor("R1", "in", "0", 1e3).SetParameter("temp", 20.0));
            var temp = 20 + Constants.CelsiusKelvin;

            var noise  = new SpiceSharp.Simulations.Noise("noise", "in", new DecadeSweep(10, 10e9, 10));
            var onoise = new OutputNoiseDensityExport(noise);
            var inoise = new InputNoiseDensityExport(noise);

            noise.ExportSimulationData += (sender, args) =>
            {
                // We expect 4*k*T*R noise variance
                Assert.AreEqual(4 * Constants.Boltzmann * temp * 1e3, onoise.Value, 1e-20);
                Assert.AreEqual(4 * Constants.Boltzmann * temp / 1e3, inoise.Value, 1e-20);
            };
            noise.Run(ckt);
        }
Пример #2
0
        public void When_MultipliersNoise_Expect_Reference()
        {
            var cktActual = new Circuit(
                new VoltageSource("V1", "in", "0", 4.0),
                new Resistor("Rs", "in", "out", 10e3),
                new Resistor("R1", "out", "0", 1e3).SetParameter("m", 3.0).SetParameter("n", 2.0)
                );
            var cktReference = new Circuit(
                new VoltageSource("V1", "in", "0", 4.0),
                new Resistor("Rs", "in", "out", 10e3));

            ParallelSeries(cktReference, name => new Resistor(name, "", "", 1e3), "out", "0", 3, 2);

            var noise   = new SpiceSharp.Simulations.Noise("op", "out", new LinearSweep(0, 10, 2));
            var exports = new IExport <double>[] { new OutputNoiseDensityExport(noise), new InputNoiseDensityExport(noise) };

            Compare(noise, cktReference, cktActual, exports);
            DestroyExports(exports);
        }