def setUp(self): parser = Parser() deck = parser.parse(test_path('spe3/SPE3CASE1.DATA')) int_array = np.ones(324) actnum_kw = DeckKeyword(parser["ACTNUM"], int_array) deck.add(actnum_kw) self.spe3 = EclipseState(deck) self.props = self.spe3.field_props()
def test_parse_norne(self): parse_context = ParseContext( [('PARSE_RANDOM_SLASH', opm.io.action.ignore)] ) deck = Parser().parse(self.norne_fname, parse_context) es = EclipseState( deck ) self.assertEqual(46, es.grid().nx) self.assertEqual(112, es.grid().ny) self.assertEqual(22, es.grid().nz)
def setUpClass(cls): parser = Parser() cls.deck_cpa = parser.parse(test_path('data/CORNERPOINT_ACTNUM.DATA')) cls.cp_state = EclipseState(cls.deck_cpa) cls.deck_spe3 = parser.parse(test_path('spe3/SPE3CASE1.DATA')) cls.state = EclipseState(cls.deck_spe3) cls.schedule = Schedule(cls.deck_spe3, cls.state) cls.summary_config = SummaryConfig(cls.deck_spe3, cls.state, cls.schedule)
def test_faults(self): self.assertEquals([], self.state.faultNames()) parser = Parser() faultdeck = parser.parse_string(self.FAULTS_DECK) faultstate = EclipseState(faultdeck) self.assertEqual(['F1', 'F2'], faultstate.faultNames()) # 'F2' 5 5 1 4 1 4 'X-' / \n" f2 = faultstate.faultFaces('F2') self.assertTrue((4, 0, 0, 'X-') in f2) self.assertFalse((3, 0, 0, 'X-') in f2)
def setUpClass(cls): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) print("Creating state") cls.state = EclipseState(deck) print("State OK") cls.sch = Schedule(deck, cls.state) cls.timesteps = cls.sch.timesteps
def test_all(self): with pushd(self.data_dir): self.deck = Parser().parse('SPE1CASE1.DATA') state = EclipseState(self.deck) self.schedule = Schedule(self.deck, state) summary_config = SummaryConfig(self.deck, state, self.schedule) self.unit_system = self.deck.active_unit_system() self.assertTrue('PROD' in self.schedule) self.assertTrue('INJ' in self.schedule) self.assertEqual(dt.datetime(2015, 1, 1), self.schedule.start) self.assertEqual(dt.datetime(2016, 1, 1), self.schedule.end) self.sim = BlackOilSimulator(self.deck, state, self.schedule, summary_config) tsteps = self.schedule.timesteps self.assertEqual(dt.datetime(2015, 1, 1), tsteps[0]) last_step = len(tsteps) - 1 self.assertEqual(dt.datetime(2016, 1, 1), tsteps[last_step]) self.sim.step_init() report_step = 4 self.sim.advance(report_step=report_step) well_name = "PROD" prod = self.schedule.get_well(well_name, 2) self.assertEqual(prod.status(), "OPEN") #schedule.shut_well("PROD", 3) #prod = schedule.get_well("PROD", 3) #self.assertEqual(prod.status(), "SHUT") self.subtest_modify_prod_weltarg_dynamically( well_name, report_step) self.sim.step() report_step = self.sim.current_step() well_name = "INJ" self.subtest_modify_inj_weltarg_dynamically(well_name, report_step) self.sim.advance(report_step=last_step) self.sim.step_cleanup()
def test_well_names(self): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) state = EclipseState(deck) sch = Schedule(deck, state) wnames = sch.well_names("*") self.assertTrue("PROD" in wnames) self.assertTrue("INJ" in wnames) self.assertEqual(len(wnames), 2)
def test_parse_with_multiple_recoveries(self): recoveries = [("PARSE_RANDOM_SLASH", opm.io.action.ignore), ("FOO", opm.io.action.warn), ("PARSE_RANDOM_TEXT", opm.io.action.throw)] parse_context = ParseContext(recoveries) deck = Parser().parse(self.spe3fn, parse_context) state = EclipseState(deck)
def parse(fname): s = dt.now() ps = ParseContext([('PARSE_RANDOM_SLASH', opm.io.action.ignore)]) deck = Parser().parse(fname, ps) es = EclipseState(deck) e = dt.now() print('Parsing took %s sec' % (e - s).seconds) return es
def main(): deck = parse(join(opmdatadir(), 'norne/NORNE_ATW2013.DATA')) es = EclipseState(deck) sc = Schedule(deck, es) wp = sc.get_wells(100)[20] wi = sc.get_wells(100)[19] fn = es.faultNames() f0 = fn[0] fl = es.faultFaces(f0) print('state: %s' % es) print('schedule: %s' % sc) print('the grid: %s' % es.grid()) print('at timestep 100 (%s)' % sc.timesteps[100]) print('prod well: %s' % wp) print('inj well: %s' % wi) print('pos: %s' % list(wp.pos())) print('fault: %s' % f0) print(' comprised of %d cells' % len(fl)) swof_krw(es)
def test_open_shut(self): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) state = EclipseState(deck) sch = Schedule(deck, state) prod = sch.get_well("PROD", 1) self.assertEqual(prod.status(), "OPEN") sch.shut_well("PROD", 10) prod = sch.get_well("PROD", 10) self.assertEqual(prod.status(), "SHUT")
def test_getitem(self): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) state = EclipseState(deck) sch = Schedule(deck, state) self.assertEqual(len(sch), 176) with self.assertRaises(IndexError): a = sch[200] st100 = sch[100] nupcol = st100.nupcol
def test_production_properties(self): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) state = EclipseState(deck) sch = Schedule(deck, state) report_step = 4 well_name = 'PROD' prop = sch.get_production_properties(well_name, report_step) self.assertEqual(prop['alq_value'], 0.0) self.assertEqual(prop['bhp_target'], 500.0) self.assertEqual(prop['gas_rate'], 6200.0) self.assertEqual(prop['liquid_rate'], 0.0) self.assertEqual(prop['oil_rate'], 0.0) self.assertEqual(prop['resv_rate'], 0.0) self.assertEqual(prop['thp_target'], 0.0) self.assertEqual(prop['water_rate'], 0.0)
def main(): deck = Parser().parse('../tests/spe3/SPE3CASE1.DATA') es = EclipseState(deck) sc = Schedule(deck, es) wp = sc.get_wells(0)[0] # producer wi = sc.get_wells(0)[1] # injector print('state: %s' % es) print('schedule: %s' % sc) print('prod well: %s' % wp) print('inj well: %s' % wi) for i in range(len(sc.timesteps)): if not sc.get_wells(i)[0].isproducer() or sc.get_wells(i)[0].isinjector(): print('wp is not producer in step %s' % sc.timesteps[i]) if not sc.get_wells(i)[1].isinjector() or sc.get_wells(i)[1].isproducer(): print('wi is not injector in step %s' % sc.timesteps[i])
def test_injection_properties(self): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) state = EclipseState(deck) sch = Schedule(deck, state) report_step = 4 well_name = 'INJ' prop = sch.get_injection_properties(well_name, report_step) self.assertEqual(prop['surf_inj_rate'], 4700.0) # Mscf/day self.assertEqual(prop['resv_inj_rate'], 0.0) # rb/day self.assertEqual(prop['bhp_target'], 4000.0) # psi self.assertEqual(prop['thp_target'], 0.0) with self.assertRaises(IndexError): prop = sch.get_injection_properties("UNDEF", report_step) with self.assertRaises(KeyError): prop = sch.get_injection_properties("PROD", report_step)
def test_jfunc(self): # jf["FLAG"] = WATER; # set in deck # jf["DIRECTION"] = XY; # default # jf["ALPHA_FACTOR"] = 0.5 # default # jf["BETA_FACTOR"] = 0.5 # default # jf["OIL_WATER"] = 21.0 # set in deck # jf["GAS_OIL"] = -1.0 # N/A parser = Parser() deck = parser.parse(test_path('data/JFUNC.DATA')) js = EclipseState(deck) self.assertEqual('JFUNC TEST', js.title) jf = js.jfunc() print(jf) self.assertEqual(jf['FLAG'], 'WATER') self.assertEqual(jf['DIRECTION'], 'XY') self.assertFalse('GAS_OIL' in jf) self.assertTrue('OIL_WATER' in jf) self.assertEqual(jf['OIL_WATER'], 21.0) self.assertEqual(jf["ALPHA_FACTOR"], 0.5) # default self.assertEqual(jf["BETA_FACTOR"], 0.5) # default jfunc_gas = """ DIMENS 10 10 10 / ENDSCALE / GRID DX 1000*0.25 / DY 1000*0.25 / DZ 1000*0.25 / TOPS 100*0.25 / PORO 1000*0.15 / JFUNC GAS * 13.0 0.6 0.7 Z / PROPS\nREGIONS """ deck2 = parser.parse_string(jfunc_gas) js_gas = EclipseState(deck2) jf = js_gas.jfunc() self.assertEqual(jf['FLAG'], 'GAS') self.assertEqual(jf['DIRECTION'], 'Z') self.assertTrue('GAS_OIL' in jf) self.assertFalse('OIL_WATER' in jf) self.assertEqual(jf['GAS_OIL'], 13.0) self.assertEqual(jf["ALPHA_FACTOR"], 0.6) # default self.assertEqual(jf["BETA_FACTOR"], 0.7) # default
def test_all(self): with pushd(self.data_dir): deck = Parser().parse('SPE1CASE1.DATA') state = EclipseState(deck) schedule = Schedule(deck, state) summary_config = SummaryConfig(deck, state, schedule) self.assertTrue('PROD' in schedule) self.assertTrue('INJ' in schedule) self.assertEqual(dt.datetime(2015, 1, 1), schedule.start) self.assertEqual(dt.datetime(2016, 1, 1), schedule.end) sim = BlackOilSimulator(deck, state, schedule, summary_config) sim.step_init() sim.step() prod = schedule.get_well("PROD", 2) self.assertEqual(prod.status(), "OPEN") #schedule.shut_well("PROD", 3) #prod = schedule.get_well("PROD", 3) #self.assertEqual(prod.status(), "SHUT") sim.step() sim.step()
def setUp(self): parser = Parser() deck = parser.parse(test_path('spe3/SPE3CASE1.DATA')) self.spe3 = EclipseState(deck) self.props = self.spe3.props()
class TestProps(unittest.TestCase): def assertClose(self, expected, observed, epsilon=1e-08): diff = abs(expected - observed) err_msg = '|%g - %g| = %g > %g' % (expected, observed, diff, epsilon) self.assertTrue(diff <= epsilon, msg=err_msg) def setUp(self): parser = Parser() deck = parser.parse(test_path('spe3/SPE3CASE1.DATA')) self.spe3 = EclipseState(deck) self.props = self.spe3.props() def test_contains(self): p = self.props self.assertTrue('PORO' in p) self.assertFalse('NONO' in p) self.assertTrue('PORV' in p) # auto generated def test_getitem(self): p = self.props poro = p['PORO'] self.assertEqual(324, len(poro)) self.assertEqual(0.13, poro[0]) self.assertTrue('PERMX' in p) px = p['PERMX'] print(len(px)) self.assertEqual(324, len(px)) def test_permx_values(self): def md2si(md): #millidarcy->SI return md * 1e-3 * 9.869233e-13 e3dp = self.props grid = self.spe3.grid() permx = e3dp['PERMX'] print('set(PERMX) = %s' % set(permx)) # 130mD, 40mD, 20mD, and 150mD, respectively, top to bottom darcys = {0: md2si(130), 1: md2si(40), 2: md2si(20), 3: md2si(150)} for i in range(grid.nx): for j in range(grid.ny): for k in range(grid.nz): g_idx = grid.globalIndex(i, j, k) perm = permx[g_idx] darcy = darcys[k] self.assertClose(darcy, perm) def test_volume(self): e3dp = self.props grid = self.spe3.grid() for i in range(grid.nx): for j in range(grid.ny): for k in range(grid.nz): g_idx = grid.globalIndex(i, j, k) exp = 293.3 * 293.3 * 30 # cubicfeet = 73 078.6084 cubic meter exp *= (12 * 0.0254)**3 # cubic feet to cubic meter if k == 0: self.assertClose(exp, grid.getCellVolume(g_idx)) self.assertEqual(grid.getCellVolume(g_idx), grid.getCellVolume(i, j, k))
def test_parse_with_recovery(self): recovery = [("PARSE_RANDOM_SLASH", opm.io.action.ignore)] parse_context = ParseContext(recovery) deck = Parser().parse(self.spe3fn, parse_context) state = EclipseState(deck)
def test_parse(self): deck = Parser().parse(self.spe3fn) state = EclipseState(deck) self.assertEqual('SPE 3 - CASE 1', state.title)
def setUpClass(cls): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) state = EclipseState(deck) cls.sch = Schedule(deck, state) cls.timesteps = cls.sch.timesteps
def test_restart(self): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) state = EclipseState(deck) sch = Schedule(deck, state) rst = sch.restart
def test_open_shut(self): deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) state = EclipseState(deck) sch = Schedule(deck, state)