Port python examples from sunbeam to opm.io
This commit is contained in:
@@ -2,9 +2,15 @@
|
||||
|
||||
import sys
|
||||
from os.path import isdir, join
|
||||
import sunbeam
|
||||
from datetime import datetime as dt
|
||||
|
||||
import opm.io
|
||||
from opm.io import Parser, ParseContext
|
||||
from opm.io.ecl_state import EclipseState
|
||||
from opm.io.schedule import Schedule
|
||||
from opm.io.summary import SummaryConfig
|
||||
|
||||
|
||||
def opmdatadir():
|
||||
global OPMDATA_DIR
|
||||
if isdir(OPMDATA_DIR):
|
||||
@@ -21,29 +27,31 @@ def haveopmdata():
|
||||
|
||||
def parse(fname):
|
||||
s = dt.now()
|
||||
es = sunbeam.parse(fname, ('PARSE_RANDOM_SLASH', sunbeam.action.ignore))
|
||||
ps = ParseContext([('PARSE_RANDOM_SLASH', opm.io.action.ignore)])
|
||||
deck = Parser().parse(fname, ps)
|
||||
e = dt.now()
|
||||
print('Parsing took %s sec' % (e - s).seconds)
|
||||
return es
|
||||
return deck
|
||||
|
||||
def swof_krw(ecl):
|
||||
assert('SWOF' in ecl.table)
|
||||
krw = ecl.table['SWOF', 'KRW']
|
||||
krow = ecl.table['SWOF', 'KROW']
|
||||
pcow = ecl.table['SWOF', 'PCOW']
|
||||
assert('SWOF' in ecl.tables())
|
||||
krw = lambda x: ecl.tables().evaluate('SWOF', 0, 'KRW', x)
|
||||
krow = lambda x: ecl.tables().evaluate('SWOF', 0, 'KROW', x)
|
||||
pcow = lambda x: ecl.tables().evaluate('SWOF', 0, 'PCOW', x)
|
||||
|
||||
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)))
|
||||
|
||||
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
|
||||
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.faults()[f0]
|
||||
fl = es.faultFaces(f0)
|
||||
print('state: %s' % es)
|
||||
print('schedule: %s' % sc)
|
||||
print('the grid: %s' % es.grid())
|
||||
|
||||
@@ -2,18 +2,22 @@
|
||||
|
||||
import sys
|
||||
from os.path import isdir, join
|
||||
import sunbeam
|
||||
from datetime import datetime as dt
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
import opm.io
|
||||
from opm.io.parser import Parser, ParseContext
|
||||
from opm.io.ecl_state import EclipseState
|
||||
from opm.io.schedule import Schedule
|
||||
|
||||
|
||||
def plotswof(ecl):
|
||||
assert('SWOF' in ecl.table)
|
||||
krw = ecl.table['SWOF', 'KRW']
|
||||
krow = ecl.table['SWOF', 'KROW']
|
||||
pcow = ecl.table['SWOF', 'PCOW']
|
||||
assert('SWOF' in ecl.tables())
|
||||
krw = lambda x: ecl.tables().evaluate('SWOF', 0, 'KRW', x)
|
||||
krow = lambda x: ecl.tables().evaluate('SWOF', 0, 'KROW', x)
|
||||
pcow = lambda x: ecl.tables().evaluate('SWOF', 0, 'PCOW', x)
|
||||
|
||||
swofl = [x/20.0 for x in range(21)]
|
||||
krwl = [krw(x/20.0) for x in range(21)]
|
||||
@@ -48,7 +52,9 @@ def haveopmdata():
|
||||
|
||||
def parse(fname):
|
||||
s = dt.now()
|
||||
es = sunbeam.parse(fname, ('PARSE_RANDOM_SLASH', sunbeam.action.ignore))
|
||||
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
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import sunbeam
|
||||
from opm.io.parser import Parser
|
||||
from opm.io.ecl_state import EclipseState
|
||||
from opm.io.schedule import Schedule
|
||||
|
||||
def main():
|
||||
es = sunbeam.parse('../tests/spe3/SPE3CASE1.DATA')
|
||||
sc = es.schedule
|
||||
wp = sc.wells[0] # producer
|
||||
wi = sc.wells[1] # injector
|
||||
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 wp.isproducer(i) or wp.isinjector(i):
|
||||
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 wi.isinjector(i) or wi.isproducer(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])
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user