private List <SimulationResults.HoleGeometrySimulationResult.Step> Calculate(HoleGeometrySetting setting, CancellationToken cancellationToken) { var steps = new List <SimulationResults.HoleGeometrySimulationResult.Step>(); int progressMaximum = (int)Math.Round((setting.MaximumReflectionCoefficient - setting.MinimumReflectionCoefficient) / setting.ReflectionCoefficientInterval + 1) * (int)Math.Round((setting.MaximumRadius - setting.MinimumRadius) / setting.RadiusInterval + 1); int progress = 0; //プログレスバー初期化 ShowProgress(progress, progressMaximum); //ジオメトリ初期化 var geometry = setting.HoleGeometry; geometry.ReflectionPattern = setting.ReflectionPattern; geometry.ReflectionLimit = setting.ReflectionLimit; //計算を回す for (var coefficient = setting.MinimumReflectionCoefficient; coefficient <= setting.MaximumReflectionCoefficient; coefficient += setting.ReflectionCoefficientInterval) { var results = new List <(double Radius, long Count)>(); geometry.ReflectionCoefficient = coefficient; for (var radius = setting.MinimumRadius; radius <= setting.MaximumRadius; radius += setting.RadiusInterval) { if (cancellationToken.IsCancellationRequested) { Dispatcher.Invoke(() => { ProgressLabel.Content = "進捗:中断"; System.Windows.Forms.Application.DoEvents(); }); return(steps); } geometry.Hole = new Hole(geometry.Hole.ID, geometry.Hole.Position, geometry.Hole.Direction, radius); var atoms = geometry.ProcessAsParallel(setting.SimulationCount); //GetAverageReflectionCount(atoms, 0, 2); //GetAverageReflectionCount(atoms, 8, 10); var count = atoms.Count(atom => atom.IsValid); results.Add((radius, count)); ShowProgress(++progress, progressMaximum); } var step = new SimulationResults.HoleGeometrySimulationResult.Step(); step.ReflectionCoefficient = coefficient; step.Datas = results; steps.Add(step); } ShowProgress(progressMaximum, progressMaximum); return(steps); }
public HoleGeometrySimulationResult(List <Step> steps, HoleGeometrySetting setting) { Steps = steps; GeometrySetting = setting; var subnozzle = GeometrySetting.HoleGeometry.SubNozzle; var builder = new StringBuilder(); builder.Append("サブノズル "); builder.Append("半径:" + subnozzle.Radius + ","); builder.Append("長さ:" + subnozzle.Length + ","); builder.Append("距離:" + (subnozzle.Position.Z - 40)); builder.Append("ホール板:" + GeometrySetting.HoleGeometry.Hole.Position.Z); Discription = builder.ToString(); }
private HoleGeometrySetting GetSetting() { var setting = new HoleGeometrySetting(); setting.HoleGeometry = GetGeometry(); setting.MinimumReflectionCoefficient = Math.Round(MinimumReflectionCoefficientUpDown.Value.Value, 2); setting.MaximumReflectionCoefficient = Math.Round(MaximumReflectionCoefficientUpDown.Value.Value, 2); setting.ReflectionCoefficientInterval = Math.Round(ReflectionCoefficientIntervalUpDown.Value.Value, 2); setting.MinimumRadius = Math.Round(MinimumRadiusUpDown.Value.Value, 1); setting.MaximumRadius = Math.Round(MaximumRadiusUpDown.Value.Value, 1); setting.RadiusInterval = Math.Round(RadiusIntervalUpDown.Value.Value, 1); setting.SimulationCount = SimulationCountUpDown.Value.Value; setting.ReflectionPattern = ReflectionPatternSelector.ReflectionPattern; setting.ReflectionLimit = ReflectionLimitUpDown.Value.Value; return(setting); }