예제 #1
0
        public void DCTestCircuit_SolveX()
        {
            var builder = Vector <double> .Build;
            var testCkt = DCTestCircuit();

            double[] shouldArr = { -8, 24, 20, -4, 1 };
            var      should    = builder.DenseOfArray(shouldArr);

            Assert.True(Precision.AlmostEqual(DCAnalysis.SolveX(testCkt), should, 8));
        }
예제 #2
0
        public void DCTestCircuit_GenZ()
        {
            var builder = Vector <double> .Build;
            var testCkt = DCTestCircuit();

            double[] shouldArr = { 0, 0, 0, 32, 20 };
            var      should    = builder.DenseOfArray(shouldArr);

            Assert.True(Precision.AlmostEqual(DCAnalysis.GenZ(testCkt), should, 8));
        }
예제 #3
0
        public void DCTestCircuit_GenA()
        {
            var builder = Matrix <double> .Build;
            var testCkt = DCTestCircuit();

            double[,] shouldArr =
            {
                { 0.5,     0,     0, -1, 0 },
                {   0, 0.375, -0.25,  1, 0 },
                {   0, -0.25,  0.25,  0, 1 },
                {  -1,     1,     0,  0, 0 },
                {   0,     0,     1,  0, 0 },
            };
            var should = builder.DenseOfArray(shouldArr);

            Assert.True(Precision.AlmostEqual(DCAnalysis.GenA(testCkt), should, 8));
        }
예제 #4
0
        static void Main(string[] args)
        {
            int i = 2;

            switch (i)
            {
            case 0:
                cir.ReadCircuit("circuits/RLcharge.net");
                cir2 = (Circuit)cir.Clone();
                DCSolver.Optimize(cir2);
                DCAnalysis ac0    = (DCAnalysis)cir2.Setup[0];
                DCSolver   solver = (DCSolver)ac0.Solver;
                //solver.Solve(cir2, );
                cir2.Solve();
                solver.ExportToCSV("e:/Test.csv");

                break;

            case 1:
                cir.ReadCircuit("circuits/testidc.net");
                cir2 = (Circuit)cir.Clone();
                DCSolver.Optimize(cir2);
                DCAnalysis ac3     = (DCAnalysis)cir2.Setup[0];
                DCSolver   solver3 = (DCSolver)ac3.Solver;
                //solver.Solve(cir2, );
                cir2.Solve();
                solver3.ExportToCSV("e:/Test.csv");

                break;


            case 2:
                cir.ReadCircuit("circuits/derivador.net");
                //cir.ReadCircuit("RCL.net");
                cir2 = (Circuit)cir.Clone();
                cir2.Setup.RemoveAt(0);
                ACAnalysis ac = new ACAnalysis();
                cir2.Setup.Add(ac);
                ACSweepSolver.Optimize(cir2);
                cir2.Solve();

                ACSweepSolver sol = (ACSweepSolver)ac.Solver;
                sol.ExportToCSV("ACSweep.csv");
                break;

            case 3:
                //cir.ReadCircuit("derivador.net");
                cir.ReadCircuit("circuits/RLC.net");
                cir2 = (Circuit)cir.Clone();
                cir2.Setup.RemoveAt(0);
                ComplexPlainAnalysis ac1 = new ComplexPlainAnalysis();
                cir2.Setup.Add(ac1);
                ACSweepSolver.Optimize(cir2);
                cir2.Solve();
                sol1 = (ComplexPlainSolver)ac1.Solver;
                sol1.SelectedNode = sol1.CurrentCircuit.Nodes["out"];
                // sol1.
                sol1.ExportToCSV("e:/plain.csv");
                Bitmap bmp = FileUtils.DrawImage(func, ac1.Points, ac1.Points);
                bmp.Save("e:/plain.bmp");
                break;


            case 4:
                cir.ReadCircuit("circuits/RCL.net");
                //cir.ReadCircuit("RCcharge.net");
                cir2 = (Circuit)cir.Clone();
                cir2.Setup.RemoveAt(0);
                TransientAnalysis ac5 = new TransientAnalysis();
                ac5.Step = "10n";
                cir2.Setup.Add(ac5);
                TransientSolver sol5 = (TransientSolver)ac5.Solver;
                TransientSolver.Optimize(cir2);
                cir2.Solve();
                sol5.ExportToCSV("e:/time.csv");
                break;

            case 5:
                cir.ReadCircuit("circuits/vsingain.net");
                //cir.ReadCircuit("RCcharge.net");
                cir2 = (Circuit)cir.Clone();
                cir2.Setup.RemoveAt(0);
                TransientAnalysis ac6 = new TransientAnalysis();
                ac6.Step = "100n";
                cir2.Setup.Add(ac6);
                TransientSolver sol6 = (TransientSolver)ac6.Solver;
                TransientSolver.Optimize(cir2);
                cir2.Solve();
                sol6.ExportToCSV("e:/time.csv");
                break;

            default:
                break;
            }



            Console.ReadKey();
        }