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_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 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 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 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_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 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_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 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 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])
class TestBasic(unittest.TestCase): @classmethod def setUpClass(cls): # NOTE: See comment in test_basic.py for the reason why we are # only using a single test_all() function instead of splitting # it up in multiple test functions test_dir = Path(os.path.dirname(__file__)) cls.data_dir = test_dir.parent.joinpath("test_data/SPE1CASE1b") 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 subtest_modify_inj_weltarg_dynamically(self, well_name, report_step): prop = self.schedule.get_injection_properties(well_name, report_step) self.assertEqual(prop['surf_inj_rate'], 100000.0) # Mscf/day self.assertEqual(prop['resv_inj_rate'], 0.0) # rb/day self.assertEqual(prop['bhp_target'], 9014.0) # psi self.assertEqual(prop['thp_target'], 0.0) new_grat_target = prop['surf_inj_rate'] - 100 # stb/day self.update_inj_grat_target_wconinje(well_name, new_grat_target) self.sim.step() prop2 = self.schedule.get_injection_properties(well_name, report_step + 1) self.assertEqual(prop2['surf_inj_rate'], new_grat_target) new_grat_target += 200 self.update_inj_grat_target_weltarg(well_name, new_grat_target) self.sim.step() prop3 = self.schedule.get_injection_properties(well_name, report_step + 2) self.assertEqual(prop3['surf_inj_rate'], new_grat_target) def subtest_modify_prod_weltarg_dynamically(self, well_name, report_step): prop = self.schedule.get_production_properties(well_name, report_step) self.assertEqual(prop['alq_value'], 0.0) self.assertEqual(prop['bhp_target'], 1000.0) self.assertEqual(prop['gas_rate'], 0.0) self.assertEqual(prop['liquid_rate'], 0.0) self.assertEqual(prop['oil_rate'], 20000.0) self.assertEqual(prop['resv_rate'], 0.0) self.assertEqual(prop['thp_target'], 0.0) self.assertEqual(prop['water_rate'], 0.0) new_oil_target = prop['oil_rate'] + 10000 # stb/day self.update_prod_orat_target_wconprod(well_name, new_oil_target) self.sim.step() prop2 = self.schedule.get_production_properties( well_name, report_step + 1) self.assertEqual(prop2['oil_rate'], new_oil_target) new_oil_target += 1000 self.update_prod_orat_target_weltarg(well_name, new_oil_target) self.sim.step() prop3 = self.schedule.get_production_properties( well_name, report_step + 2) self.assertEqual(prop3['oil_rate'], new_oil_target) # This is an alternative to using WELTARG def update_inj_grat_target_wconinje(self, well_name, new_surf_flow_rate): data = self.deck["WCONINJE"] # assumes data looks like this: # WCONINJE # 'INJ' 'GAS' 'OPEN' 'RATE' 100000 1* 9014 / # / # The initial rate can also be obtained from data[0][4].get_uda(0).get_double() data = re.sub(pattern='100000', repl=str(new_surf_flow_rate), string=str(data), count=1) report_step = self.sim.current_step() self.schedule.insert_keywords(data, step=report_step, unit_system=self.unit_system) # This is an alternative to using WCONINJE to modify injection properties def update_inj_grat_target_weltarg(self, well_name, net_surf_flow_rate): data = """ WELTARG '{}' GRAT {} / / """.format(well_name, net_surf_flow_rate) report_step = self.sim.current_step() self.schedule.insert_keywords(data, step=report_step, unit_system=self.unit_system) # This is an alternative to using WCONPROD to modify production properties def update_prod_orat_target_weltarg(self, well_name, oil_target): data = """ WELTARG '{}' ORAT {} / / """.format(well_name, oil_target) report_step = self.sim.current_step() self.schedule.insert_keywords(data, step=report_step, unit_system=self.unit_system) # This is an alternative to using WELTARG to modify production properties def update_prod_orat_target_wconprod(self, well_name, oil_target): well_status = "OPEN" control_mode = "ORAT" bhp_limit = 1000 # psia data = """ WCONPROD '{}' '{}' '{}' {} 4* {} / / """.format(well_name, well_status, control_mode, oil_target, bhp_limit) report_step = self.sim.current_step() self.schedule.insert_keywords(data, step=report_step, unit_system=self.unit_system)
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)