Merge pull request #5215 from vkip/nextstep_without_tuning

Ensure NEXTSTEP is respected also without --enable-tuning=true
This commit is contained in:
Markus Blatt 2024-02-21 16:09:23 +01:00 committed by GitHub
commit 4d40197406
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 11 deletions

View File

@ -473,7 +473,7 @@ beginEpisode_(bool enableExperiments,
{
const auto& sched_state = schedule_[episodeIdx];
const auto& tuning = sched_state.tuning();
initialTimeStepSize_ = sched_state.max_next_tstep();
initialTimeStepSize_ = sched_state.max_next_tstep(enableTuning_);
maxTimeStepAfterWellEvent_ = tuning.TMAXWC;
return true;
}

View File

@ -286,15 +286,15 @@ public:
bool enableTUNING = EWOMS_GET_PARAM(TypeTag, bool, EnableTuning);
if (enableAdaptive) {
const UnitSystem& unitSystem = this->ebosSimulator_.vanguard().eclState().getUnits();
const auto& sched_state = schedule()[timer.currentStepNum()];
auto max_next_tstep = sched_state.max_next_tstep(enableTUNING);
if (enableTUNING) {
const auto& sched_state = schedule()[timer.currentStepNum()];
auto max_next_tstep = sched_state.max_next_tstep();
adaptiveTimeStepping_ = std::make_unique<TimeStepper>(max_next_tstep,
sched_state.tuning(),
unitSystem, terminalOutput_);
}
else {
adaptiveTimeStepping_ = std::make_unique<TimeStepper>(unitSystem, terminalOutput_);
adaptiveTimeStepping_ = std::make_unique<TimeStepper>(unitSystem, max_next_tstep, terminalOutput_);
}
if (isRestart()) {
@ -379,18 +379,21 @@ public:
// \Note: The sub stepping will require a copy of the state variables
if (adaptiveTimeStepping_) {
const auto& events = schedule()[timer.currentStepNum()].events();
if (enableTUNING) {
if (events.hasEvent(ScheduleEvents::TUNING_CHANGE)) {
const auto& sched_state = schedule()[timer.currentStepNum()];
if (events.hasEvent(ScheduleEvents::TUNING_CHANGE)) {
const auto& sched_state = schedule()[timer.currentStepNum()];
const auto& max_next_tstep = sched_state.max_next_tstep(enableTUNING);
if (enableTUNING) {
const auto& tuning = sched_state.tuning();
const auto& max_next_tstep = sched_state.max_next_tstep();
adaptiveTimeStepping_->updateTUNING(max_next_tstep, tuning);
// \Note: Assumes TUNING is only used with adaptive time-stepping
// \Note: Need to update both solver (model) and simulator since solver is re-created each report step.
solver_->model().updateTUNING(tuning);
this->updateTUNING(tuning);
} else {
adaptiveTimeStepping_->updateNEXTSTEP(max_next_tstep);
}
}
bool event = events.hasEvent(ScheduleEvents::NEW_WELL) ||
events.hasEvent(ScheduleEvents::INJECTION_TYPE_CHANGED) ||
events.hasEvent(ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER) ||

View File

@ -249,6 +249,7 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
//! \brief contructor taking parameter object
AdaptiveTimeStepping(const UnitSystem& unitSystem,
const double max_next_tstep = -1.0,
const bool terminalOutput = true)
: timeStepControl_()
, restartFactor_(EWOMS_GET_PARAM(TypeTag, double, SolverRestartFactor)) // 0.33
@ -260,7 +261,7 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
, solverRestartMax_(EWOMS_GET_PARAM(TypeTag, int, SolverMaxRestarts)) // 10
, solverVerbose_(EWOMS_GET_PARAM(TypeTag, int, SolverVerbosity) > 0 && terminalOutput) // 2
, timestepVerbose_(EWOMS_GET_PARAM(TypeTag, int, TimeStepVerbosity) > 0 && terminalOutput) // 2
, suggestedNextTimestep_(EWOMS_GET_PARAM(TypeTag, double, InitialTimeStepInDays)*24*60*60) // 1.0
, suggestedNextTimestep_((max_next_tstep <= 0 ? EWOMS_GET_PARAM(TypeTag, double, InitialTimeStepInDays) : max_next_tstep)*24*60*60) // 1.0
, fullTimestepInitially_(EWOMS_GET_PARAM(TypeTag, bool, FullTimeStepInitially)) // false
, timestepAfterEvent_(EWOMS_GET_PARAM(TypeTag, double, TimeStepAfterEventInDays)*24*60*60) // 1e30
, useNewtonIteration_(false)
@ -289,7 +290,7 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
, solverRestartMax_(EWOMS_GET_PARAM(TypeTag, int, SolverMaxRestarts)) // 10
, solverVerbose_(EWOMS_GET_PARAM(TypeTag, int, SolverVerbosity) > 0 && terminalOutput) // 2
, timestepVerbose_(EWOMS_GET_PARAM(TypeTag, int, TimeStepVerbosity) > 0 && terminalOutput) // 2
, suggestedNextTimestep_(max_next_tstep <= 0 ? EWOMS_GET_PARAM(TypeTag, double, InitialTimeStepInDays)*86400 : max_next_tstep) // 1.0
, suggestedNextTimestep_(max_next_tstep <= 0 ? EWOMS_GET_PARAM(TypeTag, double, InitialTimeStepInDays)*24*60*60 : max_next_tstep) // 1.0
, fullTimestepInitially_(EWOMS_GET_PARAM(TypeTag, bool, FullTimeStepInitially)) // false
, timestepAfterEvent_(tuning.TMAXWC) // 1e30
, useNewtonIteration_(false)
@ -625,11 +626,16 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
growthFactor_ = tuning.TFDIFF;
maxGrowth_ = tuning.TSFMAX;
maxTimeStep_ = tuning.TSMAXZ;
updateNEXTSTEP(max_next_tstep);
timestepAfterEvent_ = tuning.TMAXWC;
}
void updateNEXTSTEP(double max_next_tstep)
{
// \Note Only update next suggested step if TSINIT was explicitly set in TUNING or NEXTSTEP is active.
if (max_next_tstep > 0) {
suggestedNextTimestep_ = max_next_tstep;
}
timestepAfterEvent_ = tuning.TMAXWC;
}
template<class Serializer>