Exemplo n.º 1
0
        public AllPlotsForPhysicsTask(SDE task)
        {
            InitializeComponent();
            Plot1.Series[0].Points.Clear();
            Plot1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;
            Plot1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;
            Plot1.Series[0].IsVisibleInLegend           = false;
            Plot1.Series[0].Color                       = Color.Green;
            Plot1.ChartAreas[0].AxisY.Title             = "v";
            Plot1.ChartAreas[0].AxisX.Title             = "x";
            Plot1.ChartAreas[0].AxisX.LabelStyle.Format = "{0:0.00}";
            Plot1.ChartAreas[0].AxisY.LabelStyle.Format = "{0:0.00}";

            Plot2.Series[0].Points.Clear();
            Plot2.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;
            Plot2.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;
            Plot2.Series[0].IsVisibleInLegend           = false;
            Plot2.Series[0].Color                       = Color.Green;
            Plot2.ChartAreas[0].AxisY.Title             = "v'";
            Plot2.ChartAreas[0].AxisX.Title             = "x";
            Plot2.ChartAreas[0].AxisX.LabelStyle.Format = "{0:0.00}";
            Plot2.ChartAreas[0].AxisY.LabelStyle.Format = "{0:0.00}";

            PhasePlot.Series[0].Points.Clear();
            PhasePlot.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;
            PhasePlot.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;
            PhasePlot.Series[0].IsVisibleInLegend           = false;
            PhasePlot.Series[0].Color                       = Color.Green;
            PhasePlot.ChartAreas[0].AxisY.Title             = "v";
            PhasePlot.ChartAreas[0].AxisX.Title             = "v'";
            PhasePlot.ChartAreas[0].AxisX.LabelStyle.Format = "{0:0.00}";
            PhasePlot.ChartAreas[0].AxisY.LabelStyle.Format = "{0:0.00}";


            for (int i = 0; i <= task.IterationsCount; i++)
            {
                Plot1.Series[0].Points.AddXY(task.xi[i], task.V[i, 1]);
                Plot2.Series[0].Points.AddXY(task.xi[i], task.V[i, 0]);
                PhasePlot.Series[0].Points.AddXY(task.V[i, 0], task.V[i, 1]);
            }
        }
Exemplo n.º 2
0
        private void Base2Button_Click(object sender, EventArgs e)
        {
            double h, eps, X, u00, u01, a, b;
            int    Nmax;

            try
            {
                h    = Double.Parse(StepTextBox.Text);
                eps  = Double.Parse(EpsTextBox.Text);
                X    = Double.Parse(XmaxTextBox.Text);
                Nmax = Int32.Parse(NmaxTextBox.Text);
                u00  = Double.Parse(InitBounds2textBox.Text);
                u01  = Double.Parse(InitBounds1textBox.Text);
                a    = Double.Parse(ParAtextBox.Text);
                b    = Double.Parse(ParBtextBox.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Один из параметров задан неверно!");
                return;
            }
            BaseSecond7F1 Function1 = new BaseSecond7F1(a, b);
            BaseSecond7F2 Function2 = new BaseSecond7F2();
            double        x0        = 0;

            task = new RK4System(u00, u01, Function1, Function2, x0, X, h, Nmax, eps);
            if (ControlCondcheckBox.Checked)
            {
                task.CondControl = true;
            }
            if (ControlErrorcheckBox.Checked)
            {
                task.solveWithControlError();
            }
            if (!ControlErrorcheckBox.Checked)
            {
                task.solve();
            }

            table.ColumnCount = 9;
            table.RowCount    = task.IterationsCount + 2;

            table[0, 0].Value = "i";
            table[1, 0].Value = "Xi";
            table[2, 0].Value = "Vi";
            table[3, 0].Value = "V2i";
            table[4, 0].Value = "|Vi - V2i|";
            table[5, 0].Value = "ОЛП";
            table[6, 0].Value = "hi";
            table[7, 0].Value = "C1";
            table[8, 0].Value = "C2";

            for (int i = 1; i < table.RowCount; i++)
            {
                table[0, i].Value = i - 1;
                table[1, i].Value = task.xi[i - 1];
                table[2, i].Value = task.V[i - 1, 1];
                table[3, i].Value = task.V2[i - 1, 1];
                table[4, i].Value = Math.Abs(task.V[i - 1, 1] - task.V2[i - 1, 1]).ToString("e3");
                table[5, i].Value = (Math.Pow(2, (double)task.P) * Math.Max(task.S[i - 1, 0], task.S[i - 1, 1])).ToString("e3");
                table[6, i].Value = task.H[i - 1];
                table[7, i].Value = task.DoubleCount[i - 1];
                table[8, i].Value = task.HalfCount[i - 1];
            }
            Plot.Series[0].Points.Clear();
            Plot.Series[1].Points.Clear();
            Plot.ChartAreas[0].AxisX.Minimum = 0;
            Plot.ChartAreas[0].AxisX.Maximum = task.xi[task.IterationsCount];
            for (int i = 0; i <= task.IterationsCount; i++)
            {
                Plot.Series[0].Points.AddXY(task.xi[i], task.V[i, 1]);
            }
            TaskSolved = true;
        }