コード例 #1
0
ファイル: PICTest.cs プロジェクト: vlad294/PICSolver
        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();
        }
コード例 #2
0
ファイル: PICSolver2d.cs プロジェクト: vlad294/PICSolver
        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);
        }