Ejemplo n.º 1
0
    def createSingleCellGrid(cls, corners):
        """
        Provided with the corners of the grid in a similar manner as the eight
        corners are output for a single cell, this method will create a grid
        consisting of a single cell with the specified corners as its corners.
        """

        zcorn = [corners[i][2] for i in range(8)]

        flatten = lambda l : [elem for sublist in l for elem in sublist]
        coord = [(corners[i], corners[i+4]) for i in range(4)]
        coord = flatten(flatten(coord))

        def constructFloatKW(name, values):
            kw = EclKW(name, len(values), EclDataType.ECL_FLOAT)
            for i in range(len(values)):
                kw[i] = values[i]
            return kw

        grid = EclGrid.create((1,1,1), constructFloatKW("ZCORN", zcorn), constructFloatKW("COORD", coord), None)

        if not corners == [grid.getCellCorner(i, 0) for i in range(8)]:
            raise AssertionError("Failed to generate single cell grid. " +
                    "Did not end up the expected corners.")

        return grid
Ejemplo n.º 2
0
 def loadGrid(self):
     grid_file   = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl")
     fileH = open(grid_file, "r")
     specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False)
     zcorn = EclKW.read_grdecl(fileH, "ZCORN")
     coord = EclKW.read_grdecl(fileH, "COORD")
     actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE)
     
     return EclGrid.create(specgrid, zcorn, coord, actnum)
Ejemplo n.º 3
0
    def create(self, filename, load_actnum=True):
        fileH = open(filename, "r")
        specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False)
        zcorn = EclKW.read_grdecl(fileH, "ZCORN")
        coord = EclKW.read_grdecl(fileH, "COORD")
        if load_actnum:
            actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE)
        else:
            actnum = None

        mapaxes = EclKW.read_grdecl(fileH, "MAPAXES")
        grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes)
        return grid
Ejemplo n.º 4
0
 def create(self, filename, load_actnum=True):
     fileH = open(filename, "r")
     specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False)
     zcorn = EclKW.read_grdecl(fileH, "ZCORN")
     coord = EclKW.read_grdecl(fileH, "COORD")
     if load_actnum:
         actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE)
     else:
         actnum = None
 
     mapaxes = EclKW.read_grdecl(fileH, "MAPAXES")
     grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes)
     return grid
Ejemplo n.º 5
0
    def loadGrid(self):
        grid_file = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl")
        fileH = open(grid_file, "r")
        specgrid = EclKW.read_grdecl(fileH,
                                     "SPECGRID",
                                     ecl_type=EclDataType.ECL_INT,
                                     strict=False)
        zcorn = EclKW.read_grdecl(fileH, "ZCORN")
        coord = EclKW.read_grdecl(fileH, "COORD")
        actnum = EclKW.read_grdecl(fileH,
                                   "ACTNUM",
                                   ecl_type=EclDataType.ECL_INT)

        return EclGrid.create(specgrid, zcorn, coord, actnum)
Ejemplo n.º 6
0
def loadGrid(path, load_actnum=True):
    """ @rtype: EclGrid """
    with open(path, "r") as f:
        specgrid = EclKW.read_grdecl(f, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False)
        zcorn = EclKW.read_grdecl(f, "ZCORN")
        coord = EclKW.read_grdecl(f, "COORD")

        actnum = None
        if load_actnum:
            actnum = EclKW.read_grdecl(f, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE)

        mapaxes = EclKW.read_grdecl(f, "MAPAXES")
        grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes)

    return grid
Ejemplo n.º 7
0
def loadGrid(path, load_actnum=True):
    """ @rtype: EclGrid """
    with open(path, "r") as f:
        specgrid = EclKW.read_grdecl(f, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False)
        zcorn = EclKW.read_grdecl(f, "ZCORN")
        coord = EclKW.read_grdecl(f, "COORD")

        actnum = None
        if load_actnum:
            actnum = EclKW.read_grdecl(f, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE)

        mapaxes = EclKW.read_grdecl(f, "MAPAXES")
        grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes)

    return grid
