예제 #1
0
    def test_writer(self):
        writer = EclSum.writer("CASE", datetime.date(2000, 1, 1), 10, 10, 5)
        self.assertIsInstance(self.ecl_sum, EclSum)

        writer.addVariable("FOPT")
        self.assertTrue(writer.has_key("FOPT"))

        writer.addTStep(1, 100)
예제 #2
0
    def test_writer(self):
        writer = EclSum.writer("CASE" , datetime.date( 2000 , 1 , 1) , 10 , 10 , 5)
        self.assertIsInstance(self.ecl_sum, EclSum)


        writer.addVariable( "FOPT" )
        self.assertTrue( writer.has_key( "FOPT" ))

        writer.addTStep( 1 , 100 )
def create_synthetic_refcase(case_name: pathlib.Path,
                             schedule: Schedule,
                             nx: int = 1,
                             ny: int = 1,
                             nz: int = 1):
    """
    This function creates a synthetic simulation output in order to please ERT, which
    uses it for mapping the dates to report step.

    Args:
        case_name: Case name for synthetic case
        schedule: FlowNet Schedule instance
        nx: Number of grid blocks in the x-direction
        ny: Number of grid blocks in the y-direction
        nz: Number of grid blocks in the z-direction

    Returns:
        Nothing

    """
    datetimes = schedule.get_dates()
    numdates = [date2num(date) for date in datetimes]

    start_time = CTime._timegm(  # pylint: disable=protected-access
        0, 0, 0, datetimes[0].day, datetimes[0].month, datetimes[0].year)

    eclsum = EclSum.writer(str(case_name), start_time, nx, ny, nz)

    vectors = []
    for well in schedule.get_wells():
        vectors.append(["WOPR", well, 0, "Sm3/day"])
        vectors.append(["WWPR", well, 0, "Sm3/day"])
        vectors.append(["WGOR", well, 0, "Sm3/day"])
        vectors.append(["WBHP", well, 0, "Sm3/day"])

    for vector in vectors:
        # pylint: disable=no-member
        EclSum.addVariable(eclsum, vector[0], vector[1], vector[2], vector[3])

    for report_step, _ in enumerate(numdates):
        # pylint: disable=no-member
        if report_step == 0:
            tstep = EclSum.addTStep(eclsum, 1,
                                    numdates[report_step] - numdates[0])
        else:
            tstep = EclSum.addTStep(eclsum, report_step,
                                    numdates[report_step] - numdates[0])

        for vector in vectors:
            tstep[f"{vector[0]}:{vector[1]}"] = 0

    EclSum.fwrite(eclsum)
예제 #4
0
def run_simulator(time_step_count, start_date):
    """@rtype: EclSum"""
    ecl_sum = EclSum.writer("SNAKE_OIL_FIELD", start_date, 10, 10, 10)

    ecl_sum.addVariable("FOPR", unit="SM3/DAY")
    ecl_sum.addVariable("FOPRH", unit="SM3/DAY")

    ecl_sum.addVariable("WOPR", wgname="OP1", unit="SM3/DAY")
    ecl_sum.addVariable("WOPRH", wgname="OP1", unit="SM3/DAY")

    mini_step_count = 10
    for report_step in range(time_step_count):
        for mini_step in range(mini_step_count):
            t_step = ecl_sum.addTStep(report_step + 1,
                                      sim_days=report_step * mini_step_count +
                                      mini_step)
            t_step["FOPR"] = 1
            t_step["WOPR:OP1"] = 2
            t_step["FOPRH"] = 3
            t_step["WOPRH:OP1"] = 4

    return ecl_sum
예제 #5
0
def _create_synthetic_smry(directory_path: pathlib.Path, length: int = 3):
    """Create synthetic TEST.UNSMRY and TEST.SMSPEC files in a specified directory"""
    sum_keys = {
        "FOPT": [i for i in range(length)],
        "FOPR": [1] * length,
    }
    dimensions = [10, 10, 10]
    ecl_sum = EclSum.writer("TEST", datetime.date(2000, 1, 1), *dimensions)

    for key in sum_keys:
        ecl_sum.add_variable(key)

    for val, idx in enumerate(range(0, length, 1)):
        t_step = ecl_sum.add_t_step(idx, val)
        for key, item in sum_keys.items():
            t_step[key] = item[idx]

    # libecl can only write UNSMRY+SMSPEC files to current working directory
    old_dir = os.getcwd()
    try:
        os.chdir(directory_path)
        ecl_sum.fwrite()
    finally:
        os.chdir(old_dir)
