Exemplo n.º 1
0
        private void mScheme_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    int index = int.Parse(indexUpDown.Value.ToString());
                    int n     = int.Parse(edtDivisionCounter.Text);
                    //Us = new double[n + 1];

                    var sc = new SchemeSolution(n,
                                                double.Parse(edtHighestTemp.Text),
                                                double.Parse(edtPowerTemp.Text),
                                                double.Parse(edtRadius.Text));
                    sc.MScheme = double.Parse(mScheme.Text);
                    sc.Solve(index);

                    for (int iz = 0; iz <= n; iz++)
                    {
                        tab[5, iz].Value = string.Format("{0:E5}", sc.U[iz]);
                        tab[7, iz].Value = string.Format("{0:E5}", sc.DivF[iz]);
                    }

                    ShowGraph();
                    sc = null;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Analys coefficient m (scheme) by searching beginning point
        /// </summary>
        /// <param name="__NZ"></param>
        /// <param name="T0"></param>
        /// <param name="M"></param>
        /// <param name="Radius"></param>
        /// <param name="index"></param>
        /// <returns>M (scheme) value</returns>
        public double FirstMethod(int __NZ, double T0, double M, double Radius, int index)
        {
            var sc = new SchemeSolution(__NZ, T0, M, Radius);

            double begin = 0.0, end = 1000.0, middle = 0.5;
            double beginValue = Process(sc, index, begin),
                   endValue   = Process(sc, index, end);

            while (!FirstCriteria(beginValue, endValue, begin, end))
            {
                middle = (begin + end) / 2.0;
                double middleValue = Process(sc, index, middle);

                if (CompareToBase(beginValue) && CompareToBase(middleValue))
                {
                    begin      = middle;
                    beginValue = middleValue;
                }
                else
                {
                    end      = middle;
                    endValue = middleValue;
                }
            }

            return(middle);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private void reportBtn_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);
                selector.SetItemChecked(6, true);

                double[] result = new double[__NZ + 1];
                var      sc     = new SchemeSolution(__NZ, T0, M, Radius);
                sc.MScheme = double.Parse(mScheme.Text);
                //sc.MScheme = 0.15;

                for (int i = 0; i < sc.NFreq; i++)
                {
                    sc.Solve(i);
                    for (int j = 0; j <= __NZ; j++)
                    {
                        result[j] += sc.DivF[j] * sc.dFreq;
                    }
                }

                for (int j = 0; j <= __NZ; j++)
                {
                    tab[8, j].Value = string.Format("{0:E5}", result[j]);
                }

                ShowGraph();
                sc = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 5
0
        private void btnThreadbyFreq_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);
                selector.SetItemChecked(7, true);

                //int MaxIndex = 20;
                int      MaxIndex    = int.Parse(indexUpDown.Value.ToString());
                double[] Freq        = new double[MaxIndex + 1];
                double[] deltaThread = new double[MaxIndex + 1];

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

                // save m (analys) and tau to file
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..//..//Thread//ThreadByFrequency.csv"))
                {
                    for (int i = 0; i <= MaxIndex; i++)
                    {
                        sc.Solve(i);
                        Freq[i]        = sc.Freq;
                        deltaThread[i] = sc.F[__NZ] / sc.dFreq;
                        Console.WriteLine("{0}", deltaThread[i]);

                        // write to file
                        for (int j = 0; j < __NZ; j++)
                        {
                            file.Write("{0:E},", sc.F[j]);
                        }
                        file.WriteLine("{0:E}", sc.F[__NZ]);
                    }
                }

                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..//..//Thread//ThreadByFrequency.txt"))
                {
                    // X-axis
                    for (int j = 0; j <= MaxIndex; j++)
                    {
                        for (int i = 0; i <= __NZ; i++)
                        {
                            if (j == MaxIndex && i == __NZ)
                            {
                                file.WriteLine("{0:E}", 1.0);
                            }
                            else
                            {
                                file.Write("{0:E},", (double)i / __NZ);
                            }
                        }
                    }

                    // Y-axis
                    var modelBase = new ModelBase();
                    for (int j = 0; j <= MaxIndex; j++)
                    {
                        for (int i = 0; i <= __NZ; i++)
                        {
                            if (j == MaxIndex && i == __NZ)
                            {
                                file.WriteLine("{0:E}", (modelBase.Frequency[MaxIndex + 1] + modelBase.Frequency[MaxIndex]) / 2.0);
                            }
                            else
                            {
                                file.Write("{0:E},", (modelBase.Frequency[j + 1] + modelBase.Frequency[j]) / 2.0);
                            }
                        }
                    }
                    modelBase = null;

                    // Z-axis
                    for (int j = 0; j <= MaxIndex; j++)
                    {
                        sc.Solve(j);
                        for (int i = 0; i <= __NZ; i++)
                        {
                            if (j == MaxIndex && i == __NZ)
                            {
                                file.WriteLine("{0:E}", sc.F[__NZ]);
                            }
                            else
                            {
                                file.Write("{0:E},", sc.F[i]);
                            }
                        }
                    }
                }
                sc = null;

                // 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(7, true);
                GraphList[7] = true;

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

                // 3. Draw result
                Draw(7, Freq, deltaThread);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Main process: Scheme Solution
 /// </summary>
 /// <param name="scheme"></param>
 /// <param name="index"></param>
 /// <param name="MS"></param>
 /// <returns></returns>
 private double Process(SchemeSolution scheme, int index, double MS)
 {
     scheme.MScheme = MS;
     scheme.Solve(index);
     return(scheme.U[0]);
 }