Ejemplo n.º 8
0
    def createGrid(cls, dims, dV, offset=1,
            escape_origo_shift=(1,1,0),
            irregular_offset=False, irregular=False, concave=False,
            faults=False, scale=1, translation=(0,0,0), rotate=False,
            misalign=False):
        """
        Will create a new grid where each cell is a parallelogram (skewed by z-value).
        The number of cells are given by @dims = (nx, ny, nz) and the dimention
        of each cell by @dV = (dx, dy, dz).

        All cells are guaranteed to not be self-intersecting. Hence, no twisted
        cells and somewhat meaningfull cells.

        @offset gives how much the layers should fluctuate or "wave" as you
        move along the X-axis.

        @irregular_offset decides whether the offset should be constant or
        increase by dz/2 every now and then.

        @irregular if true some of the layers will be inclining and others
        declining at the start.

        @concave decides whether the cells are to be convex or not. In
        particular, if set to False, all cells of the grid will be concave.

        @escape_origo_shift is used to prevent any cell of having corners in (0,0,z)
        as there is a heuristic in ecl_grid.c that marks such cells as tainted.

        @faults decides if there are to be faults in the grid.

        @scale A positive number that scales the "lower" endpoint of all
        coord's. In particular, @scale != 1 creates trapeziod cells in both the XZ
        and YZ-plane.

        @translation the lower part of the grid is translated ("slided") by the specified
        additive factor.

        @rotate the lower part of the grid is rotated 90 degrees around its
        center.

        @misalign will toggle COORD's slightly in various directions to break
        alignment

        Note that cells in the lowermost layer can have multiple corners
        at the same point.

        For testing it should give good coverage of the various scenarios this
        method can produce, by leting @dims be (10,10,10), @dV=(2,2,2), @offset=1,
        and try all 4 different configurations of @concave and
        @irregular_offset.
        """

        nx, ny, nz = dims
        dx, dy, dz = dV

        # Validate arguments
        if min(dims + dV) <= 0:
            raise ValueError("Expected positive grid and cell dimentions")

        if offset < 0:
            raise ValueError("Expected non-negative offset")

        if irregular and offset + (dz/2. if irregular_offset else 0) > dz:
            raise AssertionError("Arguments can result in self-" +
                    "intersecting cells. Increase dz, deactivate eiter " +
                    "irregular or irregular_offset, or decrease offset to avoid " +
                    "any problems")

        verbose = lambda l : [elem for elem in l for i in range(2)][1:-1:]
        flatten = lambda l : [elem for sublist in l for elem in sublist]

        # Compute zcorn
        z = escape_origo_shift[2]
        zcorn = [z]*(4*nx*ny)
        for k in range(nz-1):
            z = z+dz
            local_offset = offset + (dz/2. if irregular_offset and k%2 == 0 else 0)

            layer = []
            for i in range(ny+1):
                shift = ((i if concave else 0) + (k/2 if irregular else 0)) % 2
                path = [z if i%2 == shift else z+local_offset for i in range(nx+1)]
                layer.append(verbose(path))

            zcorn = zcorn + (2*flatten(verbose(layer)))

        z = z+dz
        zcorn = zcorn + ([z]*(4*nx*ny))

        if faults:
            # Ensure that drop does not align with grid structure
            drop = (offset+dz)/2. if abs(offset-dz/2.) > 0.2 else offset + 0.4
            zcorn = cls.__createFaults(nx, ny, nz, zcorn, drop)

        cls.assertZcorn(nx, ny, nz, zcorn)

        # Compute coord
        coord = []
        for j, i in itertools.product(range(ny+1), range(nx+1)):
            x, y = i*dx+escape_origo_shift[0], j*dy+escape_origo_shift[1]
            coord = coord + [x, y, escape_origo_shift[2], x, y, z]

        # Apply transformations
        lower_center = (
                nx*dx/2. + escape_origo_shift[0],
                ny*dy/2. + escape_origo_shift[1]
                )

        if misalign:
            coord = cls.__misalignCoord(coord, dims, dV)

        coord = cls.__scaleCoord(coord, scale, lower_center)

        if rotate:
            coord = cls.__rotateCoord(coord, lower_center)

        coord = cls.__translateCoord(coord, translation)

        cls.assertCoord(nx, ny, nz, coord)

        # Construct grid
        def constructFloatKW(name, values):
            kw = EclKW(name, len(values), EclDataType.ECL_FLOAT)
            for i in range(len(values)):
                kw[i] = values[i]
            return kw

        return EclGrid.create(dims, constructFloatKW("ZCORN", zcorn), constructFloatKW("COORD", coord), None)