Add sub iterations for balancing the network

This commit is contained in:
Tor Harald Sandve 2024-11-13 15:17:49 +01:00
parent b4fe429b35
commit 93206349c8
3 changed files with 15 additions and 9 deletions

View File

@ -1392,7 +1392,7 @@ inferLocalShutWells()
template<class Scalar>
Scalar BlackoilWellModelGeneric<Scalar>::
updateNetworkPressures(const int reportStepIdx)
updateNetworkPressures(const int reportStepIdx, const Scalar damping_factor)
{
// Get the network and return if inactive (no wells in network at this time)
const auto& network = schedule()[reportStepIdx].network();
@ -1432,7 +1432,6 @@ updateNetworkPressures(const int reportStepIdx)
// 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
constexpr Scalar damping_factor = 0.1;
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;

View File

@ -332,7 +332,8 @@ protected:
bool wasDynamicallyShutThisTimeStep(const int well_index) const;
Scalar updateNetworkPressures(const int reportStepIdx);
Scalar updateNetworkPressures(const int reportStepIdx,
const Scalar damping_factor);
void updateWsolvent(const Group& group,
const int reportStepIdx,

View File

@ -2187,12 +2187,18 @@ namespace Opm {
const double dt = this->simulator_.timeStepSize();
// Calculate common THP for subsea manifold well group (item 3 of NODEPROP set to YES)
computeWellGroupThp(dt, deferred_logger);
const auto local_network_imbalance = this->updateNetworkPressures(episodeIdx);
const Scalar network_imbalance = comm.max(local_network_imbalance);
const auto& balance = this->schedule()[episodeIdx].network_balance();
constexpr Scalar relaxation_factor = 10.0;
const Scalar tolerance = relax_network_tolerance ? relaxation_factor * balance.pressure_tolerance() : balance.pressure_tolerance();
more_network_update = this->networkActive() && network_imbalance > tolerance;
const int number_of_sub_iterations = 10;
const Scalar damping_factor = 1.0/number_of_sub_iterations;
for (int i = 0; i < number_of_sub_iterations; i++) {
const auto local_network_imbalance = this->updateNetworkPressures(episodeIdx, damping_factor);
const Scalar network_imbalance = comm.max(local_network_imbalance);
const auto& balance = this->schedule()[episodeIdx].network_balance();
constexpr Scalar relaxation_factor = 10.0;
const Scalar tolerance = relax_network_tolerance ? relaxation_factor * balance.pressure_tolerance() : balance.pressure_tolerance();
more_network_update = this->networkActive() && network_imbalance > tolerance;
if (!more_network_update)
break;
}
}
bool changed_well_group = false;