예제 #1
0
        private void button_start_Click(object sender, EventArgs e)
        {
            if (Convert.ToDouble(textBox_borderAccuracy.Text) < Convert.ToDouble(textBox_eps.Text))
            {
                System.Windows.MessageBox.Show("Лучше так не делать, точность выхода на границу меньше, чем контроль локальной погрешности!");
                return;
            }
            CounterOfTests++;
            dataGridView_MetodInfo.Rows.Clear();
            dataGridView_TaskInfo.Rows.Clear();
            Function Func = new Function();

            Func.SetFunction(Convert.ToDouble(textBox_alfa.Text), Convert.ToDouble(textBox_sigma.Text));
            FunkDelegate function = Func.FunctionValue;

            TrueSolution trueSolution = new TrueSolution(Convert.ToDouble(textBox_alfa.Text),
                                                         Convert.ToDouble(textBox_sigma.Text),
                                                         Convert.ToDouble(textBox_u_0.Text));

            Runge_Kutta_2 RK_2 = new Runge_Kutta_2();

            RK_2.Init(Convert.ToDouble(textBox_x_0.Text), Convert.ToDouble(textBox_u_0.Text),
                      Convert.ToDouble(textBox_h.Text), Convert.ToDouble(textBox_eps.Text),
                      Convert.ToDouble(textBox_borderAccuracy.Text), Convert.ToInt32(textBox_max_iter.Text), function, checkBox_StepControl.Checked);

            RK_2.Run();

            cartesianChart1.Series.Add(new LineSeries
            {
                Title  = "Численное решение #" + Convert.ToString(CounterOfTests),
                Values = new ChartValues <ObservablePoint>(RK_2
                                                           .GetPoints()
                                                           .Select(_ => new ObservablePoint(_.X, _.V))),
                PointGeometrySize = 5
            });
            List <MetodInfo> metodInfos = RK_2.GetMetodInfos();

            metodInfos.ForEach(_ =>
                               dataGridView_MetodInfo.Rows.Add
                                   (_.Iteration, _.H, _.X, _.V, _.UHalf, _.V - _.UHalf,
                                   _.S, _.e, _.UCorr, _.V, trueSolution.FunctionValue(_.X), Math.Abs(trueSolution.FunctionValue(_.X) - _.V).ToString("F8"), _.CountMinusH, _.CountPlusH));
            dataGridView_MetodInfo.AutoResizeColumns();

            TaskInfo taskInfo = new TaskInfo(CounterOfTests,
                                             Convert.ToDouble(textBox_alfa.Text), Convert.ToDouble(textBox_sigma.Text),
                                             Convert.ToDouble(textBox_x_0.Text), Convert.ToDouble(textBox_u_0.Text),
                                             Convert.ToDouble(textBox_h.Text), Convert.ToDouble(textBox_eps.Text),
                                             Convert.ToInt32(textBox_max_iter.Text));

            dataGridView_TaskInfo.Rows.Add(taskInfo.Number, taskInfo.Alfa, taskInfo.Sigma, taskInfo.X0, taskInfo.U0,
                                           taskInfo.h0, taskInfo.e, taskInfo.Max_iteration);

            listExperimentInfos.Add(new ExperimentInfo(taskInfo, metodInfos));
            comboBox_TaskSelector.Items.Add("Тест №" + Convert.ToString(CounterOfTests));

            richTextBox_log.AppendText("    Время вытекания жидкости в Тесте №" + Convert.ToString(CounterOfTests) +
                                       ": " + RK_2.GetResultTime() + " секунд.\n");
        }
예제 #2
0
        private void comboBox_TaskSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataGridView_MetodInfo.Rows.Clear();
            dataGridView_TaskInfo.Rows.Clear();
            int          index        = comboBox_TaskSelector.SelectedIndex;
            TrueSolution trueSolution = new TrueSolution(listExperimentInfos[index].TaskInformation.Alfa,
                                                         listExperimentInfos[index].TaskInformation.Sigma,
                                                         listExperimentInfos[index].TaskInformation.U0);

            dataGridView_TaskInfo.Rows.Add(listExperimentInfos[index].TaskInformation.Number, listExperimentInfos[index].TaskInformation.Alfa, listExperimentInfos[index].TaskInformation.Sigma, listExperimentInfos[index].TaskInformation.X0, listExperimentInfos[index].TaskInformation.U0,
                                           listExperimentInfos[index].TaskInformation.h0, listExperimentInfos[index].TaskInformation.e, listExperimentInfos[index].TaskInformation.Max_iteration);
            listExperimentInfos[index].MetodInformation.ForEach(_ =>
                                                                dataGridView_MetodInfo.Rows.Add
                                                                    (_.Iteration, _.H, _.X, _.V, _.UHalf, _.V - _.UHalf,
                                                                    _.S, _.e, _.UCorr, _.V, trueSolution.FunctionValue(_.X), Math.Abs(trueSolution.FunctionValue(_.X) - _.V).ToString("F8"), _.CountMinusH, _.CountPlusH));
        }