Exemplo n.º 1
0
        private void button_ciclo_Click(object sender, RoutedEventArgs e)
        {
            if (matrix == null)
            {
                MessageBox.Show("Please, create the GRID before the Simulation");
            }
            else if (selectboundarycond == true)
            {
                matrix.neighbours();
                matrix.actualizar();
                matrixrectangle_phase       = matrix.colorearphase(matrixrectangle_phase);
                matrixrectangle_temperature = matrix.colortemperature(matrixrectangle_temperature);

                listPoint_solids  = matrix.contarsolids(listPoint_solids);
                listPoint_avgtemp = matrix.avgtemp(listPoint_avgtemp);

                RawDataSource d1 = new RawDataSource(listPoint_solids);
                RawDataSource d2 = new RawDataSource(listPoint_avgtemp);

                plot_phase.AddLineGraph(d1, Colors.Blue, 1, "Number solids");
                plot_phase.LegendVisible = false;
                plot_temp.AddLineGraph(d2, Colors.Red, 1, "Average temperature");
                plot_temp.LegendVisible = false;
            }
            else if (selectboundarycond == false)
            {
                MessageBox.Show("Please, select Boundary Conditions before the Simulation");
            }
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            //InitializeComponent();
            Random random = new Random();
List<Point>
  points = new List<Point>
    ();
            for (int i = 0; i < 30; i++)
            {
                Point point = new Point(i, random.Next(10));
                points.Add(point);
            }
            RawDataSource rawDataSource = new RawDataSource(points);
            //chartPlotter.AddLineGraph(rawDataSource, Colors.Black, 2, "Portfolio Hist Positions");
            //chartPlotter.DataContext = rawDataSource;
            //lineGraph.DataSource = rawDataSource;
        }
Exemplo n.º 3
0
        private void timer_Tick(object sender, EventArgs e)
        {
            matrix.neighbours();
            matrix.actualizar();
            matrixrectangle_phase       = matrix.colorearphase(matrixrectangle_phase);
            matrixrectangle_temperature = matrix.colortemperature(matrixrectangle_temperature);

            listPoint_solids  = matrix.contarsolids(listPoint_solids);
            listPoint_avgtemp = matrix.avgtemp(listPoint_avgtemp);

            RawDataSource d1 = new RawDataSource(listPoint_solids);
            RawDataSource d2 = new RawDataSource(listPoint_avgtemp);

            plot_phase.AddLineGraph(d1, Colors.Blue, 1, "Number solids");
            plot_phase.LegendVisible = false;
            plot_temp.AddLineGraph(d2, Colors.Red, 1, "Average temperature");
            plot_temp.LegendVisible = false;
        }
Exemplo n.º 4
0
        private void comboBox_boundary_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((comboBox_boundary.SelectedIndex != -1) && (matrix != null))
            {
                if (comboBox_boundary.SelectedIndex == 0)
                {
                    matrix.initialconditions(0);
                }
                else if (comboBox_boundary.SelectedIndex == 1)
                {
                    matrix.initialconditions(1);
                }
                else if (comboBox_boundary.SelectedIndex == 2)
                {
                    matrix.initialconditions(2);
                }
                else
                {
                    matrix.initialconditions(-1);
                }
                matrix.initialSolid(Convert.ToInt32(Math.Ceiling(Convert.ToDouble(rows / 2))), Convert.ToInt32(Math.Ceiling(Convert.ToDouble(columns / 2))));
                matrixrectangle_phase       = matrix.colorearphase(matrixrectangle_phase);
                matrixrectangle_temperature = matrix.colortemperature(matrixrectangle_temperature);
                selectboundarycond          = true;

                listPoint_solids  = matrix.contarsolids(listPoint_solids);
                listPoint_avgtemp = matrix.avgtemp(listPoint_avgtemp);

                RawDataSource d1 = new RawDataSource(listPoint_solids);
                RawDataSource d2 = new RawDataSource(listPoint_avgtemp);
            }
            else
            {
                MessageBox.Show("Please create the grid first!");
            }
        }
