コード例 #1
0
 def test_EGRID( self ):
     grid = EclGrid(self.egrid_file())
     self.assertTrue(grid)
     dims = grid.getDims()
     self.assertEqual(dims[0] , grid.getNX())
     self.assertEqual(dims[1] , grid.getNY())
     self.assertEqual(dims[2] , grid.getNZ())
コード例 #2
0
ファイル: test_fk_user_data.py プロジェクト: OPM/ResInsight
    def test_cell_containment(self):

        grid_location = "local/ECLIPSE/faarikaal/faarikaal%d.EGRID"
        well_location = "local/ECLIPSE/faarikaal/faarikaal%d.txt"

        for i in range(1, 8):
            grid_file = self.createTestPath(grid_location % i)
            well_file = self.createTestPath(well_location % i)

            grid = EclGrid(grid_file)

            # Load well data
            with open(well_file, "r") as f:
                lines = [line.split() for line in f.readlines()]

            points = [map(float, line[:3:]) for line in lines]
            exp_cells = [tuple(map(int, line[3::])) for line in lines]

            msg = "Expected point %s to be in cell %s, was in %s."
            for point, exp_cell in zip(points, exp_cells):
                reported_cell = grid.find_cell(*point)
                self.assertEqual(
                        exp_cell,
                        reported_cell,
                        msg % (str(point), str(exp_cell), str(reported_cell))
                        )
コード例 #3
0
    def test_grdecl_load(self):
        with self.assertRaises(IOError):
            grid = EclGrid.loadFromGrdecl("/file/does/not/exists")

        with TestAreaContext("python/grid-test/grdeclLoad"):
            with open("grid.grdecl","w") as f:
                f.write("Hei ...")

            with self.assertRaises(ValueError):
                grid = EclGrid.loadFromGrdecl("grid.grdecl")

            actnum = IntVector(default_value = 1 , initial_size = 1000)
            actnum[0] = 0
            g1 = EclGrid.createRectangular((10,10,10) , (1,1,1) , actnum = actnum )
            self.assertEqual( g1.getNumActive() , actnum.elementSum() )
            g1.save_EGRID("G.EGRID")

            with open("grid.grdecl" , "w") as f2:
                f2.write("SPECGRID\n")
                f2.write("  10  10  10  \'F\' /\n")

            with openEclFile("G.EGRID") as f:
                with copen("grid.grdecl" , "a") as f2:

                    coord_kw = f["COORD"][0]
                    coord_kw.write_grdecl( f2 )

                    zcorn_kw = f["ZCORN"][0]
                    zcorn_kw.write_grdecl( f2 )

                    actnum_kw = f["ACTNUM"][0]
                    actnum_kw.write_grdecl( f2 )

            g2 = EclGrid.loadFromGrdecl("grid.grdecl")
            self.assertTrue( g1.equal( g2 ))
コード例 #4
0
ファイル: test_grid_generator.py プロジェクト: OPM/ResInsight
    def test_actnum_extraction(self):
        dims = (4,4,4)

        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)

        actnum = EclKW("ACTNUM", six.functools.reduce(operator.mul, dims),
                       EclDataType.ECL_INT)
        random.seed(1337)
        for i in range(len(actnum)):
            actnum[i] = random.randint(0, 1)

        grid = EclGrid.create(dims, zcorn, coord, actnum)

        ijk_bounds = generate_ijk_bounds(dims)
        for ijk_bound in ijk_bounds:
            if not decomposition_preserving(ijk_bound):
                continue

            sub = GridGen.extract_subgrid_data(
                                         dims,
                                         coord,
                                         zcorn,
                                         ijk_bound,
                                         actnum=actnum
                                       )

            sub_coord, sub_zcorn, sub_actnum = sub
            sub_dims = tuple([u-l+1 for l, u in ijk_bound])
            subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, sub_actnum)
            self.assertEqual(sub_dims, subgrid.getDims()[:-1:])
            self.assertSubgrid(grid, subgrid, ijk_bound)
コード例 #5
0
    def test_output_units(self):
        n = 10
        a = 1
        grid = GridGen.createRectangular( (n,n,n), (a,a,a))

        with TestAreaContext("python/ecl_grid/units"):
            grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_FIELD_UNITS )
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip( ) , "FEET" )
            g2 = EclGrid("CASE.EGRID")
            self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 3.28084*3.28084*3.28084)


            grid.save_EGRID( "CASE.EGRID" )
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip( ) , "METRES" )

            grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_LAB_UNITS)
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip() , "CM" )
            g2 = EclGrid("CASE.EGRID")
            self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 100*100*100 )
コード例 #6
0
ファイル: test_grid_generator.py プロジェクト: OPM/ResInsight
    def test_translation(self):
        dims = (3,3,3)

        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)
        grid = EclGrid.create(dims, zcorn, coord, None)

        ijk_bound = [(0, d-1) for d in dims]
        translation = (1, 2, 3)
        sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data(
                                                        dims,
                                                        coord,
                                                        zcorn,
                                                        ijk_bound,
                                                        translation=translation
                                                       )

        tgrid = EclGrid.create(dims, sub_zcorn, sub_coord, None)
        self.assertEqual(grid.getGlobalSize(), tgrid.getGlobalSize())

        for gi in range(grid.getGlobalSize()):
            translation = numpy.array(translation)
            corners = [grid.getCellCorner(i, gi) for i in range(8)]
            corners = [tuple(numpy.array(c)+translation) for c in corners]

            tcorners = [tgrid.getCellCorner(i, gi) for i in range(8)]

            self.assertEqual(corners, tcorners)
コード例 #7
0
    def test_num_active_large_memory(self):
        case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE")
        vecList = []
        for i in range(12500):
            vec = DoubleVector()
            vec[81920] = 0
            vecList.append(vec)

        grid1 = EclGrid(case)
        grid2 = EclGrid(case)
        self.assertEqual(grid1.getNumActive(), grid2.getNumActive())
        self.assertEqual(grid1.getNumActive(), 34770)
コード例 #8
0
 def test_repr_and_name(self):
     grid = GridGen.createRectangular((2,2,2), (10,10,10), actnum=[0,0,0,0,1,1,1,1])
     pfx = 'EclGrid('
     rep = repr(grid)
     self.assertEqual(pfx, rep[:len(pfx)])
     self.assertEqual(type(rep), type(''))
     self.assertEqual(type(grid.getName()), type(''))
     with TestAreaContext("python/ecl_grid/repr"):
         grid.save_EGRID("CASE.EGRID")
         g2 = EclGrid("CASE.EGRID")
         r2 = repr(g2)
         self.assertEqual(pfx, r2[:len(pfx)])
         self.assertEqual(type(r2), type(''))
         self.assertEqual(type(g2.getName()), type(''))
コード例 #9
0
ファイル: test_region_statoil.py プロジェクト: OPM/ResInsight
    def test_heidrun(self):
        root = self.createTestPath("Statoil/ECLIPSE/Heidrun")
        grid = EclGrid( "%s/FF12_2013B2_AMAP_AOP-J15_NO62_MOVEX.EGRID" % root)

        polygon = []
        with open("%s/polygon.ply" % root) as fileH:
            for line in fileH.readlines():
                tmp = line.split()
                polygon.append( (float(tmp[0]) , float(tmp[1])))
        self.assertEqual( len(polygon) , 11 )

        reg = EclRegion( grid , False )
        reg.select_inside_polygon( polygon )
        self.assertEqual( 0 , len(reg.getGlobalList()) % grid.getNZ())
