Ejemplo n.º 1
0
        private void btnTransfer_Click(object sender, EventArgs e)
        {
            isReal = true;
            view.Output.ClearScreen();
            grcTabRes.DataSource = null;
            n = int.Parse(txtN.Text);
            setCount = rbN1.Checked ? 1 : 2;

            double t = 0;
            var r = new RKResults();
            foreach (double y in ASignal)
            {
                r.Add(new RKResult(t, new Vector(1, y)));
                t += 0.01;
            }
            res = r;
            randomStartParameters = GetRandomStartParam();

            var gammaList = new List<double>();
            for (int i = 0; i < dgvGama.ColumnCount; i++)
            {
                gammaList.Add(Convert.ToDouble(dgvGama.Rows[0].Cells[i].Value));
            }

            var list = new List<TaskParameter>();
            for (int i = 0; i < dgvParameters.RowCount; i++)
            {
                var tp = new TaskParameter(dgvParameters.ColumnCount);
                for (int j = 0; j < dgvParameters.ColumnCount; j++)
                {
                    double val = Convert.ToDouble(dgvParameters.Rows[i].Cells[j].Value);
                    tp.Param[j] = val;
                }
                list.Add(tp);
            }

            tps = new TaskParameters(list, gammaList);
            string mfName = setCount == 1 ? "MF1" : "MF2";
            funcDescr = new Functions_2_2(mfName, fnames[(sfList.SelectedItem as string).ToUpper()]);
            startVector = new Vector(1, 0);
            tw = new TaskWorker(tps, funcDescr.GetType(), funcDescr.MainFuncName, funcDescr.SecFuncName, funcDescr);

            xtcMain.SelectedTabPageIndex = 2;
        }
Ejemplo n.º 2
0
        private void btnSolveRK_Click(object sender, EventArgs e)
        {
            this.rtbResult1.Text = this.rtbResult2.Text = string.Empty;
            this.dgvTabRes.DataSource = null;
            this.n = int.Parse(this.txtN.Text);
            this.setCount = this.rbN1.Checked ? 1 : 2;
            //this.gamma = double.Parse(txtGamma.Text);

            ZedGraph.GraphPane gp = this.zgcMainChart2.GraphPane;
            gp.CurveList.Clear();
            this.curves.Clear();

            this.curves.Add(this.curveName, new PointPairList());
            gp.AddCurve(this.curveName, this.curves[curveName], Color.Black, SymbolType.None);

            List<double> gammaList = new List<double>();
            List<double> p = new List<double>();

            for (int i = 0; i < dgvGama.ColumnCount; i++)
            {
                gammaList.Add(Convert.ToDouble(dgvGama.Rows[0].Cells[i].Value));
            }

            List<TaskParameter> list = new List<TaskParameter>();
            for (int i = 0; i < dgvParameters.RowCount; i++)
            {
                TaskParameter tp = new TaskParameter(dgvParameters.ColumnCount);
                for (int j = 0; j < dgvParameters.ColumnCount; j++)
                {
                    double val = Convert.ToDouble(dgvParameters.Rows[i].Cells[j].Value);
                    tp.Param[j] = val;
                }
                list.Add(tp);
            }

            this.tps = new TaskParameters(list, gammaList);
            string mfName = this.setCount == 1 ? "MF1" : "MF2";
            this.funcDescr = new Functions_2_2(mfName, this.fnames[(sfList.SelectedItem as string).ToUpper()]);

            this.tw = new TaskWorker(tps, funcDescr.GetType(), funcDescr.MainFuncName, funcDescr.SecFuncName, funcDescr);

            this.startVector = this.setCount == 1 ? new Vector(1, double.Parse(this.txtY0.Text)) :
                new Vector(2, double.Parse(this.txtY00.Text), double.Parse(this.txtY01.Text));

            RKVectorForm rk = new RKVectorForm(tw, curveName, double.Parse(this.txtT0.Text), double.Parse(this.txtT1.Text), startVector);
            this.res = rk.SolveWithConstH(n, RKMetodType.RK4_1);

            if (this.rbN1.Checked)
            {
                res.ForEach(r => this.curves[curveName].Add(r.X, r.Y[0]));
            }
            else
            {
                res.ForEach(r => this.curves[curveName].Add(r.Y[0], r.Y[1]));
            }
            this.zgcMainChart2.AxisChange();
            this.zgcMainChart2.Refresh();

            if (this.setCount == 1)
            {
                this.tblResList = new List<ResPointViewType1>();
                for (int i = 0; i < res.Count - 1; i++)
                    (this.tblResList as List<ResPointViewType1>).Add(new ResPointViewType1(res[i].X, res[i].Y[0], -1, -1));
                this.dgvTabRes.DataSource = null;
                this.dgvTabRes.DataSource = tblResList;
            }
            else
            {
                this.tblResList = new List<ResPointViewType2>();
                for (int i = 0; i < res.Count - 2; i++)
                    (this.tblResList as List<ResPointViewType2>).Add(new ResPointViewType2(res[i].X, res[i].Y[0], res[i].Y[1], -1, -1));
                this.dgvTabRes.DataSource = null;
                this.dgvTabRes.DataSource = tblResList;
            }
            this.dgvTabRes.RefreshDataSource();

            this.randomStartParameters = this.GetRandomStartParam();
        }
