void CreateSeries()
        {
            if (series != null)
            {
                return;
            }
            if (selection == null)
            {
                return;
            }
            IMeasurements m = selection;

            if (m.Count < 2)
            {
                return;
            }
            double[][] d = new double[][] { (double[])m[0].Parameter(), (double[])m[1].Parameter() };
            series = new DataPerformer.Series();
            ser    = new Chart.Drawing.Series.SimpleSeries();
            int n = d[0].Length;

            for (int i = 0; i < n; i++)
            {
                double x = d[0][i];
                double y = d[1][i];
                series.AddXY(x, y);
                ser.AddXY(x, y);
            }
        }
        private void ShowTransient()
        {
            double step  = 1 / (30 * max);
            double eps   = 0.001;
            double coeff = clone.Coefficient;

            if (coeff <1 & coeff> 1e-15)
            {
                eps *= coeff;
            }
            double a = 0;

            if (min > 0)
            {
                a = 1 / min;
            }
            Chart.Drawing.Series.SimpleSeries ss = new Chart.Drawing.Series.SimpleSeries();
            double t  = 0;
            double ed = 1;
            double y1 = 0;
            IDifferentialEquationsSystem sys = clone;
            int maxm = 0;

            while (true)
            {
                ++maxm;
                if (maxm > 10000)
                {
                    break;
                }
                double te = t + step;
                clone.Step(t, te, 1);
                double y = clone.Output;
                t = te;
                ss.AddXY(t, y);
                double ep = y - coeff;
                if (!transform.IsStable)
                {
                    if (t > 10 * a)
                    {
                        break;
                    }
                }
                if (Math.Abs(ep) < eps & Math.Abs(ed) < eps & t > (3 * a))
                {
                    break;
                }
                ed = (y1 - y) / step;
                y1 = y;
            }
            userControlChartTransient.AddSeries(ss, Color.Red);
        }
        private void ShowFreq()
        {
            for (int i = 1; i < 3; i++)
            {
                UserControlChart chart = charts[i];
                chart.RemoveAll();
                chart.Coordinator = new SimpleCoordinator(5, 5, chart.Performer);
            }
            Chart.Drawing.Series.SimpleSeries sa = new Chart.Drawing.Series.SimpleSeries();
            Chart.Drawing.Series.SimpleSeries sp = new Chart.Drawing.Series.SimpleSeries();
            freqstep = maxfreq / 400;
            double maxamp = 0;
            double coeff  = clone.HighFrequecyCoefficient;
            int    max    = 0;

            for (int i = 0; ; i++)
            {
                ++max;
                if (max > 10000)
                {
                    break;
                }
                double a = (double)i * freqstep;
                double amp;
                double ph;
                clone.GetFrequencyCharacteristics(a, out amp, out ph);
                if (a > maxfreq & ((Math.Abs(amp - coeff) < 0.01 * Math.Abs(maxamp - coeff))
                                   | amp > maxamp))
                {
                    break;
                }
                if (amp > maxamp)
                {
                    maxamp = amp;
                }
                sa.AddXY(a / (2 * Math.PI), amp);
                sp.AddXY(a / (2 * Math.PI), 180 * ph / Math.PI);
            }
            Chart.Drawing.Series.SimpleSeries[] ss = new Chart.Drawing.Series.SimpleSeries[] { sa, sp };
            for (int i = 0; i < 2; i++)
            {
                charts[i + 1].AddSeries(ss[i], Color.Red);
            }
        }
Beispiel #4
0
            DataPerformer.Series CreateSeries(BitmapGraphSelection selection)
            {
                IMeasurements m = selection;

                if (m.Count < 2)
                {
                    return(null);
                }
                double[][]           d                = new double[][] { (double[])m[0].Parameter(), (double[])m[1].Parameter() };
                DataPerformer.Series series           = new DataPerformer.Series();
                Chart.Drawing.Series.SimpleSeries ser = new Chart.Drawing.Series.SimpleSeries();
                int n = d[0].Length;

                for (int i = 0; i < n; i++)
                {
                    double x = d[0][i];
                    double y = d[1][i];
                    series.AddXY(x, y);
                    ser.AddXY(x, y);
                }
                return(series);
            }
        private void ShowLog()
        {
            if (clone == null)
            {
                return;
            }
            for (int i = 1; i < 3; i++)
            {
                UserControlChart chart = charts[i];
                chart.RemoveAll();
                LogarithmCoordinator coord = new LogarithmCoordinator(chart.Performer);
                coord.LogX = true;
                if (i == 1)
                {
                    coord.LogY = true;
                }
                chart.Coordinator = coord;
            }
            double ml = Math.Log10(maxfreq);

            //double step = ml / 400;
            Chart.Drawing.Series.SimpleSeries sa = new Chart.Drawing.Series.SimpleSeries();
            Chart.Drawing.Series.SimpleSeries sp = new Chart.Drawing.Series.SimpleSeries();
            double dec    = 100;
            double minlog = -3;

            if (minfreq > 0)
            {
                minlog = Math.Log10(minfreq);
            }
            double step   = Math.Log10(dec) / 400;
            double logpi  = Math.Log10(2 * Math.PI);
            double maxamp = 0;
            double coeff  = clone.HighFrequecyCoefficient;
            int    max    = 0;

            for (int i = 1; ; i++)
            {
                ++max;
                if (max > 10000)
                {
                    break;
                }
                double x = (double)i * step + minlog;
                double f = Math.Pow(10, x);
                double amp;
                double ph;
                clone.GetFrequencyCharacteristics(f, out amp, out ph);
                if (amp > maxamp)
                {
                    maxamp = amp;
                }
                if (f > maxfreq & ((Math.Abs(amp - coeff) < 0.01 * Math.Abs(maxamp - coeff))
                                   | amp > maxamp))
                {
                    break;
                }
                amp = Math.Log10(amp);
                double fr = x - logpi;
                sa.AddXY(fr, amp);
                sp.AddXY(fr, 180 * ph / Math.PI);
            }
            Chart.Drawing.Series.SimpleSeries[] ss = new Chart.Drawing.Series.SimpleSeries[] { sa, sp };
            for (int i = 0; i < 2; i++)
            {
                charts[i + 1].AddSeries(ss[i], Color.Red);
            }
        }