private void Button_Click(object sender, RoutedEventArgs e)
        {
            model             = new ComplexPlainViewModel();
            model.ColorCoding = ColorCoding.ByLights;

            Circuit cir = new Circuit();

            cir.ReadCircuit("Circuits/RCL.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;

            int scalefactor = 5000;

            model.MinX    = ac1.SigmaMin / scalefactor;
            model.MaxX    = ac1.SigmaMax / scalefactor;
            model.MaxY    = ac1.WMax / scalefactor;
            model.MinY    = ac1.WMin / scalefactor;
            model.Columns = ac1.Points;
            model.Rows    = ac1.Points;
            var data = new Point3D[model.Rows, model.Columns];

            //public Tuple<Complex32, Complex32>[,] Results { get; set; }
            MathNet.Numerics.Complex32 W;
            for (int i = 0; i < model.Rows; i++)
            {
                for (int j = 0; j < model.Columns; j++)
                {
                    W = sol1.WfromIndexes[new Tuple <int, int>(i, j)];
                    foreach (var node in sol1.Voltages[W])
                    {
                        if (node.Key == "out")
                        {
                            data[i, j] = new Point3D(W.Real / scalefactor,
                                                     W.Imaginary / scalefactor,
                                                     //node.Value.Magnitude);
                                                     2 * Math.Log10(node.Value.Magnitude));
                        }
                    }
                }
            }

            model.Data = data;
            model.UpdateModel(false);
            //model.CreateDataArray(ModuleInDB);

            DataContext = model;
        }
예제 #2
0
        public ComplexPlain3DViewer()
        {
            InitializeComponent();
            model = new ComplexPlainViewModel();

            model.ColorCoding = ColorCoding.ByGradientY;
            // model.SurfaceBitmap = (System.Drawing.Bitmap)System.Drawing.Bitmap.("Images/planocomplejo.jpg");// CreateBitmap();
            //System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(
            //                                System.Reflection.Assembly.GetEntryAssembly().
            //                                GetManifestResourceStream("MyProject.Resources.planocomplejo.png"));
            model.SurfaceBitmap = global::ComplexPlainVisualizer.Properties.Resources.planocomplejo;;
            Simulate(TxtCircuitFile.Text);
        }
        public ComplexPlain3DViewer()
        {
            InitializeComponent();
            model = new ComplexPlainViewModel();

            model.ColorCoding = ColorCoding.ByGradientY;
           // model.SurfaceBitmap = (System.Drawing.Bitmap)System.Drawing.Bitmap.("Images/planocomplejo.jpg");// CreateBitmap();
            //System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(
            //                                System.Reflection.Assembly.GetEntryAssembly().
            //                                GetManifestResourceStream("MyProject.Resources.planocomplejo.png"));
            model.SurfaceBitmap = global::ComplexPlainVisualizer.Properties.Resources.planocomplejo; ;
            Simulate(TxtCircuitFile.Text);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            model = new ComplexPlainViewModel();
            model.ColorCoding = ColorCoding.ByLights;

            Circuit cir = new Circuit();
            cir.ReadCircuit("Circuits/RCL.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;

            int scalefactor = 5000;
            model.MinX = ac1.SigmaMin / scalefactor;
            model.MaxX = ac1.SigmaMax / scalefactor;
            model.MaxY = ac1.WMax / scalefactor;
            model.MinY = ac1.WMin / scalefactor;
            model.Columns = ac1.Points;
            model.Rows = ac1.Points;
            var data = new Point3D[model.Rows, model.Columns];
            //public Tuple<Complex32, Complex32>[,] Results { get; set; }
            MathNet.Numerics.Complex32 W;
            for (int i = 0; i < model.Rows; i++)
                for (int j = 0; j < model.Columns; j++)
                {
                    W = sol1.WfromIndexes[new Tuple<int, int>(i, j)];
                    foreach (var node in sol1.Voltages[W])
                    {
                        if (node.Key == "out")
                            data[i, j] = new Point3D(W.Real /scalefactor, 
                                                    W.Imaginary /scalefactor,
                                                    //node.Value.Magnitude);
                                                    2 * Math.Log10(node.Value.Magnitude));
                    }
                }

            model.Data = data;
            model.UpdateModel(false);         
            //model.CreateDataArray(ModuleInDB);

            DataContext = model;

        }