コード例 #1
0
    def _test_pypic_FiniteDifferences_Staircase_SquareGrid(self):
        #mesh = RectMesh2D(x0=-0.5, y0=-0.5, dx=0.1, dy=0.1, nx=31, ny=31)
        #mesh = RectMesh2D(x0=0., y0=0., dx=0.04, dy=0.04, nx=21, ny=21)
        #mesh = RectMesh2D(x0=-0.5, y0=-0.5, dx=0.1, dy=0.1, nx=11, ny=11)
        # mesh = self.make_centered_mesh(1., 1., 23, 23)
        # print mesh.nx
        # chamber = self.gen_fake_chamber(mesh)
        # print(chamber.x_aper)
        # poissonsolver = FD.FiniteDifferences_Staircase_SquareGrid(
        #         chamb=chamber, Dh=mesh.dx)

        dx = 0.1
        chamber = self.gen_rect_chamber(1, 1)
        poissonsolver = FD.FiniteDifferences_ShortleyWeller_SquareGrid_extrapolation(
            chamb=chamber, Dh=dx)
        mesh = RectMesh2D(
            poissonsolver.bias_y, poissonsolver.bias_x, dx, dx,
            poissonsolver.Nyg,
            poissonsolver.Nxg)  #somehow x,y are reversed in the chamber...

        pp = PyPIC(mesh, poissonsolver)
        #print(len(pp.poisson_solve.flag_inside_n))
        n_particles = 10000
        np.random.seed(0)
        xx = np.random.normal(0., 0.1, n_particles)
        yy = np.random.normal(0., 0.1, n_particles)
        plt.figure()
        plt.scatter(xx, yy)
        plt.show()
        [fx, fy] = pp.pic_solve(xx, yy)
        fig = plt.figure()
        f = plt.scatter(xx, yy, s=40, c=fx)
        plt.colorbar()
        plt.show()
コード例 #2
0
 def _test_FORTRAN_pypic_FiniteDifferences_ShortleyWeller_SquareGrid(self):
     dx = 0.2
     chamber = self.gen_rect_chamber(1, 1)
     poissonsolver = FD.FiniteDifferences_ShortleyWeller_SquareGrid_extrapolation(
         chamb=chamber, Dh=dx)
     mesh = RectMesh2D(poissonsolver.bias_y, poissonsolver.bias_x, dx, dx,
                       poissonsolver.Nyg, poissonsolver.Nxg)
     pp = PyPIC_Fortran_M2P_P2M(mesh,
                                poissonsolver,
                                gradient=poissonsolver.gradient)
     n_particles = 10000
     np.random.seed(0)
     xx = np.random.normal(0., 0.2, n_particles)
     yy = np.random.normal(0., 0.2, n_particles)
     plt.figure()
     plt.scatter(xx, yy)
     plt.show()
     [fx, fy] = pp.pic_solve(xx, yy)
     fig = plt.figure()
     plt.title('ex')
     f = plt.scatter(xx, yy, s=40, c=fx)
     plt.colorbar()
     plt.show()
     fig = plt.figure()
     plt.title('ey')
     f = plt.scatter(xx, yy, s=40, c=fy)
     plt.colorbar()
     plt.show()
コード例 #3
0
    def _test_pypic_FiniteDifferences_ShortleyWeller_SquareGrid(self):
        # mesh = self.make_centered_mesh(2., 2., 23, 23)
        # chamber = self.gen_rect_chamber(1, 1)
        # poissonsolver = FD.FiniteDifferences_ShortleyWeller_SquareGrid(
        #         chamb=chamber, Dh=mesh.dx)

        dx = 0.1
        chamber = self.gen_rect_chamber(1, 1)
        poissonsolver = FD.FiniteDifferences_ShortleyWeller_SquareGrid(
            chamb=chamber, Dh=dx)
        mesh = RectMesh2D(poissonsolver.bias_y, poissonsolver.bias_x, dx, dx,
                          poissonsolver.Nyg, poissonsolver.Nxg)

        pp = PyPIC(mesh, poissonsolver, gradient=poissonsolver.gradient)
        n_particles = 10000
        np.random.seed(0)
        xx = np.random.normal(0., 0.1, n_particles)
        yy = np.random.normal(0., 0.1, n_particles)
        plt.figure()
        plt.scatter(xx, yy)
        plt.show()
        [fx, fy] = pp.pic_solve(xx, yy)
        fig = plt.figure()
        plt.title('ex')
        f = plt.scatter(xx, yy, s=40, c=fx)
        plt.colorbar()
        plt.show()
        fig = plt.figure()
        plt.title('ey')
        f = plt.scatter(xx, yy, s=40, c=fy)
        plt.colorbar()
        plt.show()
コード例 #4
0
 def _test_pypic_cpu_new(self):
     mesh = RectMesh2D(x0=-0.5, y0=-0.5, dx=0.1, dy=0.1, nx=16, ny=16)
     #mesh = RectMesh2D(x0=0.0, y0=0.0, dx=0.1, dy=0.1, nx=10, ny=10)
     poissonsolver = FD.CPUFiniteDifferencePoissonSolver(
         mesh, laplacian_stencil=FD.laplacian_2D_5stencil)
     pp = PyPIC(mesh, poissonsolver)
     n_particles = 10000
     np.random.seed(0)
     xx = np.random.normal(0.0, 0.1, n_particles)
     yy = np.random.normal(0.0, 0.1, n_particles)
     fx, fy = pp.pic_solve(xx, yy)
     fig = plt.figure()
     f = plt.scatter(xx, yy, s=40, c=fx)
     plt.colorbar()
     plt.show()
コード例 #5
0
 def __init__(self, chamb, Dh, sparse_solver='scipy_slu'):
     poissonsolver = FD.FiniteDifferences_ShortleyWeller_SquareGrid_extrapolation(
         chamb=chamb, Dh=Dh, sparse_solver=sparse_solver)
     super(_FiniteDifferences_ShortleyWeller_SquareGrid_extrapolation,
           self).__init__(poissonsolver)
コード例 #6
0
 def __init__(self, chamb, Dh, sparse_solver='scipy_slu'):
     poissonsolver = FD.FiniteDifferences_ShortleyWeller_SquareGrid(
         chamb=chamb, Dh=Dh, sparse_solver=sparse_solver, ext_boundary=True)
     super(_FiniteDifferences_ShortleyWeller_SquareGrid,
           self).__init__(poissonsolver)