예제 #6
0
def runSimulator(simulator, history_simulator, time_step_count):
    """@rtype: EclSum"""
    ecl_sum = EclSum.writer("SNAKE_OIL_FIELD", datetime(2010, 1, 1), 10, 10, 10)

    ecl_sum.addVariable("FOPT")
    ecl_sum.addVariable("FOPR")
    ecl_sum.addVariable("FGPT")
    ecl_sum.addVariable("FGPR")
    ecl_sum.addVariable("FWPT")
    ecl_sum.addVariable("FWPR")
    ecl_sum.addVariable("FGOR")
    ecl_sum.addVariable("FWCT")

    ecl_sum.addVariable("FOPTH")
    ecl_sum.addVariable("FOPRH")
    ecl_sum.addVariable("FGPTH")
    ecl_sum.addVariable("FGPRH")
    ecl_sum.addVariable("FWPTH")
    ecl_sum.addVariable("FWPRH")
    ecl_sum.addVariable("FGORH")
    ecl_sum.addVariable("FWCTH")

    ecl_sum.addVariable("WOPR", wgname="OP1")
    ecl_sum.addVariable("WOPR", wgname="OP2")
    ecl_sum.addVariable("WWPR", wgname="OP1")
    ecl_sum.addVariable("WWPR", wgname="OP2")
    ecl_sum.addVariable("WGPR", wgname="OP1")
    ecl_sum.addVariable("WGPR", wgname="OP2")
    ecl_sum.addVariable("WGOR", wgname="OP1")
    ecl_sum.addVariable("WGOR", wgname="OP2")
    ecl_sum.addVariable("WWCT", wgname="OP1")
    ecl_sum.addVariable("WWCT", wgname="OP2")

    ecl_sum.addVariable("WOPRH", wgname="OP1")
    ecl_sum.addVariable("WOPRH", wgname="OP2")
    ecl_sum.addVariable("WWPRH", wgname="OP1")
    ecl_sum.addVariable("WWPRH", wgname="OP2")
    ecl_sum.addVariable("WGPRH", wgname="OP1")
    ecl_sum.addVariable("WGPRH", wgname="OP2")
    ecl_sum.addVariable("WGORH", wgname="OP1")
    ecl_sum.addVariable("WGORH", wgname="OP2")
    ecl_sum.addVariable("WWCTH", wgname="OP1")
    ecl_sum.addVariable("WWCTH", wgname="OP2")

    ecl_sum.addVariable("BPR", num=globalIndex(5, 5, 5))
    ecl_sum.addVariable("BPR", num=globalIndex(1, 3, 8))

    time_map = []
    mini_step_count = 10
    total_step_count = time_step_count * mini_step_count

    for report_step in range(time_step_count):
        for mini_step in range(mini_step_count):
            t_step = ecl_sum.addTStep(
                report_step + 1, sim_days=report_step * mini_step_count + mini_step
            )

            time_map.append(t_step.getSimTime().datetime().strftime("%d/%m/%Y"))

            simulator.step(scale=1.0 / total_step_count)
            history_simulator.step(scale=1.0 / total_step_count)

            t_step["FOPR"] = simulator.fopr()
            t_step["FOPT"] = simulator.fopt()
            t_step["FGPR"] = simulator.fgpr()
            t_step["FGPT"] = simulator.fgpt()
            t_step["FWPR"] = simulator.fwpr()
            t_step["FWPT"] = simulator.fwpt()
            t_step["FGOR"] = simulator.fgor()
            t_step["FWCT"] = simulator.fwct()

            t_step["WOPR:OP1"] = simulator.opr("OP1")
            t_step["WOPR:OP2"] = simulator.opr("OP2")

            t_step["WGPR:OP1"] = simulator.gpr("OP1")
            t_step["WGPR:OP2"] = simulator.gpr("OP2")

            t_step["WWPR:OP1"] = simulator.wpr("OP1")
            t_step["WWPR:OP2"] = simulator.wpr("OP2")

            t_step["WGOR:OP1"] = simulator.gor("OP1")
            t_step["WGOR:OP2"] = simulator.gor("OP2")

            t_step["WWCT:OP1"] = simulator.wct("OP1")
            t_step["WWCT:OP2"] = simulator.wct("OP2")

            t_step["BPR:5,5,5"] = simulator.bpr("5,5,5")
            t_step["BPR:1,3,8"] = simulator.bpr("1,3,8")

            t_step["FOPRH"] = history_simulator.fopr()
            t_step["FOPTH"] = history_simulator.fopt()
            t_step["FGPRH"] = history_simulator.fgpr()
            t_step["FGPTH"] = history_simulator.fgpt()
            t_step["FWPRH"] = history_simulator.fwpr()
            t_step["FWPTH"] = history_simulator.fwpt()
            t_step["FGORH"] = history_simulator.fgor()
            t_step["FWCTH"] = history_simulator.fwct()

            t_step["WOPRH:OP1"] = history_simulator.opr("OP1")
            t_step["WOPRH:OP2"] = history_simulator.opr("OP2")

            t_step["WGPRH:OP1"] = history_simulator.gpr("OP1")
            t_step["WGPRH:OP2"] = history_simulator.gpr("OP2")

            t_step["WWPRH:OP1"] = history_simulator.wpr("OP1")
            t_step["WWPRH:OP2"] = history_simulator.wpr("OP2")

            t_step["WGORH:OP1"] = history_simulator.gor("OP1")
            t_step["WGORH:OP2"] = history_simulator.gor("OP2")

            t_step["WWCTH:OP1"] = history_simulator.wct("OP1")
            t_step["WWCTH:OP2"] = history_simulator.wct("OP2")

    return ecl_sum, time_map
예제 #7
0
def test_write_repr():
    """repr(EclSum) used to segfault when there is only a startdate"""
    writer = EclSum.writer("TEST", datetime.date(2000, 2, 3), 10, 10, 10)
    assert repr(writer).startswith(
        'EclSum(name="writer", time=[2000-02-03 00:00:00, 2000-02-03 00:00:00], keys=0) at 0x'
    )
