Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support restart for TEMP (and gas tracers) #4382

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Output and restore injection temp from SWELL, also adding gas tracer.
vkip committed Dec 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 13cc18d38bba8a7ab223e246732cde3f3889e063
6 changes: 6 additions & 0 deletions opm/input/eclipse/EclipseState/Runspec.cpp
Original file line number Diff line number Diff line change
@@ -598,6 +598,12 @@ Tracers Tracers::serializationTestObject() {
int Tracers::water_tracers() const {
return this->m_water_tracers;
}
int Tracers::gas_tracers() const {
return this->m_gas_tracers;
}
int Tracers::oil_tracers() const {
return this->m_oil_tracers;
}


Tracers::Tracers(const Deck& deck) {
2 changes: 2 additions & 0 deletions opm/input/eclipse/EclipseState/Runspec.hpp
Original file line number Diff line number Diff line change
@@ -449,6 +449,8 @@ class Tracers {

explicit Tracers(const Deck& );
int water_tracers() const;
int gas_tracers() const;
int oil_tracers() const;

template<class Serializer>
void serializeOp(Serializer& serializer) {
25 changes: 22 additions & 3 deletions opm/input/eclipse/Schedule/Well/Well.cpp
Original file line number Diff line number Diff line change
@@ -155,6 +155,7 @@ Opm::Well::ProducerCMode producer_cmode_from_int(const int pmode)
case CModeVal::BHP: return Opm::Well::ProducerCMode::BHP;
}

// Return BHP as default instead, since -10 might be written for some unused wells..??
throw std::invalid_argument {
fmt::format("Cannot convert integer value {} to producer control mode", pmode)
};
@@ -466,11 +467,29 @@ Well::Well(const RestartIO::RstWell& rst_well,
this->updateInjection(std::move(i));

if (!rst_well.tracer_concentration_injection.empty()) {
const auto isTemp = (rst_well.inj_temperature > (0.5 * RestartIO::RstWell::UNDEFINED_VALUE));
std::size_t tracer_conc_index = 0;
if (isTemp) {
this->well_inj_temperature = rst_well.inj_temperature;
++tracer_conc_index;
}
auto tracer = std::make_shared<WellTracerProperties>(this->getTracerProperties());
for (std::size_t tracer_index = 0; tracer_index < tracer_config.size(); tracer_index++) {
for (std::size_t tracer_index = 0; tracer_index < tracer_config.size(); ++tracer_index) {
const auto& tname = tracer_config[tracer_index].name;
const auto concentration = rst_well.tracer_concentration_injection[tracer_index];
tracer->setConcentration(tname, concentration);
const auto phase = tracer_config[tracer_index].phase;
if (phase == Phase::WATER) {
const auto concentration = rst_well.tracer_concentration_injection[tracer_conc_index];
tracer->setConcentration(tname, concentration);
} else {
const auto free_conc = rst_well.tracer_concentration_injection[tracer_conc_index];
const auto sol_conc = rst_well.tracer_concentration_injection[++tracer_conc_index];
if (WellType::gas_injector(this->wtype.ecl_wtype()) || WellType::oil_injector(this->wtype.ecl_wtype())) {
tracer->setConcentration(tname, free_conc);
if (sol_conc > 0.0) {
OpmLog::warning(fmt::format("Well {}: Restoring a non-zero solution concentration of tracer {} is not yet supported.", rst_well.name, tname));
}
}
}
}
this->updateTracer(tracer);
}
1 change: 0 additions & 1 deletion opm/input/eclipse/share/keywords/000_Eclipse100/G/GLIFTOPT
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
"sections": [
"SCHEDULE"
],
"requires" : ["LIFTOPT"],
"items": [
{
"name": "GROUP_NAME",
11 changes: 9 additions & 2 deletions opm/io/eclipse/rst/well.cpp
Original file line number Diff line number Diff line change
@@ -187,8 +187,15 @@ Opm::RestartIO::RstWell::RstWell(const UnitSystem& unit_system,
active_control = VI::IWell::Value::WellCtrlMode::Group;
}

for (std::size_t tracer_index = 0;
tracer_index < static_cast<std::size_t>(header.runspec.tracers().water_tracers());
// If the TEMP option is active, this is the first tracer
std::size_t tracer_index = 0;
const bool isTemp = header.runspec.temp();
if (isTemp) {
this->inj_temperature = swel[VI::SWell::TracerOffset + tracer_index++];
}
const auto& tracers = header.runspec.tracers();
for (const auto num_tracer_injconcs = tracers.water_tracers() + 2*(tracers.gas_tracers() + tracers.oil_tracers()) + tracer_index;
tracer_index < static_cast<std::size_t>(num_tracer_injconcs);
++tracer_index)
{
this->tracer_concentration_injection.push_back(swel[VI::SWell::TracerOffset + tracer_index]);
1 change: 1 addition & 0 deletions opm/io/eclipse/rst/well.hpp
Original file line number Diff line number Diff line change
@@ -129,6 +129,7 @@ struct RstWell
float dfac_corr_coeff_a{};
float dfac_corr_exponent_b{};
float dfac_corr_exponent_c{};
float inj_temperature{UNDEFINED_VALUE};
std::vector<float> tracer_concentration_injection;

double oil_rate;
28 changes: 25 additions & 3 deletions opm/output/eclipse/AggregateWellData.cpp
Original file line number Diff line number Diff line change
@@ -1080,18 +1080,37 @@ namespace {
void assignTracerData(const Opm::TracerConfig& tracers,
const Opm::SummaryState& smry,
const std::string& wname,
SWellArray& sWell)
SWellArray& sWell,
const bool isTemp = false)
{
auto output_index = static_cast<std::size_t>(VI::SWell::index::TracerOffset);
// Temperature tracer is first, if present
const std::size_t tempOffset = isTemp ? 1 : 0;
auto output_index = tempOffset + static_cast<std::size_t>(VI::SWell::index::TracerOffset);

for (const auto& tracer : tracers) {
if (tracer.phase == Opm::Phase::WATER) {
sWell[output_index++] =
smry.get_well_var(wname, fmt::format("WTIC{}", tracer.name), 0.0);
} else {
sWell[output_index++] =
smry.get_well_var(wname, fmt::format("WTICF{}", tracer.name), 0.0);
sWell[output_index++] =
smry.get_well_var(wname, fmt::format("WTICS{}", tracer.name), 0.0);
}
}
}

template <class SWellArray>
void assignTempData(const std::string& wname,
const Opm::SummaryState& smry,
SWellArray& sWell)
{
// TEMP is the first tracer
auto output_index = static_cast<std::size_t>(VI::SWell::index::TracerOffset);
sWell[output_index] = smry.get_well_var(wname, "WTICHEA", 0.0);
}


template <class SWellArray>
void staticContrib(const Opm::Well& well,
const Opm::GasLiftOpt& glo,
@@ -1133,7 +1152,10 @@ namespace {
assignDFactorCorrelation(well, units, sWell);
assignEconomicLimits(well, swprop, sWell);
assignWellTest(well.name(), sched, wtest_state, sim_step, swprop, sWell);
assignTracerData(tracers, smry, well.name(), sWell);

const auto isTemp = sched.runspec().temp();
if (isTemp) assignTempData(well.name(), smry, sWell);
assignTracerData(tracers, smry, well.name(), sWell, isTemp);
assignBhpVfpAdjustment(well, swprop, sWell);
}
} // SWell
7 changes: 5 additions & 2 deletions opm/output/eclipse/CreateInteHead.cpp
Original file line number Diff line number Diff line change
@@ -573,7 +573,10 @@ createInteHead(const EclipseState& es,
const auto& tdim = es.getTableManager();
const auto& rdim = tdim.getRegdims();
const auto& rckcfg = es.getSimulationConfig().rock_config();
auto num_water_tracer = es.runspec().tracers().water_tracers();
const auto& tracers = es.runspec().tracers();
// TEMP is a tracer, oil&gas tracers have both free and solution parts.
const auto num_tracer_items = 2 * (tracers.water_tracers() + 2*(tracers.oil_tracers() + tracers.gas_tracers()) + (es.runspec().temp() ? 1 : 0));
const auto num_water_tracer = tracers.water_tracers();
int nxwelz_tracer_shift = num_water_tracer*5 + 2 * (num_water_tracer > 0);

const auto ih = InteHEAD{}
@@ -588,7 +591,7 @@ createInteHead(const EclipseState& es,
// across a range of reference cases, but are not guaranteed to be
// universally valid.
.drsdt(sched, lookup_step)
.params_NWELZ (155 + num_water_tracer, 122 + 2*num_water_tracer, 130 + nxwelz_tracer_shift, 3) // n{isxz}welz: number of data elements per well in {ISXZ}WELL
.params_NWELZ (155 + num_water_tracer, 122 + num_tracer_items, 130 + nxwelz_tracer_shift, 3) // n{isxz}welz: number of data elements per well in {ISXZ}WELL
.params_NCON (25, 41, 58 + 5*num_water_tracer) // n{isx}conz: number of data elements per completion in ICON
.params_GRPZ (getNGRPZ(nwgmax, ngmax, num_water_tracer, rspec))
.aquiferDimensions (inferAquiferDimensions(es, sched[lookup_step]))