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

[fix] Use minimum positive value of competing max initial time steps. #3954

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion opm/input/eclipse/Schedule/ScheduleState.cpp
Expand Up @@ -382,7 +382,11 @@ Tuning& ScheduleState::tuning() {
double ScheduleState::max_next_tstep(const bool enableTUNING) const {
double tuning_value = (enableTUNING && this->m_tuning.TSINIT.has_value()) ? this->m_tuning.TSINIT.value() : -1.0;
double next_value = this->next_tstep.has_value() ? this->next_tstep->value() : -1.0;
return std::max(next_value, tuning_value);
if (tuning_value > -1 and next_value > -1) {
return std::min(next_value, tuning_value);
} else {
return std::max(next_value, tuning_value);
}
}

void ScheduleState::update_events(Events events) {
Expand Down
32 changes: 32 additions & 0 deletions tests/parser/TuningTests.cpp
Expand Up @@ -73,6 +73,26 @@ TUNING
/
WSEGITER
/

DATES
1 FEB 1982 13:55:44 / -- 11
/
TUNING
2 300 0.3 0.30 6 0.6 0.2 2.25 2E20 10.0/
/
/
NEXTSTEP
1 /

DATES
10 FEB 1982 13:55:44 / -- 12
/
TUNING
1 300 0.3 0.30 6 0.6 0.2 2.25 2E20 10.0/
/
/
NEXTSTEP
2 /
)";


Expand Down Expand Up @@ -378,4 +398,16 @@ BOOST_AUTO_TEST_CASE(TuningTest) {
BOOST_CHECK_EQUAL(NEWTMX, 13);

}
/*** TIMESTEP 11 ***/
{
std::size_t timestep = 11;
BOOST_CHECK_CLOSE(schedule[timestep].max_next_tstep(true), 1.0 * Metric::Time, diff);
BOOST_CHECK_CLOSE(schedule[timestep].max_next_tstep(false), 1.0 * Metric::Time, diff);
}
/*** TIMESTEP 12 ***/
{
std::size_t timestep = 12;
BOOST_CHECK_CLOSE(schedule[timestep].max_next_tstep(true), 1.0 * Metric::Time, diff);
BOOST_CHECK_CLOSE(schedule[timestep].max_next_tstep(false), 2.0 * Metric::Time, diff);
}
Comment on lines +401 to +412
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good. Do you think you could add a test for the max_next_tstep() < 0 case as well–i.e., for when there is no NEXTSTEP and we do not enable TUNING?

}