2021-04-01 09:41:46 -05:00
|
|
|
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
// vi: set et ts=4 sw=4 sts=4:
|
|
|
|
/*
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM 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.
|
|
|
|
|
|
|
|
OPM 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 for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Consult the COPYING file in the top-level source directory of this
|
|
|
|
module for the precise wording of the license and the list of
|
|
|
|
copyright holders.
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#define BOOST_TEST_MODULE Glift1
|
|
|
|
|
|
|
|
#include <opm/models/utils/propertysystem.hh>
|
|
|
|
#include <opm/models/utils/parametersystem.hh>
|
|
|
|
#include <ebos/equil/equilibrationhelpers.hh>
|
|
|
|
#include <ebos/eclproblem.hh>
|
|
|
|
#include <ebos/ebos.hh>
|
|
|
|
#include <opm/models/utils/start.hh>
|
|
|
|
|
2023-01-11 08:39:00 -06:00
|
|
|
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
2021-12-14 01:30:15 -06:00
|
|
|
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
|
|
|
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
|
2021-04-01 09:41:46 -05:00
|
|
|
#include <opm/simulators/utils/DeferredLogger.hpp>
|
|
|
|
#include <opm/simulators/flow/BlackoilModelEbos.hpp>
|
|
|
|
#include <opm/simulators/wells/BlackoilWellModel.hpp>
|
|
|
|
#include <opm/simulators/wells/StandardWell.hpp>
|
|
|
|
#include <opm/simulators/wells/GasLiftSingleWell.hpp>
|
2021-05-27 01:31:49 -05:00
|
|
|
#include <opm/simulators/wells/GasLiftSingleWellGeneric.hpp>
|
|
|
|
#include <opm/simulators/wells/GasLiftGroupInfo.hpp>
|
2021-05-20 06:32:18 -05:00
|
|
|
#include <opm/simulators/wells/WellState.hpp>
|
2021-04-01 09:41:46 -05:00
|
|
|
|
|
|
|
#if HAVE_DUNE_FEM
|
|
|
|
#include <dune/fem/misc/mpimanager.hh>
|
|
|
|
#else
|
|
|
|
#include <dune/common/parallel/mpihelper.hh>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <exception>
|
|
|
|
#include <iostream>
|
|
|
|
#include <memory>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <boost/version.hpp>
|
|
|
|
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 71
|
|
|
|
#include <boost/test/floating_point_comparison.hpp>
|
|
|
|
#else
|
|
|
|
#include <boost/test/tools/floating_point_comparison.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Opm::Properties {
|
|
|
|
namespace TTag {
|
|
|
|
struct TestGliftTypeTag {
|
|
|
|
using InheritsFrom = std::tuple<EbosTypeTag>;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class TypeTag>
|
|
|
|
std::unique_ptr<Opm::GetPropType<TypeTag, Opm::Properties::Simulator>>
|
|
|
|
initSimulator(const char *filename)
|
|
|
|
{
|
|
|
|
using Simulator = Opm::GetPropType<TypeTag, Opm::Properties::Simulator>;
|
|
|
|
|
|
|
|
std::string filename_arg = "--ecl-deck-file-name=";
|
|
|
|
filename_arg += filename;
|
|
|
|
|
|
|
|
const char* argv[] = {
|
|
|
|
"test_equil",
|
|
|
|
filename_arg.c_str()
|
|
|
|
};
|
|
|
|
|
|
|
|
Opm::setupParameters_<TypeTag>(/*argc=*/sizeof(argv)/sizeof(argv[0]), argv, /*registerParams=*/true);
|
|
|
|
|
2022-06-14 07:25:46 -05:00
|
|
|
Opm::EclGenericVanguard::readDeck(filename);
|
|
|
|
|
|
|
|
return std::make_unique<Simulator>();
|
2021-04-01 09:41:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct GliftFixture {
|
|
|
|
GliftFixture() {
|
|
|
|
int argc = boost::unit_test::framework::master_test_suite().argc;
|
|
|
|
char** argv = boost::unit_test::framework::master_test_suite().argv;
|
|
|
|
#if HAVE_DUNE_FEM
|
|
|
|
Dune::Fem::MPIManager::initialize(argc, argv);
|
|
|
|
#else
|
|
|
|
Dune::MPIHelper::instance(argc, argv);
|
|
|
|
#endif
|
2021-10-06 01:52:19 -05:00
|
|
|
Opm::EclGenericVanguard::setCommunication(std::make_unique<Opm::Parallel::Communication>());
|
2021-04-01 09:41:46 -05:00
|
|
|
using TypeTag = Opm::Properties::TTag::EclFlowProblem;
|
|
|
|
Opm::registerAllParameters_<TypeTag>();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_GLOBAL_FIXTURE(GliftFixture);
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(G1)
|
|
|
|
{
|
|
|
|
//using TypeTag = Opm::Properties::TTag::EclFlowProblem;
|
|
|
|
using TypeTag = Opm::Properties::TTag::TestGliftTypeTag;
|
|
|
|
//using EclProblem = Opm::EclProblem<TypeTag>;
|
|
|
|
//using EclWellModel = typename EclProblem::EclWellModel;
|
|
|
|
using WellModel = Opm::BlackoilWellModel<TypeTag>;
|
2021-05-20 06:32:18 -05:00
|
|
|
using WellState = Opm::WellState;
|
2021-04-01 09:41:46 -05:00
|
|
|
using StdWell = Opm::StandardWell<TypeTag>;
|
|
|
|
using GasLiftSingleWell = Opm::GasLiftSingleWell<TypeTag>;
|
2021-05-27 01:31:49 -05:00
|
|
|
using GasLiftGroupInfo = Opm::GasLiftGroupInfo;
|
|
|
|
using GasLiftSingleWellGeneric = Opm::GasLiftSingleWellGeneric;
|
|
|
|
using GLiftEclWells = typename GasLiftGroupInfo::GLiftEclWells;
|
2021-04-01 09:41:46 -05:00
|
|
|
const std::string filename = "GLIFT1.DATA";
|
2021-05-27 01:31:49 -05:00
|
|
|
using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups;
|
2021-04-01 09:41:46 -05:00
|
|
|
|
|
|
|
auto simulator = initSimulator<TypeTag>(filename.data());
|
|
|
|
|
|
|
|
simulator->model().applyInitialSolution();
|
|
|
|
simulator->setEpisodeIndex(-1);
|
|
|
|
simulator->setEpisodeLength(0.0);
|
|
|
|
simulator->startNextEpisode(/*episodeStartTime=*/0.0, /*episodeLength=*/1e30);
|
|
|
|
simulator->setTimeStepSize(43200); // 12 hours
|
|
|
|
simulator->model().newtonMethod().setIterationIndex(0);
|
|
|
|
WellModel& well_model = simulator->problem().wellModel();
|
|
|
|
int report_step_idx = 0;
|
|
|
|
well_model.beginReportStep(report_step_idx);
|
|
|
|
well_model.beginTimeStep();
|
|
|
|
Opm::DeferredLogger deferred_logger;
|
|
|
|
well_model.calculateExplicitQuantities(deferred_logger);
|
|
|
|
well_model.prepareTimeStep(deferred_logger);
|
2023-04-24 15:51:46 -05:00
|
|
|
well_model.updateWellControls(false, deferred_logger);
|
2021-04-01 09:41:46 -05:00
|
|
|
well_model.initPrimaryVariablesEvaluation();
|
|
|
|
Opm::WellInterface<TypeTag> *well_ptr = well_model.getWell("B-1H").get();
|
|
|
|
StdWell *std_well = dynamic_cast<StdWell *>(well_ptr);
|
|
|
|
|
|
|
|
const auto& schedule = simulator->vanguard().schedule();
|
|
|
|
auto wells_ecl = schedule.getWells(report_step_idx);
|
|
|
|
std::optional<std::size_t> idx;
|
|
|
|
int num_producers = 0;
|
|
|
|
for(std::size_t i = 0; i < wells_ecl.size(); ++i) {
|
|
|
|
const auto &well = wells_ecl[i];
|
|
|
|
if (well.isProducer()) {
|
|
|
|
idx = i;
|
|
|
|
num_producers++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BOOST_CHECK_EQUAL( num_producers, 1);
|
|
|
|
const auto &well = wells_ecl[*idx];
|
|
|
|
BOOST_CHECK_EQUAL( well.name(), "B-1H");
|
|
|
|
const auto& summary_state = simulator->vanguard().summaryState();
|
2021-05-19 07:51:14 -05:00
|
|
|
WellState &well_state = well_model.wellState();
|
2021-06-23 08:46:33 -05:00
|
|
|
const auto &group_state = well_model.groupState();
|
2021-05-27 01:31:49 -05:00
|
|
|
GLiftEclWells ecl_well_map;
|
|
|
|
well_model.initGliftEclWellMap(ecl_well_map);
|
|
|
|
const int iteration_idx = simulator->model().newtonMethod().numIterations();
|
2022-03-24 06:42:46 -05:00
|
|
|
const auto& comm = simulator->vanguard().grid().comm();
|
2021-05-27 01:31:49 -05:00
|
|
|
GasLiftGroupInfo group_info {
|
|
|
|
ecl_well_map,
|
|
|
|
schedule,
|
|
|
|
summary_state,
|
|
|
|
simulator->episodeIndex(),
|
|
|
|
iteration_idx,
|
|
|
|
well_model.phaseUsage(),
|
|
|
|
deferred_logger,
|
2021-06-22 02:52:22 -05:00
|
|
|
well_state,
|
2022-10-20 05:58:42 -05:00
|
|
|
group_state,
|
2022-03-24 06:42:46 -05:00
|
|
|
comm,
|
Improve debugging tools in gaslift code.
Introduces a gaslift debugging variable in ALQState in WellState. This
variable will persist between timesteps in contrast to when debugging
variables are defined in GasLiftSingleWell, GasLiftGroupState, or GasLiftStage2.
Currently only an integer variable debug_counter is added to ALQState,
which can be used as follows: First debugging is switched on globally
for BlackOilWellModel, GasLiftSingleWell, GasLiftGroupState, and
GasLiftStage2 by setting glift_debug to a true value in BlackOilWellModelGeneric.
Then, the following debugging code can be added to e.g. one of
GasLiftSingleWell, GasLiftGroupState, or GasLiftStage2 :
auto count = debugUpdateGlobalCounter_();
if (count == some_integer) {
displayDebugMessage_("stop here");
}
Here, the integer "some_integer" is determined typically by looking at
the debugging output of a previous run. This can be done since the
call to debugUpdateGlobalCounter_() will print out the current value
of the counter and then increment the counter by one. And it will be
easy to recognize these values in the debug ouput. If you find a place
in the output that looks suspect, just take a note of the counter
value in the output around that point and insert the value for
"some_integer", then after recompiling the code with the desired value
for "some_integer", it is now easy to set a breakpoint in GDB at the
line
displayDebugMessage_("stop here").
shown in the above snippet. This should improve the ability to quickly
to set a breakpoint in GDB around at a given time and point in the simulation.
2022-01-23 13:37:26 -06:00
|
|
|
/*glift_debug=*/false
|
2021-05-27 01:31:49 -05:00
|
|
|
};
|
|
|
|
GLiftSyncGroups sync_groups;
|
2021-04-01 09:41:46 -05:00
|
|
|
GasLiftSingleWell glift {*std_well, *(simulator.get()), summary_state,
|
Improve debugging tools in gaslift code.
Introduces a gaslift debugging variable in ALQState in WellState. This
variable will persist between timesteps in contrast to when debugging
variables are defined in GasLiftSingleWell, GasLiftGroupState, or GasLiftStage2.
Currently only an integer variable debug_counter is added to ALQState,
which can be used as follows: First debugging is switched on globally
for BlackOilWellModel, GasLiftSingleWell, GasLiftGroupState, and
GasLiftStage2 by setting glift_debug to a true value in BlackOilWellModelGeneric.
Then, the following debugging code can be added to e.g. one of
GasLiftSingleWell, GasLiftGroupState, or GasLiftStage2 :
auto count = debugUpdateGlobalCounter_();
if (count == some_integer) {
displayDebugMessage_("stop here");
}
Here, the integer "some_integer" is determined typically by looking at
the debugging output of a previous run. This can be done since the
call to debugUpdateGlobalCounter_() will print out the current value
of the counter and then increment the counter by one. And it will be
easy to recognize these values in the debug ouput. If you find a place
in the output that looks suspect, just take a note of the counter
value in the output around that point and insert the value for
"some_integer", then after recompiling the code with the desired value
for "some_integer", it is now easy to set a breakpoint in GDB at the
line
displayDebugMessage_("stop here").
shown in the above snippet. This should improve the ability to quickly
to set a breakpoint in GDB around at a given time and point in the simulation.
2022-01-23 13:37:26 -06:00
|
|
|
deferred_logger, well_state, group_state, group_info, sync_groups,
|
2022-03-24 06:42:46 -05:00
|
|
|
comm, /*glift_debug=*/false
|
Improve debugging tools in gaslift code.
Introduces a gaslift debugging variable in ALQState in WellState. This
variable will persist between timesteps in contrast to when debugging
variables are defined in GasLiftSingleWell, GasLiftGroupState, or GasLiftStage2.
Currently only an integer variable debug_counter is added to ALQState,
which can be used as follows: First debugging is switched on globally
for BlackOilWellModel, GasLiftSingleWell, GasLiftGroupState, and
GasLiftStage2 by setting glift_debug to a true value in BlackOilWellModelGeneric.
Then, the following debugging code can be added to e.g. one of
GasLiftSingleWell, GasLiftGroupState, or GasLiftStage2 :
auto count = debugUpdateGlobalCounter_();
if (count == some_integer) {
displayDebugMessage_("stop here");
}
Here, the integer "some_integer" is determined typically by looking at
the debugging output of a previous run. This can be done since the
call to debugUpdateGlobalCounter_() will print out the current value
of the counter and then increment the counter by one. And it will be
easy to recognize these values in the debug ouput. If you find a place
in the output that looks suspect, just take a note of the counter
value in the output around that point and insert the value for
"some_integer", then after recompiling the code with the desired value
for "some_integer", it is now easy to set a breakpoint in GDB at the
line
displayDebugMessage_("stop here").
shown in the above snippet. This should improve the ability to quickly
to set a breakpoint in GDB around at a given time and point in the simulation.
2022-01-23 13:37:26 -06:00
|
|
|
};
|
2021-08-05 04:00:31 -05:00
|
|
|
group_info.initialize();
|
2021-05-27 01:31:49 -05:00
|
|
|
auto state = glift.runOptimize(iteration_idx);
|
2021-04-01 09:41:46 -05:00
|
|
|
BOOST_CHECK_CLOSE(state->oilRate(), 0.01736111111111111, 1e-8);
|
2022-09-16 05:59:15 -05:00
|
|
|
BOOST_CHECK_CLOSE(state->gasRate(), 1.6464, 1e-3);
|
2021-04-01 09:41:46 -05:00
|
|
|
BOOST_CHECK(state->oilIsLimited());
|
|
|
|
BOOST_CHECK(!state->gasIsLimited());
|
|
|
|
BOOST_CHECK(!state->alqIsLimited());
|
|
|
|
BOOST_CHECK_CLOSE(state->alq(), 0.0, 1e-8);
|
|
|
|
BOOST_CHECK(!state->increase().has_value());
|
|
|
|
}
|
2021-05-27 01:31:49 -05:00
|
|
|
|