Exemplo n.º 5
0
        private void button_open_Click(object sender, RoutedEventArgs e)
        {
            //open .txt with the initial parameters and calculate the simulation
            try
            {
                matrix.Open();

                matrix.Initialize();
                matrix.calculate();
                matrix.calculatePoligons();
                matrix.colorPolygons();
                List <List <Polygon> > listPolygons = matrix.getListPolygons();
                listPolygons_u   = listPolygons[0];
                listPolygons_v   = listPolygons[1];
                listPolygons_rho = listPolygons[2];
                listPolygons_P   = listPolygons[3];
                listPolygons_T   = listPolygons[4];
                listPolygons_M   = listPolygons[5];

                textBox_columns.Text = matrix.columns.ToString();
                textBox_E.Text       = matrix.E.ToString();
                textBox_theta.Text   = matrix.theta.ToString();
                textBox_M.Text       = matrix.matrix[0, 0].M.ToString();
                textBox_P.Text       = matrix.matrix[0, 0].P.ToString();
                textBox_rho.Text     = matrix.matrix[0, 0].Rho.ToString();
                textBox_T.Text       = matrix.matrix[0, 0].T.ToString();
                textBox_R.Text       = matrix.R_air.ToString();
                textBox_gamma.Text   = matrix.Gamma.ToString();
                textBox_rows.Text    = matrix.rows.ToString();



                listCells = matrix.getListCells();

                for (int i = 0; i < listPolygons_u.Count; i++)
                {
                    listPolygons_u[i].MouseEnter += Polygon_MouseEnter;
                    listPolygons_u[i].MouseLeave += Polygon_MouseLeave;

                    grid_u.Children.Add(listPolygons_u[i]);

                    listPolygons_v[i].MouseEnter += Polygon_MouseEnter;
                    listPolygons_v[i].MouseLeave += Polygon_MouseLeave;

                    grid_v.Children.Add(listPolygons_v[i]);

                    listPolygons_rho[i].MouseEnter += Polygon_MouseEnter;
                    listPolygons_rho[i].MouseLeave += Polygon_MouseLeave;

                    grid_rho.Children.Add(listPolygons_rho[i]);

                    listPolygons_P[i].MouseEnter += Polygon_MouseEnter;
                    listPolygons_P[i].MouseLeave += Polygon_MouseLeave;

                    grid_P.Children.Add(listPolygons_P[i]);

                    listPolygons_T[i].MouseEnter += Polygon_MouseEnter;
                    listPolygons_T[i].MouseLeave += Polygon_MouseLeave;

                    grid_T.Children.Add(listPolygons_T[i]);

                    listPolygons_M[i].MouseEnter += Polygon_MouseEnter;
                    listPolygons_M[i].MouseLeave += Polygon_MouseLeave;

                    grid_M.Children.Add(listPolygons_M[i]);
                }

                listTables = matrix.createTables();

                rectangle_gradient.Visibility = Visibility.Visible;

                label_min.Visibility = Visibility.Visible;
                label_max.Visibility = Visibility.Visible;


                List <List <Point> > listPoints = matrix.calculateGraph();
                RawDataSource        u_body     = new RawDataSource(listPoints[0]);
                RawDataSource        v_body     = new RawDataSource(listPoints[1]);
                RawDataSource        rho_body   = new RawDataSource(listPoints[2]);
                RawDataSource        P_body     = new RawDataSource(listPoints[3]);
                RawDataSource        T_body     = new RawDataSource(listPoints[4]);
                RawDataSource        M_body     = new RawDataSource(listPoints[5]);

                RawDataSource u_bnd   = new RawDataSource(listPoints[6]);
                RawDataSource v_bnd   = new RawDataSource(listPoints[7]);
                RawDataSource rho_bnd = new RawDataSource(listPoints[8]);
                RawDataSource P_bnd   = new RawDataSource(listPoints[9]);
                RawDataSource T_bnd   = new RawDataSource(listPoints[10]);
                RawDataSource M_bnd   = new RawDataSource(listPoints[11]);

                plot_u.AddLineGraph(u_body, Colors.Blue, 2, "Body");
                plot_u.AddLineGraph(u_bnd, Colors.Red, 2, "Boundary");

                plot_v.AddLineGraph(v_body, Colors.Blue, 2, "Body");
                plot_v.AddLineGraph(v_bnd, Colors.Red, 2, "Boundary");

                plot_rho.AddLineGraph(rho_body, Colors.Blue, 2, "Body");
                plot_rho.AddLineGraph(rho_bnd, Colors.Red, 2, "Boundary");

                plot_P.AddLineGraph(P_body, Colors.Blue, 2, "Body");
                plot_P.AddLineGraph(P_bnd, Colors.Red, 2, "Boundary");

                plot_T.AddLineGraph(T_body, Colors.Blue, 2, "Body");
                plot_T.AddLineGraph(T_bnd, Colors.Red, 2, "Boundary");

                plot_M.AddLineGraph(M_body, Colors.Blue, 2, "Body");
                plot_M.AddLineGraph(M_bnd, Colors.Red, 2, "Boundary");

                grid_plot_u.Children.Add(plot_u);
                grid_plot_v.Children.Add(plot_v);
                grid_plot_rho.Children.Add(plot_rho);
                grid_plot_P.Children.Add(plot_P);
                grid_plot_T.Children.Add(plot_T);
                grid_plot_M.Children.Add(plot_M);

                plot_u.Background   = Brushes.Transparent;
                plot_v.Background   = Brushes.Transparent;
                plot_rho.Background = Brushes.Transparent;
                plot_P.Background   = Brushes.Transparent;
                plot_T.Background   = Brushes.Transparent;
                plot_M.Background   = Brushes.Transparent;

                plot_u.Foreground   = Brushes.White;
                plot_v.Foreground   = Brushes.White;
                plot_rho.Foreground = Brushes.White;
                plot_P.Foreground   = Brushes.White;
                plot_T.Foreground   = Brushes.White;
                plot_M.Foreground   = Brushes.White;

                plot_u.Legend.Foreground   = Brushes.Black;
                plot_v.Legend.Foreground   = Brushes.Black;
                plot_rho.Legend.Foreground = Brushes.Black;
                plot_P.Legend.Foreground   = Brushes.Black;
                plot_T.Legend.Foreground   = Brushes.Black;

                label_plot_yaxis.Content = "U (m/s)";
                grid_plot_u.Visibility   = Visibility.Visible;

                label_plot_title.Visibility = Visibility.Visible;
                label_plot_xaxis.Visibility = Visibility.Visible;
                label_plot_yaxis.Visibility = Visibility.Visible;

                isCalculatePressed = true;
            }
            catch (Exception m)
            {
                MessageBox.Show(m.Message);
            }
        }
