Beispiel #1
0
 def test_load(self):
     faults = FaultCollection(self.grid, self.faults1)
     self.assertEqual(3, len(faults))
     faults.load(self.faults2)
     self.assertEqual(7, len(faults))
     fault1 = faults["F1"]
     layer8 = fault1[8]
     self.assertEqual(len(layer8), 1)
Beispiel #2
0
 def test_load(self):
     faults = FaultCollection(self.grid , self.faults1)
     self.assertEqual( 3 , len(faults))
     faults.load( self.faults2 )
     self.assertEqual( 7 , len(faults))
     fault1 = faults["F1"]
     layer8 = fault1[8]
     self.assertEqual( len(layer8) , 1 ) 
Beispiel #3
0
def loadFaults(grid , fault_file):
    faults = FaultCollection( grid )
    faults.load( fault_file )        
    try:
        faults.load( fault_file )        
    except Exception as e:
        traceback.print_tb(e)
        print("Loading from fault file:%s failed" % fault_file)

    return faults
Beispiel #4
0
 def test_load(self):
     faults = FaultCollection(self.grid , self.faults1)
     self.assertEqual( 3 , len(faults))
     faults.load( self.grid , self.faults2 )
     self.assertEqual( 7 , len(faults))
     fault1 = faults["F1"]
     layer8 = fault1[8]
     self.assertEqual( len(layer8) , 1 ) 
 
     with self.assertRaises(IOError):
         faults.load(self.grid , "No/this/does/not/exist")
Beispiel #5
0
    def test_empty_collection(self):
        faults = FaultCollection(self.grid)
        self.assertEqual(0, len(faults))

        self.assertFalse(faults.hasFault("FX"))

        with self.assertRaises(TypeError):
            f = faults[[]]

        with self.assertRaises(KeyError):
            f = faults["FX"]

        with self.assertRaises(IndexError):
            f = faults[0]
Beispiel #6
0
    def test_empty_collection(self):
        faults = FaultCollection(self.grid)
        self.assertEqual(0 , len(faults))

        self.assertFalse( faults.hasFault("FX") )
        
        with self.assertRaises(TypeError):
            f = faults[ [] ]

        with self.assertRaises(KeyError):
            f = faults["FX"]

        with self.assertRaises(IndexError):
            f = faults[0]
Beispiel #7
0
 def test_iter(self):
     faults = FaultCollection(self.grid, self.faults1, self.faults2)
     self.assertEqual(7, len(faults))
     c = 0
     for f in faults:
         c += 1
     self.assertEqual(c, len(faults))
Beispiel #8
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))
Beispiel #9
0
    def test_splitLine(self):
        faults = FaultCollection(self.grid)
        with self.assertRaises(ValueError):
            # Not slash terminated
            t = faults.splitLine("'F1'             149  149     29   29      1   43    'Y'")

        with self.assertRaises(ValueError):
            # Not integer
            t = faults.splitLine("'F1'             149  149     29   29      1   43X    'Y' /")

        with self.assertRaises(ValueError):
            # Missing item
            t = faults.splitLine("'F1'             149     29   29      1   43    'Y' /")

        with self.assertRaises(ValueError):
            # Quote fuckup
            t = faults.splitLine("'F1             149     149 29   29      1   43    'X' /")
Beispiel #10
0
    def test_fault_barrier(self):
        nx = 120
        ny = 60
        nz = 43
        grid = EclGrid.create_rectangular( (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 ))
Beispiel #11
0
 def test_load(self):
     grid = self.loadGrid()
     faults_file = self.createTestPath(
         "Statoil/ECLIPSE/Faults/faults.grdecl")
     faults = FaultCollection(grid, faults_file)
     for fault in faults:
         for layer in fault:
             for fl in layer:
                 fl.verify()
Beispiel #12
0
 def test_iter(self):
     faults = FaultCollection(self.grid , self.faults1 , self.faults2)
     self.assertEqual( 7 , len(faults))
     c = 0
     for f in faults:
         c += 1
     self.assertEqual( c , len(faults))
     
     for f in ["F1","F2","F3" ,"F4"]:
         self.assertTrue( f in faults )
     
     self.assertFalse("FX" in faults )
