コード例 #1
0
        /// <summary>
        /// Plots the specified result.
        /// </summary>
        /// <param name="result">The result.</param>
        public void Plot(SimulationResultDictionary result)
        {
            Func <KeyValuePair <SpectrumUnit, SimulationResult>, double> selector = x => x.Key.ToType(SpectrumUnitType.WaveLength);
            var waveLengths = result.Select(selector).Select(x => x / 1e-9).ToList();

            var values = result.OrderBy(selector).Select(x => x.Value).ToList();

            var point = result.First().Value.ElectricField.Length / 4;

            this.gp.Set("style data lines");
            this.gp.HoldOn();
            this.gp.Plot(waveLengths, values.Select(x => x.ElectricField[point].Norm), "title 'inc norm'");
            this.gp.Plot(waveLengths, values.Select(x => x.ElectricField[point].X.Real), "title 'inc x real'");
            this.gp.Plot(waveLengths, values.Select(x => x.ElectricField[point].X.Imaginary), "title 'inc x imag'");
            this.gp.Plot(waveLengths, values.Select(x => x.ElectricField[point].Y.Real), "title 'inc y real'");
            this.gp.Plot(waveLengths, values.Select(x => x.ElectricField[point].Y.Imaginary), "title 'inc y imag'");
            this.gp.Plot(waveLengths, values.Select(x => x.ElectricField[point].Z.Real), "title 'inc y real'");
            this.gp.Plot(waveLengths, values.Select(x => x.ElectricField[point].Z.Imaginary), "title 'inc y imag'");

            this.gp.Plot(waveLengths, values.Select(x => x.Polarization[point].Norm), "title 'pol norm'");
            this.gp.Plot(waveLengths, values.Select(x => x.Polarization[point].X.Real), "title 'pol x real'");
            this.gp.Plot(waveLengths, values.Select(x => x.Polarization[point].X.Imaginary), "title 'pol x imag'");
            this.gp.Plot(waveLengths, values.Select(x => x.Polarization[point].Y.Real), "title 'pol y real'");
            this.gp.Plot(waveLengths, values.Select(x => x.Polarization[point].Y.Imaginary), "title 'pol y imag'");
            this.gp.Plot(waveLengths, values.Select(x => x.Polarization[point].Z.Real), "title 'pol y real'");
            this.gp.Plot(waveLengths, values.Select(x => x.Polarization[point].Z.Imaginary), "title 'pol y imag'");

            this.gp.Wait();
        }
コード例 #2
0
        /// <summary>
        /// Calculates the cross extinction.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The simulation results.</returns>
        public SimulationResultDictionary CalculateCrossExtinction(SimulationParameters parameters)
        {
            var result = new SimulationResultDictionary();

            var partitions = Partitioner.Create(parameters.Spectrum).GetPartitions(Environment.ProcessorCount);

            var concurent = new ConcurrentDictionary <SpectrumUnit, SimulationResult>();

            var tasks = partitions
                        .Select(partition => Task.Run(() =>
            {
                using (partition)
                {
                    var polarization = this.initPolarization(parameters);

                    while (partition.MoveNext())
                    {
                        concurent.TryAdd(partition.Current, this.CalculateSingleDDA(partition.Current, parameters, polarization));
                    }
                }
            }))
                        .ToArray();

            Task.WaitAll(tasks);

            foreach (var keyvalue in concurent.OrderBy(pair => pair.Key))
            {
                result.Add(keyvalue.Key, keyvalue.Value);
            }

            return(result);
        }
コード例 #3
0
        private void calculateOneStepDiffRadius(
            double radius1,
            double radius2,
            double distance,
            double maxRadius,
            Func <SimulationResult, double> valueSelector)
        {
            var firstPoint = new CartesianCoordinate(maxRadius, maxRadius, 0);

            double secondPointCoord = maxRadius + 2 * radius1 + distance * radius2;
            var    secondPoint      = new CartesianCoordinate(maxRadius, secondPointCoord, 0);

            var systConfig = new SystemConfig(
                new List <double>
            {
                radius1,
                radius2
            },
                new List <CartesianCoordinate>
            {
                firstPoint,
                secondPoint
            });

            SimulationResultDictionary result = DDAProgram.Calculate(this.ddaConfig, systConfig, this.opticalConstants);

            string filename = this.getFileFormatDiffRadiuses(this.TestContext.TestName, distance, radius1, radius2);

            SimpleFormatter.Write(
                filename,
                result.ToDictionary(x => x.ToType(SpectrumUnitType.WaveLength), valueSelector));
        }
コード例 #4
0
        /// <summary>
        /// Converts IEnumerable to the simulation result dictionary.
        /// </summary>
        /// <param name="spectrum">The spectrum.</param>
        /// <param name="selector">The selector.</param>
        /// <returns>The new instance of SimulationResultDictionary.</returns>
        public static SimulationResultDictionary ToSimulationResult(
            this IEnumerable <SpectrumUnit> spectrum,
            Func <SpectrumUnit, SimulationResult> selector)
        {
            var result = new SimulationResultDictionary();

            foreach (SpectrumUnit freq in spectrum)
            {
                result.Add(freq, selector(freq));
            }
            return(result);
        }
コード例 #5
0
        /// <summary>
        /// Plots the specified result.
        /// </summary>
        /// <param name="result">The result.</param>
        public void Plot(SimulationResultDictionary result)
        {
            Func <KeyValuePair <SpectrumUnit, SimulationResult>, double> selector = x => x.Key.ToType(SpectrumUnitType.WaveLength);
            var waveLengths = result.Select(selector).Select(x => x / 1e-9).ToList();

            var values = result.OrderBy(selector).Select(x => x.Value).ToList();

            this.gp.Set("style data lines");
            this.gp.HoldOn();
            this.gp.Plot(waveLengths, values.Select(x => x.EffectiveCrossSectionAbsorption), "title 'eff abs'");
            this.gp.Plot(waveLengths, values.Select(x => x.EffectiveCrossSectionExtinction), "title 'eff ext'");

            this.gp.Wait();
        }
コード例 #6
0
        private void calculateOneParticle(
            double radius,
            Func <SimulationResult, double> valueSelector)
        {
            var firstPoint = new CartesianCoordinate(radius, radius, 0);

            var systConfig = new SystemConfig(
                new List <double>
            {
                radius
            },
                new List <CartesianCoordinate>
            {
                firstPoint
            });

            SimulationResultDictionary result = DDAProgram.Calculate(this.ddaConfig, systConfig, this.opticalConstants);

            string filename = this.getFileFormatOneParticle(this.TestContext.TestName, radius);

            SimpleFormatter.Write(
                filename,
                result.ToDictionary(x => x.ToType(SpectrumUnitType.WaveLength), valueSelector));
        }