コード例 #10
0
ファイル: test_ecl_well3.py プロジェクト: trhallam/ecl
    def test_rates(self):
        grid_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID")
        rst_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST")
        sum_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.SMSPEC")

        grid = EclGrid(grid_path)
        well_info = WellInfo(grid, rst_path)
        sum = EclSum(sum_path)

        for wtl in well_info:
            for well_state in wtl:
                # print "%03d  %g   %g " % (R , well_state.oilRate(), sum.get_from_report( "WOPR:%s" % well , R))
                if wtl.getName() == "OP_4":
                    pass
                    # print well_state.oilRate(), well_state.waterRate(), well_state.gasRate(), well_state.volumeRate()
                    # print well_state.oilRateSI(), well_state.waterRateSI(), well_state.gasRateSI(), well_state.volumeRateSI()
                    self.assertEqual(well_state.oilRate(), well_state.oilRateSI())
                    self.assertEqual(well_state.waterRate(), well_state.waterRateSI())
                    self.assertEqual(well_state.gasRate(), well_state.gasRateSI())
                    self.assertEqual(well_state.volumeRate(), well_state.volumeRateSI())
                    # print sum.get_from_report("WOPR:%s" % wtl.getName(), 1)
                    # print sum.get_from_report( "WWPR:%s" % wtl.getName(), 30 )

                    for conn in well_state.globalConnections():
                        # print conn.gasRate(), conn.waterRate(), conn.oilRate()
                        # print conn.gasRateSI(), conn.waterRateSI(), conn.oilRateSI()
                        self.assertEqual(conn.gasRate(), conn.gasRateSI())
                        self.assertEqual(conn.waterRate(), conn.waterRateSI())
                        self.assertEqual(conn.oilRate(), conn.oilRateSI())
                        self.assertEqual(conn.volumeRate(), conn.volumeRateSI())
コード例 #11
0
ファイル: test_grid_equinor.py プロジェクト: trhallam/ecl
    def test_boundingBox(self):
        grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1))
        with self.assertRaises(ValueError):
            bbox = grid.getBoundingBox2D(layer=-1)

        with self.assertRaises(ValueError):
            bbox = grid.getBoundingBox2D(layer=11)

        bbox = grid.getBoundingBox2D(layer=10)
        self.assertEqual(bbox, ((0, 0), (10, 0), (10, 10), (0, 10)))

        with self.assertRaises(ValueError):
            grid.getBoundingBox2D(lower_left=(-1, 0))

        with self.assertRaises(ValueError):
            grid.getBoundingBox2D(lower_left=(6, 10))

        bbox = grid.getBoundingBox2D(lower_left=(3, 3))
        self.assertEqual(bbox, ((3, 3), (10, 3), (10, 10), (3, 10)))

        with self.assertRaises(ValueError):
            grid.getBoundingBox2D(lower_left=(3, 3), upper_right=(2, 2))

        bbox = grid.getBoundingBox2D(lower_left=(3, 3), upper_right=(7, 7))
        self.assertEqual(bbox, ((3, 3), (7, 3), (7, 7), (3, 7)))
コード例 #12
0
    def test_Load(self):
        kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX")
        self.assertTrue(kw)

        grid = EclGrid(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE"))
        kw = Ecl3DKW.read_grdecl(grid, copen(self.src_file, "r"), "PERMX")
        self.assertTrue(isinstance(kw, Ecl3DKW))
コード例 #13
0
ファイル: test_faults.py プロジェクト: OPM/ResInsight
    def test_extend_polyline_on(self):
        grid = EclGrid.createRectangular( (3,3,1) , (1 , 1 , 1))

        #  o   o   o   o
        #               
        #  o---o---o---o
        #  
        #  o===o===o===o
        #  
        #  o   o   o   o

        fault1 = Fault(grid , "Fault")
        fault1.addRecord(0 , 2 , 0 , 0 , 0 , 0 , "Y")

        polyline0 = CPolyline( init_points = [(0,2)])
        polyline1 = CPolyline( init_points = [(0,2) , (3,2)])
        polyline2 = CPolyline( init_points = [(1,3) , (1,2)])
        polyline3 = CPolyline( init_points = [(1,3) , (1,0)])

        with self.assertRaises(ValueError):
            fault1.extendPolylineOnto( polyline0 , 0 )
            
        points = fault1.extendPolylineOnto( polyline1 , 0 )
        self.assertIsNone( points )

        points = fault1.extendPolylineOnto( polyline2 , 0)
        self.assertEqual( points , [(1,2) , (1,1)])

        points = fault1.extendPolylineOnto( polyline3 , 0)
        self.assertIsNone( points )
コード例 #14
0
ファイル: test_faults.py プロジェクト: OPM/ResInsight
    def test_connectWithPolyline(self):
        grid = EclGrid.createRectangular( (4,4,1) , (1 , 1 , 1))

        
        #  o   o   o   o   o 
        #                   
        #  o   o   o   o   o
        #                   
        #  o---o---o---o---o
        #                   
        #  o   o   o   o   o
        #          |        
        #  o   o   o   o   o

        fault1 = Fault(grid , "Fault1")
        fault1.addRecord(0 , 3 , 1 , 1 , 0 , 0 , "Y")

        fault2 = Fault(grid , "Fault2")
        fault2.addRecord(1 , 1 , 0 , 0 , 0 , 0 , "X")

        fault3 = Fault(grid , "Fault3")
        fault3.addRecord(1 , 1 , 0 , 2 , 0 , 0 , "X")
        
        self.assertIsNone( fault3.connect( fault1 , 0 ))
        
        
        intersect = fault2.connect( fault1 , 0 )
        self.assertEqual( len(intersect) , 2 )
        p1 = intersect[0]
        p2 = intersect[1]
        
        self.assertEqual( p1 , (2,1))
        self.assertEqual( p2 , (2,2))
コード例 #15
0
ファイル: test_faults.py プロジェクト: OPM/ResInsight
    def test_fault_line_order(self):
        nx = 120
        ny = 60
        nz = 43
        grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) )
        with TestAreaContext("python/faults/line_order"):
            with open("faults.grdecl" , "w") as f:
                f.write("""FAULTS
\'F\'              105  107     50   50      1   43    \'Y\'    /
\'F\'              108  108     50   50      1   43    \'X\'    /
\'F\'              108  108     50   50     22   43    \'Y\'    /
\'F\'              109  109     49   49      1   43    \'Y\'    /
\'F\'              110  110     49   49      1   43    \'X\'    /
\'F\'              111  111     48   48      1   43    \'Y\'    /
/
""")
            faults = FaultCollection( grid , "faults.grdecl" )

        fault = faults["F"]
        layer = fault[29]
        self.assertEqual(len(layer) , 2)

        line1 = layer[0]
        line2 = layer[1]
        self.assertEqual(len(line1) , 4)
        self.assertEqual(len(line2) , 2)

        seg0 = line1[0]
        seg1 = line1[1]
        seg2 = line1[2]
        seg3 = line1[3]
        self.assertEqual( seg0.getCorners() , (50 * (nx + 1) + 104 , 50 * (nx + 1) + 107))
        self.assertEqual( seg1.getCorners() , (50 * (nx + 1) + 107 , 50 * (nx + 1) + 108))
        self.assertEqual( seg2.getCorners() , (50 * (nx + 1) + 108 , 49 * (nx + 1) + 108))
        self.assertEqual( seg3.getCorners() , (49 * (nx + 1) + 108 , 49 * (nx + 1) + 109))
