예제 #1
0
        /// <summary>
        /// Solution
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExecute_Click(object sender, EventArgs e)
        {
            try
            {
                int    index  = int.Parse(indexUpDown.Value.ToString());
                int    __NZ   = int.Parse(edtDivisionCounter.Text);
                double T0     = double.Parse(edtHighestTemp.Text);
                double M      = double.Parse(edtPowerTemp.Text);
                double Radius = double.Parse(edtRadius.Text);

                //var ex = new ExactTest(__NZ, T0, M, Radius);
                var ex = new ExactSolution(__NZ, T0, M, Radius);
                ex.Solve(index);

                var sc = new SchemeSolution(__NZ, T0, M, Radius);
                sc.MScheme = double.Parse(mScheme.Text);
                sc.Solve(index);

                //var ss = new Schuster_Schwarzschild(n,
                //                            double.Parse(edtHighestTemp.Text),
                //                            double.Parse(edtPowerTemp.Text),
                //                            double.Parse(edtRadius.Text));
                //ss.Solve(index);                // Table
                tab.RowCount = __NZ + 1;
                for (int iz = 0; iz <= __NZ; iz++)
                {
                    tab[0, iz].Value = iz.ToString();
                    tab[1, iz].Value = string.Format("{0:E5}", ex.Z[iz]);
                    tab[2, iz].Value = string.Format("{0:E5}", sc.K[iz]);
                    tab[3, iz].Value = string.Format("{0:E5}", ex.Up[iz]);

                    tab[4, iz].Value = string.Format("{0:E5}", ex.U[iz]);
                    tab[5, iz].Value = string.Format("{0:E5}", sc.U[iz]);

                    tab[6, iz].Value = string.Format("{0:E5}", ex.DivF[iz]);
                    tab[7, iz].Value = string.Format("{0:E5}", sc.DivF[iz]);
                }

                ShowGraph();

                ex = null;
                sc = null;
                //ss = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
예제 #2
0
        private void collectAnalysBtn_Click(object sender, EventArgs e)
        {
            try
            {
                // initialize
                int    __NZ   = int.Parse(edtDivisionCounter.Text);
                double T0     = double.Parse(edtHighestTemp.Text);
                double M      = double.Parse(edtPowerTemp.Text);
                double Radius = double.Parse(edtRadius.Text);

                //var ex = new ExactTest(__NZ, T0, M, Radius);
                var ex = new ExactSolution(__NZ, T0, M, Radius);

                //int MaxIndex = ex.NFreq - 1;          // HERE!!!
                int      MaxIndex = int.Parse(indexUpDown.Value.ToString());
                double[] Freq     = new double[MaxIndex + 1];
                double[] MS       = new double[MaxIndex + 1];
                double[] Tau      = new double[MaxIndex + 1];

                // main stuff: collecting mScheme       # found exception: 31-33
                for (int index = 0; index <= MaxIndex; index++)
                {
                    ex.Solve(index);
                    var    AC    = new AnalysingCoefficient(ex.U, ex.DivF);
                    double value = AC.FirstMethod(__NZ, T0, M, Radius, index);

                    Freq[index] = ex.Freq;
                    Tau[index]  = ex.Tau;
                    MS[index]   = value;
                    AC          = null;
                }
                ex = null;

                // save m (analys) and tau to file
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..//..//MT-reports//MT.txt"))
                {
                    for (int j = 0; j <= MaxIndex; j++)
                    {
                        file.Write("{0}\t{1}\t{2}\n", Freq[j], MS[j], Tau[j]);
                    }
                }

                // Graph
                // 1. Correct interface
                for (int i = 0; i < GraphCount; i++)
                {
                    selector.SetItemChecked(i, false);
                    GraphList[i]            = false;
                    chart.Series[i].Enabled = GraphList[i];
                }

                selector.SetItemChecked(5, true);
                GraphList[5] = true;

                // 2. Clear old chart
                foreach (var s in chart.Series)
                {
                    s.Points.Clear();
                }

                // 3. Draw result
                Draw(5, Freq, MS);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }