1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
// -*- 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"
#include "TestTypeTag.hpp"
#define BOOST_TEST_MODULE Glift1
#include <opm/models/utils/propertysystem.hh>
#include <opm/models/utils/parametersystem.hpp>
#include <opm/models/utils/start.hh>
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
#include <opm/simulators/utils/DeferredLogger.hpp>
#include <opm/simulators/flow/BlackoilModel.hpp>
#include <opm/simulators/flow/FlowProblemBlackoil.hpp>
#include <opm/simulators/flow/equil/EquilibrationHelpers.hpp>
#include <opm/simulators/wells/BlackoilWellModel.hpp>
#include <opm/simulators/wells/StandardWell.hpp>
#include <opm/simulators/wells/GasLiftSingleWell.hpp>
#include <opm/simulators/wells/GasLiftSingleWellGeneric.hpp>
#include <opm/simulators/wells/GasLiftGroupInfo.hpp>
#include <opm/simulators/wells/WellState.hpp>
#if HAVE_DUNE_FEM
#include <dune/fem/misc/mpimanager.hh>
#else
#include <dune/common/parallel/mpihelper.hh>
#endif
#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<TestTypeTag>;
};
}
}
template <class TypeTag>
std::unique_ptr<Opm::GetPropType<TypeTag, Opm::Properties::Simulator>>
initSimulator(const char *filename)
{
using namespace Opm;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
std::string filename_arg = "--ecl-deck-file-name=";
filename_arg += filename;
const char* argv[] = {
"test_equil",
filename_arg.c_str()
};
Parameters::reset();
registerAllParameters_<TypeTag>(false);
registerEclTimeSteppingParameters<double>();
BlackoilModelParameters<double>::registerParameters();
Parameters::Register<Parameters::EnableTerminalOutput>("Do *NOT* use!");
Opm::Parameters::SetDefault<Opm::Parameters::ThreadsPerProcess>(2);
Parameters::endRegistration();
setupParameters_<TypeTag>(/*argc=*/sizeof(argv) / sizeof(argv[0]),
argv,
/*registerParams=*/false,
/*allowUnused*/false,
/*handleHelp*/true,
/*myRank*/0);
FlowGenericVanguard::readDeck(filename);
return std::make_unique<Simulator>();
}
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
Opm::FlowGenericVanguard::setCommunication(std::make_unique<Opm::Parallel::Communication>());
}
};
}
BOOST_GLOBAL_FIXTURE(GliftFixture);
BOOST_AUTO_TEST_CASE(G1)
{
//using TypeTag = Opm::Properties::TTag::FlowProblemBlackoil;
using TypeTag = Opm::Properties::TTag::TestGliftTypeTag;
//using EclProblem = Opm::EclProblem<TypeTag>;
//using EclWellModel = typename EclProblem::EclWellModel;
using FluidSystem = Opm::GetPropType<TypeTag, Opm::Properties::FluidSystem>;
using IndexTraits = typename FluidSystem::IndexTraitsType;
using WellModel = Opm::BlackoilWellModel<TypeTag>;
using WellState = Opm::WellState<double, IndexTraits>;
using StdWell = Opm::StandardWell<TypeTag>;
using GasLiftSingleWell = Opm::GasLiftSingleWell<TypeTag>;
using GasLiftGroupInfo = Opm::GasLiftGroupInfo<double, IndexTraits>;
using GasLiftSingleWellGeneric = Opm::GasLiftSingleWellGeneric<double, IndexTraits>;
using GLiftEclWells = typename GasLiftGroupInfo::GLiftEclWells;
const std::string filename = "GLIFT1.DATA";
using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups;
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);
well_model.updateWellControls(deferred_logger);
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();
WellState &well_state = well_model.wellState();
const auto &group_state = well_model.groupState();
GLiftEclWells ecl_well_map;
Opm::BlackoilWellModelGasLift<TypeTag>::
initGliftEclWellMap(well_model.localNonshutWells(), ecl_well_map);
const int iteration_idx = simulator->model().newtonMethod().numIterations();
const auto& comm = simulator->vanguard().grid().comm();
GasLiftGroupInfo group_info {
ecl_well_map,
schedule,
summary_state,
simulator->episodeIndex(),
iteration_idx,
deferred_logger,
well_state,
group_state,
comm,
/*glift_debug=*/false
};
GLiftSyncGroups sync_groups;
GasLiftSingleWell glift {*std_well, *(simulator.get()), summary_state,
deferred_logger, well_state, group_state, group_info, sync_groups,
comm, /*glift_debug=*/false
};
group_info.initialize();
auto state = glift.runOptimize(iteration_idx);
BOOST_CHECK_CLOSE(state->oilRate(), 0.01736111111111111, 1e-8);
BOOST_CHECK_CLOSE(state->gasRate(), 1.6464, 1e-1);
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());
}
|