Ejemplo n.º 1
0
        public static PatternValue[] GetPatternValuesParallel
        (
            this Antenna antenna,
            double f,
            double phi = 0 *Consts.ToRad,
            double th1 = -181 *Consts.ToRad,
            double th2 = 181 *Consts.ToRad,
            double dth = 1 *Consts.ToRad,
            CancellationToken Cancel = default
        )
        {
            var parallel_query = GetAngles(th1, th2, dth).AsParallel().AsOrdered();

            if (Cancel != default)
            {
                parallel_query = parallel_query.WithCancellation(Cancel);
            }
            return(parallel_query.Select(th => new PatternValue(th, antenna.Pattern(th, phi, f))).ToArray());
        }
Ejemplo n.º 2
0
        public static PatternValue[] GetPatternPhi
        (
            this Antenna antenna,
            double f,
            double phi = 0 *Consts.ToRad,
            double th1 = -180 *Consts.ToRad,
            double th2 = 180 *Consts.ToRad,
            double dth = 1 *Consts.ToRad
        )
        {
            var th = Math.Min(th1, th2);

            dth = Math.Abs(dth);
            var result = new PatternValue[(int)((Math.Max(th1, th2) - Math.Min(th1, th2)) / dth) + 1];

            for (var i = 0; i < result.Length; i++, th += dth)
            {
                result[i] = new PatternValue(th, antenna.Pattern(th, phi, f));
            }
            return(result);
        }
Ejemplo n.º 3
0
 public static Task <PatternValue[]> GetPatternPhiAsync
 (
     this Antenna antenna,
     double f,
     double phi = 0 *Consts.ToRad,
     double th1 = -180 *Consts.ToRad,
     double th2 = 180 *Consts.ToRad,
     double dth = 1 *Consts.ToRad,
     IProgress <PatternCalculationTaskProgressInfo> Progress = null,
     CancellationToken Cancel = default
 ) => Task.Factory.StartNew(() =>
 {
     var th     = Math.Min(th1, th2);
     dth        = Math.Abs(dth);
     var result = new PatternValue[(int)((Math.Max(th1, th2) - Math.Min(th1, th2)) / dth) + 1];
     for (int i = 0, len = result.Length; i < len && !Cancel.IsCancellationRequested; i++, th += dth)
     {
         var pattern_value = new PatternValue(th, antenna.Pattern(th, phi, f));
         result[i]         = pattern_value;
         Progress?.Report(new PatternCalculationTaskProgressInfo((double)i / len, pattern_value));
     }
     Cancel.ThrowIfCancellationRequested();
     return(result);
 }, Cancel);
Ejemplo n.º 4
0
        /// <summary>Метод инициализации элементов решётки</summary>
        /// <param name="Nx">Число элементов по оси X</param>
        /// <param name="Ny">Число элементов по оси Y</param>
        /// <param name="dx">Шаг между элементами по оси X</param>
        /// <param name="dy">Шаг между элементами по оси Y</param>
        /// <param name="Element">Антенный элемент</param>
        /// <param name="Distribution">Распределение</param>
        /// <returns>Перечисление антенных элементов решётки</returns>
        private static IEnumerable <AntennaItem> Initialize(int Nx, int Ny, double dx, double dy, Antenna Element, Distribution Distribution)
        {
            var Lx = (Nx - 1) * dx;
            var Ly = (Ny - 1) * dy;
            var x0 = Lx / 2;
            var y0 = Ly / 2;

            var angle = new SpaceAngle();

            for (var ix = 0; ix < Nx; ix++)
            {
                for (var iy = 0; iy < Ny; iy++)
                {
                    var x = ix * dx - x0;
                    var y = iy * dy - y0;
                    var k = Distribution(x, y);
                    yield return(new AntennaItem(Element, new Vector3D(x, y), angle, k));
                }
            }
        }