예제 #8
0
def runSimulator(simulator, history_simulator, time_step_count):
    """ @rtype: EclSum """
    ecl_sum = EclSum.writer("SNAKE_OIL_FIELD", datetime(2010, 1, 1), 10, 10,
                            10)

    ecl_sum.addVariable('FOPT', unit="SM3")
    ecl_sum.addVariable('FOPR', unit="SM3/DAY")
    ecl_sum.addVariable('FGPT', unit="SM3")
    ecl_sum.addVariable('FGPR', unit="SM3/DAY")
    ecl_sum.addVariable('FWPT', unit="SM3")
    ecl_sum.addVariable('FWPR', unit="SM3/DAY")
    ecl_sum.addVariable('FGOR', unit="SM3/SM3")
    ecl_sum.addVariable('FWCT', unit="SM3/SM3")

    ecl_sum.addVariable('FOIP', unit="SM3")
    ecl_sum.addVariable('FGIP', unit="SM3")
    ecl_sum.addVariable('FWIP', unit="SM3")

    ecl_sum.addVariable('FOPTH', unit="SM3")
    ecl_sum.addVariable('FOPRH', unit="SM3/DAY")
    ecl_sum.addVariable('FGPTH', unit="SM3")
    ecl_sum.addVariable('FGPRH', unit="SM3/DAY")
    ecl_sum.addVariable('FWPTH', unit="SM3")
    ecl_sum.addVariable('FWPRH', unit="SM3/DAY")
    ecl_sum.addVariable('FGORH', unit="SM3/SM3")
    ecl_sum.addVariable('FWCTH', unit="SM3/SM3")

    ecl_sum.addVariable('FOIPH', unit="SM3")
    ecl_sum.addVariable('FGIPH', unit="SM3")
    ecl_sum.addVariable('FWIPH', unit="SM3")

    ecl_sum.addVariable('WOPR', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WOPR', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WWPR', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WWPR', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WGPR', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WGPR', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WGOR', wgname='OP1', unit="SM3/SM3")
    ecl_sum.addVariable('WGOR', wgname='OP2', unit="SM3/SM3")
    ecl_sum.addVariable('WWCT', wgname='OP1', unit="SM3/SM3")
    ecl_sum.addVariable('WWCT', wgname='OP2', unit="SM3/SM3")

    ecl_sum.addVariable('WOPRH', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WOPRH', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WWPRH', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WWPRH', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WGPRH', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WGPRH', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WGORH', wgname='OP1', unit="SM3/SM3")
    ecl_sum.addVariable('WGORH', wgname='OP2', unit="SM3/SM3")
    ecl_sum.addVariable('WWCTH', wgname='OP1', unit="SM3/SM3")
    ecl_sum.addVariable('WWCTH', wgname='OP2', unit="SM3/SM3")

    ecl_sum.addVariable('BPR', num=globalIndex(5, 5, 5), unit="BARSA")
    ecl_sum.addVariable('BPR', num=globalIndex(1, 3, 8), unit="BARSA")

    time_map = []
    mini_step_count = 10
    total_step_count = time_step_count * mini_step_count

    for report_step in range(time_step_count):
        for mini_step in range(mini_step_count):
            t_step = ecl_sum.addTStep(report_step + 1,
                                      sim_days=report_step * mini_step_count +
                                      mini_step)

            time_map.append(
                t_step.getSimTime().datetime().strftime("%d/%m/%Y"))

            simulator.step(scale=1.0 / total_step_count)
            history_simulator.step(scale=1.0 / total_step_count)

            t_step['FOPR'] = simulator.fopr()
            t_step['FOPT'] = simulator.fopt()
            t_step['FGPR'] = simulator.fgpr()
            t_step['FGPT'] = simulator.fgpt()
            t_step['FWPR'] = simulator.fwpr()
            t_step['FWPT'] = simulator.fwpt()
            t_step['FGOR'] = simulator.fgor()
            t_step['FWCT'] = simulator.fwct()

            t_step['FOIP'] = simulator.foip()
            t_step['FGIP'] = simulator.fgip()
            t_step['FWIP'] = simulator.fwip()

            t_step['WOPR:OP1'] = simulator.opr('OP1')
            t_step['WOPR:OP2'] = simulator.opr('OP2')

            t_step['WGPR:OP1'] = simulator.gpr('OP1')
            t_step['WGPR:OP2'] = simulator.gpr('OP2')

            t_step['WWPR:OP1'] = simulator.wpr('OP1')
            t_step['WWPR:OP2'] = simulator.wpr('OP2')

            t_step['WGOR:OP1'] = simulator.gor('OP1')
            t_step['WGOR:OP2'] = simulator.gor('OP2')

            t_step['WWCT:OP1'] = simulator.wct('OP1')
            t_step['WWCT:OP2'] = simulator.wct('OP2')

            t_step['BPR:5,5,5'] = simulator.bpr('5,5,5')
            t_step['BPR:1,3,8'] = simulator.bpr('1,3,8')

            t_step['FOPRH'] = history_simulator.fopr()
            t_step['FOPTH'] = history_simulator.fopt()
            t_step['FGPRH'] = history_simulator.fgpr()
            t_step['FGPTH'] = history_simulator.fgpt()
            t_step['FWPRH'] = history_simulator.fwpr()
            t_step['FWPTH'] = history_simulator.fwpt()
            t_step['FGORH'] = history_simulator.fgor()
            t_step['FWCTH'] = history_simulator.fwct()
            t_step['FOIPH'] = history_simulator.foip()
            t_step['FGIPH'] = history_simulator.fgip()
            t_step['FWIPH'] = history_simulator.fwip()

            t_step['WOPRH:OP1'] = history_simulator.opr('OP1')
            t_step['WOPRH:OP2'] = history_simulator.opr('OP2')

            t_step['WGPRH:OP1'] = history_simulator.gpr('OP1')
            t_step['WGPRH:OP2'] = history_simulator.gpr('OP2')

            t_step['WWPRH:OP1'] = history_simulator.wpr('OP1')
            t_step['WWPRH:OP2'] = history_simulator.wpr('OP2')

            t_step['WGORH:OP1'] = history_simulator.gor('OP1')
            t_step['WGORH:OP2'] = history_simulator.gor('OP2')

            t_step['WWCTH:OP1'] = history_simulator.wct('OP1')
            t_step['WWCTH:OP2'] = history_simulator.wct('OP2')

    return ecl_sum, time_map
