Пример #1
0
 public void Start()
 {
     while (!NeedStop())
     {
         double _h        = h; // тот h, который нужен для получения новой точки
         Point1 newpoint  = MakeStep(currP, h);
         Point1 halfpoint = HalfPointM(currP, h);
         double s         = Math.Abs(GetS(halfpoint, newpoint));
         double err_l     = Math.Abs(Math.Pow(2.0, 2.0) * s);
         double corr_v    = GetVCorrect(newpoint, s);
         if (s <= eps / (Math.Pow(2.0, 3.0)))
         {
             currP = newpoint;
             h     = 2.0 * h;
             pluscorr_Step++;
             points.Add(newpoint);
         }
         else if (s > eps)
         {
             h = h / 2.0;
             minuscorr_Step++;
         }
         else
         {
             currP = newpoint;
             points.Add(newpoint);
         }
         table_data.Add(new TableInfo1(step_counter, _h, currP, halfpoint.V, err_l, currP.V - halfpoint.V,
                                       s, corr_v, pluscorr_Step, minuscorr_Step));
         step_counter++;
     }
 }
Пример #2
0
        private Point1 MakeStep(Point1 p, double h)
        {
            double pX = GetNextX(p.X, h);
            double pV = GetNextV(p.X, p.V, h);

            return(new Point1(pX, pV));
        }
Пример #3
0
 public void Init(Point1 _currP, int _maxsteps, double _h, double _eps, double _eBorder,
                  int _plus_corr_Step, int _minus_corr_Step)
 {
     currP          = _currP;
     maxsteps       = _maxsteps;
     h              = _h;
     eps            = _eps;
     eBorder        = _eBorder;
     pluscorr_Step  = _plus_corr_Step;
     minuscorr_Step = _minus_corr_Step;
     points.Add(currP);
     table_data.Add(new TableInfo1(step_counter, h, currP, 0, 0, 0, 0, 0, 0, 0));
     step_counter++;
 }
Пример #4
0
 public TableInfo1(int _iter, double _integr_step, Point1 _point, double _half_V, double _err_loc,
                   double _dV, double _S, double _corr_V, int _plus_corr_Step, int _minus_corr_Step)
 {
     iter            = _iter;
     integr_step     = _integr_step;
     point           = _point;
     half_V          = _half_V;
     dV              = _dV;
     S               = _S;
     err_loc         = _err_loc;
     corr_V          = _corr_V;
     plus_corr_Step  = _plus_corr_Step;
     minus_corr_Step = _minus_corr_Step;
 }
Пример #5
0
        private Point1 HalfPointM(Point1 p, double h)
        {
            Point1 _p = MakeStep(p, h / 2.0);

            return(MakeStep(_p, h / 2.0));
        }
Пример #6
0
 private double GetS(Point1 _halfPoint, Point1 _newPoint)
 {
     return((_halfPoint.V - _newPoint.V) / (2.0 * 2.0 - 1.0));
 }
Пример #7
0
 private double GetVCorrect(Point1 p, double s)
 {
     return(p.V + Math.Pow(2.0, 2.0) * s);
 }
Пример #8
0
        private void button4_Click(object sender, EventArgs e)
        {
            Method1 RK1 = new Method1();
            double  V0  = Convert.ToDouble(textBox10.Text);
            Point1  p   = new Point1(0, V0);

            int _maxsteps1 = Convert.ToInt32(textBox3.Text);

            double _h1       = Convert.ToDouble(textBox9.Text);
            double _eps1     = Convert.ToDouble(textBox2.Text);
            double _eBorder1 = Convert.ToDouble(textBox8.Text);

            RK1.Init(p, _maxsteps1, _h1, _eps1, _eBorder1, 0, 0);
            RK1.Start();

            dataGridView2.RowCount    = RK1.GetMetodInfos().Count;
            dataGridView2.ColumnCount = 12;

            int n = RK1.GetMetodInfos().Count;

            dataGridView2.Columns[0].HeaderText = "№";
            for (int i = 0; i < n; i++)
            {
                dataGridView2[0, i].Value = i;
            }

            dataGridView2.Columns[1].HeaderText = "h_i-1"; //
            for (int i = 0; i < n; i++)
            {
                dataGridView2[1, i].Value = RK1.GetMetodInfos()[i].integr_step;
            }

            dataGridView2.Columns[2].HeaderText = "x_i"; //
            for (int i = 0; i < n; i++)
            {
                dataGridView2[2, i].Value = RK1.GetMetodInfos()[i].point.X;
            }

            dataGridView2.Columns[3].HeaderText = "v_i";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[3, i].Value = RK1.GetMetodInfos()[i].point.V;
            }

            dataGridView2.Columns[4].HeaderText = "v_удв";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[4, i].Value = RK1.GetMetodInfos()[i].half_V;
            }

            dataGridView2.Columns[5].HeaderText = "v_i - v_удв";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[5, i].Value = RK1.GetMetodInfos()[i].dV;
            }

            dataGridView2.Columns[6].HeaderText = "v_итог";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[6, i].Value = RK1.GetMetodInfos()[i].point.V;
            }

            dataGridView2.Columns[7].HeaderText = "S";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[7, i].Value = RK1.GetMetodInfos()[i].S;
            }

            dataGridView2.Columns[8].HeaderText = "e";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[8, i].Value = RK1.GetMetodInfos()[i].err_loc;
            }

            dataGridView2.Columns[9].HeaderText = "v_corr";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[9, i].Value = RK1.GetMetodInfos()[i].corr_V;
            }

            dataGridView2.Columns[10].HeaderText = "Увеличение шага";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[10, i].Value = RK1.GetMetodInfos()[i].plus_corr_Step;
            }

            dataGridView2.Columns[11].HeaderText = "Уменьшение шага";//
            for (int i = 0; i < n; i++)
            {
                dataGridView2[11, i].Value = RK1.GetMetodInfos()[i].minus_corr_Step;
            }

            cartesianChart2.Series.Add(new LineSeries
            {
                Title  = "Численное решение",
                Values = new ChartValues <ObservablePoint>(RK1
                                                           .GetPoints()
                                                           .Select(_ => new ObservablePoint(_.X, _.V))),
                PointGeometrySize = 5
            });
            copy1 = RK1.GetPoints();
        }