コード例 #16
0
ファイル: test_faults.py プロジェクト: OPM/ResInsight
    def test_extend_to_polyline(self):
        grid = EclGrid.createRectangular( (3,3,1) , (1 , 1 , 1))

        #  o   o   o   o
        #               
        #  o---o---o---o
        #  
        #  o===+   o   o
        #  |   
        #  o   o   o   o

        fault1 = Fault(grid , "Fault")

        fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "X-")
        fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "Y")

        polyline = CPolyline( init_points = [(0,2) , (3,2)])
        points = fault1.extendToPolyline( polyline , 0 )
        self.assertEqual( points , [(1,1) , (2,2)])

        end_join = fault1.endJoin( polyline , 0 )
        self.assertEqual( end_join, [(1,1) , (0,2)] )
        
        polyline2 = CPolyline( init_points = [(0.8,2) , (0.8,0.8)])
        end_join = fault1.endJoin( polyline2 , 0 )
        self.assertIsNone( end_join )
コード例 #17
0
ファイル: test_faults.py プロジェクト: OPM/ResInsight
    def test_join_faults(self):
        grid = EclGrid.createRectangular( (100,100,10) , (1,1,1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   -------  Fault2       |
        #      |                         |
        #      |                         |
        #
        #          -------- Fault3
        #

        fault1 = Fault(grid , "Fault1")
        fault2 = Fault(grid , "Fault2")
        fault3 = Fault(grid , "Fault3")
        fault4 = Fault(grid , "Fault4")

        fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X")
        fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y")
        fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y")
        fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X")

        rays = fault1.getEndRays(0)
        self.assertEqual( rays[0] , [(2,10) , (0,-1)])
        self.assertEqual( rays[1] , [(2,100) , (0,1)])
        
        extra = Fault.joinFaults( fault1 , fault3 , 0)
        self.assertEqual( extra , [(2,10) , (2,6) , (5,6)] )
コード例 #18
0
ファイル: test_faults.py プロジェクト: OPM/ResInsight
    def test_contact(self):
        grid = EclGrid.createRectangular( (100,100,10) , (1,1,1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   ----------------------+--  Fault2       
        #      |                         |
        #      |                         |
        #
        #          -------- Fault3
        #

        fault1 = Fault(grid , "Fault1")
        fault2 = Fault(grid , "Fault2")
        fault3 = Fault(grid , "Fault3")
        fault4 = Fault(grid , "Fault4")

        fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X")
        fault2.addRecord(5 , 30 , 15 , 15 , 0 , 0 , "Y")
        fault3.addRecord(2 , 10 , 9 , 9 , 0 , 0 , "Y")
        fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X")

        #self.assertFalse( fault1.intersectsFault(fault2 , 0) )
        #self.assertFalse( fault2.intersectsFault(fault1 , 0) )
        
        #self.assertTrue( fault2.intersectsFault(fault4 , 0) )        
        #self.assertTrue( fault4.intersectsFault(fault2 , 0) )

        self.assertTrue( fault1.intersectsFault(fault1 , 0) )        
コード例 #19
0
    def test_get_ijk(self):
        with TestAreaContext(
                "python/fault_block_layer/neighbour") as work_area:
            with open("kw.grdecl", "w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 0 0\n")
                fileH.write("1 2 2 0 3\n")
                fileH.write("4 2 2 3 3\n")
                fileH.write("4 4 4 0 0\n")
                fileH.write("4 4 4 0 5\n")
                fileH.write("/\n")
            with cwrap.open("kw.grdecl") as f:
                kw = EclKW.read_grdecl(f,
                                       "FAULTBLK",
                                       ecl_type=EclDataType.ECL_INT)

        grid = EclGrid.createRectangular((5, 5, 1), (1, 1, 1))
        layer = FaultBlockLayer(grid, 0)
        layer.loadKeyword(kw)

        block = layer[0, 0]
        self.assertEqual(block.getBlockID(), 1)

        block = layer[2, 2]
        self.assertEqual(block.getBlockID(), 2)

        with self.assertRaises(ValueError):
            layer[3, 3]

        with self.assertRaises(IndexError):
            layer[5, 5]
コード例 #20
0
    def test_add_polyline_barrier2(self):
        grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1))
        layer = FaultBlockLayer(self.grid, 0)
        polyline = Polyline(init_points=[(0.1, 0.9), (8.9, 0.9), (8.9, 8.9)])

        points = [
            ((0, 0), (0, 1)),
            ((2, 0), (2, 1)),
            ((4, 0), (4, 1)),
            ((6, 0), (6, 1)),
            ((8, 0), (8, 1)),
            #
            ((8, 1), (9, 1)),
            ((8, 3), (9, 3)),
            ((8, 5), (9, 5)),
            ((8, 7), (9, 7)),
        ]

        geo_layer = layer.getGeoLayer()
        for p1, p2 in points:
            self.assertTrue(geo_layer.cellContact(p1, p2))

        layer.addPolylineBarrier(polyline)
        for p1, p2 in points:
            print(p1, p2)
            self.assertFalse(geo_layer.cellContact(p1, p2))
コード例 #21
0
ファイル: test_fault_blocks.py プロジェクト: OPM/ResInsight
    def test_get_ijk(self):
        with TestAreaContext("python/fault_block_layer/neighbour") as work_area:
            with open("kw.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 0 0\n")
                fileH.write("1 2 2 0 3\n")
                fileH.write("4 2 2 3 3\n")
                fileH.write("4 4 4 0 0\n")
                fileH.write("4 4 4 0 5\n")
                fileH.write("/\n")
            with cwrap.open("kw.grdecl") as f:
                kw = EclKW.read_grdecl(
                    f, "FAULTBLK", ecl_type=EclDataType.ECL_INT)

        grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )
        layer.loadKeyword( kw )

        block = layer[0,0]
        self.assertEqual( block.getBlockID() , 1 )

        block = layer[2,2]
        self.assertEqual( block.getBlockID() , 2 )

        with self.assertRaises(ValueError):
            layer[3,3]

        with self.assertRaises(IndexError):
            layer[5,5]
コード例 #22
0
ファイル: test_layer.py プロジェクト: OPM/ResInsight
    def test_contact2(self):
        nx = 10
        ny = 10
        layer = Layer(nx,ny)
        grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) )

        # Too short
        with self.assertRaises(ValueError):
            layer.addIJBarrier( [(1,5)] )

        # Out of range
        with self.assertRaises(ValueError):
            layer.addIJBarrier( [(10,15),(5,5)] )

        # Out of range
        with self.assertRaises(ValueError):
            layer.addIJBarrier( [(7,7),(-5,5)] )
            
        # Must have either i1 == i2 or j1 == j2
        with self.assertRaises(ValueError):
            layer.addIJBarrier( [(7,8),(6,5)] )

        p1 = (0 , 4)
        p2 = (0 , 5)
        self.assertTrue(layer.cellContact( p1 , p2 ))
        layer.addIJBarrier( [(0,5) , (nx , 5)] )
        self.assertFalse(layer.cellContact( p1 , p2 ))