예제 #9
0
def runSimulator(simulator, history_simulator, time_step_count):
    """ @rtype: EclSum """
    ecl_sum = EclSum.writer("SNAKE_OIL_FIELD", datetime(2010, 1, 1), 10, 10, 10)

    ecl_sum.addVariable("FOPT")
    ecl_sum.addVariable("FOPR")
    ecl_sum.addVariable("FGPT")
    ecl_sum.addVariable("FGPR")
    ecl_sum.addVariable("FWPT")
    ecl_sum.addVariable("FWPR")
    ecl_sum.addVariable("FGOR")
    ecl_sum.addVariable("FWCT")

    ecl_sum.addVariable("FOPTH")
    ecl_sum.addVariable("FOPRH")
    ecl_sum.addVariable("FGPTH")
    ecl_sum.addVariable("FGPRH")
    ecl_sum.addVariable("FWPTH")
    ecl_sum.addVariable("FWPRH")
    ecl_sum.addVariable("FGORH")
    ecl_sum.addVariable("FWCTH")

    ecl_sum.addVariable("WOPR", wgname="OP1")
    ecl_sum.addVariable("WOPR", wgname="OP2")
    ecl_sum.addVariable("WWPR", wgname="OP1")
    ecl_sum.addVariable("WWPR", wgname="OP2")
    ecl_sum.addVariable("WGPR", wgname="OP1")
    ecl_sum.addVariable("WGPR", wgname="OP2")
    ecl_sum.addVariable("WGOR", wgname="OP1")
    ecl_sum.addVariable("WGOR", wgname="OP2")
    ecl_sum.addVariable("WWCT", wgname="OP1")
    ecl_sum.addVariable("WWCT", wgname="OP2")

    ecl_sum.addVariable("WOPRH", wgname="OP1")
    ecl_sum.addVariable("WOPRH", wgname="OP2")
    ecl_sum.addVariable("WWPRH", wgname="OP1")
    ecl_sum.addVariable("WWPRH", wgname="OP2")
    ecl_sum.addVariable("WGPRH", wgname="OP1")
    ecl_sum.addVariable("WGPRH", wgname="OP2")
    ecl_sum.addVariable("WGORH", wgname="OP1")
    ecl_sum.addVariable("WGORH", wgname="OP2")
    ecl_sum.addVariable("WWCTH", wgname="OP1")
    ecl_sum.addVariable("WWCTH", wgname="OP2")

    ecl_sum.addVariable("BPR", num=globalIndex(5, 5, 5))
    ecl_sum.addVariable("BPR", num=globalIndex(1, 3, 8))

    time_map = []
    mini_step_count = 10
    total_step_count = time_step_count * mini_step_count

    for report_step in range(time_step_count):
        for mini_step in range(mini_step_count):
            t_step = ecl_sum.addTStep(report_step + 1, sim_days=report_step * mini_step_count + mini_step)

            time_map.append(t_step.getSimTime().datetime().strftime("%d/%m/%Y"))

            simulator.step(scale=1.0 / total_step_count)
            history_simulator.step(scale=1.0 / total_step_count)

            t_step["FOPR"] = simulator.fopr()
            t_step["FOPT"] = simulator.fopt()
            t_step["FGPR"] = simulator.fgpr()
            t_step["FGPT"] = simulator.fgpt()
            t_step["FWPR"] = simulator.fwpr()
            t_step["FWPT"] = simulator.fwpt()
            t_step["FGOR"] = simulator.fgor()
            t_step["FWCT"] = simulator.fwct()

            t_step["WOPR:OP1"] = simulator.opr("OP1")
            t_step["WOPR:OP2"] = simulator.opr("OP2")

            t_step["WGPR:OP1"] = simulator.gpr("OP1")
            t_step["WGPR:OP2"] = simulator.gpr("OP2")

            t_step["WWPR:OP1"] = simulator.wpr("OP1")
            t_step["WWPR:OP2"] = simulator.wpr("OP2")

            t_step["WGOR:OP1"] = simulator.gor("OP1")
            t_step["WGOR:OP2"] = simulator.gor("OP2")

            t_step["WWCT:OP1"] = simulator.wct("OP1")
            t_step["WWCT:OP2"] = simulator.wct("OP2")

            t_step["BPR:5,5,5"] = simulator.bpr("5,5,5")
            t_step["BPR:1,3,8"] = simulator.bpr("1,3,8")

            t_step["FOPRH"] = history_simulator.fopr()
            t_step["FOPTH"] = history_simulator.fopt()
            t_step["FGPRH"] = history_simulator.fgpr()
            t_step["FGPTH"] = history_simulator.fgpt()
            t_step["FWPRH"] = history_simulator.fwpr()
            t_step["FWPTH"] = history_simulator.fwpt()
            t_step["FGORH"] = history_simulator.fgor()
            t_step["FWCTH"] = history_simulator.fwct()

            t_step["WOPRH:OP1"] = history_simulator.opr("OP1")
            t_step["WOPRH:OP2"] = history_simulator.opr("OP2")

            t_step["WGPRH:OP1"] = history_simulator.gpr("OP1")
            t_step["WGPRH:OP2"] = history_simulator.gpr("OP2")

            t_step["WWPRH:OP1"] = history_simulator.wpr("OP1")
            t_step["WWPRH:OP2"] = history_simulator.wpr("OP2")

            t_step["WGORH:OP1"] = history_simulator.gor("OP1")
            t_step["WGORH:OP2"] = history_simulator.gor("OP2")

            t_step["WWCTH:OP1"] = history_simulator.wct("OP1")
            t_step["WWCTH:OP2"] = history_simulator.wct("OP2")

    return ecl_sum, time_map
