Ejemplo n.º 1
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)))
Ejemplo n.º 2
0
    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())
Ejemplo n.º 3
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)))
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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))
Ejemplo n.º 8
0
    def test_geertsma_kernel():
        grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50))
        with TestAreaContext("Subsidence"):
            p1 = [1]
            create_restart(grid, "TEST", p1)
            create_init(grid, "TEST")

            init = EclFile("TEST.INIT")
            restart_file = EclFile("TEST.UNRST")

            restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1))

            subsidence = EclSubsidence(grid, init)
            subsidence.add_survey_PRESSURE("S1", restart_view1)

            youngs_modulus = 5E8
            poisson_ratio = 0.3
            seabed = 0
            above = 100
            topres = 2000
            receiver = (1000, 1000, 0)

            dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed)
            np.testing.assert_almost_equal(dz, 3.944214576168326e-09)

            receiver = (1000, 1000, topres - seabed - above)

            dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed)
            np.testing.assert_almost_equal(dz, 5.8160298201497136e-08)
Ejemplo n.º 9
0
    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)])
Ejemplo n.º 10
0
    def test_create(self):
        grid = EclGrid.createRectangular((10, 20, 5), (1, 1, 1))
        field_config = FieldConfig("PRESSURE", grid)
        block_obs = BlockObservation("P-CONFIG", field_config, grid)

        self.assertEqual(len(block_obs), 0)

        block_obs.addPoint(1, 2, 3, 100, 25)
        self.assertEqual(len(block_obs), 1)
        self.assertEqual(block_obs.getValue(0), 100)
        self.assertEqual(block_obs.getStd(0), 25)
        self.assertEqual(block_obs.getStdScaling(0), 1)

        block_obs.addPoint(1, 2, 4, 200, 50)
        self.assertEqual(len(block_obs), 2)
        self.assertEqual(block_obs.getValue(1), 200)
        self.assertEqual(block_obs.getStd(1), 50)
        self.assertEqual(block_obs.getStdScaling(1), 1)

        active_list = ActiveList()
        block_obs.updateStdScaling(0.50, active_list)
        self.assertEqual(block_obs.getStdScaling(0), 0.50)
        self.assertEqual(block_obs.getStdScaling(1), 0.50)

        active_list.addActiveIndex(1)
        block_obs.updateStdScaling(2.00, active_list)
        self.assertEqual(block_obs.getStdScaling(0), 0.50)
        self.assertEqual(block_obs.getStdScaling(1), 2.00)
Ejemplo n.º 11
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
Ejemplo n.º 12
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")

            kw = EclKW.read_grdecl(open("kw.grdecl"),
                                   "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]
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
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))
Ejemplo n.º 15
0
    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))
Ejemplo n.º 16
0
    def test_sum(self):
        grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1))
        kw_mask = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT)
        int_value = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT)
        float_value = EclKW("FLOAT", grid.getGlobalSize(),
                            EclDataType.ECL_FLOAT)
        double_value = EclKW("DOUBLE", grid.getGlobalSize(),
                             EclDataType.ECL_DOUBLE)
        bool_value = EclKW("BOOL", grid.getGlobalSize(), EclDataType.ECL_BOOL)

        kw_mask[0:50] = 1

        for i in range(len(int_value)):
            float_value[i] = i
            double_value[i] = i
            int_value[i] = i
            bool_value[i] = True

        region = EclRegion(grid, False)
        region.select_equal(kw_mask, 1)

        self.assertEqual(int_value.sum(), 99 * 100 / 2)
        self.assertEqual(int_value.sum(mask=region), 49 * 50 / 2)
        self.assertEqual(double_value.sum(mask=region), 1.0 * 49 * 50 / 2)
        self.assertEqual(float_value.sum(mask=region), 1.0 * 49 * 50 / 2)
        self.assertEqual(bool_value.sum(mask=region), 50)
Ejemplo n.º 17
0
    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))
Ejemplo n.º 18
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)
Ejemplo n.º 19
0
    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))
Ejemplo n.º 20
0
    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))
Ejemplo n.º 21
0
    def test_geertsma_kernel_2_source_points_2_vintages():
        grid = EclGrid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100))

        with TestAreaContext("Subsidence"):
            p1 = [1, 10]
            p2 = [10, 20]
            create_restart(grid, "TEST", p1, p2)
            create_init(grid, "TEST")

            init = EclFile("TEST.INIT")
            restart_file = EclFile("TEST.UNRST")

            restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1))
            restart_view2 = restart_file.restartView(sim_time=datetime.date(2010, 1, 1))

            subsidence = EclSubsidence(grid, init)
            subsidence.add_survey_PRESSURE("S1", restart_view1)
            subsidence.add_survey_PRESSURE("S2", restart_view2)

            youngs_modulus = 5E8
            poisson_ratio = 0.3
            seabed = 0
            receiver = (1000, 1000, 0)

            dz1 = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed)
            np.testing.assert_almost_equal(dz1, 8.65322541521704e-07)

            dz2 = subsidence.evalGeertsma("S2", None, receiver, youngs_modulus, poisson_ratio, seabed)
            np.testing.assert_almost_equal(dz2, 2.275556615015282e-06)

            np.testing.assert_almost_equal(dz1-dz2, -1.4102340734935779e-06)

            dz = subsidence.evalGeertsma("S1", "S2", receiver, youngs_modulus, poisson_ratio, seabed)
            np.testing.assert_almost_equal(dz, dz1-dz2)
