/// <summary>
        ///     Initializes a new instance of the <see cref="DrudeLorentzFactor" /> class.
        /// </summary>
        /// <param name="medium">The medium.</param>
        /// <param name="timeStep">The time step.</param>
        public DrudeLorentzFactor(DrudeLorentz medium, double timeStep)
            : base(medium, timeStep)
        {
            this.OscillatorCount = medium.OscillatorTerms.Count;

            this.SampledLorentzShift1 = new double[this.OscillatorCount];
            this.SampledLorentzShift2 = new double[this.OscillatorCount];
            this.ElectricLorentz      = new double[this.OscillatorCount];

            double plasmaFreq = medium.PlasmaTerm.ResonanceFrequency.ToType(SpectrumUnitType.CycleFrequency);

            for (int l = 0; l < this.OscillatorCount; l++)
            {
                double collisionFreq =
                    medium.OscillatorTerms[l].CollisionFrequency.ToType(SpectrumUnitType.Frequency);
                double resonatorFreq =
                    medium.OscillatorTerms[l].ResonanceFrequency.ToType(SpectrumUnitType.CycleFrequency);
                double alfadt = (collisionFreq / 2.0) * timeStep;
                double sqrtl  =
                    Math.Sqrt(Math.Pow(resonatorFreq, 2.0) - (Math.Pow(collisionFreq, 2.0) / 4.0));
                double betadt = sqrtl * timeStep;

                double gammadt = Math.Pow(plasmaFreq, 2.0) / sqrtl * medium.OscillatorTerms[l].StrengthFactor * timeStep;
                double exp     = Math.Exp(alfadt);
                this.SampledLorentzShift1[l] = 2.0 * exp * Math.Cos(betadt);
                this.SampledLorentzShift2[l] = Math.Exp(2.0 * alfadt);
                this.ElectricLorentz[l]      = exp * Math.Sin(betadt) * gammadt;
            }
        }
        public void CalculateOpticalConstants_DrudeLorentz_Gnuplot()
        {
            // Arrange
            var optConst     = ParameterHelper.ReadOpticalConstants("opt_const.txt");
            var drudeLorentz = new DrudeLorentz();
            var dict         = new Dictionary <double, Complex>();

            foreach (var waveLength in optConst.WaveLengthList)
            {
                var freq = new SpectrumUnit(waveLength / OpticalConstants.WaveLengthMultiplier,
                                            SpectrumUnitType.WaveLength);
                dict.Add(waveLength, drudeLorentz.GetPermittivity(freq));
            }

            ParameterHelper.WriteOpticalConstants("opt_const_drudeLorentz.txt", dict);

            using (var gp = new GnuPlot())
            {
                gp.HoldOn();
                gp.Set("style data lines");

                gp.Plot(getPermitivittyFunc(optConst));
                gp.Plot(dict);

                gp.Wait();
            }
            // Act

            // Assert
        }
Пример #3
0
 private void initFactors()
 {
     this.mediumFactors.Add(
         "silver",
         () =>
     {
         var silver = new DrudeLorentz();
         return(new DrudeLorentzFactor(silver, this.timeStep));
     });
 }