コード例 #23
0
ファイル: test_ecl_well.py プロジェクト: equinor/ecl
 def test_load_broken_direction(self):
     grid_path = self.createTestPath(
         "Equinor/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.EGRID")
     rst_path = self.createTestPath(
         "Equinor/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.UNRST")
     grid = EclGrid(grid_path)
     well_info = WellInfo(grid, rst_path)
コード例 #24
0
ファイル: test_region.py プロジェクト: OPM/ResInsight
    def test_truth_and_size(self):
        actnum = IntVector( initial_size = 100, default_value = 0)
        actnum[0:50] = 1
        grid = EclGrid.createRectangular( (10,10,1) , (1,1,1), actnum = actnum)
        region = EclRegion(grid, False)

        self.assertFalse( region )
        self.assertEqual( 0, region.active_size( ))
        self.assertEqual( 0, region.global_size( ))

        region.select_all( )
        self.assertTrue( region )
        self.assertEqual( 50, region.active_size( ))
        self.assertEqual( 100, region.global_size( ))
        
        region.deselect_all()
        self.assertFalse( region )
        self.assertEqual( 0, region.active_size( ))
        self.assertEqual( 0, region.global_size( ))
        
        region = EclRegion(grid, False)
        region.select_inactive()
        self.assertTrue( region )
        self.assertEqual( 0 , region.active_size( ))
        self.assertEqual( 50, region.global_size( ))
コード例 #25
0
    def test_boundingBox(self):
        grid = EclGrid.createRectangular((10,10,10) , (1,1,1))
        with self.assertRaises(ValueError):
            bbox = grid.getBoundingBox2D(layer = -1 )

        with self.assertRaises(ValueError):
            bbox = grid.getBoundingBox2D( layer = 11 )

        bbox = grid.getBoundingBox2D( layer = 10 )
        self.assertEqual( bbox , ((0,0) , (10, 0) , (10 , 10) , (0,10)))


        with self.assertRaises(ValueError):
            grid.getBoundingBox2D( lower_left = (-1,0) )

        with self.assertRaises(ValueError):
            grid.getBoundingBox2D( lower_left = (6,10) )

        bbox = grid.getBoundingBox2D( lower_left = (3,3) )
        self.assertEqual( bbox , ((3,3) , (10,3) , (10,10) , (3,10)))

        with self.assertRaises(ValueError):
            grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (2,2))

        bbox = grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (7,7))
        self.assertEqual( bbox , ((3,3) , (7,3) , (7,7) , (3,7)))
コード例 #26
0
ファイル: test_kw_function.py プロジェクト: OPM/ResInsight
    def test_region_filter(self):
        nx = 10
        ny = 10
        nz = 1
        actnum = IntVector( initial_size = nx*ny*nz , default_value = 1 )
        actnum[nx*ny - 1] = 0

        grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) , actnum = actnum)
        self.assertEqual( grid.getNumActive() , nx*ny*nz - 1 )

        kw = Ecl3DKW.create( "REGIONS" , grid , EclDataType.ECL_INT , global_active = True )
        kw.assign( 0 )
        kw[0:int(nx*ny/2)] = 1
        kw[5,2,0] = 0
        kw[0,9,0] = 2

        kw.fixUninitialized( grid )

        # Not assigned because they are in contact with a '2'; these
        # two are problem cells.
        self.assertEqual( kw[0,ny - 2,0] , 0)
        self.assertEqual( kw[1,ny - 1,0] , 0)

        # Not assigned because it is inactive
        self.assertEqual( kw[nx - 1,ny - 1,0] , 0)

        self.assertEqual( kw[5,2,0] , 1 )
        for j in range(5,10):
            self.assertEqual( kw[5,j,0] , 1 )

        for i in range(10):
            self.assertEqual( kw[i,7,0] , 1 )
コード例 #27
0
ファイル: test_faults.py プロジェクト: trhallam/ecl
    def test_polyline_intersection(self):
        grid = EclGrid.createRectangular((100, 100, 10), (0.25, 0.25, 1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   -------  Fault2       |
        #      |                         |
        #      |                         |
        #                              (5 , 2.50)
        #          -------- Fault3
        #

        fault1 = Fault(grid, "Fault1")
        fault2 = Fault(grid, "Fault2")
        fault3 = Fault(grid, "Fault3")
        fault4 = Fault(grid, "Fault4")

        fault1.addRecord(1, 1, 10, grid.getNY() - 1, 0, 0, "X")
        fault2.addRecord(5, 10, 15, 15, 0, 0, "Y")
        fault3.addRecord(5, 10, 5, 5, 0, 0, "Y")
        fault4.addRecord(20, 20, 10, grid.getNY() - 1, 0, 0, "X")

        polyline = Polyline(init_points=[(4, 4), (8, 4)])
        self.assertTrue(fault4.intersectsPolyline(polyline, 0))

        cpolyline = CPolyline(init_points=[(4, 4), (8, 4)])
        self.assertTrue(fault4.intersectsPolyline(cpolyline, 0))

        polyline = Polyline(init_points=[(8, 4), (16, 4)])
        self.assertFalse(fault4.intersectsPolyline(polyline, 0))

        cpolyline = CPolyline(init_points=[(8, 4), (16, 4)])
        self.assertFalse(fault4.intersectsPolyline(cpolyline, 0))
コード例 #28
0
ファイル: test_ecl_3dkw.py プロジェクト: OPM/ResInsight
    def test_setitem( self ):
        actnum = IntVector(default_value = 1 , initial_size = 1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum)
        kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT , default_value = 77)
        
        with self.assertRaises(IndexError):
            kw[1000]

        with self.assertRaises(IndexError):
            kw[0,10,100]

        with self.assertRaises(ValueError):
            kw[1,1]

        with self.assertRaises(ValueError):
            kw[1,1,1,1]

        kw.assign(99)
        self.assertEqual( kw[0,0,0] , 77 )
        self.assertEqual( kw[0,0,1] , 99 )

        
        with self.assertRaises(ValueError):
            kw[0,0,0] = 88
            
        kw[0,0,1] = 100 
        self.assertEqual( kw[0,0,1] , 100 )
コード例 #29
0
ファイル: ecl_grid_generator.py プロジェクト: OPM/ResInsight
    def create_single_cell_grid(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)]

        coord = [(corners[i], corners[i+4]) for i in range(4)]
        coord = flatten(flatten(coord))

        def construct_floatKW(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),
                construct_floatKW("ZCORN", zcorn),
                construct_floatKW("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
コード例 #30
0
ファイル: test_faults.py プロジェクト: trhallam/ecl
    def test_join_faults(self):
        grid = EclGrid.createRectangular((100, 100, 10), (1, 1, 1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   -------  Fault2       |
        #      |                         |
        #      |                         |
        #
        #          -------- Fault3
        #

        fault1 = Fault(grid, "Fault1")
        fault2 = Fault(grid, "Fault2")
        fault3 = Fault(grid, "Fault3")
        fault4 = Fault(grid, "Fault4")

        fault1.addRecord(1, 1, 10, grid.getNY() - 1, 0, 0, "X")
        fault2.addRecord(5, 10, 15, 15, 0, 0, "Y")
        fault3.addRecord(5, 10, 5, 5, 0, 0, "Y")
        fault4.addRecord(20, 20, 10, grid.getNY() - 1, 0, 0, "X")

        rays = fault1.getEndRays(0)
        self.assertEqual(rays[0], [(2, 10), (0, -1)])
        self.assertEqual(rays[1], [(2, 100), (0, 1)])

        extra = Fault.joinFaults(fault1, fault3, 0)
        self.assertEqual(extra, [(2, 10), (2, 6), (5, 6)])
コード例 #31
0
    def test_setitem(self):
        actnum = IntVector(default_value=1, initial_size=1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1),
                                         actnum=actnum)
        kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT, default_value=77)

        with self.assertRaises(IndexError):
            kw[1000]

        with self.assertRaises(IndexError):
            kw[0, 10, 100]

        with self.assertRaises(ValueError):
            kw[1, 1]

        with self.assertRaises(ValueError):
            kw[1, 1, 1, 1]

        kw.assign(99)
        self.assertEqual(kw[0, 0, 0], 77)
        self.assertEqual(kw[0, 0, 1], 99)

        with self.assertRaises(ValueError):
            kw[0, 0, 0] = 88

        kw[0, 0, 1] = 100
        self.assertEqual(kw[0, 0, 1], 100)
コード例 #32
0
ファイル: test_faults.py プロジェクト: trhallam/ecl
    def test_extend_to_polyline(self):
        grid = EclGrid.createRectangular((3, 3, 1), (1, 1, 1))

        #  o   o   o   o
        #
        #  o---o---o---o
        #
        #  o===+   o   o
        #  |
        #  o   o   o   o

        fault1 = Fault(grid, "Fault")

        fault1.addRecord(0, 0, 0, 0, 0, 0, "X-")
        fault1.addRecord(0, 0, 0, 0, 0, 0, "Y")

        polyline = CPolyline(init_points=[(0, 2), (3, 2)])
        points = fault1.extendToPolyline(polyline, 0)
        self.assertEqual(points, [(1, 1), (2, 2)])

        end_join = fault1.endJoin(polyline, 0)
        self.assertEqual(end_join, [(1, 1), (0, 2)])

        polyline2 = CPolyline(init_points=[(0.8, 2), (0.8, 0.8)])
        end_join = fault1.endJoin(polyline2, 0)
        self.assertIsNone(end_join)
コード例 #33
0
ファイル: make_data.py プロジェクト: berland/ert
def make_grid( ):
    grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) )
    if not os.path.isdir("grid"):
        os.makedirs("grid")
    grid.save_EGRID("grid/CASE.EGRID")

    return grid
