示例#1
0
文件: test_grid.py 项目: kgreg1/ert
 def test_create(self):
     with self.assertRaises(ValueError):
         grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = [0,1,1,2])
         
     with self.assertRaises(ValueError):
         grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = IntVector(initial_size = 10))
 
     actnum = IntVector(default_value = 1 , initial_size = 6000)
     actnum[0] = 0
     actnum[1] = 0
     grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = actnum)
     self.assertEqual( grid.getNumActive( ) , 30*20*10 - 2)
示例#2
0
文件: test_grid.py 项目: kgreg1/ert
 def test_numpy3D(self):
     nx = 10
     ny = 7
     nz = 5
     grid = GridGen.createRectangular((nx,ny,nz) , (1,1,1))
     kw = EclKW( "SWAT" , nx*ny*nz , EclDataType.ECL_FLOAT )
     numpy_3d = grid.create3D( kw )
示例#3
0
文件: test_grid.py 项目: kgreg1/ert
    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 )
示例#4
0
文件: test_grid.py 项目: kgreg1/ert
    def test_oom_grid(self):
        nx = 2000
        ny = 2000
        nz = 2000

        with self.assertRaises(MemoryError):
            grid = GridGen.createRectangular( (nx,ny,nz), (1,1,1))
示例#5
0
文件: test_grid.py 项目: kgreg1/ert
 def test_compressed_copy(self):
     nx = 10
     ny = 10
     nz = 10
     grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) )
     kw1 = EclKW("KW" , 1001 , EclDataType.ECL_INT )
     with self.assertRaises(ValueError):
         cp = grid.compressedKWCopy( kw1 )
示例#6
0
文件: test_grid.py 项目: kgreg1/ert
 def test_dims(self):
     grid = GridGen.createRectangular( (10,20,30) , (1,1,1) )
     self.assertEqual( grid.getNX() , 10 )
     self.assertEqual( grid.getNY() , 20 )
     self.assertEqual( grid.getNZ() , 30 )
     self.assertEqual( grid.getGlobalSize() , 30*10*20 )
 
     self.assertEqual( grid.getDims() , (10,20,30,6000) )
示例#7
0
文件: test_grid.py 项目: kgreg1/ert
 def test_dxdydz(self):
     nx = 10
     ny = 10
     nz = 10
     grid = GridGen.createRectangular( (nx,ny,nz) , (2,3,4) )
 
     (dx,dy,dz) = grid.getCellDims( active_index = 0 )
     self.assertEqual( dx , 2 )
     self.assertEqual( dy , 3 )
     self.assertEqual( dz , 4 )
示例#8
0
文件: test_grid.py 项目: kgreg1/ert
    def test_cell_corner_containment(self):
        n = 4
        d = 10
        grid = GridGen.createRectangular( (n, n, n), (d, d, d))

        for x, y, z in itertools.product(range(0, n*d+1, d), repeat=3):
            self.assertEqual(
                    1,
                    [grid.cell_contains(x, y, z, i) for i in range(n**3)].count(True)
                    )
示例#9
0
文件: test_grid.py 项目: kgreg1/ert
    def test_cell_corner_containment_compatability(self):
        grid = GridGen.createRectangular( (3,3,3), (1,1,1) )

        for x, y, z in itertools.product(range(4), repeat=3):
            for i in range(27):
                if grid.cell_contains(x, y, z, i):
                    self.assertEqual(
                            CORNER_HOME[(x,y,z)],
                            i
                            )
示例#10
0
文件: test_grid.py 项目: kgreg1/ert
 def test_truncated_file(self):
     grid = GridGen.createRectangular( (10,20,30) , (1,1,1) )
     with TestAreaContext("python/ecl_grid/truncated"):
         grid.save_EGRID( "TEST.EGRID")
 
         size = os.path.getsize( "TEST.EGRID")
         with open("TEST.EGRID" , "r+") as f:
             f.truncate( size / 2 )
 
         with self.assertRaises(IOError):
             EclGrid("TEST.EGRID")
示例#11
0
文件: test_grid.py 项目: kgreg1/ert
 def test_posXY1(self):
     nx = 4
     ny = 1
     nz = 1
     grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) )
     (i,j) = grid.findCellXY( 0.5 , 0.5, 0 )   
     self.assertEqual(i , 0)
     self.assertEqual(j , 0)
 
     (i,j) = grid.findCellXY( 3.5 , 0.5, 0 )   
     self.assertEqual(i , 3)
     self.assertEqual(j , 0)
示例#12
0
文件: test_grid.py 项目: kgreg1/ert
 def test_node_pos(self):
     grid = GridGen.createRectangular( (10,20,30) , (1,1,1) )
     with self.assertRaises(IndexError):
         grid.getNodePos(-1,0,0)
 
     with self.assertRaises(IndexError):
         grid.getNodePos(11,0,0)
 
     p0 = grid.getNodePos(0,0,0)
     self.assertEqual( p0 , (0,0,0))
 
     p7 = grid.getNodePos(10,20,30)
     self.assertEqual( p7 , (10,20,30))
