def test_throw_on_invalid_recovery(self): recoveries = [ ("PARSE_RANDOM_SLASH", 3.14 ) ] with self.assertRaises(TypeError): sunbeam.parse(self.spe3fn, recovery=recoveries) with self.assertRaises(ValueError): sunbeam.parse(self.spe3fn, recovery="PARSE_RANDOM_SLASH")
def testThrowOnInvalidAction(self): actions = [("PARSE_RANDOM_SLASH", 3.14)] with self.assertRaises(TypeError): sunbeam.parse(self.spe3, actions) with self.assertRaises(ValueError): sunbeam.parse(self.spe3, "PARSE_RANDOM_SLASH")
def test_parse_with_multiple_recoveries(self): recoveries = [ ("PARSE_RANDOM_SLASH", sunbeam.action.ignore), ("FOO", sunbeam.action.warn), ("PARSE_RANDOM_TEXT", sunbeam.action.throw) ] spe3 = sunbeam.parse(self.spe3fn, recovery=recoveries) self.assertEqual('SPE 3 - CASE 1', spe3.title)
def testParseWithMultipleActions(self): actions = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore), ("FOO", sunbeam.action.warn), ("PARSE_RANDOM_TEXT", sunbeam.action.throw)] spe3 = sunbeam.parse(self.spe3, actions) self.assertEqual('SPE 3 - CASE 1', spe3.title)
def test_parse_norne(self): state = sunbeam.parse(self.norne_fname, recovery=[('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]) es = state.state self.assertEqual(46, es.grid().getNX()) self.assertEqual(112, es.grid().getNY()) self.assertEqual(22, es.grid().getNZ())
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 js = sunbeam.parse('data/JFUNC.DATA') 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 = """RUNSPEC DIMENS 10 10 10 / GRID DX 1000*0.25 / DY 1000*0.25 / DZ 1000*0.25 / TOPS 100*0.25 / JFUNC GAS * 13.0 0.6 0.7 Z / PROPS\nREGIONS """ js_gas = sunbeam.parse(jfunc_gas) 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_faults(self): self.assertEquals([], self.spe3.faultNames()) self.assertEquals({}, self.spe3.faults()) faultdeck = sunbeam.parse(self.FAULTS_DECK) self.assertEqual(['F1', 'F2'], faultdeck.faultNames()) # 'F2' 5 5 1 4 1 4 'X-' / \n" f2 = faultdeck.faultFaces('F2') self.assertTrue((4, 0, 0, 'X-') in f2) self.assertFalse((3, 0, 0, 'X-') in f2)
def main(): es = sunbeam.parse('../tests/spe3/SPE3CASE1.DATA') sc = es.schedule wp = sc.wells[0] # producer wi = sc.wells[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 wp.isproducer(i) or wp.isinjector(i): print('wp is not producer in step %s' % sc.timesteps[i]) if not wi.isinjector(i) or wi.isproducer(i): print('wi is not injector in step %s' % sc.timesteps[i])
def parse(fname): s = dt.now() es = sunbeam.parse(fname, ('PARSE_RANDOM_SLASH', sunbeam.action.ignore)) e = dt.now() print('Parsing took %s sec' % (e - s).seconds) return es
def setUp(self): if self.spe3 is None: self.spe3 = sunbeam.parse('spe3/SPE3CASE1.DATA') self.sch = spe3.schedule
import sunbeam from simulators import simulators p = simulators.BlackOilSimulator() norne = sunbeam.parse('../../../opm-data/norne/NORNE_ATW2013.DATA', recovery=[('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]) p.setEclipseState(norne._state()) p.setDeck(norne._deck()) p.setSchedule(norne._schedule()) p.setSummaryConfig(norne._summary_config()) p.run()
def test_data(self): regtest = sunbeam.parse(self.REGIONDATA) self.assertEqual([3,3,1,2], regtest.props()['OPERNUM'])
def setUp(self): self.spe3 = sunbeam.parse('spe3/SPE3CASE1.DATA') self.props = self.spe3.props()
def testParseWithAction(self): action = ("PARSE_RANDOM_SLASH", sunbeam.action.ignore) spe3 = sunbeam.parse(self.spe3, action) self.assertEqual('SPE 3 - CASE 1', spe3.title)
def setUp(self): norne = 'examples/data/norne/NORNE_ATW2013.DATA' self.sch = sunbeam.parse( norne, [('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]).schedule
def setUpClass(cls): cls.sch = sunbeam.parse('spe3/SPE3CASE1.DATA').schedule cls.timesteps = cls.sch.timesteps
def test_parse_with_multiple_recoveries(self): recoveries = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore), ("FOO", sunbeam.action.warn), ("PARSE_RANDOM_TEXT", sunbeam.action.throw)] spe3 = sunbeam.parse(self.spe3fn, recovery=recoveries)
def setUp(self): norne = '../../examples/data/norne/NORNE_ATW2013.DATA' self.es = sunbeam.parse(norne, ('PARSE_RANDOM_SLASH', sunbeam.action.ignore))
def setUp(self): if self.spe3 is None: self.spe3 = sunbeam.parse('spe3/SPE3CASE1.DATA') self.state = self.spe3
def setUpClass(cls): cls.sch = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').schedule
def setUpClass(cls): norne = python_dir + '/examples/data/norne/NORNE_ATW2013.DATA' cls.sch = sunbeam.parse( norne, [('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]).schedule
def setUpClass(cls): cls.spe3 = sunbeam.parse('spe3/SPE3CASE1.DATA') cls.timesteps = cls.spe3.schedule.timesteps cls.wells = cls.spe3.schedule.wells
def test_parse(self): spe3 = sunbeam.parse(self.spe3fn) self.assertEqual('SPE 3 - CASE 1', spe3.title)
def setUpClass(cls): cls.spe3 = sunbeam.parse('spe3/SPE3CASE1.DATA') cls.sch = cls.spe3.schedule
def test_parse_with_recovery(self): recovery = ("PARSE_RANDOM_SLASH", sunbeam.action.ignore) spe3 = sunbeam.parse(self.spe3fn, recovery=recovery) self.assertEqual('SPE 3 - CASE 1', spe3.title)
import unittest import datetime as dt import sunbeam spe3 = sunbeam.parse('spe3/SPE3CASE1.DATA') class TestSchedule(unittest.TestCase): def setUp(self): self.sch = spe3.schedule def testWells(self): self.assertEqual(2, len(self.sch.wells)) def testContains(self): self.assertTrue('PROD' in self.sch) self.assertTrue('INJ' in self.sch) self.assertTrue('NOT' not in self.sch) self.assertFalse('NOT' in self.sch) def testStartEnd(self): self.assertEqual(dt.date(2015, 1, 1), self.sch.start) self.assertEqual(dt.date(2029, 12, 27), self.sch.end) def testTimesteps(self): timesteps = self.sch.timesteps self.assertEqual(176, len(timesteps)) self.assertEqual(dt.date(2015, 12, 31), timesteps[7]) def testGroups(self): g1 = self.sch.group('G1').wells(0)
def test_parse_with_recovery(self): recovery = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore)] spe3 = sunbeam.parse(self.spe3fn, recovery=recovery)
def setUpClass(cls): cls.spe3 = sunbeam.parse('spe3/SPE3CASE1.DATA') cpa = sunbeam.parse('data/CORNERPOINT_ACTNUM.DATA') cls.state = cls.spe3.state cls.cp_state = cpa.state
def setUp(self): self.spe3 = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').state self.props = self.spe3.props()