コード例 #34
0
ファイル: test_faults.py プロジェクト: trhallam/ecl
    def test_connectWithPolyline(self):
        grid = EclGrid.createRectangular((4, 4, 1), (1, 1, 1))

        #  o   o   o   o   o
        #
        #  o   o   o   o   o
        #
        #  o---o---o---o---o
        #
        #  o   o   o   o   o
        #          |
        #  o   o   o   o   o

        fault1 = Fault(grid, "Fault1")
        fault1.addRecord(0, 3, 1, 1, 0, 0, "Y")

        fault2 = Fault(grid, "Fault2")
        fault2.addRecord(1, 1, 0, 0, 0, 0, "X")

        fault3 = Fault(grid, "Fault3")
        fault3.addRecord(1, 1, 0, 2, 0, 0, "X")

        self.assertIsNone(fault3.connect(fault1, 0))

        intersect = fault2.connect(fault1, 0)
        self.assertEqual(len(intersect), 2)
        p1 = intersect[0]
        p2 = intersect[1]

        self.assertEqual(p1, (2, 1))
        self.assertEqual(p2, (2, 2))
コード例 #35
0
    def test_no_mapaxes_check_for_nan(self):
        grid_paths = ["Statoil/ECLIPSE/NoMapaxes/ECLIPSE.EGRID", "Statoil/ECLIPSE/NoMapaxes/ECLIPSE.GRID"]

        for grid_path in grid_paths:
            test_grid_path = self.createTestPath(grid_path)
            grid = EclGrid(test_grid_path)

            xyz = grid.get_xyz(ijk=(0, 0, 0))
            self.assertFalse(math.isnan(xyz[0]))
            self.assertFalse(math.isnan(xyz[1]))
            self.assertFalse(math.isnan(xyz[2]))

            xyz = grid.get_xyz(ijk=(1, 1, 1))
            self.assertFalse(math.isnan(xyz[0]))
            self.assertFalse(math.isnan(xyz[1]))
            self.assertFalse(math.isnan(xyz[2]))
コード例 #36
0
    def test_cast(self):
        actnum = IntVector(default_value=1, initial_size=1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1),
                                         actnum=actnum)
        kw_wrong_size = EclKW("KW", 27, EclDataType.ECL_FLOAT)
        kw_global_size = EclKW("KW", grid.getGlobalSize(),
                               EclDataType.ECL_FLOAT)
        kw_active_size = EclKW("KW", grid.getNumActive(),
                               EclDataType.ECL_FLOAT)

        with self.assertRaises(ValueError):
            Ecl3DKW.castFromKW(kw_wrong_size, grid)

        Ecl3DKW.castFromKW(kw_global_size, grid)
        self.assertTrue(isinstance(kw_global_size, Ecl3DKW))

        Ecl3DKW.castFromKW(kw_active_size, grid, default_value=66)
        self.assertTrue(isinstance(kw_active_size, Ecl3DKW))

        self.assertEqual(kw_active_size[0, 0, 0], 66)
        with self.assertRaises(ValueError):
            kw_active_size[0, 0, 0] = 88
コード例 #37
0
    def test_create(self):
        ensemble_config = EnsembleConfig()
        obs = EnkfObs(ensemble_config)
        self.assertEqual(len(obs), 0)

        self.assertFalse(obs.valid)
        with self.assertRaises(ValueError):
            obs.load(self.obs_config)
        self.assertEqual(len(obs), 0)

        time_map = TimeMap()
        obs = EnkfObs(ensemble_config, external_time_map=time_map)
        self.assertEqual(len(obs), 0)

        grid = EclGrid(self.grid)
        refcase = EclSum(self.refcase)

        history = History(refcase, False)
        obs = EnkfObs(ensemble_config, grid=grid, history=history)
        self.assertTrue(obs.valid)
        with self.assertRaises(IOError):
            obs.load("/does/not/exist")

        obs.load(self.obs_config)
        self.assertTrue(obs.valid)
        self.assertEqual(len(obs), 33)
        obs.clear()
        self.assertEqual(len(obs), 0)

        obs.load(self.obs_config)
        self.assertEqual(len(obs), 33)
        self.assertNotIn("RFT2", obs)
        obs.load(self.obs_config2)
        self.assertEqual(len(obs), 35)
        self.assertIn("RFT2", obs)
