public void Prepare(PICProject project) { backscattering = project.Backscattering; alfa = project.BackscatteringAlfa; beta = project.BackscatteringBeta; step = project.Step; u = project.Voltage; particles = new ParticleArrayStorage<Particle>(100000); boundaryConditions = new BoundaryConditions { Top = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Neumann }, Bottom = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Neumann }, Left = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Dirichlet }, Right = new BoundaryCondition { Value = x => u, Type = BoundaryConditionType.Dirichlet } }; emitter = new Emitter2D(0, project.EmitterBottom, 0, project.EmitterTop, project.ParticlesCount, 0, 0, -Constants.ChildLangmuirCurrent(project.Length, u), step); mover = new Leapfrog(); grid = new Grid2D(); grid.InitializeGrid(project.GridN, project.GridM, 0, project.Length, 0, project.Height); mesh = new Mesh2D(); mesh.InitializeMesh(grid.N * grid.M); interpolator = new CloudInCell(particles, grid, mesh, false); poissonSolver = new Poisson2DFdmSolver(grid, boundaryConditions); poissonSolver.FdmMatrix = poissonSolver.BuildMatrix(); h = step * Constants.LightVelocity; Monitor = new PICMonitor(grid, mesh, particles,this); }
public void UpdatePlots(PICMonitor monitor) { Task.Run(() => { foreach (var model in Workspaces.Where(p => p.GetType() == typeof(PlotViewModel)).Cast<PlotViewModel>()) { switch (model.PICPlot.PlotType) { case PlotType.Heatmap: switch (model.PICPlot.PlotSource) { case PlotSource.Density: model.HeatMapSeries.Data = monitor.Rho; break; case PlotSource.Potential: model.HeatMapSeries.Data = monitor.Potential; break; case PlotSource.ElectricFieldX: model.HeatMapSeries.Data = monitor.Ex; break; case PlotSource.ElectricFieldY: model.HeatMapSeries.Data = monitor.Ey; break; default: throw new ArgumentOutOfRangeException(); } model.HeatMapSeries.Invalidate(); model.PlotModel.InvalidatePlot(true); break; case PlotType.Line: var lineSeries = new LineSeries { MarkerType = MarkerType.Circle }; var data = monitor.GetLine(model.PICPlot.PlotSource, model.PICPlot.LinePlotAlignment, model.PICPlot.LinePlotСoordinate); for (var i = 0; i < data.Length; i++) lineSeries.Points.Add(new DataPoint(monitor.GridX[i], data[i])); model.PlotModel.Series.Clear(); model.PlotModel.Series.Add(lineSeries); model.PlotModel.InvalidatePlot(true); break; case PlotType.Trajectories: model.PlotModel.Series.Clear(); foreach (var trajectory in monitor.Trajectories.OrderBy(x => x.First().Item3).Where((c, i) => i % 5 == 0)) { var series = new LineSeries { MarkerType = MarkerType.None, LineStyle = LineStyle.Solid, Color = OxyColors.Black }; foreach (var point in trajectory) series.Points.Add(new DataPoint(point.Item2, point.Item3)); model.PlotModel.Series.Add(series); } model.PlotModel.InvalidatePlot(true); break; default: throw new ArgumentOutOfRangeException(); } } }); }