public void Calculate_PerformanceMetrics() { var serialTicks = 192769194.79518071; List <double> all = new List <double>(); var gp = new GnuPlot(); gp.Set("style data linespoints"); gp.HoldOn(); for (int i = 256; i <= 1024; i = i * 2) { List <long> list = new List <long>(); for (int j = 0; j < 20; j++) { Stopwatch watch = Stopwatch.StartNew(); //ArrayExtensions.MaxDegreeOfParallelism = i; FDTDProgram.Calculate(); watch.Stop(); list.Add(watch.ElapsedTicks); } all.Add(list.Average()); } gp.Plot(all.Select(x => serialTicks / x)); gp.Wait(); }
public void RadiusChangeOutput_InterparticleDistance_Spectrum() { // Arrange GnuPlot gp = null; var radius1 = 20; var radiuses = new List <double> { 4, 10, 15, 20 }; double distance = 70; string dirAzimuth45 = "RadiusChangeOutput_InterparticleDistance_Spectrum"; //foreach (var radius1 in radiuses) //{ gp = new GnuPlot(); setLineStyle(gp); gp.HoldOn(); setColorPalette(gp); gp.Set(String.Format("title \"{0}\"", radius1)); foreach (double radius in radiuses) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth45, distance, radius1, radius)) .ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim45, string.Format(@"title ""{0}""", radius)); //gp.Clear(); } //} gp.Wait(); }
public void AreClose_Radius40_OpticalConst_DrudeLorentz() { // Arrange const double DistanceMax = 0.5; const double DistanceStep = 0.1; List <double> distances = getDistances(DistanceStep, DistanceMax); var radius = 40; string dirOpticalConst = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirDrudeLorentz = "RadiusDistanceDrudeLorentz_Azimuth45_EffectiveCrossExt"; var gp = new GnuPlot(); setLineStyle(gp); gp.HoldOn(); foreach (double distance in distances) { Dictionary <double, double> optical = SimpleFormatter.Read( this.getFileFormat(dirOpticalConst, distance, radius)); Dictionary <double, double> drudeLorentz = SimpleFormatter.Read( this.getFileFormat(dirDrudeLorentz, distance, radius)); gp.Plot(optical, @"title ""optical"""); gp.Plot(drudeLorentz, @"title ""drude-lorentz"""); //AssertHelper.DictionaryAreClose(optical, drudeLorentz, 0.1); } gp.Wait(); }
public void AreCloseDistance3_OpticalConst_DrudeLorentz() { // Arrange var distance = 2.9; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; string dirOpticalConst = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirDrudeLorentz = "RadiusDistanceDrudeLorentz_Azimuth45_EffectiveCrossExt"; var gp = new GnuPlot(); setLineStyle(gp); gp.HoldOn(); foreach (double radius in radiuses) { Dictionary <double, double> optical = SimpleFormatter.Read( this.getFileFormat(dirOpticalConst, distance, radius)); Dictionary <double, double> drudeLorentz = SimpleFormatter.Read( this.getFileFormat(dirDrudeLorentz, distance, radius)); gp.Plot(optical, @"title ""optical"""); gp.Plot(drudeLorentz, @"title ""drude-lorentz"""); //AssertHelper.DictionaryAreClose(optical, drudeLorentz, 0.1); } gp.Wait(); }
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 }
public void Peaks_Azimuth0_Azimuth90() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radiuses = new List <double> { 4, 10, 20, 40 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth0 = "RadiusDistanceOutput_Azimuth0"; string dirAzimuth90 = "RadiusDistanceOutput_Azimuth90"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.Set("xtics 0.5"); gp.Set("grid xtics ytics"); gp.Set("size square"); gp.HoldOn(); radiuses.Reverse(); foreach (double radius in radiuses) { Dictionary <double, double> peaks0 = this.getPeaks0(distances, radius, dirAzimuth0); Dictionary <double, double> peaks90 = this.getPeaks90(distances, radius, dirAzimuth90); //gp.HoldOn(); // gp.Set(string.Format("terminal win {0}", radius)); gp.Plot(peaks0); gp.Plot(peaks90); // gp.HoldOff(); } gp.Wait(); }
public void TestMethod1() { Stopwatch watch = new Stopwatch(); var gp = new GnuPlot(); gp.HoldOn(); for (int j = 0; j < 5; j++) { List <TimeSpan> list = new List <TimeSpan>(); for (var i = 1; i <= 16; i++) { watch.Start(); ParallelIterator.MaxDegreeOfParallelism = i; FDTDProgram.Calculate(); watch.Stop(); list.Add(watch.Elapsed); watch.Reset(); } gp.Plot(list.Select(x => (double)x.Milliseconds)); } gp.Wait(); }
public void RadiusChangeOutput_Azimuth_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radius1 = 4; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth45 = "RadiusChangeOutput_Azimuth45"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); foreach (double radius in radiuses) { Dictionary <decimal, List <double> > spectrum = this.zipToDictionaryDiffRadiuses(distances, dirAzimuth45, radius1, radius); string filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim45.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); foreach (double distance in distances.Take(5)) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth45, distance, radius1, radius)); gp.Plot(azim45, string.Format(@"title ""{0}""", radius)); } gp.Clear(); } gp.Wait(); }
public void RadiusChangeOutputPeaks_Azimuth0_Azimuth90() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; var radius1 = 4; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth0 = "RadiusChangeOutput_Azimuth0"; string dirAzimuth90 = "RadiusChangeOutput_Azimuth90"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); radiuses.Reverse(); foreach (double radius in radiuses) { var peaks0 = new Dictionary <double, double>(); var peaks90 = new Dictionary <double, double>(); foreach (double distance in distances) { Dictionary <double, double> azim0 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth0, distance, radius1, radius)); Dictionary <double, double> azim90 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth90, distance, radius1, radius)); peaks0.Add(distance, azim0.MaxPair().Key); peaks90.Add(distance, azim0.MaxPair().Key); } // gp.HoldOn(); // gp.Set(string.Format("terminal win {0}", radius)); gp.Plot(peaks0); gp.Plot(peaks90); // gp.HoldOff(); string basepath = Path.Combine(BasePath, this.TestContext.TestName); string filename0 = Path.Combine( basepath, string.Format("peaks_0deg_{0}.txt", radius)); SimpleFormatter.Write(filename0, peaks0); string filename90 = Path.Combine( basepath, string.Format("peaks_90deg_{0}.txt", radius)); SimpleFormatter.Write(filename90, peaks90); } gp.Wait(); }
[TestMethod]//todo public void RadiusChangeOutput_Azimuth_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.5; GnuPlot gp = null; var radius1 = 4; var radiuses = new List <double> { 4, 10, 20, 40 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth45 = "RadiusChangeOutput_Azimuth45_EffectiveExtinction"; string dirAzimuthOne = "OneParticle_EffectiveCrossExt"; //foreach (var radius1 in radiuses) //{ gp = new GnuPlot(); setLineStyle(gp); foreach (double distance in distances) { gp.HoldOn(); //gp.Set(String.Format("title \"{0}\"", radius1)); foreach (double radius in radiuses) { //Dictionary<decimal, List<double>> spectrum = this.zipToDictionaryDiffRadiuses(distances, // dirAzimuth45, radius1, radius); //string filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim45.txt"); //SimpleFormatter.WriteDictionary(filename, spectrum, distances); Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth45, distance, radius1, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim45, string.Format(@"title ""{0}""", radius)); gp.Clear(); Dictionary <double, double> azim = SimpleFormatter.Read( this.getFileFormatOneParticle(dirAzimuthOne, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim, @"title ""single"""); } } //} gp.Wait(); }
public void GetPermittivity_Silver_EqualValue() { // Arrange var target = new Drude(); var collection = new OpticalSpectrum( new LinearDiscreteCollection(300e-9, 1000e-9, 10), SpectrumUnitType.WaveLength); var gp = new GnuPlot(); // Act var dictionary = collection.ToDictionary(s => s.ToType(SpectrumUnitType.WaveLength), s => target.GetPermittivity(s)); gp.Plot(dictionary); // Assert Assert.IsTrue(dictionary.All(x => x.Value.Imaginary >= 0)); gp.Wait(); }
public void RadiusChangeOutput_Hybridization_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.5; GnuPlot gp = null; var radius1 = 10; var radiuses = new List <double> { 4, 10 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth90 = "RadiusChangeOutput_Azimuth90"; string dirAzimuth0 = "RadiusChangeOutput_Azimuth0"; //foreach (var radius1 in radiuses) //{ gp = new GnuPlot(); setLineStyle(gp); //gp.Set(String.Format("title \"{0}\"", radius1)); foreach (double radius in radiuses) { double distance = 0; gp.HoldOn(); Dictionary <double, double> azim90 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth90, distance, radius1, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim90, @"title ""90"""); Dictionary <double, double> azim0 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth0, distance, radius1, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim0, @"title ""0"""); } //} gp.Wait(); }
public void Radius10_Azimuth_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; int radius = 10; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth45 = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirAzimuth0 = "RadiusDistanceOutput_Azimuth0_EffectiveCrossExt"; string dirAzimuth90 = "RadiusDistanceOutput_Azimuth90_EffectiveCrossExt"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); Dictionary <decimal, List <double> > spectrum = this.zipToDictionary(distances, dirAzimuth45, radius); string filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim45.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); foreach (double distance in distances) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormat(dirAzimuth45, distance, radius)); gp.Plot(azim45, string.Format(@"title ""{0}""", distance)); } spectrum = this.zipToDictionary(distances, dirAzimuth0, radius); filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim0.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); spectrum = this.zipToDictionary(distances, dirAzimuth90, radius); filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim90.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); gp.Wait(); }
public void RadiusChangeOutputPeaks_Azimuth0_Azimuth90() { // Arrange const int DistanceMax = 10; const double DistanceStep = 0.02; var radiuses = new List <double> { 4, 10, 20, 40 }; var radius1 = 4; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth0 = "RadiusChangeOutput_Azimuth0_EffectiveExtinction"; string dirAzimuth90 = "RadiusChangeOutput_Azimuth90_EffectiveExtinction"; GnuPlot gp = null; gp = new GnuPlot(); gp.HoldOn(); radiuses.Reverse(); //foreach (var radius1 in radiuses) //{ gp.Set("style data lines"); foreach (double radius in radiuses) { Dictionary <double, double> peaks0 = this.getPeaksDiffRad0(distances, radius1, radius, dirAzimuth0); Dictionary <double, double> peaks90 = this.getPeaksDiffRad90(distances, radius1, radius, dirAzimuth90); // gp.HoldOn(); // gp.Set(string.Format("terminal win {0}", radius)); gp.Plot(peaks0, string.Format(@"smooth acsplines title ""0.{0}""", radius)); gp.Plot(peaks90, string.Format(@"smooth acsplines title ""90.{0}""", radius)); // gp.HoldOff(); } //} gp.Wait(); }