From 1d2e413d63cfff92a21e3273ab8d88ccbf6d8e35 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Mon, 27 Jan 2025 11:44:10 +0100 Subject: [PATCH] Parameterize network sub-iterations and pressure update dampening --- opm/simulators/flow/BlackoilModelParameters.cpp | 9 +++++++++ opm/simulators/flow/BlackoilModelParameters.hpp | 14 ++++++++++++++ opm/simulators/wells/BlackoilWellModelGeneric.cpp | 10 ++++------ opm/simulators/wells/BlackoilWellModelGeneric.hpp | 3 ++- opm/simulators/wells/BlackoilWellModel_impl.hpp | 7 ++++--- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/opm/simulators/flow/BlackoilModelParameters.cpp b/opm/simulators/flow/BlackoilModelParameters.cpp index 5dea7b5c5..03c46a97d 100644 --- a/opm/simulators/flow/BlackoilModelParameters.cpp +++ b/opm/simulators/flow/BlackoilModelParameters.cpp @@ -97,6 +97,9 @@ BlackoilModelParameters::BlackoilModelParameters() deck_file_name_ = Parameters::Get(); network_max_strict_iterations_ = Parameters::Get(); network_max_iterations_ = Parameters::Get(); + network_max_sub_iterations_ = Parameters::Get(); + network_pressure_update_damping_factor_ = Parameters::Get>(); + network_max_pressure_update_in_bars_ = Parameters::Get>(); local_domain_ordering_ = domainOrderingMeasureFromString(Parameters::Get()); write_partitions_ = Parameters::Get(); @@ -220,6 +223,12 @@ void BlackoilModelParameters::registerParameters() ("Maximum iterations in network solver before relaxing tolerance"); Parameters::Register ("Maximum number of iterations in the network solver before giving up"); + Parameters::Register + ("Maximum number of sub-iterations to update network pressures (within a single well/group control update)"); + Parameters::Register> + ("Damping factor in the inner network pressure update iterations"); + Parameters::Register> + ("Maximum pressure update in the inner network pressure update iterations"); Parameters::Register ("Choose nonlinear solver. Valid choices are newton or nldd."); Parameters::Register diff --git a/opm/simulators/flow/BlackoilModelParameters.hpp b/opm/simulators/flow/BlackoilModelParameters.hpp index 256a07039..3ba5d0473 100644 --- a/opm/simulators/flow/BlackoilModelParameters.hpp +++ b/opm/simulators/flow/BlackoilModelParameters.hpp @@ -130,6 +130,11 @@ struct CheckGroupConstraintsInnerWellIterations { static constexpr bool value = // Network solver parameters struct NetworkMaxStrictIterations { static constexpr int value = 10; }; struct NetworkMaxIterations { static constexpr int value = 20; }; +struct NetworkMaxSubIterations { static constexpr int value = 20; }; +template +struct NetworkPressureUpdateDampingFactor { static constexpr Scalar value = 0.1; }; +template +struct NetworkMaxPressureUpdateInBars { static constexpr Scalar value = 5.0; }; struct NonlinearSolver { static constexpr auto value = "newton"; }; struct LocalSolveApproach { static constexpr auto value = "gauss-seidel"; }; struct MaxLocalSolveIterations { static constexpr int value = 20; }; @@ -297,6 +302,15 @@ public: /// Maximum number of iterations in the network solver before giving up int network_max_iterations_; + /// Maximum number of sub-iterations to update network pressures (within a single well/group control update) + int network_max_sub_iterations_; + + /// Damping factor in the inner network pressure update iterations + Scalar network_pressure_update_damping_factor_; + + /// Maximum pressure update in the inner network pressure update iterations + Scalar network_max_pressure_update_in_bars_; + /// Nonlinear solver type: newton or nldd. std::string nonlinear_solver_; /// 'jacobi' and 'gauss-seidel' supported. diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index baaa63328..83b4a2d31 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -1516,7 +1516,7 @@ inferLocalShutWells() template Scalar BlackoilWellModelGeneric:: -updateNetworkPressures(const int reportStepIdx, const Scalar damping_factor) +updateNetworkPressures(const int reportStepIdx, const Scalar damping_factor, const Scalar upper_update_bound) { OPM_TIMEFUNCTION(); // Get the network and return if inactive (no wells in network at this time) @@ -1552,11 +1552,9 @@ updateNetworkPressures(const int reportStepIdx, const Scalar damping_factor) if (std::abs(change) > network_imbalance) { network_imbalance = std::abs(change); } - // we dampen the amount of the nodal pressure can change during one iteration - // due to the fact our nodal pressure calculation is somewhat explicit - // TODO: the following parameters are subject to adjustment for optimization purpose - constexpr Scalar upper_update_bound = 5.0 * unit::barsa; - // relative dampening factor based on update value + // We dampen the nodal pressure change during one iteration since our nodal pressure calculation + // is somewhat explicit. There is a relative dampening factor applied to the update value, and also + // the maximum update is limited (to 5 bar by default, can be changed with --network-max-pressure-update-in-bars). const Scalar damped_change = std::min(damping_factor * std::abs(change), upper_update_bound); const Scalar sign = change > 0 ? 1. : -1.; node_pressures_[name] = pressure + sign * damped_change; diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index 0d0040851..541a18d61 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -351,7 +351,8 @@ protected: bool wasDynamicallyShutThisTimeStep(const int well_index) const; Scalar updateNetworkPressures(const int reportStepIdx, - const Scalar damping_factor); + const Scalar damping_factor, + const Scalar update_upper_bound); void updateWsolvent(const Group& group, const int reportStepIdx, diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 2111dc512..736ba7c90 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -1919,11 +1919,12 @@ namespace Opm { const double dt = this->simulator_.timeStepSize(); // Calculate common THP for subsea manifold well group (item 3 of NODEPROP set to YES) bool well_group_thp_updated = computeWellGroupThp(dt, deferred_logger); - constexpr int max_number_of_sub_iterations = 20; - constexpr Scalar damping_factor = 0.1; + const int max_number_of_sub_iterations = param_.network_max_sub_iterations_; + const Scalar network_pressure_update_damping_factor = param_.network_pressure_update_damping_factor_; + const Scalar network_max_pressure_update = param_.network_max_pressure_update_in_bars_ * unit::barsa; bool more_network_sub_update = false; for (int i = 0; i < max_number_of_sub_iterations; i++) { - const auto local_network_imbalance = this->updateNetworkPressures(episodeIdx, damping_factor); + const auto local_network_imbalance = this->updateNetworkPressures(episodeIdx, network_pressure_update_damping_factor, network_max_pressure_update); const Scalar network_imbalance = comm.max(local_network_imbalance); const auto& balance = this->schedule()[episodeIdx].network_balance(); constexpr Scalar relaxation_factor = 10.0;