Files
opm-common/python/examples/norne.py

66 lines
1.7 KiB
Python
Raw Normal View History

2017-02-17 15:07:22 +01:00
#!/usr/bin/env python
2017-01-09 21:18:48 +01:00
import sys
from os.path import isdir, join
import sunbeam
from datetime import datetime as dt
def opmdatadir():
global OPMDATA_DIR
if isdir(OPMDATA_DIR):
return OPMDATA_DIR
if len(sys.argv) < 2:
return None
d = sys.argv[1]
if isdir(d) and isdir(join(d, 'norne')):
return d
return None
def haveopmdata():
return opmdatadir() is not None
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
2017-02-17 15:07:22 +01:00
def swof_krw(ecl):
assert('SWOF' in ecl.table)
krw = ecl.table['SWOF', 'KRW']
krow = ecl.table['SWOF', 'KROW']
pcow = ecl.table['SWOF', 'PCOW']
print('SWOF\tKRW\tKROW\tPCOW')
for i in range(21):
print('%.2f\t%.4f\t%.4f\t%.4f' % (i/20.0, krw(i/20.0), krow(i/20.0), pcow(i/20.0)))
2017-01-09 21:18:48 +01:00
def main():
es = parse(join(opmdatadir(), 'norne/NORNE_ATW2013.DATA'))
sc = es.schedule
wp = sc.wells[23] # producer
wi = sc.wells[20] # injector at ts 100
2017-01-14 13:05:28 +01:00
fn = es.faultNames()
f0 = fn[0]
fl = es.faults()[f0]
2017-01-09 21:18:48 +01:00
print('state: %s' % es)
print('schedule: %s' % sc)
2017-01-12 13:12:00 +01:00
print('the grid: %s' % es.grid())
2017-01-09 21:18:48 +01:00
print('at timestep 100 (%s)' % sc.timesteps[100])
print('prod well: %s' % wp)
print('inj well: %s' % wi)
print('pos: %s' % list(wp.pos()))
2017-01-14 13:05:28 +01:00
print('fault: %s' % f0)
print(' comprised of %d cells' % len(fl))
2017-02-17 15:07:22 +01:00
swof_krw(es)
2017-01-09 21:18:48 +01:00
if __name__ == '__main__':
global OPMDATA_DIR
OPMDATA_DIR = '../../opm-data'
if haveopmdata():
2017-01-14 13:05:28 +01:00
print('Found norne, parsing ...')
2017-01-09 21:18:48 +01:00
main()
else:
print('Need to have path "%s" or give opm-data as argument' % OPMDATA_DIR)