How to use the pytools.ind2loc function in pytools

To help you get started, we’ve selected a few pytools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github natj / runko / tests / test_pic.py View on Github external
def insert_em(grid, conf, ffunc):

    Lx  = conf.Nx*conf.NxMesh #XXX scaled length
    for i in range(grid.get_Nx()):
        for j in range(grid.get_Ny()):
            for k in range(grid.get_Nz()):
                c = grid.get_tile(i,j,k)
                yee = c.get_yee()

                for l in range(conf.NxMesh):
                    for m in range(conf.NyMesh):
                        for n in range(conf.NzMesh):

                            # get x_i,j,k
                            xloc0 = pytools.ind2loc(grid, (i,j,k), (l,m,n), conf)

                            #get x_i+1/2, x_j+1/2, x_k+1/2
                            xloc1 = pytools.ind2loc(grid, (i,j,k), (l+1,m,  n),   conf)
                            yloc1 = pytools.ind2loc(grid, (i,j,k), (l,  m+1,n),   conf)
                            zloc1 = pytools.ind2loc(grid, (i,j,k), (l,  m,  n+1), conf)

                            # values in Yee lattice corners
                            xcor = xloc0[0]
                            ycor = xloc0[1]
                            zcor = xloc0[2]

                            # values in Yee lattice mids
                            xmid = 0.5*(xloc0[0] + xloc1[0])
                            ymid = 0.5*(xloc0[1] + yloc1[1])
                            zmid = 0.5*(xloc0[2] + zloc1[2])
github natj / runko / tests / test_pic.py View on Github external
Lx  = conf.Nx*conf.NxMesh #XXX scaled length
    for i in range(grid.get_Nx()):
        for j in range(grid.get_Ny()):
            for k in range(grid.get_Nz()):
                c = grid.get_tile(i,j,k)
                yee = c.get_yee()

                for l in range(conf.NxMesh):
                    for m in range(conf.NyMesh):
                        for n in range(conf.NzMesh):

                            # get x_i,j,k
                            xloc0 = pytools.ind2loc(grid, (i,j,k), (l,m,n), conf)

                            #get x_i+1/2, x_j+1/2, x_k+1/2
                            xloc1 = pytools.ind2loc(grid, (i,j,k), (l+1,m,  n),   conf)
                            yloc1 = pytools.ind2loc(grid, (i,j,k), (l,  m+1,n),   conf)
                            zloc1 = pytools.ind2loc(grid, (i,j,k), (l,  m,  n+1), conf)

                            # values in Yee lattice corners
                            xcor = xloc0[0]
                            ycor = xloc0[1]
                            zcor = xloc0[2]

                            # values in Yee lattice mids
                            xmid = 0.5*(xloc0[0] + xloc1[0])
                            ymid = 0.5*(xloc0[1] + yloc1[1])
                            zmid = 0.5*(xloc0[2] + zloc1[2])

                            #val = ffunc(xmid, ymid, zmid)

                            # enforce Yee lattice structure
github natj / runko / tests / test_pic.py View on Github external
for i in range(grid.get_Nx()):
        for j in range(grid.get_Ny()):
            for k in range(grid.get_Nz()):
                c = grid.get_tile(i,j,k)
                yee = c.get_yee()

                for l in range(conf.NxMesh):
                    for m in range(conf.NyMesh):
                        for n in range(conf.NzMesh):

                            # get x_i,j,k
                            xloc0 = pytools.ind2loc(grid, (i,j,k), (l,m,n), conf)

                            #get x_i+1/2, x_j+1/2, x_k+1/2
                            xloc1 = pytools.ind2loc(grid, (i,j,k), (l+1,m,  n),   conf)
                            yloc1 = pytools.ind2loc(grid, (i,j,k), (l,  m+1,n),   conf)
                            zloc1 = pytools.ind2loc(grid, (i,j,k), (l,  m,  n+1), conf)

                            # values in Yee lattice corners
                            xcor = xloc0[0]
                            ycor = xloc0[1]
                            zcor = xloc0[2]

                            # values in Yee lattice mids
                            xmid = 0.5*(xloc0[0] + xloc1[0])
                            ymid = 0.5*(xloc0[1] + yloc1[1])
                            zmid = 0.5*(xloc0[2] + zloc1[2])

                            #val = ffunc(xmid, ymid, zmid)

                            # enforce Yee lattice structure
                            yee.ex[l,m,n] = ffunc(xmid, ycor, zcor)
github natj / runko / tests / test_pic.py View on Github external
for j in range(grid.get_Ny()):
            for k in range(grid.get_Nz()):
                c = grid.get_tile(i,j,k)
                yee = c.get_yee()

                for l in range(conf.NxMesh):
                    for m in range(conf.NyMesh):
                        for n in range(conf.NzMesh):

                            # get x_i,j,k
                            xloc0 = pytools.ind2loc(grid, (i,j,k), (l,m,n), conf)

                            #get x_i+1/2, x_j+1/2, x_k+1/2
                            xloc1 = pytools.ind2loc(grid, (i,j,k), (l+1,m,  n),   conf)
                            yloc1 = pytools.ind2loc(grid, (i,j,k), (l,  m+1,n),   conf)
                            zloc1 = pytools.ind2loc(grid, (i,j,k), (l,  m,  n+1), conf)

                            # values in Yee lattice corners
                            xcor = xloc0[0]
                            ycor = xloc0[1]
                            zcor = xloc0[2]

                            # values in Yee lattice mids
                            xmid = 0.5*(xloc0[0] + xloc1[0])
                            ymid = 0.5*(xloc0[1] + yloc1[1])
                            zmid = 0.5*(xloc0[2] + zloc1[2])

                            #val = ffunc(xmid, ymid, zmid)

                            # enforce Yee lattice structure
                            yee.ex[l,m,n] = ffunc(xmid, ycor, zcor)
                            yee.ey[l,m,n] = ffunc(xcor, ymid, zcor)+1.0
github natj / runko / projects / ffe / ffe3.py View on Github external
for cid in grid.get_tile_ids():
        tile = grid.get_tile(cid)
        yee = tile.get_yee(0)

        if conf.twoD:
            ii, jj = tile.index
            kk = 0
        elif conf.threeD:
            ii, jj, kk = tile.index

        # insert values into Yee lattices; includes halos from -3 to n+3
        for n in range(conf.NzMesh):
            for m in range(conf.NyMesh):
                for l in range(conf.NxMesh):
                    # get global coordinates
                    iglob, jglob, kglob = pytools.ind2loc((ii, jj, kk), (l, m, n), conf)
                    loc = pytools.Stagger(iglob, jglob, kglob)

                    # distance from the center of the packets
                    d1 = pkg_loc1 - loc
                    d2 = pkg_loc2 - loc

                    # add stationary guide field
                    yee.bz[l, m, n] = b0

                    # amplitude for the perturbations
                    #
                    # gauss = zeta * ell * np.exp(-r1 / ell ** 2)
                    # bphi = (2.0 * b0 * w / ell ** 2) * gauss

                    # bphi = {}
                    # theta = {}