public void Test() { u = 100000; particles = new ParticleArrayStorage<Particle>(1000000); 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 } }; grid = new Grid2D(); grid.InitializeGrid(5, 5, 0, 4, 0, 4); mesh = new Mesh2D(); mesh.InitializeMesh(grid.N * grid.M); interpolator = new CloudInCellCurrentLinkage(particles, grid, mesh, false); poissonSolver = new Poisson2DFdmSolver(grid, boundaryConditions); poissonSolver.FdmMatrix = poissonSolver.BuildMatrix(); var particle = new Particle(4, 1, 0, 0, 0, 0, 1); var particleId = particles.Add(particle); particles.Set(Field.PrevX, particleId, 2); particles.Set(Field.PrevY, particleId, 1); var cell = grid.FindCell(particles.Get(Field.X, particleId), particles.Get(Field.Y, particleId)); particles.SetParticleCell(particleId, cell); interpolator.InterpolateDensity(); }
public Particle[] Inject() { ParticleCharge = currentDensity * Length * step / ParticlesCount; for (var i = 0; i < ParticlesCount; i++) { var x = fromX + (i + 0.5) * dx; var y = fromY + (i + 0.5) * dy; var q = ParticleCharge; particles[i] = new Particle(x, y, px, py, 0, 0, q); } return particles; }