示例#13
0
文件: test_grid.py 项目: kgreg1/ert
 def test_len(self):
     nx = 10
     ny = 11
     nz = 12
     actnum = EclKW( "ACTNUM" , nx*ny*nz , EclDataType.ECL_INT )
     actnum[0] = 1
     actnum[1] = 1
     actnum[2] = 1
     actnum[3] = 1
     
     grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1), actnum = actnum)
     self.assertEqual( len(grid) , nx*ny*nz )
     self.assertEqual( grid.getNumActive( ) , 4 )
示例#14
0
文件: test_grid.py 项目: kgreg1/ert
    def test_cell_face_containment(self):
        n = 4
        d = 10
        grid = GridGen.createRectangular( (n, n, n), (d, d, d))

        for x, y, z in itertools.product(range(d/2, n*d, d), repeat=3):
            for axis, direction in itertools.product(range(3), [-1, 1]):
                p = [x, y, z]
                p[axis] = p[axis] + direction*d/2
                self.assertEqual(
                        1,
                        [grid.cell_contains(p[0], p[1], p[2], i) for i in range(n**3)].count(True)
                    )
示例#15
0
文件: test_grid.py 项目: kgreg1/ert
 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(''))
示例#16
0
文件: test_grid.py 项目: kgreg1/ert
 def test_init_ACTNUM(self):
     nx = 10
     ny = 23
     nz = 7
     grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) )
     actnum = grid.exportACTNUM()
     
     self.assertEqual( len(actnum) , nx*ny*nz )
     self.assertEqual( actnum[0] , 1 )
     self.assertEqual( actnum[nx*ny*nz - 1] , 1 )
     
     actnum_kw = grid.exportACTNUMKw( )
     self.assertEqual(len(actnum_kw) , len(actnum))
     for a1,a2 in zip(actnum, actnum_kw):
         self.assertEqual(a1, a2)
示例#17
0
文件: test_grid.py 项目: kgreg1/ert
 def test_posXYEdge(self):
     nx = 10
     ny = 11
     grid = GridGen.createRectangular( (nx,ny,1) , (1,1,1) )
     self.assertEqual( grid.findCellCornerXY(0,0,0)  , 0 )
     self.assertEqual( grid.findCellCornerXY(nx,0,0) , nx)
     self.assertEqual( grid.findCellCornerXY(0 , ny , 0) , (nx + 1 ) * ny )
     self.assertEqual( grid.findCellCornerXY(nx,ny,0) , (nx + 1 ) * (ny + 1) - 1)
     
     self.assertEqual( grid.findCellCornerXY(0.25,0,0)  , 0 )
     self.assertEqual( grid.findCellCornerXY(0,0.25,0)  , 0 )
 
     self.assertEqual( grid.findCellCornerXY(nx - 0.25,0,0)  , nx )
     self.assertEqual( grid.findCellCornerXY(nx , 0.25,0)  , nx )
 
     self.assertEqual( grid.findCellCornerXY(0 , ny - 0.25, 0) , (nx + 1 ) * ny )
     self.assertEqual( grid.findCellCornerXY(0.25 , ny , 0) , (nx + 1 ) * ny )
 
     self.assertEqual( grid.findCellCornerXY(nx -0.25 ,ny,0) , (nx + 1 ) * (ny + 1) - 1)
     self.assertEqual( grid.findCellCornerXY(nx , ny - 0.25,0) , (nx + 1 ) * (ny + 1) - 1)
示例#18
0
文件: test_grid.py 项目: kgreg1/ert
 def test_posXY(self):
     nx = 10
     ny = 23
     nz = 7
     grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) )
     with self.assertRaises(IndexError):
         grid.findCellXY( 1 , 1, -1 )   
 
     with self.assertRaises(IndexError):
         grid.findCellXY( 1 , 1, nz + 1 )   
 
     with self.assertRaises(ValueError):
         grid.findCellXY(15 , 78 , 2)
     
         
     i,j = grid.findCellXY( 1.5 , 1.5 , 2 )
     self.assertEqual(i , 1)
     self.assertEqual(j , 1)
 
 
     for i in range(nx):
         for j in range(ny):
             p = grid.findCellXY(i + 0.5 , j+ 0.5 , 0)
             self.assertEqual( p[0] , i )
             self.assertEqual( p[1] , j )
     
     c = grid.findCellCornerXY( 0.10 , 0.10 , 0 )
     self.assertEqual(c , 0)
     
     c = grid.findCellCornerXY( 0.90 , 0.90 , 0 )
     self.assertEqual( c , (nx + 1) + 1 )
 
     c = grid.findCellCornerXY( 0.10 , 0.90 , 0 )
     self.assertEqual( c , (nx + 1) )
 
     c = grid.findCellCornerXY( 0.90 , 0.90 , 0 )
     self.assertEqual( c , (nx + 1) + 1 )
 
     c = grid.findCellCornerXY( 0.90 , 0.10 , 0 )
     self.assertEqual( c , 1 )
示例#19
0
 def test_EclRegion_properties(self):
     grid = EclGridGenerator.createRectangular((10, 10, 10), (1, 1, 1))
     region = EclRegion(grid, False)
示例#20
0
 def test_EclRegion_properties(self):
     grid = EclGridGenerator.createRectangular( (10,10,10) , (1,1,1))
     region = EclRegion( grid , False )