Exemplo n.º 1
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;
        }