Exemplo n.º 6
0
        private void button_calculate_Click(object sender, RoutedEventArgs e)
        {
            // Calculate the simulation!
            try
            {
                if (isCalculatePressed == true)
                {
                    MessageBox.Show("To calculate something, first restart the situation");
                }
                else if (textBox_columns.Text != "" && textBox_rows.Text != "" && textBox_rho.Text != "" && textBox_P.Text != "" && textBox_T.Text != "" && textBox_M.Text != "" && textBox_R.Text != "" && textBox_E.Text != "" && textBox_gamma.Text != "" && textBox_theta.Text != "" && isCalculatePressed == false)
                {
                    int    rows    = Convert.ToInt32(textBox_rows.Text);
                    int    columns = Convert.ToInt32(textBox_columns.Text);
                    double rho     = Convert.ToDouble(textBox_rho.Text);
                    double P       = Convert.ToDouble(textBox_P.Text);
                    double T       = Convert.ToDouble(textBox_T.Text);
                    double M       = Convert.ToDouble(textBox_M.Text);
                    double R       = Convert.ToDouble(textBox_R.Text);
                    double Gamma   = Convert.ToDouble(textBox_gamma.Text);
                    double E       = Convert.ToDouble(textBox_E.Text);
                    double theta   = Convert.ToDouble(textBox_theta.Text);

                    matrix.setParameters(rows, columns, rho, P, T, M, R, Gamma, E, theta);

                    matrix.Initialize();
                    matrix.calculate();
                    matrix.calculatePoligons();
                    matrix.colorPolygons();
                    List <List <Polygon> > listPolygons = matrix.getListPolygons();
                    listPolygons_u   = listPolygons[0];
                    listPolygons_v   = listPolygons[1];
                    listPolygons_rho = listPolygons[2];
                    listPolygons_P   = listPolygons[3];
                    listPolygons_T   = listPolygons[4];
                    listPolygons_M   = listPolygons[5];

                    listCells = matrix.getListCells();

                    for (int i = 0; i < listPolygons_u.Count; i++)
                    {
                        listPolygons_u[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_u[i].MouseLeave += Polygon_MouseLeave;

                        grid_u.Children.Add(listPolygons_u[i]);

                        listPolygons_v[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_v[i].MouseLeave += Polygon_MouseLeave;

                        grid_v.Children.Add(listPolygons_v[i]);

                        listPolygons_rho[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_rho[i].MouseLeave += Polygon_MouseLeave;

                        grid_rho.Children.Add(listPolygons_rho[i]);

                        listPolygons_P[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_P[i].MouseLeave += Polygon_MouseLeave;

                        grid_P.Children.Add(listPolygons_P[i]);

                        listPolygons_T[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_T[i].MouseLeave += Polygon_MouseLeave;

                        grid_T.Children.Add(listPolygons_T[i]);

                        listPolygons_M[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_M[i].MouseLeave += Polygon_MouseLeave;

                        grid_M.Children.Add(listPolygons_M[i]);
                    }

                    listTables = matrix.createTables();

                    rectangle_gradient.Visibility = Visibility.Visible;

                    label_min.Visibility = Visibility.Visible;
                    label_max.Visibility = Visibility.Visible;


                    List <List <Point> > listPoints = matrix.calculateGraph();
                    RawDataSource        u_body     = new RawDataSource(listPoints[0]);
                    RawDataSource        v_body     = new RawDataSource(listPoints[1]);
                    RawDataSource        rho_body   = new RawDataSource(listPoints[2]);
                    RawDataSource        P_body     = new RawDataSource(listPoints[3]);
                    RawDataSource        T_body     = new RawDataSource(listPoints[4]);
                    RawDataSource        M_body     = new RawDataSource(listPoints[5]);

                    RawDataSource u_bnd   = new RawDataSource(listPoints[6]);
                    RawDataSource v_bnd   = new RawDataSource(listPoints[7]);
                    RawDataSource rho_bnd = new RawDataSource(listPoints[8]);
                    RawDataSource P_bnd   = new RawDataSource(listPoints[9]);
                    RawDataSource T_bnd   = new RawDataSource(listPoints[10]);
                    RawDataSource M_bnd   = new RawDataSource(listPoints[11]);

                    plot_u.AddLineGraph(u_body, Colors.Blue, 2, "Body");
                    plot_u.AddLineGraph(u_bnd, Colors.Red, 2, "Boundary");

                    plot_v.AddLineGraph(v_body, Colors.Blue, 2, "Body");
                    plot_v.AddLineGraph(v_bnd, Colors.Red, 2, "Boundary");

                    plot_rho.AddLineGraph(rho_body, Colors.Blue, 2, "Body");
                    plot_rho.AddLineGraph(rho_bnd, Colors.Red, 2, "Boundary");

                    plot_P.AddLineGraph(P_body, Colors.Blue, 2, "Body");
                    plot_P.AddLineGraph(P_bnd, Colors.Red, 2, "Boundary");

                    plot_T.AddLineGraph(T_body, Colors.Blue, 2, "Body");
                    plot_T.AddLineGraph(T_bnd, Colors.Red, 2, "Boundary");

                    plot_M.AddLineGraph(M_body, Colors.Blue, 2, "Body");
                    plot_M.AddLineGraph(M_bnd, Colors.Red, 2, "Boundary");

                    grid_plot_u.Children.Add(plot_u);
                    grid_plot_v.Children.Add(plot_v);
                    grid_plot_rho.Children.Add(plot_rho);
                    grid_plot_P.Children.Add(plot_P);
                    grid_plot_T.Children.Add(plot_T);
                    grid_plot_M.Children.Add(plot_M);

                    plot_u.Background   = Brushes.Transparent;
                    plot_v.Background   = Brushes.Transparent;
                    plot_rho.Background = Brushes.Transparent;
                    plot_P.Background   = Brushes.Transparent;
                    plot_T.Background   = Brushes.Transparent;
                    plot_M.Background   = Brushes.Transparent;

                    plot_u.Foreground   = Brushes.White;
                    plot_v.Foreground   = Brushes.White;
                    plot_rho.Foreground = Brushes.White;
                    plot_P.Foreground   = Brushes.White;
                    plot_T.Foreground   = Brushes.White;
                    plot_M.Foreground   = Brushes.White;

                    plot_u.Legend.Foreground   = Brushes.Black;
                    plot_v.Legend.Foreground   = Brushes.Black;
                    plot_rho.Legend.Foreground = Brushes.Black;
                    plot_P.Legend.Foreground   = Brushes.Black;
                    plot_T.Legend.Foreground   = Brushes.Black;

                    label_plot_yaxis.Content = "U (m/s)";
                    grid_plot_u.Visibility   = Visibility.Visible;

                    label_plot_title.Visibility = Visibility.Visible;
                    label_plot_xaxis.Visibility = Visibility.Visible;
                    label_plot_yaxis.Visibility = Visibility.Visible;

                    isCalculatePressed = true;
                }
                else
                {
                    MessageBox.Show("First select all initial parameters");
                }
            }
            catch (Exception j)
            {
                MessageBox.Show(j.Message);
            }
        }
Exemplo n.º 7
0
		public RawPointEnumerator(RawDataSource dataSource) {
			this.enumerator = dataSource.Data.GetEnumerator();
		}
Exemplo n.º 8
0
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            const int N = 200;

            double step = Math.PI * 2 / N;

            #region CompositeDataSource
            double[] x = new double[N];
            double[] y = new double[N];

            for (int i = 0; i < N; i++)
            {
                x[i] = i * step;
                y[i] = Math.Sin(x[i]);
            }

            var xDataSource = x.AsXDataSource();
            var yDataSource = y.AsYDataSource();

            CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);

            sin = new LineGraph(compositeDataSource, "sin(x)");

            PlotterMain.Children.Add(sin);
            #endregion

            #region RawDataSource
            Point[] points = new Point[N];

            for (int i = 0; i < N; i++)
            {
                points[i] = new Point(i * step, (0.7 * Math.Cos(x[i] * 3) + 3) + (1.5 * Math.Sin(x[i] / 2 + 4)));
            }

            RawDataSource rawDataSource = points.AsDataSource();

            cos = new LineGraph(rawDataSource, "(0.7 * Cos(3x)+3)+(1.5*Sin(x/2+4))");

            PlotterMain.Children.Add(cos);
            #endregion

            #region EnumerableDataSource and Custom Graph Settings

            MyClass[] myObjects = new MyClass[N];
            for (int i = 0; i < N; i++)
            {
                myObjects[i] = new MyClass()
                {
                    A = 0.1 + i * step
                }
            }
            ;

            EnumerableDataSource <MyClass> enumDataSource = myObjects.AsDataSource <MyClass>();
            enumDataSource.SetXYMapping(o => new Point(o.A, o.B));

            LineGraphSettings settings = new LineGraphSettings();
            settings.LineColor     = Colors.Magenta;
            settings.LineThickness = Math.PI;
            settings.Description   = "Log10";
            log = new LineGraph(enumDataSource, settings);
            PlotterMain.Children.Add(log);

            #endregion

//            PlotterMain.FitToView();
        }