コード例 #38
0
ファイル: test_kw_function.py プロジェクト: trhallam/ecl
    def test_region_filter(self):
        nx = 10
        ny = 10
        nz = 1
        actnum = IntVector(initial_size=nx * ny * nz, default_value=1)
        actnum[nx * ny - 1] = 0

        grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1), actnum=actnum)
        self.assertEqual(grid.getNumActive(), nx * ny * nz - 1)

        kw = Ecl3DKW.create("REGIONS", grid, EclDataType.ECL_INT, global_active=True)
        kw.assign(0)
        kw[0 : int(nx * ny / 2)] = 1
        kw[5, 2, 0] = 0
        kw[0, 9, 0] = 2

        kw.fixUninitialized(grid)

        # Not assigned because they are in contact with a '2'; these
        # two are problem cells.
        self.assertEqual(kw[0, ny - 2, 0], 0)
        self.assertEqual(kw[1, ny - 1, 0], 0)

        # Not assigned because it is inactive
        self.assertEqual(kw[nx - 1, ny - 1, 0], 0)

        self.assertEqual(kw[5, 2, 0], 1)
        for j in range(5, 10):
            self.assertEqual(kw[5, j, 0], 1)

        for i in range(10):
            self.assertEqual(kw[i, 7, 0], 1)
コード例 #39
0
ファイル: test_faults.py プロジェクト: trhallam/ecl
    def test_contact(self):
        grid = EclGrid.createRectangular((100, 100, 10), (1, 1, 1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   ----------------------+--  Fault2
        #      |                         |
        #      |                         |
        #
        #          -------- Fault3
        #

        fault1 = Fault(grid, "Fault1")
        fault2 = Fault(grid, "Fault2")
        fault3 = Fault(grid, "Fault3")
        fault4 = Fault(grid, "Fault4")

        fault1.addRecord(1, 1, 10, grid.getNY() - 1, 0, 0, "X")
        fault2.addRecord(5, 30, 15, 15, 0, 0, "Y")
        fault3.addRecord(2, 10, 9, 9, 0, 0, "Y")
        fault4.addRecord(20, 20, 10, grid.getNY() - 1, 0, 0, "X")

        # self.assertFalse( fault1.intersectsFault(fault2 , 0) )
        # self.assertFalse( fault2.intersectsFault(fault1 , 0) )

        # self.assertTrue( fault2.intersectsFault(fault4 , 0) )
        # self.assertTrue( fault4.intersectsFault(fault2 , 0) )

        self.assertTrue(fault1.intersectsFault(fault1, 0))
コード例 #40
0
    def test_rect(self):
        with TestAreaContext("python/grid-test/testRect"):
            a1 = 1.0
            a2 = 2.0
            a3 = 3.0
            grid = EclGrid.createRectangular((9, 9, 9), (a1, a2, a3))
            grid.save_EGRID("rect.EGRID")
            grid2 = EclGrid("rect.EGRID")
            self.assertTrue(grid)
            self.assertTrue(grid2)

            (x, y, z) = grid.get_xyz(ijk=(4, 4, 4))
            self.assertAlmostEqualList([x, y, z], [4.5 * a1, 4.5 * a2, 4.5 * a3])

            v = grid.cell_volume(ijk=(4, 4, 4))
            self.assertFloatEqual(v, a1 * a2 * a3)

            z = grid.depth(ijk=(4, 4, 4 ))
            self.assertFloatEqual(z, 4.5 * a3)

            g1 = grid.global_index(ijk=(2, 2, 2))
            g2 = grid.global_index(ijk=(4, 4, 4))
            (dx, dy, dz) = grid.distance(g2, g1)
            self.assertAlmostEqualList([dx, dy, dz], [2 * a1, 2 * a2, 2 * a3])

            self.assertTrue(grid.cell_contains(2.5 * a1, 2.5 * a2, 2.5 * a3, ijk=(2, 2, 2)))
コード例 #41
0
ファイル: test_faults.py プロジェクト: trhallam/ecl
    def test_extend_polyline_on(self):
        grid = EclGrid.createRectangular((3, 3, 1), (1, 1, 1))

        #  o   o   o   o
        #
        #  o---o---o---o
        #
        #  o===o===o===o
        #
        #  o   o   o   o

        fault1 = Fault(grid, "Fault")
        fault1.addRecord(0, 2, 0, 0, 0, 0, "Y")

        polyline0 = CPolyline(init_points=[(0, 2)])
        polyline1 = CPolyline(init_points=[(0, 2), (3, 2)])
        polyline2 = CPolyline(init_points=[(1, 3), (1, 2)])
        polyline3 = CPolyline(init_points=[(1, 3), (1, 0)])

        with self.assertRaises(ValueError):
            fault1.extendPolylineOnto(polyline0, 0)

        points = fault1.extendPolylineOnto(polyline1, 0)
        self.assertIsNone(points)

        points = fault1.extendPolylineOnto(polyline2, 0)
        self.assertEqual(points, [(1, 2), (1, 1)])

        points = fault1.extendPolylineOnto(polyline3, 0)
        self.assertIsNone(points)
コード例 #42
0
ファイル: ecl_grid_generator.py プロジェクト: OPM/ResInsight
    def create_grid(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.
        """

        zcorn = cls.create_zcorn(dims, dV, offset, escape_origo_shift,
                                irregular_offset, irregular, concave, faults)

        coord = cls.create_coord(dims, dV, escape_origo_shift, scale,
                                translation, rotate, misalign)

        return EclGrid.create(dims, zcorn, coord, None)
コード例 #43
0
    def create_grid(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.
        """

        zcorn = cls.create_zcorn(dims, dV, offset, escape_origo_shift,
                                irregular_offset, irregular, concave, faults)

        coord = cls.create_coord(dims, dV, escape_origo_shift, scale,
                                translation, rotate, misalign)

        return EclGrid.create(dims, zcorn, coord, None)
コード例 #44
0
    def test_save(self):
        with TestAreaContext("python/grid-test/testSave"):
            g1 = EclGrid(self.egrid_file())

            g1.save_EGRID("test.EGRID")
            g2 = EclGrid("test.EGRID")
            self.assertTrue(g1.equal(g2))

            g1.save_GRID("test.GRID")
            g2 = EclGrid("test.GRID")
            self.assertTrue(g1.equal(g2))

            fileH = copen("test.grdecl", "w")
            g1.save_grdecl(fileH)
            fileH.close()
            g2 = self.create("test.grdecl")
            self.assertTrue(g1.equal(g2))
コード例 #45
0
    def __init__(
        self,
        input_case: Union[Path, str],
        perforation_handling_strategy: str = "bottom_point",
    ):
        super().__init__()

        self._input_case: Path = Path(input_case)
        self._eclsum = EclSum(str(self._input_case))
        self._init = EclFile(str(self._input_case.with_suffix(".INIT")))
        self._grid = EclGrid(str(self._input_case.with_suffix(".EGRID")))
        self._restart = EclFile(str(self._input_case.with_suffix(".UNRST")))
        self._init = EclInitFile(self._grid,
                                 str(self._input_case.with_suffix(".INIT")))
        self._wells = compdat.df(EclFiles(str(self._input_case)))

        self._perforation_handling_strategy: str = perforation_handling_strategy
コード例 #46
0
ファイル: test_layer.py プロジェクト: OPM/ResInsight
    def test_fault_barrier(self):
        nx = 120
        ny = 60
        nz = 43
        grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) )
        with TestAreaContext("python/faults/line_order"):
            with open("faults.grdecl" , "w") as f:
                f.write("""FAULTS
\'F\'              105  107     50   50      1   43    \'Y\'    / 
\'F\'              108  108     50   50      1   43    \'X\'    /
\'F\'              108  108     50   50     22   43    \'Y\'    /
\'F\'              109  109     49   49      1   43    \'Y\'    /
\'F\'              110  110     49   49      1   43    \'X\'    /
\'F\'              111  111     48   48      1   43    \'Y\'    /
/
""")                
            with open("faults.grdecl") as f:
                faults = FaultCollection( grid , "faults.grdecl" )


        # Fault layout:                
        #
        # +---+---+---+---+
        #                 |
        #                 +---+   +  
        #                         |
        #                         +---+ 

        
        fault = faults["F"]
        layer = Layer(nx,ny)
        fault_pairs = [((104,49),(104,50)),
                       ((105,49),(105,50)),
                       ((106,49),(106,50)),
                       ((107,49),(108,49)),
                       ((107,49),(107,50)),
                       ((108,48),(108,49)),
                       ((109,48),(110,48)),
                       ((110,47),(110,48))]
        gap_pair = ((109,48),(109,49))


        for p1,p2 in fault_pairs:
            self.assertTrue(layer.cellContact( p1 , p2 ))

        p1,p2 = gap_pair
        self.assertTrue(layer.cellContact( p1 , p2 ))


        layer.addFaultBarrier(fault , 30 , link_segments = False)
        for p1,p2 in fault_pairs:
            self.assertFalse(layer.cellContact( p1 , p2 ))
        p1,p2 = gap_pair
        self.assertTrue(layer.cellContact( p1 , p2 ))

        layer.addFaultBarrier(fault , 30)
        p1,p2 = gap_pair
        self.assertFalse(layer.cellContact( p1 , p2 ))
コード例 #47
0
    def test_fault_barrier(self):
        nx = 120
        ny = 60
        nz = 43
        grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) )
        with TestAreaContext("python/faults/line_order"):
            with open("faults.grdecl" , "w") as f:
                f.write("""FAULTS
\'F\'              105  107     50   50      1   43    \'Y\'    / 
\'F\'              108  108     50   50      1   43    \'X\'    /
\'F\'              108  108     50   50     22   43    \'Y\'    /
\'F\'              109  109     49   49      1   43    \'Y\'    /
\'F\'              110  110     49   49      1   43    \'X\'    /
\'F\'              111  111     48   48      1   43    \'Y\'    /
/
""")                
            with open("faults.grdecl") as f:
                faults = FaultCollection( grid , "faults.grdecl" )


        # Fault layout:                
        #
        # +---+---+---+---+
        #                 |
        #                 +---+   +  
        #                         |
        #                         +---+ 

        
        fault = faults["F"]
        layer = Layer(nx,ny)
        fault_pairs = [((104,49),(104,50)),
                       ((105,49),(105,50)),
                       ((106,49),(106,50)),
                       ((107,49),(108,49)),
                       ((107,49),(107,50)),
                       ((108,48),(108,49)),
                       ((109,48),(110,48)),
                       ((110,47),(110,48))]
        gap_pair = ((109,48),(109,49))


        for p1,p2 in fault_pairs:
            self.assertTrue(layer.cellContact( p1 , p2 ))

        p1,p2 = gap_pair
        self.assertTrue(layer.cellContact( p1 , p2 ))


        layer.addFaultBarrier(fault , 30 , link_segments = False)
        for p1,p2 in fault_pairs:
            self.assertFalse(layer.cellContact( p1 , p2 ))
        p1,p2 = gap_pair
        self.assertTrue(layer.cellContact( p1 , p2 ))

        layer.addFaultBarrier(fault , 30)
        p1,p2 = gap_pair
        self.assertFalse(layer.cellContact( p1 , p2 ))
