Added class TimeVector to be used as basis for Schedule merging.

This commit is contained in:
Joakim Hove
2018-03-14 09:39:36 +01:00
parent 371f8fe59e
commit d33a5a39b6
11 changed files with 979 additions and 3 deletions

View File

@@ -9,4 +9,4 @@ set(PYTHON_SOURCES
add_python_package(sunbeam sunbeam "${PYTHON_SOURCES}")
add_subdirectory(deck)
add_subdirectory(tools)

View File

@@ -0,0 +1,5 @@
set(PYTHON_SOURCES
__init__.py
time_vector.py)
add_python_package("sunbeam.tools" "sunbeam/tools" "${PYTHON_SOURCES}")

View File

@@ -0,0 +1,5 @@
set(PYTHON_SOURCES
__init__.py
time_vector.py)
add_python_package("sunbeam.tools" "sunbeam/tools" "${PYTHON_SOURCES}")

View File

@@ -0,0 +1 @@
from .time_vector import TimeVector, TimeStep

View File

@@ -0,0 +1,335 @@
import datetime
from operator import attrgetter
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
import sunbeam.deck
# This is from the TimeMap.cpp implementation in opm
ecl_month = {"JAN" : 1,
"FEB" : 2,
"MAR" : 3,
"APR" : 4,
"MAI" : 5,
"MAY" : 5,
"JUN" : 6,
"JLY" : 7,
"JUL" : 7,
"AUG" : 8,
"SEP" : 9,
"OCT" : 10,
"OKT" : 10,
"NOV" : 11,
"DEC" : 12,
"DES" : 12}
inv_ecl_month = {1 : "JAN",
2 : "FEB",
3 : "MAR",
4 : "APR",
5 : "MAY",
6 : "JUN",
7 : "JUL",
8 : "AUG",
9 : "SEP",
10: "OCT",
11 : "NOV",
12 : "DEC"}
def _make_datetime(dates_record):
day = dates_record[0][0]
month = dates_record[1][0]
year = dates_record[2][0]
return datetime.datetime(year, ecl_month[month], day)
class TimeStep(object):
def __init__(self, dt, keywords):
"""The TimeStep class consist of a list of keywords and a corresponding date.
Observe that the date value corresponds to a DATES / TSTEP keyword
following *after* the keywords; i.e. if the TimeStep instance contains
a WCONHIST keyword the settings in that keyword should apply *until*
the date specified is reached. See the documentation of the TimeVector
class for more details of the relationship between TimeVector and
TimeStep.
"""
self.dt = dt
self.keywords = keywords
self.is_tstep = False
self.tstep = None
def add_keyword(self, kw):
self.keywords.append(kw)
@classmethod
def create_tstep(cls, tstep, dt, keywords):
ts = cls(dt, keywords)
ts.is_tstep = True
ts.tstep = tstep
return ts
def __str__(self):
string = StringIO()
for kw in self.keywords:
string.write(str(kw))
string.write("\n")
if self.is_tstep:
string.write("TSTEP\n {}/\n\n".format( self.tstep ))
else:
day = self.dt.day
month = self.dt.month
year = self.dt.year
string.write("DATES\n {day} '{month}' {year}/\n/\n\n".format( day=day, month = inv_ecl_month[month], year=year))
return string.getvalue()
class TimeVector(object):
def __init__(self, start_date):
"""The TimeVector class is a simple vector class with DATES/TSTEP blocks.
The TimeVector class is a basic building block for tools designed to
update schedule files. A schedule file consists of a list of keywords
related to the dynamic properties of the field, like opening and
closing wells, specifiying rates and so on. The temporal advancement of
the simulator is controlled by DATES and TSTEP keywords. A typical
schedule section can look like this:
--- Step 1 -----------------------
WELSPECS
'C1' 'G1' 10 10 10 'OIL' /
/
COMPDAT
'C1' 15 20 10 16 'OPEN' /
'C1' 15 21 16 16 'OPEN' /
/
WCONHIST
'C1' 'OPEN' 'ORAT' 1000 /
/
DATES
10 'MAY' 2016 /
/
--- Step 2 ----------------------
WCONHIST
'C1' 'OPEN' 'ORAT' 2000 /
/
TSTEP
10 /
--- Step 3 ----------------------
WELSPECS
'W2' 'G1' 5 5 5 'OIL' /
/
COMPDAT
'W2' 10 10 7 10 'OPEN' /
/
WCONHIST
'C1' 'OPEN' 'ORAT' 3000 /
'W2' 'OPEN' 'ORAT' 1500 /
/
DATES
30 'MAY' 2016 /
/
As indicated above the DATES and TSTEP keywords act as delimiters in
the schedule file. In the TimeVector class the fundamental unit is
TimeStep instance which consists of a list of keywords, and a
terminating DATES or TSTEP keyword, the example above would correspond
to a TimeVector with three TimeStep instances.
Basic usage example:
#!/usr/bin/env python
from sunbeam.tools import TimeVector
# Create vector and load history.
tv = TimeVector( start )
tv.load("history.sch")
# Load predictions from another file
tv.load("prediction.sch")
# Insert the definition of one particular well at
# a specifed date.
tv.load("extra_wll.sch", date = datetime.datetime(2018,10,1))
# Check if we have a certain timestep:
if datetime.datetime(2017,1,1) in tv:
print("We have it!")
else:
print("No such date")
# Dump the updated schedule content to a file:
with open("schedule","w") as f:
f.write(str(tv))
"""
self.start_date = datetime.datetime( start_date.year, start_date.month, start_date.day)
self.time_steps_list = []
self.time_steps_dict = {}
def __len__(self):
"""
The number of timesteps in the vector.
"""
return len(self.time_steps_list)
def __getitem__(self, index):
"""Will look up a timestep in the vector.
The index argument can either be an integer or a datetime instance.
"""
if isinstance(index,int):
return self.time_steps_list[index]
else:
if isinstance(index,datetime.date):
index = datetime.datetime(index.year, index.month, index.day)
return self.time_steps_dict[index]
def __contains__(self, dt):
"""
Will return true if the vector contains a timestep at date dt.
"""
if isinstance(dt, datetime.date):
dt = datetime.datetime(dt.year, dt.month, dt.day)
return dt in self.time_steps_dict
def _add_dates_block(self, ts):
self.time_steps_list.append(ts)
self.time_steps_dict[ts.dt] = ts
def add_keywords(self, dt, keywords):
if dt <= self.start_date:
raise ValueError("Invalid datetime argument")
if dt in self.time_steps_dict:
ts = self[dt]
for kw in keywords:
ts.add_keyword(kw)
else:
ts = TimeStep(dt, keywords)
self._add_dates_block(ts)
self.time_steps_list.sort( key = attrgetter("dt"))
def append_tstep(self, tstep, keywords):
if len(self) == 0:
last_dt = self.start_data
else:
last_dt = self[-1].dt
new_dt = last_dt + datetime.timedelta(days = tstep)
ts = TimeStep.create_tstep(tstep, new_dt, keywords)
self._add_dates_block(ts)
def _add_deck(self, deck, last_date):
keywords = []
for kw in deck:
if kw.name == "DATES":
for record in kw:
dt = _make_datetime(record)
self.add_keywords(dt, keywords)
keywords = []
continue
if kw.name == "TSTEP":
record = kw[0]
for tstep in record[0]:
self.append_tstep(tstep, keywords)
keywords = []
continue
keywords.append(kw)
if last_date:
if keywords:
self.add_keywords(last_date, keywords)
def load(self, filename, date = None):
"""Will parse a Schedule file and add the keywords to the current TimeVector.
You can call the load() method repeatedly, the different timesteps will
be ordered chronologically. If a timestep is already present the
keywords will be appended.
The optional date argument can be used to insert schedule file
fragments which do not have any DATES / TSTEP keywords. Assuming you
have a base file 'base.sch' and a small fragment 'well.sch' with the
WELSPECS and COMPDAT keywords to create one well, then the new well can
be added 1.st of April 2017 as this:
tv = TimeVector( start )
tv.load("base.sch")
tv.load("well.sch", date = datetime.datetime(2017, 4, 1))
"""
deck = sunbeam.deck.parse(filename)
self._add_deck(deck, date)
def load_string(self, deck_string, date = None):
"""
Like load() - but load from a string literal instead of file.
"""
deck = sunbeam.deck.parse_string(deck_string)
self._add_deck(deck, date)
def __str__(self):
"""Will return a string representation of the vector.
The output from this method should be valid Schedule input which can be
passed to a simulator.
"""
string = StringIO()
for ts in self:
string.write(str(ts))
return string.getvalue()
@property
def dates(self):
"""
Will return a list of all the dates in the vector.
"""
return [ x.dt for x in self.time_steps_list ]

View File

@@ -1,9 +1,12 @@
configure_file(spe3/SPE3CASE1.DATA spe3/SPE3CASE1.DATA COPYONLY)
configure_file(data/CORNERPOINT_ACTNUM.DATA data/CORNERPOINT_ACTNUM.DATA COPYONLY)
configure_file(data/JFUNC.DATA data/JFUNC.DATA COPYONLY)
configure_file(data/schedule/part1.sch data/schedule/part1.sch COPYONLY)
configure_file(data/schedule/part2.sch data/schedule/part2.sch COPYONLY)
configure_file(data/schedule/part3.sch data/schedule/part3.sch COPYONLY)
configure_file(data/schedule/fragment.sch data/schedule/fragment.sch COPYONLY)
foreach(prog completions deck group_tree grupnet parse_deck parse state props schedule wells)
foreach(prog time_vector completions deck group_tree grupnet parse_deck parse state props schedule wells)
add_python_test(${prog} ${prog}.py)
endforeach()

View File

@@ -0,0 +1,4 @@
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 2503454.000 1* 600 /
/

View File

@@ -0,0 +1,177 @@
WELSPECS
'C-4H' 'MANI-C' 11 35 1* 'OIL' 7* /
'B-2H' 'B1-DUMMY' 15 31 1* 'OIL' 2* 'STOP' 4* /
'D-1H' 'MANI-D1' 22 22 1* 'OIL' 2* 'STOP' 4* /
/
COMPDAT
-- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro
'C-4H' 11 35 1 1 'OPEN' 1* 45.314 0.216 4253.571 2* 'Z' 16.503 /
'C-4H' 11 35 2 2 'OPEN' 1* 43.674 0.216 4103.809 2* 'Z' 16.588 /
'B-2H' 17 31 9 9 'OPEN' 1* 17.246 0.216 1285.863 2* 'X' 5.865 /
'B-2H' 19 31 9 9 'OPEN' 1* 13.200 0.216 991.575 2* 'X' 6.044 /
'B-2H' 20 31 10 10 'OPEN' 1* 36.540 0.216 2804.161 2* 'X' 6.593 /
'B-2H' 21 31 10 10 'OPEN' 1* 12.052 0.216 921.178 2* 'X' 6.486 /
'B-2H' 22 32 10 10 'OPEN' 1* 67.732 0.216 5174.542 2* 'X' 6.472 /
'B-2H' 24 32 10 10 'OPEN' 1* 42.421 0.216 3232.419 2* 'X' 6.404 /
'B-2H' 25 32 10 10 'OPEN' 1* 29.697 0.216 2261.930 2* 'X' 6.393 /
'B-2H' 29 33 10 10 'OPEN' 1* 10.490 0.216 807.533 2* 'X' 6.677 /
'D-1H' 22 22 5 5 'OPEN' 1* 5.505 0.216 510.312 2* 'Z' 15.511 /
'D-1H' 23 22 6 6 'OPEN' 1* 0.101 0.216 9.456 2* 'Z' 16.532 /
'D-1H' 23 22 7 7 'OPEN' 1* 4.938 0.216 452.905 2* 'Z' 14.704 /
'D-1H' 23 22 9 9 'OPEN' 1* 19.086 0.216 1745.284 2* 'Z' 14.493 /
'D-1H' 23 22 10 10 'OPEN' 1* 50.101 0.216 4655.453 2* 'Z' 15.689 /
'D-1H' 23 22 11 11 'OPEN' 1* 8.974 0.216 823.585 2* 'Z' 14.751 /
'D-1H' 23 22 12 12 'OPEN' 1* 0.479 0.216 43.304 2* 'Z' 13.707 /
'D-1H' 23 22 13 13 'OPEN' 1* 12.603 0.216 1152.420 2* 'Z' 14.489 /
/
GRUPTREE
'INJE' 'FIELD' /
'PROD' 'FIELD' /
'MANI-B2' 'PROD' /
'MANI-B1' 'PROD' /
'MANI-D1' 'PROD' /
'MANI-D2' 'PROD' /
'MANI-E1' 'PROD' /
'MANI-E2' 'PROD' /
'MANI-K1' 'MANI-B1' /
'MANI-K2' 'MANI-D2' /
'MANI-C' 'INJE' /
'MANI-F' 'INJE' /
'WI-GSEG' 'INJE' /
'B1-DUMMY' 'MANI-B1' /
'D2-DUMMY' 'MANI-D2' /
/
WCONHIST
'C-4H' 'OPEN' 'ORAT' 0.000 0.000 0.000 5* /
'B-2H' 'OPEN' 'ORAT' 0.000 0.000 0.000 5* /
'D-1H' 'OPEN' 'RESV' 4347.700 0.000 482594.703 5* /
/
WPAVE
1* 0.000 'WELL' 'ALL' /
GRUPNET
'FIELD' 20.000 5* /
'PROD' 20.000 5* /
'MANI-B2' 1* 8 1* 'NO' 2* /
'MANI-B1' 1* 8 1* 'NO' 2* /
'MANI-K1' 1* 9999 4* /
'B1-DUMMY' 1* 9999 4* /
'MANI-D1' 1* 8 1* 'NO' 2* /
'MANI-D2' 1* 8 1* 'NO' 2* /
'MANI-K2' 1* 9999 4* /
'D2-DUMMY' 1* 9999 4* /
'MANI-E1' 1* 9 1* 'NO' 2* /
'MANI-E2' 1* 9 4* /
/
VAPPARS
0.500 0.000 /
NETBALAN
0.000 0.200 6* /
-- 8.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
14 'NOV' 1997 00:00:00.001 /
/
WCONHIST
'D-1H' 'OPEN' 'RESV' 5601.953 0.000 634722.739 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 392180.973 1* 600 /
/
GECON
'FIELD' 1000.000 5* 'NO' 1* /
/
-- 25.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
1 'DEC' 1997 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 2079.506 0.000 230825.037 5* /
'D-1H' 'OPEN' 'RESV' 5433.419 0.000 651415.006 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 480352.924 1* 600 /
/
-- 41.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
17 'DEC' 1997 /
/
-- : D-2H Perforation Ile 1.3 2002 Top: 4116.90 Bot: 4136.40 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Perforation Ile 1.3 2002 Top: 4036.00 Bot: 4105.30 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Perforation Ile 1.3 2002 Top: 3978.00 Bot: 4001.00 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002 (DIVIDED)
-- : D-2H Perforation Ile 1.3 2002 Top: 4001.00 Bot: 4008.80 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Perforation Ile 1.3 2002 Top: 3902.00 Bot: 3963.60 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Perforation Ile 1.3 2002 Top: 3438.00 Bot: 3484.20 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Perforation Ile 1.3 2002 Top: 3368.00 Bot: 3421.90 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Perforation Ile 1.3 2002 Top: 3284.00 Bot: 3330.20 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Perforation Ile 1.3 2002 Top: 3078.00 Bot: 3093.40 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Perforation Ile 1.3 2002 Top: 3016.00 Bot: 3023.70 Diam: 0.22 Skin: 0.00
-- : >> --Ile 1.3 2002
-- : D-2H Connection 14 26 9 Perf. Len 7.70 ( 8.9%)
-- WARN: D-2H Cell 14 25 9 is intersected 2 times
-- : D-2H Connection 14 25 9 Perf. Len 15.40 ( 17.4%)
-- : D-2H Connection 14 23 9 Perf. Len 4.43 ( 4.9%)
-- : D-2H Connection 14 22 9 Perf. Len 56.62 ( 59.0%)
-- : D-2H Connection 14 21 9 Perf. Len 71.53 ( 84.7%)
-- : D-2H Connection 14 20 9 Perf. Len 13.72 ( 15.8%)
-- : D-2H Connection 14 15 9 Perf. Len 24.00 ( 26.4%)
-- : D-2H Connection 14 14 9 Perf. Len 69.30 ( 77.1%)
-- : D-2H Connection 14 13 9 Perf. Len 19.50 ( 20.6%)
WELSPECS
'D-2H' 'D2-DUMMY' 14 28 1* 'OIL' 2* 'STOP' 4* /
/
COMPDAT
-- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro
'D-2H' 14 26 9 9 'OPEN' 1* 21.450 0.216 1590.754 2* 'Y' 5.741 /
'D-2H' 14 25 9 9 'OPEN' 1* 39.557 0.216 2921.561 2* 'Y' 5.648 /
'D-2H' 14 23 9 9 'OPEN' 1* 10.183 0.216 748.871 2* 'Y' 5.554 /
'D-2H' 14 22 9 9 'OPEN' 1* 121.842 0.216 8821.805 2* 'Y' 5.225 /
'D-2H' 14 21 9 9 'OPEN' 1* 140.551 0.216 10196.747 2* 'Y' 5.266 /
'D-2H' 14 20 9 9 'OPEN' 1* 24.486 0.216 1793.318 2* 'Y' 5.465 /
'D-2H' 14 15 9 9 'OPEN' 1* 29.883 0.216 2344.667 2* 'Y' 7.229 /
'D-2H' 14 14 9 9 'OPEN' 1* 82.852 0.216 6372.295 2* 'Y' 6.653 /
'D-2H' 14 13 9 9 'OPEN' 1* 24.664 0.216 1809.697 2* 'Y' 5.504 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 5359.973 0.000 594956.842 5* /
'D-1H' 'OPEN' 'RESV' 5481.020 0.000 693727.779 5* /
'D-2H' 'OPEN' 'RESV' 161.927 0.000 17973.921 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 1129535.350 1* 600 /
/
-- 56.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
1 'JAN' 1998 /
/

View File

@@ -0,0 +1,135 @@
WCONHIST
'B-2H' 'OPEN' 'RESV' 5194.690 0.000 576611.282 5* /
'D-1H' 'OPEN' 'RESV' 5169.755 0.000 703808.288 5* /
'D-2H' 'OPEN' 'RESV' 5923.123 0.000 681178.935 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 1749032.706 1* 600 /
/
RPTSCHED
0 0 0 0 0 0 2 2 2 0 1 1 0 1 1 0 0 /
-- 87.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
1 'FEB' 1998 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 376.354 0.000 41775.297 5* /
'D-1H' 'OPEN' 'RESV' 370.621 0.000 53044.248 5* /
'D-2H' 'OPEN' 'RESV' 465.389 0.000 59855.401 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 137940.769 1* 600 /
/
RPTSCHED
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /
-- 115.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
1 'MAR' 1998 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 3572.118 0.000 396505.322 5* /
'D-1H' 'OPEN' 'RESV' 3487.875 0.000 563920.395 5* /
'D-2H' 'OPEN' 'RESV' 3719.518 0.000 643627.261 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 1418039.732 1* 600 /
/
-- 143.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
29 'MAR' 1998 /
/
-- : B-4H Perforation Top: 2575.00 Bot: 2605.00 Diam: 0.22 Skin: 0.00
-- : >> --for RFT pressure points
-- : B-4H Perforation Top: 2615.00 Bot: 2837.00 Diam: 0.22 Skin: 0.00
-- : >> --for RFT pressure points
-- WARN: B-4H Perf interval 2615.000000 to 2619.233018 outside all cells, discarded
-- WARN: B-4H Perf interval 2834.362584 2837.000000 below grid
-- : B-4H Connection 10 32 1 Perf. Len 10.97 (101.2%)
-- : B-4H Connection 10 32 2 Perf. Len 13.16 (101.4%)
-- : B-4H Connection 10 32 3 Perf. Len 5.87 ( 48.6%)
-- : B-4H Connection 10 32 5 Perf. Len 5.54 (101.3%)
-- : B-4H Connection 10 32 6 Perf. Len 5.55 (101.3%)
-- : B-4H Connection 10 32 7 Perf. Len 6.33 (101.4%)
-- : B-4H Connection 10 32 8 Perf. Len 6.34 (101.5%)
-- : B-4H Connection 10 32 9 Perf. Len 3.59 (101.6%)
-- : B-4H Connection 10 32 10 Perf. Len 17.43 (100.3%)
-- : B-4H Connection 9 32 13 Perf. Len 11.42 ( 90.9%)
-- : B-4H Connection 9 32 14 Perf. Len 12.64 (100.8%)
-- : B-4H Connection 9 32 15 Perf. Len 12.96 (100.5%)
-- : B-4H Connection 9 32 16 Perf. Len 10.12 (100.8%)
-- : B-4H Connection 9 32 17 Perf. Len 2.10 (100.0%)
-- : B-4H Connection 9 32 18 Perf. Len 3.55 (102.2%)
-- : B-4H Connection 9 32 19 Perf. Len 20.71 (101.2%)
-- : B-4H Connection 9 32 20 Perf. Len 13.50 ( 55.5%)
-- : B-4H Connection 9 31 20 Perf. Len 11.04 ( 45.1%)
-- : B-4H Connection 9 31 21 Perf. Len 44.76 (100.3%)
-- : B-4H Connection 9 31 22 Perf. Len 27.56 (100.0%)
-- : WCONPROD >> for RFT pressure points
-- : WRFTPLT >> RFT recorded only once
WELSPECS
'B-4H' 'B1-DUMMY' 10 32 1* 'OIL' 2* 'STOP' 4* /
/
COMPDAT
-- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro
'B-4H' 10 32 1 1 'OPEN' 1* 118.457 0.216 12025.229 2* 'Z' 24.860 /
'B-4H' 10 32 2 2 'OPEN' 1* 88.058 0.216 8892.405 2* 'Z' 24.161 /
'B-4H' 10 32 3 3 'OPEN' 1* 6.493 0.216 651.729 2* 'Z' 23.389 /
'B-4H' 10 32 5 5 'OPEN' 1* 37.039 0.216 3688.499 2* 'Z' 22.416 /
'B-4H' 10 32 6 6 'OPEN' 1* 37.182 0.216 3691.211 2* 'Z' 22.046 /
'B-4H' 10 32 7 7 'OPEN' 1* 27.449 0.216 2717.094 2* 'Z' 21.709 /
'B-4H' 10 32 8 8 'OPEN' 1* 27.553 0.216 2719.652 2* 'Z' 21.384 /
'B-4H' 10 32 9 9 'OPEN' 1* 55.934 0.216 5504.213 2* 'Z' 21.045 /
'B-4H' 10 32 10 10 'OPEN' 1* 343.826 0.216 33643.313 2* 'Z' 20.427 /
'B-4H' 9 32 13 13 'OPEN' 1* 247.048 0.216 23303.623 2* 'Z' 16.915 /
'B-4H' 9 32 14 14 'OPEN' 1* 200.684 0.216 18964.795 2* 'Z' 17.072 /
'B-4H' 9 32 15 15 'OPEN' 1* 60.756 0.216 5750.007 2* 'Z' 17.201 /
'B-4H' 9 32 16 16 'OPEN' 1* 131.035 0.216 12417.905 2* 'Z' 17.318 /
'B-4H' 9 32 17 17 'OPEN' 1* 1.215 0.216 115.284 2* 'Z' 17.399 /
'B-4H' 9 32 18 18 'OPEN' 1* 122.230 0.216 11601.419 2* 'Z' 17.455 /
'B-4H' 9 32 19 19 'OPEN' 1* 50.908 0.216 4838.953 2* 'Z' 17.585 /
'B-4H' 9 32 20 20 'OPEN' 1* 84.765 0.216 8082.179 2* 'Z' 17.865 /
'B-4H' 9 31 20 20 'OPEN' 1* 65.987 0.216 6333.601 2* 'Z' 18.482 /
'B-4H' 9 31 21 21 'OPEN' 1* 40.421 0.216 3901.629 2* 'Z' 19.028 /
'B-4H' 9 31 22 22 'OPEN' 1* 440.439 0.216 42866.883 2* 'Z' 19.863 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 5093.700 0.000 565401.375 5* /
'B-4H' 'OPEN' 'ORAT' 0.000 0.000 0.000 5* /
'D-1H' 'OPEN' 'RESV' 4638.900 0.000 772098.500 5* /
'D-2H' 'OPEN' 'RESV' 5699.300 0.000 1048260.312 5* /
/
WCONPROD
'B-4H' 'SHUT' 15* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 2370770.750 1* 600 /
/
WRFTPLT
'B-4H' 'YES' 'YES' 1* /
/
-- 144.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
30 'MAR' 1998 /
/

View File

@@ -0,0 +1,207 @@
WCONHIST
'B-2H' 'OPEN' 'RESV' 6174.300 0.000 685348.969 5* /
'D-1H' 'OPEN' 'RESV' 5427.250 0.000 906735.000 5* /
'D-2H' 'OPEN' 'RESV' 5702.450 0.000 1057381.313 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 2503454.000 1* 600 /
/
-- 146.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
1 'APR' 1998 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 5697.445 0.000 632415.385 5* /
'D-1H' 'OPEN' 'RESV' 4933.305 0.000 848627.159 5* /
'D-2H' 'OPEN' 'RESV' 5633.914 0.000 1112753.528 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 2351508.324 1* 600 /
/
RPTSCHED
0 0 0 0 0 0 2 2 2 0 1 1 0 1 1 0 0 /
-- 168.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
23 'APR' 1998 /
/
-- : B-4H Perforation Tofte 2.1 2002 Top: 2677.00 Bot: 2703.00 Diam: 0.22 Skin: 0.00
-- : >> --Tofte 2.1 2002
-- WARN: B-4H Layer Tofte 2.1 2002 Adjusted 2677.00 2703.00 to 2675.02 2701.02
-- : B-4H Perforation Tofte 2.1 2002 Top: 2666.00 Bot: 2674.00 Diam: 0.22 Skin: 0.00
-- : >> --Tofte 2.1 2002
-- : B-4H Connection 9 32 13 Perf. Len 8.40 ( 66.9%)
-- : B-4H Connection 9 32 14 Perf. Len 12.64 (100.8%)
-- : B-4H Connection 9 32 15 Perf. Len 12.96 (100.5%)
COMPDAT
-- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro
'B-4H' 9 32 13 13 'OPEN' 1* 181.797 0.216 17148.637 2* 'Z' 16.915 /
'B-4H' 9 32 14 14 'OPEN' 1* 200.684 0.216 18964.795 2* 'Z' 17.072 /
'B-4H' 9 32 15 15 'OPEN' 1* 60.756 0.216 5750.007 2* 'Z' 17.201 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 5559.200 0.000 617071.770 5* /
'B-4H' 'OPEN' 'RESV' 1994.063 0.000 221340.114 5* /
'D-1H' 'OPEN' 'RESV' 4935.888 0.000 880581.422 5* /
'D-2H' 'OPEN' 'RESV' 5681.213 0.000 1206619.906 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 2680355.703 1* 600 /
/
RPTSCHED
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /
-- 176.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
1 'MAY' 1998 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 5211.576 0.000 578485.816 5* /
'B-4H' 'OPEN' 'RESV' 5047.212 0.000 560240.344 5* /
'D-1H' 'OPEN' 'RESV' 4680.112 0.000 867679.637 5* /
'D-2H' 'OPEN' 'RESV' 5290.284 0.000 1211440.385 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 2982926.875 1* 600 /
/
-- 201.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
26 'MAY' 1998 /
/
-- : D-4H Perforation Top: 2715.00 Bot: 2756.00 Diam: 0.22 Skin: 0.00
-- : >> --for RFT pressure points
-- WARN: D-4H Perf interval 2754.172800 to 2764.886044 outside all cells, discarded
-- : D-4H Perforation Top: 2767.00 Bot: 3038.00 Diam: 0.22 Skin: 0.00
-- : >> --for RFT pressure points
-- WARN: D-4H Perf interval 3036.734009 3038.000000 below grid
-- : D-4H Connection 19 38 1 Perf. Len 8.92 ( 89.0%)
-- : D-4H Connection 19 38 2 Perf. Len 10.41 ( 84.0%)
-- : D-4H Connection 19 39 2 Perf. Len 5.77 ( 47.7%)
-- : D-4H Connection 19 39 3 Perf. Len 14.08 (126.1%)
-- : D-4H Connection 19 39 5 Perf. Len 4.28 ( 86.7%)
-- : D-4H Connection 19 39 6 Perf. Len 6.43 (127.8%)
-- : D-4H Connection 19 39 7 Perf. Len 7.69 (128.8%)
-- : D-4H Connection 19 39 8 Perf. Len 7.69 (128.1%)
-- : D-4H Connection 19 39 9 Perf. Len 5.24 (131.1%)
-- : D-4H Connection 19 39 10 Perf. Len 14.25 ( 85.0%)
-- : D-4H Connection 20 39 10 Perf. Len 7.46 ( 43.4%)
-- : D-4H Connection 20 39 11 Perf. Len 7.58 (128.6%)
-- : D-4H Connection 20 39 12 Perf. Len 4.06 (125.3%)
-- : D-4H Connection 20 39 13 Perf. Len 15.74 (128.3%)
-- : D-4H Connection 20 39 14 Perf. Len 16.26 (132.5%)
-- : D-4H Connection 20 39 15 Perf. Len 16.23 (133.7%)
-- : D-4H Connection 20 40 15 Perf. Len 0.15 ( 1.3%)
-- : D-4H Connection 20 40 16 Perf. Len 14.14 (130.6%)
-- : D-4H Connection 20 40 17 Perf. Len 4.32 (142.5%)
-- : D-4H Connection 20 40 18 Perf. Len 4.00 (145.3%)
-- : D-4H Connection 20 40 19 Perf. Len 16.97 (139.1%)
-- : D-4H Connection 20 40 20 Perf. Len 20.21 ( 98.7%)
-- : D-4H Connection 21 40 20 Perf. Len 7.54 ( 37.0%)
-- : D-4H Connection 21 40 21 Perf. Len 53.59 (141.4%)
-- : D-4H Connection 21 40 22 Perf. Len 13.75 ( 53.6%)
-- : D-4H Connection 21 41 22 Perf. Len 22.11 ( 82.9%)
-- : WCONPROD >> for RFT pressure points
-- : WRFTPLT >> RFT recorded only once
WELSPECS
'D-4H' 'D2-DUMMY' 19 38 1* 'OIL' 2* 'STOP' 4* /
/
COMPDAT
-- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro
'D-4H' 19 38 1 1 'OPEN' 1* 60.526 0.216 5653.468 2* 'Z' 16.099 /
'D-4H' 19 38 2 2 'OPEN' 1* 49.828 0.216 4693.611 2* 'Z' 16.796 /
'D-4H' 19 39 2 2 'OPEN' 1* 21.543 0.216 2035.817 2* 'Z' 17.072 /
'D-4H' 19 39 3 3 'OPEN' 1* 0.250 0.216 20.523 2* 'Z' 8.712 /
'D-4H' 19 39 5 5 'OPEN' 1* 4.500 0.216 423.108 2* 'Z' 16.639 /
'D-4H' 19 39 6 6 'OPEN' 1* 6.732 0.216 633.920 2* 'Z' 16.768 /
'D-4H' 19 39 7 7 'OPEN' 1* 9.213 0.216 866.258 2* 'Z' 16.644 /
'D-4H' 19 39 8 8 'OPEN' 1* 9.218 0.216 867.587 2* 'Z' 16.728 /
'D-4H' 19 39 9 9 'OPEN' 1* 10.139 0.216 954.302 2* 'Z' 16.728 /
'D-4H' 19 39 10 10 'OPEN' 1* 56.214 0.216 5329.133 2* 'Z' 17.348 /
'D-4H' 20 39 10 10 'OPEN' 1* 40.444 0.216 3722.832 2* 'Z' 14.970 /
'D-4H' 20 39 11 11 'OPEN' 1* 15.490 0.216 1406.637 2* 'Z' 14.010 /
'D-4H' 20 39 12 12 'OPEN' 1* 4.053 0.216 369.545 2* 'Z' 14.283 /
'D-4H' 20 39 13 13 'OPEN' 1* 81.035 0.216 7311.999 2* 'Z' 13.582 /
'D-4H' 20 39 14 14 'OPEN' 1* 61.451 0.216 5535.182 2* 'Z' 13.468 /
'D-4H' 20 39 15 15 'OPEN' 1* 37.460 0.216 3372.715 2* 'Z' 13.440 /
'D-4H' 20 40 15 15 'OPEN' 1* 0.277 0.216 25.016 2* 'Z' 13.686 /
'D-4H' 20 40 16 16 'OPEN' 1* 102.234 0.216 9166.155 2* 'Z' 13.171 /
'D-4H' 20 40 17 17 'OPEN' 1* 3.271 0.216 293.466 2* 'Z' 13.208 /
'D-4H' 20 40 18 18 'OPEN' 1* 93.337 0.216 8616.407 2* 'Z' 15.185 /
'D-4H' 20 40 19 19 'OPEN' 1* 10.950 0.216 1017.169 2* 'Z' 15.660 /
'D-4H' 20 40 20 20 'OPEN' 1* 51.137 0.216 4766.863 2* 'Z' 15.938 /
'D-4H' 21 40 20 20 'OPEN' 1* 2128.276 0.216 198528.359 2* 'Z' 15.992 /
'D-4H' 21 40 21 21 'OPEN' 1* 33.150 0.216 2906.142 2* 'Z' 11.837 /
'D-4H' 21 40 22 22 'OPEN' 1* 185.163 0.216 16461.330 2* 'Z' 12.648 /
'D-4H' 21 41 22 22 'OPEN' 1* 290.075 0.216 26112.416 2* 'Z' 13.428 /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 5389.400 0.000 598227.688 5* /
'B-4H' 'OPEN' 'RESV' 5231.200 0.000 580659.687 5* /
'D-1H' 'OPEN' 'RESV' 4782.000 0.000 912405.625 5* /
'D-2H' 'OPEN' 'RESV' 5350.400 0.000 1294097.625 5* /
'D-4H' 'OPEN' 'ORAT' 0.000 0.000 0.000 5* /
/
WCONPROD
'D-4H' 'SHUT' 15* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 3179814.500 1* 600 /
/
WRFTPLT
'D-4H' 'YES' 'YES' 1* /
/
-- 202.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
27 'MAY' 1998 /
/
TSTEP
1 1 /
-- : D-4H Squeeze Top: 2715.00 Bot: 3038.00
-- : >> --for RFT pressure points
-- WARN: D-4H Squeeze interval 2754.172800 3038.000000 Top changed to 2764.886044
-- WARN: D-4H Squeeze interval 3036.734009 3038.000000 below grid
WELOPEN
'D-4H' 'SHUT' 0 0 0 2* /
/
WCONHIST
'B-2H' 'OPEN' 'RESV' 5127.720 0.000 569177.869 5* /
'B-4H' 'OPEN' 'RESV' 4969.300 0.000 551593.825 5* /
'D-1H' 'OPEN' 'RESV' 4473.520 0.000 859087.887 5* /
'D-2H' 'OPEN' 'RESV' 4944.620 0.000 1210434.200 5* /
/
WCONINJE
'C-4H' 'GAS' 1* 'RATE' 2904366.150 1* 600 /
/
-- 207.000000 days from start of simulation ( 6 'NOV' 1997 )
DATES
1 'JUN' 1998 /
/

104
tests/time_vector.py Normal file
View File

@@ -0,0 +1,104 @@
import unittest
import datetime
from sunbeam.tools import *
class TestTimeVector(unittest.TestCase):
def setUp(self):
pass
def test_create(self):
start_date = datetime.date(2018,1,1)
tv = TimeVector( start_date )
self.assertEqual(len(tv), 0)
with self.assertRaises(IndexError):
tv[1]
passed_date = datetime.datetime(2000,1,1)
with self.assertRaises(ValueError):
tv.add_keywords(passed_date, [])
next_date = datetime.datetime(2018,2,1)
tv.add_keywords(next_date, ["KEY1"])
self.assertEqual(len(tv), 1)
middle_date = datetime.datetime(2018,1,15)
tv.add_keywords(middle_date,[])
self.assertEqual(len(tv) ,2)
ts1 = tv[0]
self.assertEqual(ts1.dt, middle_date)
tv.add_keywords(next_date, ["KEY2"])
self.assertEqual(len(tv),2)
ts = tv[-1]
self.assertEqual(ts.keywords, ["KEY1", "KEY2"])
self.assertIn(middle_date, tv)
self.assertEqual(tv.dates, [middle_date, next_date])
tv.append_tstep(10, [])
ts = tv[-1]
self.assertTrue(ts.is_tstep)
with self.assertRaises(KeyError):
tv[datetime.datetime(1980,1,1)]
ts1 = tv[next_date]
ts2 = tv[datetime.date(next_date.year, next_date.month, next_date.day)]
self.assertEqual(ts1,ts2)
def test_load(self):
tv = TimeVector(datetime.date(1997, 11, 6))
tv.load("data/schedule/part1.sch")
tv.load("data/schedule/part3.sch")
tv.load("data/schedule/part2.sch")
self.assertEqual(tv.dates, [datetime.datetime(1997, 11, 14),
datetime.datetime(1997, 12, 1),
datetime.datetime(1997, 12, 17),
datetime.datetime(1998, 1, 1),
datetime.datetime(1998, 2, 1),
datetime.datetime(1998, 3, 1),
datetime.datetime(1998, 3, 29),
datetime.datetime(1998, 3, 30),
datetime.datetime(1998, 4, 1),
datetime.datetime(1998, 4, 23),
datetime.datetime(1998, 5, 1),
datetime.datetime(1998, 5, 26),
datetime.datetime(1998, 5, 27),
datetime.datetime(1998, 5, 28),
datetime.datetime(1998, 5, 29),
datetime.datetime(1998, 6, 1)])
def test_str(self):
tv = TimeVector(datetime.date(1997, 11, 6))
tv.load("data/schedule/part1.sch")
tv.load("data/schedule/part3.sch")
tv.load("data/schedule/part2.sch")
s = str(tv)
tv2 = TimeVector(datetime.date(1997, 11, 6))
tv2.load_string(s)
for ts1,ts2 in zip(tv,tv2):
self.assertEqual(ts1.dt, ts2.dt)
def test_optional(self):
tv = TimeVector(datetime.date(1997, 11, 6))
tv.load("data/schedule/part1.sch")
tv.load("data/schedule/fragment.sch", date = datetime.datetime(1998, 1, 10))
ts = tv[-1]
self.assertEqual(ts.dt, datetime.datetime(1998, 1 , 10))
self.assertEqual(ts.keywords[0].name, "WCONINJE")
if __name__ == "__main__":
unittest.main()