예제 #10
0
def runSimulator(simulator, history_simulator, time_step_count):
    """ @rtype: EclSum """
    ecl_sum = EclSum.writer("SNAKE_OIL_FIELD", datetime(2010, 1, 1), 10, 10, 10)

    ecl_sum.addVariable('FOPT', unit="SM3")
    ecl_sum.addVariable('FOPR', unit="SM3/DAY")
    ecl_sum.addVariable('FGPT', unit="SM3")
    ecl_sum.addVariable('FGPR', unit="SM3/DAY")
    ecl_sum.addVariable('FWPT', unit="SM3")
    ecl_sum.addVariable('FWPR', unit="SM3/DAY")
    ecl_sum.addVariable('FGOR', unit="SM3/SM3")
    ecl_sum.addVariable('FWCT', unit="SM3/SM3")

    ecl_sum.addVariable('FOIP', unit="SM3")
    ecl_sum.addVariable('FGIP', unit="SM3")
    ecl_sum.addVariable('FWIP', unit="SM3")

    ecl_sum.addVariable('FOPTH', unit="SM3")
    ecl_sum.addVariable('FOPRH', unit="SM3/DAY")
    ecl_sum.addVariable('FGPTH', unit="SM3")
    ecl_sum.addVariable('FGPRH', unit="SM3/DAY")
    ecl_sum.addVariable('FWPTH', unit="SM3")
    ecl_sum.addVariable('FWPRH', unit="SM3/DAY")
    ecl_sum.addVariable('FGORH', unit="SM3/SM3")
    ecl_sum.addVariable('FWCTH', unit="SM3/SM3")

    ecl_sum.addVariable('FOIPH', unit="SM3")
    ecl_sum.addVariable('FGIPH', unit="SM3")
    ecl_sum.addVariable('FWIPH', unit="SM3")

    ecl_sum.addVariable('WOPR', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WOPR', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WWPR', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WWPR', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WGPR', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WGPR', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WGOR', wgname='OP1', unit="SM3/SM3")
    ecl_sum.addVariable('WGOR', wgname='OP2', unit="SM3/SM3")
    ecl_sum.addVariable('WWCT', wgname='OP1', unit="SM3/SM3")
    ecl_sum.addVariable('WWCT', wgname='OP2', unit="SM3/SM3")

    ecl_sum.addVariable('WOPRH', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WOPRH', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WWPRH', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WWPRH', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WGPRH', wgname='OP1', unit="SM3/DAY")
    ecl_sum.addVariable('WGPRH', wgname='OP2', unit="SM3/DAY")
    ecl_sum.addVariable('WGORH', wgname='OP1', unit="SM3/SM3")
    ecl_sum.addVariable('WGORH', wgname='OP2', unit="SM3/SM3")
    ecl_sum.addVariable('WWCTH', wgname='OP1', unit="SM3/SM3")
    ecl_sum.addVariable('WWCTH', wgname='OP2', unit="SM3/SM3")

    ecl_sum.addVariable('BPR', num=globalIndex(5, 5, 5), unit="BARSA")
    ecl_sum.addVariable('BPR', num=globalIndex(1, 3, 8), unit="BARSA")

    time_map = []
    mini_step_count = 10
    total_step_count = time_step_count * mini_step_count

    for report_step in range(time_step_count):
        for mini_step in range(mini_step_count):
            t_step = ecl_sum.addTStep(report_step + 1, sim_days=report_step * mini_step_count + mini_step)

            time_map.append(t_step.getSimTime().datetime().strftime("%d/%m/%Y"))

            simulator.step(scale=1.0 / total_step_count)
            history_simulator.step(scale=1.0 / total_step_count)

            t_step['FOPR'] = simulator.fopr()
            t_step['FOPT'] = simulator.fopt()
            t_step['FGPR'] = simulator.fgpr()
            t_step['FGPT'] = simulator.fgpt()
            t_step['FWPR'] = simulator.fwpr()
            t_step['FWPT'] = simulator.fwpt()
            t_step['FGOR'] = simulator.fgor()
            t_step['FWCT'] = simulator.fwct()

            t_step['FOIP'] = simulator.foip()
            t_step['FGIP'] = simulator.fgip()
            t_step['FWIP'] = simulator.fwip()

            t_step['WOPR:OP1'] = simulator.opr('OP1')
            t_step['WOPR:OP2'] = simulator.opr('OP2')

            t_step['WGPR:OP1'] = simulator.gpr('OP1')
            t_step['WGPR:OP2'] = simulator.gpr('OP2')

            t_step['WWPR:OP1'] = simulator.wpr('OP1')
            t_step['WWPR:OP2'] = simulator.wpr('OP2')

            t_step['WGOR:OP1'] = simulator.gor('OP1')
            t_step['WGOR:OP2'] = simulator.gor('OP2')

            t_step['WWCT:OP1'] = simulator.wct('OP1')
            t_step['WWCT:OP2'] = simulator.wct('OP2')

            t_step['BPR:5,5,5'] = simulator.bpr('5,5,5')
            t_step['BPR:1,3,8'] = simulator.bpr('1,3,8')

            t_step['FOPRH'] = history_simulator.fopr()
            t_step['FOPTH'] = history_simulator.fopt()
            t_step['FGPRH'] = history_simulator.fgpr()
            t_step['FGPTH'] = history_simulator.fgpt()
            t_step['FWPRH'] = history_simulator.fwpr()
            t_step['FWPTH'] = history_simulator.fwpt()
            t_step['FGORH'] = history_simulator.fgor()
            t_step['FWCTH'] = history_simulator.fwct()
            t_step['FOIPH'] = history_simulator.foip()
            t_step['FGIPH'] = history_simulator.fgip()
            t_step['FWIPH'] = history_simulator.fwip()

            t_step['WOPRH:OP1'] = history_simulator.opr('OP1')
            t_step['WOPRH:OP2'] = history_simulator.opr('OP2')

            t_step['WGPRH:OP1'] = history_simulator.gpr('OP1')
            t_step['WGPRH:OP2'] = history_simulator.gpr('OP2')

            t_step['WWPRH:OP1'] = history_simulator.wpr('OP1')
            t_step['WWPRH:OP2'] = history_simulator.wpr('OP2')

            t_step['WGORH:OP1'] = history_simulator.gor('OP1')
            t_step['WGORH:OP2'] = history_simulator.gor('OP2')

            t_step['WWCTH:OP1'] = history_simulator.wct('OP1')
            t_step['WWCTH:OP2'] = history_simulator.wct('OP2')

    return ecl_sum, time_map