Beispiel #13
0
    def test_internal_blocks(self):
        nx = 8
        ny = 8
        nz = 1
        grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )
        with TestAreaContext("python/FaultBlocks/internal_blocks"):
            with open("faultblock.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 4 4 1 2 5 5 2 \n")
                fileH.write("1 4 4 1 2 5 5 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 3 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("/\n")


            kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE)
            with open("faults.grdecl" , "w") as f:
                f.write("FAULTS\n")
                f.write("\'FX\'   4   4   1   4   1   1  'X'  /\n")
                f.write("\'FX\'   5   5   4   4   1   1  'Y'  /\n")
                f.write("\'FX\'   5   5   5   8   1   1  'X'  /\n")
                f.write("/")
            
            faults = FaultCollection( grid , "faults.grdecl")

        layer.loadKeyword( kw )
        layer.addFaultBarrier( faults["FX"] )
        b1 = layer.getBlock( 1 )
        b2 = layer.getBlock( 2 )
        b3 = layer.getBlock( 3 )
        b4 = layer.getBlock( 4 )
        b5 = layer.getBlock( 5 )


        nb = b1.getNeighbours()
        for b in nb:
            print('Block:%d' % b.getBlockID())

        self.assertTrue( len(nb) == 2 )
        self.assertTrue( b3 in nb )
        self.assertTrue( b4 in nb )

        nb = b2.getNeighbours()
        self.assertTrue( len(nb) == 1 )
        self.assertTrue( b5 in nb )
Beispiel #14
0
def loadFaults(grid , fault_file):
    faults = FaultCollection( grid )
    faults.load( fault_file )        
    try:
        faults.load( fault_file )        
    except Exception as e:
        traceback.print_tb(e)
        print("Loading from fault file:%s failed" % fault_file)

    return faults
Beispiel #15
0
 def test_load(self):
     faults = FaultCollection(self.grid , self.faults1)
     self.assertEqual( 3 , len(faults))
     faults.load( self.grid , self.faults2 )
     self.assertEqual( 7 , len(faults))
     fault1 = faults["F1"]
     layer8 = fault1[8]
     self.assertEqual( len(layer8) , 1 ) 
 
     with self.assertRaises(IOError):
         faults.load(self.grid , "No/this/does/not/exist")
Beispiel #16
0
    def test_contact(self):
        nx = 20
        ny = 10
        layer = Layer(nx,ny)
        grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) )
        
        with self.assertRaises(IndexError):
            layer.cellContact( (-1,0),(1,1) )

        with self.assertRaises(IndexError):
            layer.cellContact( (20,0),(1,1) )


        self.assertFalse( layer.cellContact((0,0) , (2,0)) )
        self.assertFalse( layer.cellContact((1,0) , (1,0)) )

        self.assertTrue( layer.cellContact((0,0) , (1,0)) )
        self.assertTrue( layer.cellContact((1,0) , (0,0)) )
        
        self.assertTrue( layer.cellContact((0,0) , (0,1)) )
        self.assertTrue( layer.cellContact((0,1) , (0,0)) )

        self.assertFalse( layer.cellContact((0,0) , (1,1)) )
        self.assertFalse( layer.cellContact((1,1) , (0,0)) )
        
        self.assertTrue( layer.cellContact((4,0) , (5,0)) )
        self.assertTrue( layer.cellContact((0,4) , (0,5)) )
        
        with TestAreaContext("Layer/barrier"):
            with open("faults.grdecl" , "w") as f:
                f.write("FAULTS\n")
                f.write("\'FX\'   5   5   1   10   1   1  'X'  /\n")
                f.write("\'FY\'   1   10   5   5   1   1  'Y'  /\n")
                f.write("/")
                
            faults = FaultCollection( grid , "faults.grdecl")
            
        layer.addFaultBarrier( faults["FX"] , 0 )
        self.assertFalse( layer.cellContact((4,0) , (5,0)) )

        layer.addFaultBarrier( faults["FY"] , 0 )
        self.assertFalse( layer.cellContact((0,4) , (0,5)) )

        self.assertFalse( layer.cellContact((9,4) , (9,5)) )
        self.assertTrue( layer.cellContact((10,4) , (10,5)) )
Beispiel #17
0
    def test_num_linesegment(self):
        nx = 10
        ny = 10
        nz = 1
        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
