Updated ERT to bbab02e02630924471760a7e9357825ad414e2e9

Integrated fix for MSW reading of large wells
This commit is contained in:
Magne Sjaastad 2014-11-05 17:23:07 +01:00
parent 619b7a211a
commit f2c75c7f59
11 changed files with 152 additions and 17 deletions

View File

@ -84,7 +84,9 @@ int main(int argc , char ** argv) {
time = time_union;
else
time = time_intersect;
vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ );
load_count++;
} else {
const time_interval_type * ti = ecl_sum_get_sim_time( ecl_sum );
if (time_interval_has_overlap(time , ti)) {

View File

@ -494,7 +494,7 @@ void fortio_data_fseek(fortio_type* fortio, offset_type data_offset, size_t data
int block_index = data_element / block_size;
int headers = (block_index + 1) * 4;
int trailers = block_index * 4;
int bytes_to_skip = data_offset + headers + trailers + (data_element * element_size);
offset_type bytes_to_skip = data_offset + headers + trailers + (data_element * element_size);
fortio_fseek(fortio, bytes_to_skip, SEEK_SET);
}

View File

@ -207,7 +207,7 @@ static void plplot_set_axis(plot_driver_type * driver , const plot_range_type *
static void plplot_setup_linestyle( line_attribute_type line_attr ) {
pllsty(line_attr.line_style); /* Setting solid/dashed/... */
plwid(line_attr.line_width * PLOT_DEFAULT_LINE_WIDTH); /* Setting line width.*/
plwidth(line_attr.line_width * PLOT_DEFAULT_LINE_WIDTH); /* Setting line width.*/
plcol0(line_attr.line_color); /* Setting line color. */
}

View File

@ -394,7 +394,7 @@ class EclSum(BaseCClass):
raise ValueError("Must supply either days or date")
def timeRange(self , start = None , end = None , interval = "1Y"):
def timeRange(self , start = None , end = None , interval = "1Y", extend_end = True):
(num , timeUnit) = TimeVector.parseTimeUnit( interval )
if start is None:
@ -418,26 +418,31 @@ class EclSum(BaseCClass):
month2 = end.month
day1 = start.day
day2 = end.day
if timeUnit == 'm':
if day2 > 1:
month2 += 1
if month2 == 13:
if extend_end:
if timeUnit == 'm':
if day2 > 1:
month2 += 1
if month2 == 13:
year2 += 1
month2 = 1
elif timeUnit == "y":
month1 = 1
if year2 > 1 or day2 > 1:
year2 += 1
month2 = 1
elif timeUnit == "y":
month1 = 1
if year2 > 1 or day2 > 1:
year2 += 1
month2 = 1
day1 = 1
day2 = 1
start = datetime.date( year1, month1 , day1)
end = datetime.date(year2 , month2 , day2)
trange = TimeVector.createRegular(start , end , interval)
if trange[-1] < end:
trange.appendTime( num , timeUnit )
if extend_end:
trange.appendTime( num , timeUnit )
else:
trange.append( end )
return trange

View File

@ -76,6 +76,10 @@ class WellInfo(BaseCClass):
raise TypeError("Expected the RST file to be a filename or an EclFile instance.")
def hasWell(self , well_name):
return well_name in self
def free(self):
WellInfo.cNamespace().free(self)

View File

@ -9,6 +9,9 @@ class WellSegment(BaseCClass):
def free(self):
pass
def __str__(self):
return "{Segment ID:%d BranchID:%d Length:%g}" % (self.id() , self.branchId() , self.length())
def id(self):
""" @rtype: int """
return WellSegment.cNamespace().id(self)

View File

@ -52,18 +52,38 @@ class WellState(BaseCClass):
return values
def numSegments(self):
""" @rtype: int """
segment_collection = WellState.cNamespace().get_segment_collection(self)
count = WellState.cNamespace().segment_collection_size(segment_collection)
return count
def segments(self):
""" @rtype: list of WellSegment """
segment_collection = WellState.cNamespace().get_segment_collection(self)
count = WellState.cNamespace().segment_collection_size(segment_collection)
values = []
for index in range(count):
for index in range(self.numSegments()):
value = WellState.cNamespace().segment_collection_iget(segment_collection, index).setParent(self)
values.append(value)
return values
def igetSegment(self , segment_index):
""" @rtype: WellSegment """
if segment_index < 0:
segment_index += len(self)
if not 0 <= segment_index < self.numSegments():
raise IndexError("Invalid index:%d - valid range [0,%d)" % (index , len(self)))
segment_collection = WellState.cNamespace().get_segment_collection(self)
return WellState.cNamespace().segment_collection_iget(segment_collection, segment_index).setParent(self)
# def branches(self):
# """ @rtype: BranchCollection """

View File

@ -18,6 +18,9 @@ class WellTimeLine(BaseCClass):
@rtype: WellState
"""
if index < 0:
index += len(self)
if not 0 <= index < len(self):
raise IndexError("Index must be in range 0 <= %d < %d" % (index, len(self)))
@ -32,4 +35,4 @@ cwrapper = CWrapper(ECL_WELL_LIB)
WellTimeLine.cNamespace().size = cwrapper.prototype("int well_ts_get_size(well_time_line)")
WellTimeLine.cNamespace().iget = cwrapper.prototype("well_state_ref well_ts_iget_state(well_time_line, int)")
WellTimeLine.cNamespace().iget = cwrapper.prototype("well_state_ref well_ts_iget_state(well_time_line, int)")

View File

@ -127,6 +127,7 @@ set(TEST_SOURCES
ert_tests/server/test_socket.py
ert_tests/well/test_ecl_well.py
ert_tests/well/test_ecl_well2.py
ecl_isosurf.py
ens_config_test.py
@ -445,6 +446,10 @@ add_test( NAME python.tests.ert.ecl.ecl_sum_vector
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_sum_vector.EclSumVectorTest)
add_test( NAME python.tests.ert.ecl.ecl_sum_time_range
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_sum.EclSumTest)
add_test( NAME python.tests.ert.ecl.layer
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_layer.LayerTest )
@ -601,6 +606,11 @@ add_test( NAME python.tests.ert.well.ecl_well
COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.well.test_ecl_well.EclWellTest)
add_test( NAME python.tests.ert.well.ecl_well2
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.well.test_ecl_well2.EclWellTest2)
set_property( TEST python.tests.ert.sched.sched PROPERTY LABELS Python:StatoilData )
set_property( TEST python.tests.ert.ecl.fortio PROPERTY LABELS Python:StatoilData )
set_property( TEST python.tests.ert.ecl.ecl_grdecl PROPERTY LABELS Python:StatoilData )
@ -618,6 +628,7 @@ set_property( TEST python.tests.ert.ecl.ecl_grid PROPERTY LABELS Python
set_property( TEST python.tests.ert.ecl.ecl_deprecation PROPERTY LABELS Python )
#set_property( TEST python.tests.import_local PROPERTY LABELS Python:StatoilBuild )
set_property( TEST python.tests.ert.well.ecl_well PROPERTY LABELS Python:StatoilData )
set_property( TEST python.tests.ert.well.ecl_well2 PROPERTY LABELS Python:StatoilData )
set_property( TEST python.tests.ert.test_run PROPERTY LABELS Python)
set_property( TEST python.tests.ert.import PROPERTY LABELS Python)
@ -639,6 +650,7 @@ set_property( TEST python.tests.ert.enkf.ert_test_context PROPERTY LABELS Py
set_property( TEST python.tests.ert.enkf.plot.plot_block_data PROPERTY LABELS Python:StatoilData )
set_property( TEST python.tests.ert.enkf.data.gen_data_config PROPERTY LABELS Python:StatoilData )
set_property( TEST python.tests.ert.enkf.data.gen_data PROPERTY LABELS Python:StatoilData )
set_property( TEST python.tests.ert.ecl.ecl_sum_time_range PROPERTY LABELS Python:StatoilData )
if (ERT_BUILD_GUI)
set_property( TEST python.tests.ert_gui.import PROPERTY ENVIRONMENT "ERT_SHARE_PATH=${PROJECT_SOURCE_PATH}/share")

View File

@ -0,0 +1,43 @@
# !/usr/bin/env python
# Copyright (C) 2014 Statoil ASA, Norway.
#
# The file 'test_ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool.
#
# ERT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from ert.ecl import EclSum
from ert.test import ExtendedTestCase
try:
from unittest2 import skipIf
except ImportError:
from unittest import skipIf
class EclSumTest(ExtendedTestCase):
def setUp(self):
self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC")
self.ecl_sum = EclSum(self.test_file)
def test_time_range_year(self):
real_range = self.ecl_sum.timeRange(interval="1y", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval="1y", extend_end = True)
assert real_range[-1] < extended_range[-1]
def test_time_range_day(self):
real_range = self.ecl_sum.timeRange(interval = "1d", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval = "1d", extend_end = True)
assert real_range[-1] == extended_range[-1]
def test_time_range_month(self):
real_range = self.ecl_sum.timeRange(interval = "1m", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval = "1m", extend_end = True)
assert real_range[-1] < extended_range[-1]

View File

@ -0,0 +1,43 @@
import datetime
import os.path
from ert.ecl import EclGrid, EclFile, EclFileFlagEnum
from ert.test import ExtendedTestCase
from ert.util.ctime import CTime
from ert.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment
class EclWellTest2(ExtendedTestCase):
grid = None
def getGrid(self):
if EclWellTest2.grid is None:
EclWellTest2.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID"))
return EclWellTest2.grid
def checkWell(self , rst_file):
segment_length = [2660 , 20 , 121 , 1347.916 , 20.585 , 56.249 , 115.503 , 106.978 , 47.124 , 279.529,
128.534 , 165.33 , 59.97 , 936.719 ]
well_info = WellInfo( self.getGrid() , self.createTestPath( os.path.join("Statoil/ECLIPSE/Troll/Ref2014" , rst_file )))
well_time_line = well_info["F4BYH"]
for well_state in well_time_line:
self.assertTrue( well_state.isMultiSegmentWell() )
self.assertTrue( well_state.hasSegmentData() )
for index,length in enumerate(segment_length):
segment = well_state.igetSegment(index)
self.assertFloatEqual( segment.length() , length )
def testWell(self):
self.checkWell("T07-4A-W2014-06.X0695")
self.checkWell("T07-4A-W2014-06.X0709")
self.checkWell("T07-4A-W2014-06.UNRST")