コード例 #48
0
ファイル: test_grid_pandas.py プロジェクト: xjules/libecl
    def test_dataframe_actnum(self):
        grid = EclGrid.create_rectangular((2, 3, 1), (1, 1, 1),
                                          actnum=[1, 1, 0, 0, 1, 1])
        df = grid.export_index(True)
        index_matrix = np.array([[0, 0, 0, 0], [1, 0, 0, 1], [0, 2, 0, 2],
                                 [1, 2, 0, 3]])
        assert (np.array_equal(df.values, index_matrix))

        kw_int_active = EclKW('int_act', 4, EclTypeEnum.ECL_INT_TYPE)
        kw_int_active[0] = 9
        kw_int_active[1] = 8
        kw_int_active[2] = 7
        kw_int_active[3] = 6
        data = grid.export_data(df, kw_int_active)
        assert (len(data) == 4)
        assert (np.array_equal(data, np.array([9, 8, 7, 6])))

        kw_float_active = EclKW('float_at', 4, EclTypeEnum.ECL_FLOAT_TYPE)
        kw_float_active[0] = 10.5
        kw_float_active[1] = 9.25
        kw_float_active[2] = 2.0
        kw_float_active[3] = 1.625
        data = grid.export_data(df, kw_float_active)
        assert (len(data) == 4)
        assert (np.array_equal(data, np.array([10.5, 9.25, 2.0, 1.625])))

        kw_int_global = EclKW('int_glob', 6, EclTypeEnum.ECL_INT_TYPE)
        kw_int_global[0] = 0
        kw_int_global[1] = 2
        kw_int_global[2] = 4
        kw_int_global[3] = 6
        kw_int_global[4] = 8
        kw_int_global[5] = 9
        data = grid.export_data(df, kw_int_global)
        assert (len(data) == 4)
        assert (np.array_equal(data, np.array([0, 2, 8, 9])))

        kw_double_global = EclKW('double_g', 6, EclTypeEnum.ECL_DOUBLE_TYPE)
        kw_double_global[0] = 1.1
        kw_double_global[1] = 2.2
        kw_double_global[2] = 3.3
        kw_double_global[3] = 4.4
        kw_double_global[4] = 5.5
        kw_double_global[5] = 6.6
        data = grid.export_data(df, kw_double_global)
        assert (np.array_equal(data, np.array([1.1, 2.2, 5.5, 6.6])))

        df = grid.export_index()  #DataFrame has now 6 rows
        global_index = df.index
        assert (np.array_equal(global_index, np.array([0, 1, 2, 3, 4, 5])))

        data = grid.export_data(df, kw_int_active, 9999)
        assert (np.array_equal(data, np.array([9, 8, 9999, 9999, 7, 6])))

        data = grid.export_data(df, kw_float_active, 2222.0)
        assert (np.array_equal(
            data, np.array([10.5, 9.25, 2222.0, 2222.0, 2.0, 1.625])))
コード例 #49
0
    def test_export(self):
        dims = (3, 3, 3)
        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)

        grid = EclGrid.create(dims, zcorn, coord, None)

        self.assertEqual(zcorn, grid.export_zcorn())
        self.assertEqual(coord, grid.export_coord())
コード例 #50
0
ファイル: test_ecl_well2.py プロジェクト: trhallam/ecl
    def getGrid(self):
        if EclWellTest2.grid is None:
            EclWellTest2.grid = EclGrid(
                self.createTestPath(
                    "Equinor/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID"
                )
            )

        return EclWellTest2.grid
コード例 #51
0
 def test_no_such_well(self):
     grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID")
     rst_path1 = self.createTestPath("nosuch/path/ECLIPSE.X001")
     rst_path2 = self.createTestPath("nosuch/path/ECLIPSE.X002")
     grid = EclGrid(grid_path)
     with self.assertRaises(IOError):
         _ = WellInfo(grid, rst_path1)
     with self.assertRaises(IOError):
         _ = WellInfo(grid, [rst_path1, rst_path2])