Ejemplo n.º 22
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 openEclFile("G.EGRID") as f:
                with open("grid.grdecl" , "w") as f2:
                    f2.write("SPECGRID\n")
                    f2.write("  10  10  10  \'F\' /\n")

                    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 ))
Ejemplo n.º 23
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 ))
Ejemplo n.º 24
0
    def test_create( 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 )
        self.assertEqual( len(kw) , grid.getNumActive())

        self.assertEqual( (10,10,10) , kw.dims() )
Ejemplo n.º 25
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))
Ejemplo n.º 26
0
    def test_fault_block_edge(self):
        grid = EclGrid.createRectangular((5, 5, 1), (1, 1, 1))
        kw = EclKW("FAULTBLK", grid.getGlobalSize(), EclDataType.ECL_INT)
        kw.assign(0)
        for j in range(1, 4):
            for i in range(1, 4):
                g = i + j * grid.getNX()
                kw[g] = 1

        layer = FaultBlockLayer(grid, 0)
Ejemplo n.º 27
0
    def test_connect_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")

        
        for other_fault in [fault2 , fault3,fault4]:
            with self.assertRaises(ValueError):
                fault1.extendToFault( other_fault ,0)

        with self.assertRaises(ValueError):
            fault2.extendToFault( fault3 , 0)

        for other_fault in [fault1 , fault2,fault4]:
            with self.assertRaises(ValueError):
                fault3.extendToFault( other_fault ,0 )

        for other_fault in [fault1 , fault2,fault3]:
            with self.assertRaises(ValueError):
                fault4.extendToFault( other_fault , 0)

        ext21 = fault2.extendToFault( fault1 , 0)
        self.assertEqual(len(ext21) , 2)
        p0 = ext21[0]
        p1 = ext21[1]
        self.assertEqual(p0 , (5 , 16))
        self.assertEqual(p1 , (2 , 16))
        
    
        ext24 = fault2.extendToFault( fault4,0 )
        self.assertEqual(len(ext24) , 2)
        p0 = ext24[0]
        p1 = ext24[1]
        self.assertEqual(p0 , (11 , 16))
        self.assertEqual(p1 , (21 , 16))
Ejemplo n.º 28
0
    def test_PolylineIJ(self):
        nx = 10
        ny = 10
        nz = 10
        grid = EclGrid.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1))
        f = Fault(grid, "F")
        f.addRecord(0, 1, 0, 0, 0, 0, "Y-")
        f.addRecord(2, 2, 0, 1, 0, 0, "X-")
        f.addRecord(2, 2, 1, 1, 0, 0, "Y")

        pl = f.getIJPolyline(0)
        self.assertEqual(pl, [(0, 0), (2, 0), (2, 2), (3, 2)])
Ejemplo n.º 29
0
    def test_neighbours(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")

            kw = EclKW.read_grdecl(open("kw.grdecl"),
                                   "FAULTBLK",
                                   ecl_type=EclDataType.ECL_INT)

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

        layer.loadKeyword(kw)
        block1 = layer.getBlock(1)
        block2 = layer.getBlock(2)
        block3 = layer.getBlock(3)
        block4 = layer.getBlock(4)
        block5 = layer.getBlock(5)
        self.assertEqual(block1.getParentLayer(), layer)

        #Expected: 1 -> {2,4}, 2 -> {1,3,4}, 3 -> {2}, 4 -> {1,2}, 5-> {}

        neighbours = block1.getNeighbours()
        self.assertEqual(len(neighbours), 2)
        self.assertTrue(block2 in neighbours)
        self.assertTrue(block4 in neighbours)

        neighbours = block2.getNeighbours()
        self.assertEqual(len(neighbours), 3)
        self.assertTrue(block1 in neighbours)
        self.assertTrue(block3 in neighbours)
        self.assertTrue(block4 in neighbours)

        neighbours = block3.getNeighbours()
        self.assertEqual(len(neighbours), 1)
        self.assertTrue(block2 in neighbours)

        neighbours = block4.getNeighbours()
        self.assertEqual(len(neighbours), 2)
        self.assertTrue(block1 in neighbours)
        self.assertTrue(block2 in neighbours)

        neighbours = block5.getNeighbours()
        self.assertEqual(len(neighbours), 0)
Ejemplo n.º 30
0
    def setUp(self):
        self.grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1))
        self.kw = EclKW("FAULTBLK", self.grid.getGlobalSize(),
                        EclDataType.ECL_INT)
        self.kw.assign(1)

        reg = EclRegion(self.grid, False)

        for k in range(self.grid.getNZ()):
            reg.clear()
            reg.select_kslice(k, k)
            self.kw.assign(k, mask=reg)
            self.kw[k * self.grid.getNX() * self.grid.getNY() + 7] = 177
Ejemplo n.º 31
0
    def test_active(self):
        d = 10
        layer = Layer(d, d)
        with self.assertRaises(ValueError):
            layer.activeCell(d + 1, d + 2)

        self.assertTrue(layer.activeCell(1, 2))

        grid = EclGrid.createRectangular((d, d + 1, 1), (1, 1, 1))
        with self.assertRaises(ValueError):
            layer.updateActive(grid, 0)

        grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1))
        with self.assertRaises(ValueError):
            layer.updateActive(grid, 10)

        actnum = IntVector(initial_size=d * d * 1, default_value=1)
        actnum[0] = 0
        grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1), actnum=actnum)
        layer.updateActive(grid, 0)
        self.assertTrue(layer.activeCell(1, 2))
        self.assertFalse(layer.activeCell(0, 0))