예제 #11
0
def runSimulator(simulator, history_simulator, time_step_count):
    """@rtype: EclSum"""
    ecl_sum = EclSum.writer("SNAKE_OIL_FIELD", datetime(2010, 1, 1), 10, 10,
                            10)

    ecl_sum.addVariable("FOPT", unit="SM3")
    ecl_sum.addVariable("FOPR", unit="SM3/DAY")
    ecl_sum.addVariable("FGPT", unit="SM3")
    ecl_sum.addVariable("FGPR", unit="SM3/DAY")
    ecl_sum.addVariable("FWPT", unit="SM3")
    ecl_sum.addVariable("FWPR", unit="SM3/DAY")
    ecl_sum.addVariable("FGOR", unit="SM3/SM3")
    ecl_sum.addVariable("FWCT", unit="SM3/SM3")

    ecl_sum.addVariable("FOIP", unit="SM3")
    ecl_sum.addVariable("FGIP", unit="SM3")
    ecl_sum.addVariable("FWIP", unit="SM3")

    ecl_sum.addVariable("FOPTH", unit="SM3")
    ecl_sum.addVariable("FOPRH", unit="SM3/DAY")
    ecl_sum.addVariable("FGPTH", unit="SM3")
    ecl_sum.addVariable("FGPRH", unit="SM3/DAY")
    ecl_sum.addVariable("FWPTH", unit="SM3")
    ecl_sum.addVariable("FWPRH", unit="SM3/DAY")
    ecl_sum.addVariable("FGORH", unit="SM3/SM3")
    ecl_sum.addVariable("FWCTH", unit="SM3/SM3")

    ecl_sum.addVariable("FOIPH", unit="SM3")
    ecl_sum.addVariable("FGIPH", unit="SM3")
    ecl_sum.addVariable("FWIPH", unit="SM3")

    ecl_sum.addVariable("WOPR", wgname="OP1", unit="SM3/DAY")
    ecl_sum.addVariable("WOPR", wgname="OP2", unit="SM3/DAY")
    ecl_sum.addVariable("WWPR", wgname="OP1", unit="SM3/DAY")
    ecl_sum.addVariable("WWPR", wgname="OP2", unit="SM3/DAY")
    ecl_sum.addVariable("WGPR", wgname="OP1", unit="SM3/DAY")
    ecl_sum.addVariable("WGPR", wgname="OP2", unit="SM3/DAY")
    ecl_sum.addVariable("WGOR", wgname="OP1", unit="SM3/SM3")
    ecl_sum.addVariable("WGOR", wgname="OP2", unit="SM3/SM3")
    ecl_sum.addVariable("WWCT", wgname="OP1", unit="SM3/SM3")
    ecl_sum.addVariable("WWCT", wgname="OP2", unit="SM3/SM3")

    ecl_sum.addVariable("WOPRH", wgname="OP1", unit="SM3/DAY")
    ecl_sum.addVariable("WOPRH", wgname="OP2", unit="SM3/DAY")
    ecl_sum.addVariable("WWPRH", wgname="OP1", unit="SM3/DAY")
    ecl_sum.addVariable("WWPRH", wgname="OP2", unit="SM3/DAY")
    ecl_sum.addVariable("WGPRH", wgname="OP1", unit="SM3/DAY")
    ecl_sum.addVariable("WGPRH", wgname="OP2", unit="SM3/DAY")
    ecl_sum.addVariable("WGORH", wgname="OP1", unit="SM3/SM3")
    ecl_sum.addVariable("WGORH", wgname="OP2", unit="SM3/SM3")
    ecl_sum.addVariable("WWCTH", wgname="OP1", unit="SM3/SM3")
    ecl_sum.addVariable("WWCTH", wgname="OP2", unit="SM3/SM3")

    ecl_sum.addVariable("BPR", num=globalIndex(5, 5, 5), unit="BARSA")
    ecl_sum.addVariable("BPR", num=globalIndex(1, 3, 8), unit="BARSA")

    time_map = []
    mini_step_count = 10
    total_step_count = time_step_count * mini_step_count

    for report_step in range(time_step_count):
        for mini_step in range(mini_step_count):
            t_step = ecl_sum.addTStep(report_step + 1,
                                      sim_days=report_step * mini_step_count +
                                      mini_step)

            time_map.append(
                t_step.getSimTime().datetime().strftime("%Y-%m-%d"))

            simulator.step(scale=1.0 / total_step_count)
            history_simulator.step(scale=1.0 / total_step_count)

            t_step["FOPR"] = simulator.fopr()
            t_step["FOPT"] = simulator.fopt()
            t_step["FGPR"] = simulator.fgpr()
            t_step["FGPT"] = simulator.fgpt()
            t_step["FWPR"] = simulator.fwpr()
            t_step["FWPT"] = simulator.fwpt()
            t_step["FGOR"] = simulator.fgor()
            t_step["FWCT"] = simulator.fwct()

            t_step["FOIP"] = simulator.foip()
            t_step["FGIP"] = simulator.fgip()
            t_step["FWIP"] = simulator.fwip()

            t_step["WOPR:OP1"] = simulator.opr("OP1")
            t_step["WOPR:OP2"] = simulator.opr("OP2")

            t_step["WGPR:OP1"] = simulator.gpr("OP1")
            t_step["WGPR:OP2"] = simulator.gpr("OP2")

            t_step["WWPR:OP1"] = simulator.wpr("OP1")
            t_step["WWPR:OP2"] = simulator.wpr("OP2")

            t_step["WGOR:OP1"] = simulator.gor("OP1")
            t_step["WGOR:OP2"] = simulator.gor("OP2")

            t_step["WWCT:OP1"] = simulator.wct("OP1")
            t_step["WWCT:OP2"] = simulator.wct("OP2")

            t_step["BPR:5,5,5"] = simulator.bpr("5,5,5")
            t_step["BPR:1,3,8"] = simulator.bpr("1,3,8")

            t_step["FOPRH"] = history_simulator.fopr()
            t_step["FOPTH"] = history_simulator.fopt()
            t_step["FGPRH"] = history_simulator.fgpr()
            t_step["FGPTH"] = history_simulator.fgpt()
            t_step["FWPRH"] = history_simulator.fwpr()
            t_step["FWPTH"] = history_simulator.fwpt()
            t_step["FGORH"] = history_simulator.fgor()
            t_step["FWCTH"] = history_simulator.fwct()
            t_step["FOIPH"] = history_simulator.foip()
            t_step["FGIPH"] = history_simulator.fgip()
            t_step["FWIPH"] = history_simulator.fwip()

            t_step["WOPRH:OP1"] = history_simulator.opr("OP1")
            t_step["WOPRH:OP2"] = history_simulator.opr("OP2")

            t_step["WGPRH:OP1"] = history_simulator.gpr("OP1")
            t_step["WGPRH:OP2"] = history_simulator.gpr("OP2")

            t_step["WWPRH:OP1"] = history_simulator.wpr("OP1")
            t_step["WWPRH:OP2"] = history_simulator.wpr("OP2")

            t_step["WGORH:OP1"] = history_simulator.gor("OP1")
            t_step["WGORH:OP2"] = history_simulator.gor("OP2")

            t_step["WWCTH:OP1"] = history_simulator.wct("OP1")
            t_step["WWCTH:OP2"] = history_simulator.wct("OP2")
        print(f"RESTART REPORT {report_step+1} written at {time_map[-1]}")

    return ecl_sum, time_map