\'F1\'              1    4       2    2       1    1    \'Y\'    /
\'F1\'              6    8       2    2       1    1    \'Y\'    /
\'F2\'              1    8       2    2       1    1    \'Y\'    /
/
""")
            faults = FaultCollection(grid, "faults.grdecl")

            f1 = faults["F1"]
            f2 = faults["F2"]
            self.assertEqual(2, f1.numLines(0))
            self.assertEqual(1, f2.numLines(0))
    def setUp(self):
        self.grid = EclGrid(
            self.createTestPath("Statoil/ECLIPSE/Mariner/MARINER.EGRID"))

        with open(
                self.createTestPath(
                    "Statoil/ECLIPSE/Mariner/faultblock.grdecl")) as fileH:
            self.kw = EclKW.read_grdecl(fileH,
                                        "FAULTBLK",
                                        ecl_type=EclTypeEnum.ECL_INT_TYPE)

        self.faults = FaultCollection(
            self.grid,
            self.createTestPath("Statoil/ECLIPSE/Mariner/faults.grdecl"))
        self.poly_file1 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol1.xyz")
        self.poly_file2 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol2.xyz")
        self.poly_file3 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol3.xyz")
        self.poly_file4 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol4.xyz")
        self.poly_file5 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol5.xyz")
        self.poly_file6 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol6.xyz")
        self.poly_file7 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol7.xyz")
        self.poly_file8 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol8.xyz")
        self.poly_file9 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol9.xyz")
        self.poly_file10 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol10.xyz")
        self.poly_file11 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol11.xyz")

        self.fault_blocks = []
        for k in range(self.grid.getNZ()):
            blocks = FaultBlockLayer(self.grid, k)
            blocks.scanKeyword(self.kw)
            self.fault_blocks.append(blocks)
Beispiel #19
0
    def test_neighbours3(self):
        nx = 8
        ny = 8
        nz = 1
        grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1))
        layer = FaultBlockLayer(grid, 0)
        with TestAreaContext("python/FaultBlocks/neighbours"):
            with open("faultblock.grdecl", "w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("/\n")

            kw = EclKW.read_grdecl(open("faultblock.grdecl"),
                                   "FAULTBLK",
                                   ecl_type=EclTypeEnum.ECL_INT_TYPE)
            with open("faults.grdecl", "w") as f:
                f.write("FAULTS\n")
                f.write("\'FX\'   4   4   1   4   1   1  'X'  /\n")
                f.write("\'FX\'   5   5   5   8   1   1  'X'  /\n")
                f.write("/")

            faults = FaultCollection(grid, "faults.grdecl")
        layer.loadKeyword(kw)
        b1 = layer.getBlock(1)
        b2 = layer.getBlock(2)

        nb = b1.getNeighbours()
        self.assertTrue(b2 in nb)

        layer.addFaultBarrier(faults["FX"], link_segments=False)
        nb = b1.getNeighbours()
        self.assertTrue(b2 in nb)
Beispiel #20
0
    def test_splitLine(self):
        faults = FaultCollection(self.grid)
        with self.assertRaises(ValueError):
            # Not slash terminated
            t = faults.splitLine("'F1'             149  149     29   29      1   43    'Y'")

        with self.assertRaises(ValueError):
            # Not integer
            t = faults.splitLine("'F1'             149  149     29   29      1   43X    'Y' /")

        with self.assertRaises(ValueError):
            # Missing item
            t = faults.splitLine("'F1'             149     29   29      1   43    'Y' /")

        with self.assertRaises(ValueError):
            # Quote fuckup
            t = faults.splitLine("'F1             149     149 29   29      1   43    'X' /")
    def setUp(self):
        self.grid = EclGrid.create_rectangular((16, 16, 1), (1, 1, 1))
        self.poly1 = Polyline(init_points=[(0, 0), (0, 4), (5, 5), (0, 5)])
        self.poly2 = Polyline(init_points=[(11, 11), (16, 12), (16,
                                                                16), (12, 16)])
        self.fault_block_kw = EclKW.create("FAULTBLK",
                                           self.grid.getGlobalSize(),
                                           EclTypeEnum.ECL_INT_TYPE)
        self.fault_block_kw.assign(0)
        self.faults = FaultCollection(self.grid)
        for j in range(4):
            for i in range(4):
                g1 = i + j * self.grid.getNX()
                g2 = i + 12 + (j + 12) * self.grid.getNX()

                self.fault_block_kw[g1] = 1
                self.fault_block_kw[g2] = 2

        self.fault_blocks = []
        for k in range(self.grid.getNZ()):
            block = FaultBlockLayer(self.grid, k)
            block.scanKeyword(self.fault_block_kw)
            self.fault_blocks.append(block)
Beispiel #22
0
    def test_neighbours2(self):
        nx = 8
        ny = 8
        nz = 1
        grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )
        with TestAreaContext("python/FaultBlocks/neighbours"):
            with open("faultblock.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("3 3 3 3 2 2 2 2 \n")
                fileH.write("3 3 3 3 2 2 2 2 \n")
                fileH.write("3 3 3 3 2 2 2 2 \n")
                fileH.write("3 3 3 3 2 2 2 2 \n")
                fileH.write("/\n")
                
            kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE)
            with open("faults.grdecl" , "w") as f:
                f.write("FAULTS\n")
                f.write("\'FY\'   1   4   4   4   1   1  'Y'  /\n")
                f.write("\'FX\'   4   4   1   8   1   1  'X'  /\n")
                f.write("/")
            
            faults = FaultCollection( grid , "faults.grdecl")
        layer.loadKeyword( kw )
        b1 = layer.getBlock( 1 )
        b2 = layer.getBlock( 2 )
        b3 = layer.getBlock( 3 )

        nb = b1.getNeighbours()
        self.assertTrue( b2 in nb )
        self.assertTrue( b3 in nb )
        
        polylines1 = CPolylineCollection()
        p1 = polylines1.createPolyline(name="P1")
        p1.addPoint(4,0)
        p1.addPoint(4,4)
        p1.addPoint(4,8)
        nb = b1.getNeighbours( polylines = polylines1 )
        self.assertFalse( b2 in nb )
        self.assertTrue( b3 in nb )


        polylines2 = CPolylineCollection()
        p1 = polylines2.createPolyline(name="P2")
        p1.addPoint(0,4)
        p1.addPoint(4,4)
        nb = b1.getNeighbours( polylines = polylines2 )
        self.assertTrue( b2 in nb )
        self.assertFalse( b3 in nb )

        

        layer.addFaultBarrier( faults["FY"] )
        nb = b1.getNeighbours()
        self.assertTrue( b2 in nb )
        self.assertFalse( b3 in nb )
        
        layer.addFaultBarrier( faults["FX"] )
        nb = b1.getNeighbours()
        self.assertEqual( len(nb) , 0 )
Beispiel #23
0
    def test_neighbour_cells(self):
        nx = 10
        ny = 8
        nz = 7
        grid = EclGrid.create_rectangular( (nx , ny , nz) , (1,1,1) )
        faults_file = self.createTestPath("local/ECLIPSE/FAULTS/faults_nb.grdecl")
        faults = FaultCollection( grid , faults_file )

        fault = faults["FY"]
        self.assertEqual(len(fault),1)
        fault_layer = fault[0]

        fl1 = fault_layer[0]
        nb_cells1 = fl1.getNeighborCells()
        true_nb_cells1 = [(0, nx) , (1,nx + 1), (2,nx+2) , (3,nx + 3) , (4,nx+4)]
        self.assertListEqual( nb_cells1 , true_nb_cells1 )
        
        fl2 = fault_layer[1]
        nb_cells2 = fl2.getNeighborCells()
        true_nb_cells2 = [(6, nx+6) , (7,nx + 7), (8 , nx+8) , (9,nx + 9)]
        self.assertListEqual( nb_cells2 , true_nb_cells2 )
                               
        nb_cells = fault_layer.getNeighborCells()
        self.assertListEqual( nb_cells , true_nb_cells1  + true_nb_cells2)

        
        fault = faults["FY0"]
        fault_layer = fault[0]
        fl1 = fault_layer[0]
        nb_cells1 = fl1.getNeighborCells()
        true_nb_cells1 = [(-1,0) , (-1,1), (-1,2)]
        self.assertListEqual( nb_cells1 , true_nb_cells1 )


        fault = faults["FYNY"]
        fault_layer = fault[0]
        fl1 = fault_layer[0]
        nb_cells1 = fl1.getNeighborCells()
        true_nb_cells1 = [(nx * (ny - 1) , -1), (nx * (ny - 1) + 1 , -1), (nx * (ny - 1) + 2, -1)]
        self.assertListEqual( nb_cells1 , true_nb_cells1 )

        fault = faults["FX"]
        fault_layer = fault[0]
        fl1 = fault_layer[0]
        nb_cells1 = fl1.getNeighborCells()
        true_nb_cells1 = [(0,1) , (nx , nx+1) , (2*nx , 2*nx + 1)]
        self.assertListEqual( nb_cells1 , true_nb_cells1 )


        fault = faults["FX0"]
        fault_layer = fault[0]
        fl1 = fault_layer[0]
        nb_cells1 = fl1.getNeighborCells()
        true_nb_cells1 = [(-1 , 0) , (-1 , nx) , (-1 , 2*nx)]
        self.assertListEqual( nb_cells1 , true_nb_cells1 )

        fault = faults["FXNX"]
        fault_layer = fault[0]
        fl1 = fault_layer[0]
        nb_cells1 = fl1.getNeighborCells()
        true_nb_cells1 = [(nx -1 , -1) , (2*nx -1 , -1) , (3*nx - 1 , -1)]
        self.assertListEqual( nb_cells1 , true_nb_cells1 )
Beispiel #24
0
 def test_fault_line(self ):
     faults = FaultCollection(self.grid , self.faults1 , self.faults2)
     for fault in faults:
         for layer in fault:
             for fl in layer:
                 fl.verify()
Beispiel #25
0
    def test_collection_invalid_arg(self):
        with self.assertRaises(ValueError):
            faults = FaultCollection(self.faults1)

        with self.assertRaises(ValueError):
            faults = FaultCollection(self.faults1 , self.faults2)