Ejemplo n.º 1
0
    def parse(self, filename, xmin, xmax, ymin, ymax, zmin, zmax, xstep, ystep,
              zstep):

        usrLimits = [xmin, xmax, ymin, ymax, zmin, zmax]
        limits = self.getLimits(filename)

        range = self.getRange(limits)
        step = [xstep, ystep, zstep]

        #Computes the size of the grid given the user limits and the step
        gridSize = self.getGridSize(range, step, usrLimits)

        numLines = limits[6]

        print "Number of lines in the file: ", numLines, "\n"

        #for now we will say that the size of the grid encompasses all datapoints
        print "GridSize ", gridSize[0], gridSize[1], gridSize[2]
        BXGrid = Grid3D(gridSize[0], gridSize[1], gridSize[2])
        BYGrid = Grid3D(gridSize[0], gridSize[1], gridSize[2])
        BZGrid = Grid3D(gridSize[0], gridSize[1], gridSize[2])
        fieldgrid3DMag = Grid3D(gridSize[0], gridSize[1], gridSize[2])
        XGrid = []
        YGrid = []
        ZGrid = []

        # Maps values from file to grid.

        infile1 = open(filename, "r")
        for line in infile1.readlines():
            splitLine = line.split()
            rawNumbers = map(float, splitLine)
            # 			Maps data points to integers so that they can be evaluated for stepsize
            testRS = map(int, rawNumbers)

            if (self.checkGrid(step, rawNumbers)
                    and self.checkLimits(usrLimits, rawNumbers)):

                coordinates = self.getCoordinates(gridSize, step, rawNumbers,
                                                  usrLimits)

                XGrid.append(rawNumbers[0] / 100.0)
                YGrid.append(rawNumbers[1] / 100.0)
                ZGrid.append(rawNumbers[2] / 100.0)
                BXGrid.setValue(rawNumbers[3] / 10000.0, coordinates[0],
                                coordinates[1], coordinates[2])
                BYGrid.setValue(rawNumbers[4] / 10000.0, coordinates[0],
                                coordinates[1], coordinates[2])

                BZGrid.setValue(rawNumbers[5] / 10000.0, coordinates[0],
                                coordinates[1], coordinates[2])
                getMag = ((rawNumbers[3]**2.0 + rawNumbers[4]**2.0 +
                           rawNumbers[5]**2.0)**0.5) / 10000.0

                fieldgrid3DMag.setValue(getMag, coordinates[0], coordinates[1],
                                        coordinates[2])

        MagList = [BXGrid, BYGrid, BZGrid, fieldgrid3DMag, XGrid, YGrid, ZGrid]

        return MagList
Ejemplo n.º 2
0
sizeX = 64
sizeY = 64
sizeZ = 64
xMin = -5.0
xMax = +5.0
yMin = -5.5
yMax = +5.5
zMin = -6.0
zMax = +6.0
print " x,y,z sizes: ", sizeX, " ", sizeY, " ", sizeZ
solver = PoissonSolverFFT3D(sizeX, sizeY, sizeZ, xMin, xMax, yMin, yMax, zMin,
                            zMax)

scale_coeff = 1.3

gridRho = Grid3D(sizeX, sizeY, sizeZ)
gridRho.setGridX(scale_coeff * xMin, scale_coeff * xMax)
gridRho.setGridY(scale_coeff * yMin, scale_coeff * yMax)
gridRho.setGridZ(scale_coeff * zMin, scale_coeff * zMax)

gridPhi = Grid3D(sizeX, sizeY, sizeZ)
gridPhi.setGridX(scale_coeff * xMin, scale_coeff * xMax)
gridPhi.setGridY(scale_coeff * yMin, scale_coeff * yMax)
gridPhi.setGridZ(scale_coeff * zMin, scale_coeff * zMax)

chrage_ind_x = int(sizeX / 2)
chrage_ind_y = int(sizeY / 2)
chrage_ind_z = int(sizeZ / 2)

charge = 1.0
gridRho.setValue(charge, chrage_ind_x, chrage_ind_y, chrage_ind_z)
Ejemplo n.º 3
0
#---- defines how to treat wrapping of the bunches
use_wrapping = True
#use_wrapping = False

sizeX = 64
sizeY = 64
sizeZ = 64

xMin = -1.0
xMax = +1.0
yMin = -1.0
yMax = +1.0
zMin = -1.0
zMax = +1.0

rho3D = Grid3D(sizeX, sizeY, sizeZ)
rho3D.setGridX(xMin, xMax)
rho3D.setGridY(yMin, yMax)
rho3D.setGridZ(zMin, zMax)

phi3D = Grid3D(sizeX, sizeY, sizeZ)
phi3D.setGridX(xMin, xMax)
phi3D.setGridY(yMin, yMax)
phi3D.setGridZ(zMin, zMax)

if (use_wrapping):
    print "Longitudinal wrapping for rho3D = ", rho3D.longWrapping()
    print "Longitudinal wrapping for phi3D = ", phi3D.longWrapping()

    rho3D.longWrapping(True)
    phi3D.longWrapping(True)
Ejemplo n.º 4
0
from spacecharge import Grid3D

print "Start."

sizeX = 50
sizeY = 50
sizeZ = 50
xMin = 2.0
xMax = +4.0
yMin = 1.0
yMax = +4.0
zMin = 1.0
zMax = +4.0

grid3D = Grid3D(sizeX, sizeY, sizeZ)
grid3D.setGridX(xMin, xMax)
grid3D.setGridY(yMin, yMax)
grid3D.setGridZ(zMin, zMax)


def Func(x, y, z):
    return 1.0 / (x * x + y * y + z * z)
    #return (x**2+y**2+z**2)


def FuncGrad(x, y, z):
    return (-2 * x / (x * x + y * y + z * z)**2,
            -2 * y / (x * x + y * y + z * z)**2,
            -2 * z / (x * x + y * y + z * z)**2)
    #return (2*x,2*y,2*z)