예제 #12
0
def make_poly_example(folder, source, **kwargs):
    folder = folder / "poly"
    summary_count = kwargs["summary_data_count"]
    gen_obs_count = kwargs["gen_obs_count"]
    summary_data_entries = kwargs["summary_data_entries"]
    ministeps = kwargs["ministeps"]
    file_loader = FileSystemLoader(str(folder))  # directory of template file
    env = Environment(loader=file_loader)
    shutil.copytree(source, folder)

    render_template(
        folder, env.get_template("coeff_priors.j2"), "coeff_priors", **kwargs
    )
    render_template(folder, env.get_template("coeff.tmpl.j2"), "coeff.tmpl", **kwargs)
    render_template(
        folder, env.get_template("observations.j2"), "observations", **kwargs
    )
    render_template(folder, env.get_template("poly.ert.j2"), "poly.ert", **kwargs)
    render_template(
        folder, env.get_template("poly_eval.py.j2"), "poly_eval.py", **kwargs
    )
    os.chmod(folder / "poly_eval.py", 0o775)
    for r in range(gen_obs_count):
        render_template(
            folder,
            env.get_template("poly_obs_data.txt.j2"),
            f"poly_obs_data_{r}.txt",
            **kwargs,
        )

    if not os.path.exists(folder / "refcase"):
        os.mkdir(folder / "refcase")

    use_ecl_data_io = True

    if use_ecl_data_io:
        keywords = [f"PSUM{s}" for s in range(summary_count)]
        print(keywords)
        write_summary_spec(str(folder) + "/refcase/REFCASE.SMSPEC", keywords)
        write_summary_data(
            str(folder) + "/refcase/REFCASE.UNSMRY",
            summary_data_entries,
            keywords,
            ministeps,
        )
    else:
        ecl_sum = EclSum.writer(
            str(folder) + "/refcase/REFCASE", datetime.datetime(2010, 1, 1), 10, 10, 10
        )
        for s in range(summary_count):

            ecl_sum.addVariable(f"PSUM{s}")
            render_template(
                folder,
                env.get_template("poly_obs_data.txt.j2"),
                f"poly_sum_obs_data_{s}.txt",
                **kwargs,
            )

        for x in range(summary_data_entries * ministeps):
            t_step = ecl_sum.addTStep(x // ministeps + 1, sim_days=x + 1)
            for s in range(summary_count):
                t_step[f"PSUM{s}"] = 5.0

        if summary_count > 0:
            ecl_sum.fwrite()

    return folder
예제 #13
0
def run_simulator(
    simulator: OilSimulator, history_simulator: OilSimulator, time_step_count: int
) -> EclSum:
    """@rtype: EclSum"""
    ecl_sum = EclSum.writer("SNAKE_OIL_FIELD", datetime(2010, 1, 1), 10, 10, 10)

    ecl_vectors = [
        "OPT",
        "OPR",
        "GPT",
        "GPR",
        "WPT",
        "WPR",
        "GOR",
        "WCT",
    ]

    # Field vectors ("F"-prefix):
    for ecl_vector in ecl_vectors:
        ecl_sum.addVariable("F" + ecl_vector)
        ecl_sum.addVariable("F" + ecl_vector + "H")
        # "H" suffix is for history vectors.

    # Well vectors ("W"-prefix)
    wells = ["OP1", "OP2"]
    for ecl_vector in ecl_vectors:
        for wellname in wells:
            ecl_sum.addVariable("W" + ecl_vector, wgname=wellname)
            ecl_sum.addVariable("W" + ecl_vector + "H", wgname=wellname)

    # Block pressure:
    ecl_sum.addVariable("BPR", num=global_index(5, 5, 5))
    ecl_sum.addVariable("BPR", num=global_index(1, 3, 8))

    mini_step_count = 10
    total_step_count = time_step_count * mini_step_count

    for report_step in range(time_step_count):
        for mini_step in range(mini_step_count):
            t_step = ecl_sum.addTStep(
                report_step + 1, sim_days=report_step * mini_step_count + mini_step
            )
            simulator.step(scale=1.0 / total_step_count)
            history_simulator.step(scale=1.0 / total_step_count)

            t_step["FOPR"] = simulator.fopr()
            t_step["FOPT"] = simulator.fopt()
            t_step["FGPR"] = simulator.fgpr()
            t_step["FGPT"] = simulator.fgpt()
            t_step["FWPR"] = simulator.fwpr()
            t_step["FWPT"] = simulator.fwpt()
            t_step["FGOR"] = simulator.fgor()
            t_step["FWCT"] = simulator.fwct()

            t_step["WOPR:OP1"] = simulator.opr("OP1")
            t_step["WOPR:OP2"] = simulator.opr("OP2")

            t_step["WGPR:OP1"] = simulator.gpr("OP1")
            t_step["WGPR:OP2"] = simulator.gpr("OP2")

            t_step["WWPR:OP1"] = simulator.wpr("OP1")
            t_step["WWPR:OP2"] = simulator.wpr("OP2")

            t_step["WGOR:OP1"] = simulator.gor("OP1")
            t_step["WGOR:OP2"] = simulator.gor("OP2")

            t_step["WWCT:OP1"] = simulator.wct("OP1")
            t_step["WWCT:OP2"] = simulator.wct("OP2")

            t_step["BPR:5,5,5"] = simulator.bpr("5,5,5")
            t_step["BPR:1,3,8"] = simulator.bpr("1,3,8")

            t_step["FOPRH"] = history_simulator.fopr()
            t_step["FOPTH"] = history_simulator.fopt()
            t_step["FGPRH"] = history_simulator.fgpr()
            t_step["FGPTH"] = history_simulator.fgpt()
            t_step["FWPRH"] = history_simulator.fwpr()
            t_step["FWPTH"] = history_simulator.fwpt()
            t_step["FGORH"] = history_simulator.fgor()
            t_step["FWCTH"] = history_simulator.fwct()

            t_step["WOPRH:OP1"] = history_simulator.opr("OP1")
            t_step["WOPRH:OP2"] = history_simulator.opr("OP2")

            t_step["WGPRH:OP1"] = history_simulator.gpr("OP1")
            t_step["WGPRH:OP2"] = history_simulator.gpr("OP2")

            t_step["WWPRH:OP1"] = history_simulator.wpr("OP1")
            t_step["WWPRH:OP2"] = history_simulator.wpr("OP2")

            t_step["WGORH:OP1"] = history_simulator.gor("OP1")
            t_step["WGORH:OP2"] = history_simulator.gor("OP2")

            t_step["WWCTH:OP1"] = history_simulator.wct("OP1")
            t_step["WWCTH:OP2"] = history_simulator.wct("OP2")

    return ecl_sum