def test_bulkvol_speed(): """Test cell bulk volume calculation speed.""" dimens = (100, 500, 50) grd = Grid() grd.create_box(dimension=dimens) grd._xtgformat2() t0 = xtg.timer() _ = grd.get_bulk_volume() ncells = np.prod(dimens) print(xtg.timer(t0), ncells)
def test_reverse_row_axis_box(tmpdir): """Crop a grid.""" grd = Grid() grd.create_box( origin=(1000, 4000, 300), increment=(100, 100, 2), dimension=(2, 3, 1), rotation=0, ) assert grd.ijk_handedness == "left" grd.to_file(join(tmpdir, "reverse_left.grdecl"), fformat="grdecl") grd.reverse_row_axis() assert grd.ijk_handedness == "right" grd.to_file(join(tmpdir, "reverse_right.grdecl"), fformat="grdecl")
def test_roffbin_bigbox(tmpdir): """Test roff binary for bigbox, to monitor performance""" bigbox = os.path.join(tmpdir, "bigbox.roff") if not os.path.exists(bigbox): logger.info("Create tmp big roff grid file...") grd0 = Grid() grd0.create_box(dimension=(500, 500, 100)) grd0.to_file(bigbox) grd1 = Grid() t0 = xtg.timer() grd1._xtgformat = 1 grd1.from_file(bigbox) t_old = xtg.timer(t0) logger.info("Reading bigbox xtgeformat=1 took %s seconds", t_old) cell1 = grd1.get_xyz_cell_corners((13, 14, 15)) grd2 = Grid() t0 = xtg.timer() t1 = xtg.timer() grd2._xtgformat = 2 grd2.from_file(bigbox) t_new = xtg.timer(t0) logger.info("Reading bigbox xtgformat=2 took %s seconds", t_new) cell2a = grd2.get_xyz_cell_corners((13, 14, 15)) t0 = xtg.timer() grd2._convert_xtgformat2to1() cell2b = grd2.get_xyz_cell_corners((13, 14, 15)) logger.info("Conversion to xtgformat1 took %s seconds", xtg.timer(t0)) t_newtot = xtg.timer(t1) logger.info("Total run time xtgformat=2 + conv took %s seconds", t_newtot) logger.info("Speed gain new vs old: %s", t_old / t_new) logger.info("Speed gain new incl conv vs old: %s", t_old / t_newtot) assert cell1 == cell2a assert cell1 == cell2b
def create_grid(*args, **kwargs): grid = Grid() grid.create_box(*args, **kwargs) return grid