コード例 #52
0
    def loadGrid(self):
        grid_file   = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl")
        fileH = copen(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)
コード例 #53
0
ファイル: from_eclipse.py プロジェクト: rmozart/flownet
    def __init__(
        self,
        eclipse_case: Union[Path, str],
        resample: Optional[str] = None,
        perforation_handling_strategy: str = "bottom_point",
    ):
        super().__init__()

        self._eclipse_case: Path = Path(eclipse_case)
        self._eclsum = EclSum(str(self._eclipse_case))
        self._grid = EclGrid(str(self._eclipse_case.with_suffix(".EGRID")))
        self._restart = EclFile(str(self._eclipse_case.with_suffix(".UNRST")))
        self._wells = WellInfo(
            self._grid, rst_file=self._restart, load_segment_information=True
        )

        self._resample: Union[str, None] = resample
        self._perforation_handling_strategy: str = perforation_handling_strategy
コード例 #54
0
    def test_export(self):
        dims = (3, 3, 3)
        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)

        grid = EclGrid.create(dims, zcorn, coord, None)

        self.assertEqual(zcorn, grid.export_zcorn())
        self.assertEqual(coord, grid.export_coord())
コード例 #55
0
ファイル: test_grid_equinor.py プロジェクト: bska/ResInsight
    def test_volume_kw(self):
        grid = EclGrid(self.egrid_file())
        vol = grid.createVolumeKeyword( )
        self.assertEqual( len(vol) , grid.getNumActive())
        for active_index , volume in enumerate(vol):
            self.assertEqual( volume , grid.cell_volume( active_index = active_index ))

        vol = grid.createVolumeKeyword( active_size = False )
        self.assertEqual( len(vol) , grid.getGlobalSize())
        for global_index , volume in enumerate(vol):
            self.assertEqual( volume , grid.cell_volume( global_index = global_index ))
コード例 #56
0
    def test_subgrid_translation(self):
        grid = GridGen.create_grid((4,4,4), (1,1,1), offset=0.5,
                    irregular=True, irregular_offset=True, concave=True,
                    translation=(10,10,0))

        # Create grid with MAPAXES
        mapaxes = EclKW("MAPAXES", 6, EclDataType.ECL_FLOAT)
        for i, val in enumerate([1200, 1400, 2500, 2500, 3700, 4000]):
            mapaxes[i] = val

        grid = EclGrid.create(
                grid.getDims(),
                grid.export_zcorn(),
                grid.export_coord(),
                None,
                mapaxes=mapaxes
                )

        for translation in [
                (0,0,0),
                (10, 10, 100),
                (-1, -1, -1)
                ]:
            subgrid = GridGen.extract_subgrid(
                                        grid,
                                        ((0,3), (0,3), (0,3)),
                                        translation=translation
                                        )

            self.assertEqual(grid.getDims(), subgrid.getDims())

            translation = numpy.array(translation)
            for gindex in range(grid.getGlobalSize()):
                grid_corners = [
                                grid.getCellCorner(i, global_index=gindex)
                                for i in range(8)
                              ]

                subgrid_corners = [
                                subgrid.getCellCorner(i, global_index=gindex)
                                for i in range(8)
                                ]

                subgrid_corners = [
                                list(numpy.array(corner) - translation)
                                for corner in subgrid_corners
                                ]

                for gc, sc in zip(grid_corners, subgrid_corners):
                    self.assertAlmostEqualList(
                            gc,
                            sc,
                            msg="Failed to translate corners correctly." +
                                "Expected %s, was %s." % (gc, sc),
                            tolerance=10e-10
                            )
コード例 #57
0
    def extract_subgrid(cls, grid, ijk_bounds,
            decomposition_change=False, translation=None):

        """
        Extracts a subgrid from the given grid according to the specified
        bounds.

        @ijk_bounds: The bounds describing the subgrid. Should be a tuple of
        length 3, where each element gives the bound for the i, j, k
        coordinates of the subgrid to be described, respectively. Each bound
        should either be an interval of the form (a, b) where 0 <= a <= b < nx
        or a single integer a which is equivialent to the bound (a, a).

        NOTE: The given bounds are including endpoints.

        @decomposition_change: Depending on the given ijk_bounds, libecl might
        decompose the cells of the subgrid differently when extracted from
        grid. This is somewhat unexpected behaviour and if this event occur we
        give an exception together with an description for how to avoid this,
        unless decompostion_change is set to True.

        @translation: Gives the possibility of translating the subgrid. Should
        be given as a tuple (dx, dy, dz), where each coordinate of the grid
        will be moved by di in direction i.

        """

        gdims = grid.getDims()[:-1:]
        nx, ny, nz = gdims
        ijk_bounds = cls.assert_ijk_bounds(gdims, ijk_bounds)

        coord = grid.export_coord()
        cls.assert_coord(nx, ny, nz, coord, negative_values=True)

        zcorn = grid.export_zcorn()
        cls.assert_zcorn(nx, ny, nz, zcorn)

        actnum = grid.export_actnum()
        cls.assert_actnum(nx, ny, nz, actnum)

        mapaxes = grid.export_mapaxes()

        sub_data = cls.extract_subgrid_data(
                                    gdims,
                                    coord, zcorn,
                                    ijk_bounds=ijk_bounds,
                                    actnum=actnum,
                                    mapaxes=mapaxes,
                                    decomposition_change=decomposition_change,
                                    translation=translation
                                    )

        sdim = tuple([b-a+1 for a,b in ijk_bounds])
        sub_coord, sub_zcorn, sub_actnum = sub_data

        return EclGrid.create(sdim, sub_zcorn, sub_coord, sub_actnum, mapaxes=mapaxes)
コード例 #58
0
ファイル: test_grid_statoil.py プロジェクト: xjules/libecl
    def test_no_mapaxes_check_for_nan(self):
        grid_paths = [
            "Statoil/ECLIPSE/NoMapaxes/ECLIPSE.EGRID",
            "Statoil/ECLIPSE/NoMapaxes/ECLIPSE.GRID"
        ]

        for grid_path in grid_paths:
            test_grid_path = self.createTestPath(grid_path)
            grid = EclGrid(test_grid_path)

            xyz = grid.get_xyz(ijk=(0, 0, 0))
            self.assertFalse(math.isnan(xyz[0]))
            self.assertFalse(math.isnan(xyz[1]))
            self.assertFalse(math.isnan(xyz[2]))

            xyz = grid.get_xyz(ijk=(1, 1, 1))
            self.assertFalse(math.isnan(xyz[0]))
            self.assertFalse(math.isnan(xyz[1]))
            self.assertFalse(math.isnan(xyz[2]))
コード例 #59
0
 def test_add_polyline_barrier(self):
     d = 10
     layer = Layer(d, d)
     grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1))
     pl = CPolyline(init_points=[(0, 0), (d / 2, d / 2), (d, d)])
     layer.addPolylineBarrier(pl, grid, 0)
     for i in range(d):
         self.assertTrue(layer.bottomBarrier(i, i))
         if i < (d - 1):
             self.assertTrue(layer.leftBarrier(i + 1, i))