Skip to content

Commit

Permalink
Allow for zero guiderates computed from NETV
Browse files Browse the repository at this point in the history
  • Loading branch information
Tor Harald Sandve committed Dec 20, 2024
1 parent f9d1e94 commit a8f4a60
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
3 changes: 1 addition & 2 deletions opm/input/eclipse/Schedule/Group/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ class Group {
VOID = 2,
NETV = 3,
RESV = 4,
POTN = 5,
NO_GUIDE_RATE = 6
NO_GUIDE_RATE = 5
};
static GuideRateInjTarget GuideRateInjTargetFromString( const std::string& stringValue );
static GuideRateInjTarget GuideRateInjTargetFromInt(int ecl_id);
Expand Down
14 changes: 7 additions & 7 deletions opm/input/eclipse/Schedule/Group/GuideRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,22 +283,22 @@ void Opm::GuideRate::group_compute(const std::string& wgname,
}
}

void Opm::GuideRate::compute(const std::string& wgname,
const Phase& phase,
const std::size_t report_step,
const double guide_rate)
void Opm::GuideRate::compute(const std::string& wgname,
const Phase& phase,
const std::size_t report_step,
const std::optional<double> guide_rate)
{
const auto& config = this->schedule[report_step].guide_rate();
if (!config.has_injection_group(phase, wgname))
return;

if (guide_rate > 0) {
this->injection_group_values[std::make_pair(phase, wgname)] = guide_rate;
if (guide_rate) {
this->injection_group_values[std::make_pair(phase, wgname)] = *guide_rate;
return;
}

const auto& group = config.injection_group(phase, wgname);
if (group.target == Group::GuideRateInjTarget::POTN) {
if (group.target == Group::GuideRateInjTarget::NO_GUIDE_RATE) {
return;
}
this->injection_group_values[std::make_pair(phase, wgname)] = group.guide_rate;
Expand Down
8 changes: 4 additions & 4 deletions opm/input/eclipse/Schedule/Group/GuideRate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ class GuideRate
const double gas_pot,
const double wat_pot);

void compute(const std::string& wgname,
const Phase& phase,
const std::size_t report_step,
const double guide_rate);
void compute(const std::string& wgname,
const Phase& phase,
const std::size_t report_step,
const std::optional<double> guide_rate);

bool has(const std::string& name) const;
bool hasPotentials(const std::string& name) const;
Expand Down
8 changes: 4 additions & 4 deletions tests/parser/GroupTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,10 @@ GCONINJE
GuideRate gr = GuideRate(schedule);
const auto& g1 = schedule.getGroup("G1", 1);
const auto& g2 = schedule.getGroup("G2", 1);
gr.compute(g1.name(), Phase::WATER, 1, 0.0);
gr.compute(g1.name(), Phase::GAS, 1, 0.0);
gr.compute(g2.name(), Phase::WATER, 1, 0.0);
gr.compute(g2.name(), Phase::GAS, 1, 0.0);
gr.compute(g1.name(), Phase::WATER, 1, std::nullopt);
gr.compute(g1.name(), Phase::GAS, 1, std::nullopt);
gr.compute(g2.name(), Phase::WATER, 1, std::nullopt);
gr.compute(g2.name(), Phase::GAS, 1, std::nullopt);

BOOST_CHECK( gr.has(g1.name(), Phase::WATER));
BOOST_CHECK( gr.has(g1.name(), Phase::GAS));
Expand Down

0 comments on commit a8f4a60

Please sign in to comment.