Ejemplo n.º 3
0
        private void btnSolveRK_Click(object sender, EventArgs e)
        {
            try
            {
                btnSolveRK.Enabled = false;
                isReal = false;
                view.Output.ClearScreen();
                grcTabRes.DataSource = null;
                n = int.Parse(txtN.Text, enUsCulture);
                setCount = rbN1.Checked ? 1 : 2;
                //this.gamma = double.Parse(txtGamma.Text);

                if (setCount == 1)
                {
                    view.ConfigGraphPane(zgcMainChart2, this, PaneLayout.SingleColumn, new List<ChartInfo>
                                                                                           {
                                                                                               new ChartInfo
                                                                                                   {
                                                                                                       Title = "(t,z1)",
                                                                                                       XAxisTitle = "t",
                                                                                                       YAxisTitle = "z1"
                                                                                                   },
                                                                                           });
                }
                else
                {
                    view.ConfigGraphPane(zgcMainChart2, this, PaneLayout.SingleColumn, new List<ChartInfo>
                                                                                           {
                                                                                               new ChartInfo
                                                                                                   {
                                                                                                       Title = "(t,z1)",
                                                                                                       XAxisTitle = "t",
                                                                                                       YAxisTitle = "z1"
                                                                                                   },
                                                                                               new ChartInfo
                                                                                                   {
                                                                                                       Title = "(z1,z2)",
                                                                                                       XAxisTitle = "z1",
                                                                                                       YAxisTitle = "z2"
                                                                                                   }
                                                                                           });
                }
                //ZedGraph.GraphPane gp = this.zgcMainChart2.GraphPane;
                //gp.CurveList.Clear();
                curves.Clear();

                if (setCount == 1)
                {
                    curves.Add(curveName, new PointPairList());
                    zgcMainChart2.MasterPane[0].AddCurve(curveName, curves[curveName], Color.Black, SymbolType.None);
                }
                else
                {
                    curves.Add(curveName, new PointPairList());
                    curves.Add(curveName + curveNameSuff, new PointPairList());
                    zgcMainChart2.MasterPane[0].AddCurve(curveName + curveNameSuff, curves[curveName + curveNameSuff],
                                                         Color.Black, SymbolType.None);
                    zgcMainChart2.MasterPane[1].AddCurve(curveName, curves[curveName], Color.Black, SymbolType.None);
                }

                var p = new List<double>();

                var gammaList = new List<double>();
                for (int i = 0; i < dgvGama.ColumnCount; i++)
                {
                    double d = double.Parse(dgvGama.Rows[0].Cells[i].Value.ToString().Replace(',', '.'), enUsCulture);
                    gammaList.Add(d);
                }

                var list = new List<TaskParameter>();
                for (int i = 0; i < dgvParameters.RowCount; i++)
                {
                    var tp = new TaskParameter(dgvParameters.ColumnCount);
                    for (int j = 0; j < dgvParameters.ColumnCount; j++)
                    {
                        double val = double.Parse(dgvParameters.Rows[i].Cells[j].Value.ToString().Replace(',', '.'),
                                                  enUsCulture);
                        tp.Param[j] = val;
                    }
                    list.Add(tp);
                }

                tps = new TaskParameters(list, gammaList);
                string mfName = setCount == 1 ? "MF1" : "MF2";
                funcDescr = new Functions_2_2(mfName, fnames[(sfList.SelectedItem as string).ToUpper()]);

                tw = new TaskWorker(tps, funcDescr.GetType(), funcDescr.MainFuncName, funcDescr.SecFuncName, funcDescr);

                startVector = setCount == 1
                                  ? new Vector(1, double.Parse(txtY0.Text.Replace(',', '.'), enUsCulture))
                                  : new Vector(2, double.Parse(txtY00.Text.Replace(',', '.'), enUsCulture),
                                               double.Parse(txtY01.Text.Replace(',', '.'), enUsCulture));

                var rk = new RKVectorForm(tw, curveName, double.Parse(txtT0.Text.Replace(',', '.'), enUsCulture),
                                          double.Parse(txtT1.Text.Replace(',', '.'), enUsCulture), startVector);
                res = rk.SolveWithConstH(n, RKMetodType.RK4_1);

                if (rbN1.Checked)
                {
                    for (int i = 0; i < res.Count - 1; i++)
                    {
                        curves[curveName].Add(res[i].X, res[i].Y[0]);
                    }
                    //res.ForEach(r => this.curves[curveName].Add(r.X, r.Y[0]));
                }
                else
                {
                    for (int i = 0; i < res.Count - 2; i++)
                    {
                        curves[curveName + curveNameSuff].Add(res[i].X, res[i].Y[0]);
                        curves[curveName].Add(res[i].Y[0], res[i].Y[1]);
                    }
                    //res.ForEach(r => this.curves[curveName].Add(r.Y[0], r.Y[1]));
                }
                zgcMainChart2.AxisChange();
                zgcMainChart2.Refresh();

                if (setCount == 1)
                {
                    tblResList = new List<ResPointViewType1>();
                    for (int i = 0; i < res.Count - 1; i++)
                        (tblResList as List<ResPointViewType1>).Add(new ResPointViewType1(res[i].X, res[i].Y[0], -1, -1));
                    grcTabRes.DataSource = null;
                    grcTabRes.DataSource = tblResList;
                }
                else
                {
                    tblResList = new List<ResPointViewType2>();
                    for (int i = 0; i < res.Count - 2; i++)
                        (tblResList as List<ResPointViewType2>).Add(new ResPointViewType2(res[i].X, res[i].Y[0],
                                                                                          res[i].Y[1], -1, -1));
                    grcTabRes.DataSource = null;
                    grcTabRes.DataSource = tblResList;
                }
                grcTabRes.RefreshDataSource();
            }
            finally
            {
                btnSolveRK.Enabled = true;
            }
        }