예제 #1
0
        /// <summary>
        /// Create a new excitation object with default values
        /// </summary>
        public GEMSExcitationSource(GEMSProject parent)
        {
            this.parent = parent;

            this.sourcePluseType = PluseType.Gaussian;
            this.lossness        = 0;
            this.maxFrequency    = new Frequency(1, Frequency.FrequencyUnit.GHz);
        }
예제 #2
0
        public ExcitationSourceForm(GEMSExcitationSource source)
        {
            InitializeComponent();

            this.source = source;

            //Copy the data
            this.pluseType    = source.SourcePluseType;
            this.lossness     = source.Lossness == 0 ? 20 : source.Lossness;
            this.maxFrequency = source.MaxFrequency;
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public static double[] GetPulseSerials(double fmin,
                                               double fmax,
                                               int lossness,
                                               PluseType pluseType,
                                               int num, ref double tao, out double[] tsteps)
        {
            double t0 = 0.0;

            CalculateTaoT0(fmin, fmax, lossness, pluseType, ref tao, ref t0);

            //We should compute the dt by ourself
            double dt = (double)(t0 * 2.0 / num);

            return(ComputePulseData(pluseType, dt, num, tao, t0, out tsteps));
        }
예제 #4
0
        /// <summary>
        /// Create a new excitation object and load the information from the specified file
        /// </summary>
        /// <param name="navigator"></param>
        /// <returns></returns>
        public GEMSExcitationSource(XPathNavigator navigator, GEMSProject parent)
        {
            this.parent = parent;

            navigator.MoveToChild("Pulse", "");
            sourcePluseType = (PluseType)Enum.Parse(typeof(PluseType), navigator.GetAttribute("kind", ""));

            if (sourcePluseType != PluseType.None)
            {
                navigator.MoveToFirstChild();
                lossness = int.Parse(navigator.GetAttribute("lossness", ""));
                navigator.MoveToParent();
            }
            navigator.MoveToParent();

            navigator.MoveToChild("Max", "");
            MaxFrequency = new Frequency(navigator.GetAttribute("value", ""), navigator.GetAttribute("unit", ""));
            navigator.MoveToParent();
        }
예제 #5
0
        public static double[] ComputeFrequencyData(
            PluseType pluseType, double tao, double fmax, int num, out double[] fsteps)
        {
            fsteps = new double[num];
            double[] data = new double[num];

            double maxv = -1.0;

            switch (pluseType)
            {
            case PluseType.Gaussian:
            {
                for (int i = 0; i < num; i++)
                {
                    fsteps[i] = fmax * 2 / num * i / 10e8;
                    data[i]   = Math.Exp(-Math.Pow(Math.PI * tao * fsteps[i] * 10e8, 2.0));
                }
                break;
            }

            case PluseType.Differentiated_Gaussian:
            {
                for (int i = 0; i < num; i++)
                {
                    fsteps[i] = fmax * 2 / num * i / 10e8;
                    data[i]   = fsteps[i] * 10e9 * Math.Exp(-Math.Pow(Math.PI * tao * fsteps[i] * 10e8, 2.0));

                    maxv = maxv > data[i] ? maxv : data[i];
                }

                for (int i = 0; i < num; i++)
                {
                    data[i] = data[i] / maxv;
                }
                break;
            }

            default:
                break;
            }

            return(data);
        }
예제 #6
0
        private void cbDGaussian_Click(object sender, EventArgs e)
        {
            if (cbGaussian.Checked)
            {
                cbGaussian.Checked = false;
            }

            UpdateControlsStatus(cbDGaussian.Checked);

            if (cbDGaussian.Checked)
            {
                this.pluseType = PluseType.Differentiated_Gaussian;
            }
            else
            {
                this.pluseType = PluseType.None;
            }

            RenderWave();
        }
예제 #7
0
        /// <summary>
        /// Compute tao and to
        /// </summary>
        private static void CalculateTaoT0(double fmin,
                                           double fmax,
                                           int lossness,
                                           PluseType pluseType,
                                           ref double tao,
                                           ref double t0)
        {
            const double crt  = 4.0;
            double       loss = 1.0 / Math.Pow(10.0, lossness / 20.0);

            switch (pluseType)
            {
            case PluseType.Gaussian:
            {
                tao = Math.Sqrt(-Math.Log(loss)) / (Math.PI * fmax);
                t0  = Math.Sqrt(crt * Math.Log(10.0)) * tao;
                break;
            }

            case PluseType.Differentiated_Gaussian:
            {
                double[] c = new double[2] {
                    0, 0
                };
                c[0] = Math.PI * Math.PI * fmax * fmax;
                c[1] = Math.Log(loss / (Math.Sqrt(2.0) * Math.PI * fmax)) - 0.5;
                tao  = NewtonSolver(c, 1.0);

                t0   = tao / Math.Sqrt(2.0) * 1.001;
                c[0] = 1.0 / (tao * tao);
                c[1] = -crt *Math.Log(10.0) + Math.Log(tao / Math.Sqrt(2.0)) - 0.5;

                t0 = NewtonSolver(c, t0);

                break;
            }

            default:
                break;
            }
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public static double[] GetPulseSerials(double fmin,
                                               double fmax,
                                               int lossness,
                                               PluseType pluseType,
                                               float dt, int num, ref double tao, out double[] tsteps)
        {
            double t0 = 0.0;

            CalculateTaoT0(fmin, fmax, lossness, pluseType, ref tao, ref t0);

            //Determine the choose of num
            int n;

            n = (int)(t0 * 2.0 / dt);
            if (num < n)
            {
                num = n;
            }

            return(ComputePulseData(pluseType, dt, num, tao, t0, out tsteps));
        }
예제 #9
0
        private static double[] ComputePulseData(
            PluseType pluseType, double dt, int num, double tao, double t0, out double[] tsteps)
        {
            tsteps = new double[num];
            double[] data = new double[num];

            double t, v;

            double maxv = -1.0;

            switch (pluseType)
            {
            case PluseType.Gaussian:
            {
                for (int i = 0; i < num; i++)
                {
                    t = dt * i;
                    v = (t - t0) / tao;
                    v = v * v;
                    v = Math.Exp(-v);
                    if (maxv < Math.Abs(v))
                    {
                        maxv = Math.Abs(v);
                    }
                    data[i]   = v;
                    tsteps[i] = t;
                }
                break;
            }

            case PluseType.Differentiated_Gaussian:
            {
                for (int i = 0; i < num; i++)
                {
                    t = dt * i;
                    v = (t - t0) / tao;
                    v = v * v;
                    v = Math.Exp(-v);
                    v = -2.0 * (t - t0) * v;
                    v = v / (tao * tao);
                    if (maxv < Math.Abs(v))
                    {
                        maxv = Math.Abs(v);
                    }
                    data[i]   = v;
                    tsteps[i] = t;
                }
                break;
            }

            default:
                break;
            }


            for (int i = 0; i < num; i++)
            {
                data[i] = data[i] / maxv;
            }

            return(data);
        }