try to honor the network balance tolerance

without considering the iteration number. Because of the different
implementaion from other simulators, it is difficult to honour
procedure-dependent parameters.
This commit is contained in:
Kai Bao 2023-04-24 22:51:46 +02:00
parent 6148e97771
commit b9348ee435
5 changed files with 9 additions and 26 deletions

View File

@ -294,8 +294,7 @@ namespace Opm {
void initPrimaryVariablesEvaluation() const;
std::pair<bool, bool>
updateWellControls(const bool mandatory_network_balance, DeferredLogger& deferred_logger,
const std::size_t network_update_it);
updateWellControls(const bool mandatory_network_balance, DeferredLogger& deferred_logger);
void updateAndCommunicate(const int reportStepIdx,
const int iterationIdx,
@ -401,7 +400,6 @@ namespace Opm {
// the returned two booleans are {continue_due_to_network, well_group_control_changed}, respectively
std::pair<bool, bool> updateWellControlsAndNetworkIteration(const bool mandatory_network_balance,
const double dt,
const std::size_t network_update_iteration,
DeferredLogger& local_deferredLogger);
bool updateWellControlsAndNetwork(const bool mandatory_network_balance,

View File

@ -1292,17 +1292,7 @@ shouldBalanceNetwork(const int reportStepIdx, const int iterationIdx) const
}
}
bool
BlackoilWellModelGeneric::
moreNetworkIteration(const int reportStepIdx,
const std::size_t iteration,
const double network_imbalance) const
{
const auto& balance = schedule()[reportStepIdx].network_balance();
// Iterate if not converged, and number of iterations is not yet max (NETBALAN item 3).
return iteration < balance.pressure_max_iter() &&
network_imbalance > balance.pressure_tolerance();
}
std::vector<int>
BlackoilWellModelGeneric::

View File

@ -177,10 +177,6 @@ public:
bool shouldBalanceNetwork(const int reportStepIndex,
const int iterationIdx) const;
bool moreNetworkIteration(const int reportStepIdx,
const std::size_t iteration,
const double network_imbalance) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{

View File

@ -953,14 +953,14 @@ namespace Opm {
BlackoilWellModel<TypeTag>::
updateWellControlsAndNetwork(const bool mandatory_network_balance, const double dt, DeferredLogger& local_deferredLogger)
{
// TODO: adding max_iter and also the iteration that we need to use relaxed tolerance and what happens if not converged?
// not necessarily that we always need to update once of the network solutions
bool do_network_update = true;
bool well_group_control_changed = false;
std::size_t network_update_iteration = 0;
while (do_network_update) {
std::tie(do_network_update, well_group_control_changed) =
updateWellControlsAndNetworkIteration(mandatory_network_balance, dt,
network_update_iteration, local_deferredLogger);
updateWellControlsAndNetworkIteration(mandatory_network_balance, dt,local_deferredLogger);
++network_update_iteration;
}
return well_group_control_changed;
@ -974,11 +974,10 @@ namespace Opm {
BlackoilWellModel<TypeTag>::
updateWellControlsAndNetworkIteration(const bool mandatory_network_balance,
const double dt,
const std::size_t network_update_iteration,
DeferredLogger& local_deferredLogger)
{
auto [well_group_control_changed, more_network_update] =
updateWellControls(mandatory_network_balance,local_deferredLogger,network_update_iteration);
updateWellControls(mandatory_network_balance, local_deferredLogger);
bool alq_updated = false;
OPM_BEGIN_PARALLEL_TRY_CATCH();
@ -1557,8 +1556,7 @@ namespace Opm {
template<typename TypeTag>
std::pair<bool, bool>
BlackoilWellModel<TypeTag>::
updateWellControls(const bool mandatory_network_balance, DeferredLogger& deferred_logger,
const std::size_t network_update_it)
updateWellControls(const bool mandatory_network_balance, DeferredLogger& deferred_logger)
{
const int episodeIdx = ebosSimulator_.episodeIndex();
const auto& network = schedule()[episodeIdx].network();
@ -1575,7 +1573,8 @@ namespace Opm {
if (shouldBalanceNetwork(episodeIdx, iterationIdx) || mandatory_network_balance) {
const auto local_network_imbalance = updateNetworkPressures(episodeIdx);
const double network_imbalance = comm.max(local_network_imbalance);
more_network_update = moreNetworkIteration(episodeIdx, network_update_it, network_imbalance);
const auto& balance = schedule()[episodeIdx].network_balance();
more_network_update = network_imbalance > balance.pressure_tolerance();
}
bool changed_well_group = false;

View File

@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE(G1)
Opm::DeferredLogger deferred_logger;
well_model.calculateExplicitQuantities(deferred_logger);
well_model.prepareTimeStep(deferred_logger);
well_model.updateWellControls(false, deferred_logger, 0);
well_model.updateWellControls(false, deferred_logger);
well_model.initPrimaryVariablesEvaluation();
Opm::WellInterface<TypeTag> *well_ptr = well_model.getWell("B-1H").get();
StdWell *std_well = dynamic_cast<StdWell *>(well_ptr);