mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
clean up the logging message
This commit is contained in:
@@ -1777,11 +1777,14 @@ namespace Opm {
|
||||
|
||||
auto& well_state = well_state_;
|
||||
const Group2::ProductionCMode& oldControl = well_state.currentProductionGroupControl(group.name());
|
||||
const std::string from = Group2::ProductionCMode2String(oldControl);
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << "Group " << group.name() << " exceeding "
|
||||
<< from << " limit \n";
|
||||
|
||||
if (oldControl != newControl) {
|
||||
const std::string from = Group2::ProductionCMode2String(oldControl);
|
||||
ss << "Group " << group.name() << " exceeding "
|
||||
<< from << " limit \n";
|
||||
}
|
||||
switch(exceed_action) {
|
||||
case Group2::ExceedAction::NONE: {
|
||||
OPM_DEFLOG_THROW(std::runtime_error, "Group " + group.name() + "GroupProductionExceedLimit NONE not implemented", deferred_logger);
|
||||
@@ -1804,10 +1807,11 @@ namespace Opm {
|
||||
break;
|
||||
}
|
||||
case Group2::ExceedAction::RATE: {
|
||||
well_state.setCurrentProductionGroupControl(group.name(), newControl);
|
||||
ss << "Switching control mode for group to " << Group2::ProductionCMode2String(newControl)
|
||||
<< " \n Wells in group " + group.name() + " switches to GRUP control limit";
|
||||
wellGroupHelpers::setGroupControl(group, schedule(), reportStepIdx, false, well_state);
|
||||
if (oldControl != newControl) {
|
||||
well_state.setCurrentProductionGroupControl(group.name(), newControl);
|
||||
ss << "Switching control mode for group to " << Group2::ProductionCMode2String(newControl);
|
||||
}
|
||||
wellGroupHelpers::setGroupControl(group, schedule(), reportStepIdx, false, well_state, ss);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -1818,7 +1822,8 @@ namespace Opm {
|
||||
if (cc.size() > 1) {
|
||||
ss << " on rank " << cc.rank();
|
||||
}
|
||||
deferred_logger.info(ss.str());
|
||||
if (!ss.str().empty())
|
||||
deferred_logger.info(ss.str());
|
||||
|
||||
|
||||
}
|
||||
@@ -1830,19 +1835,24 @@ namespace Opm {
|
||||
actionOnBrokenConstraints(const Group2& group, const Group2::InjectionCMode& newControl, const int reportStepIdx, Opm::DeferredLogger& deferred_logger) {
|
||||
auto& well_state = well_state_;
|
||||
const Group2::InjectionCMode& oldControl = well_state.currentInjectionGroupControl(group.name());
|
||||
const std::string from = Group2::InjectionCMode2String(oldControl);
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << "Group " << group.name() << " exceeding "
|
||||
<< from << " limit \n";
|
||||
ss << "Switching control mode for group to " << Group2::InjectionCMode2String(newControl)
|
||||
<< " \n Wells in group " + group.name() + " switches to GRUP control limit";
|
||||
auto cc = Dune::MPIHelper::getCollectiveCommunication();
|
||||
if (cc.size() > 1) {
|
||||
ss << " on rank " << cc.rank();
|
||||
if (oldControl != newControl) {
|
||||
const std::string from = Group2::InjectionCMode2String(oldControl);
|
||||
ss << "Group " << group.name() << " exceeding "
|
||||
<< from << " limit \n";
|
||||
ss << "Switching control mode for group to " << Group2::InjectionCMode2String(newControl);
|
||||
auto cc = Dune::MPIHelper::getCollectiveCommunication();
|
||||
if (cc.size() > 1) {
|
||||
ss << " on rank " << cc.rank();
|
||||
}
|
||||
well_state.setCurrentInjectionGroupControl(group.name(), newControl);
|
||||
}
|
||||
deferred_logger.info(ss.str());
|
||||
well_state.setCurrentInjectionGroupControl(group.name(), newControl);
|
||||
wellGroupHelpers::setGroupControl(group, schedule(), reportStepIdx, /*isInjector*/true, well_state);
|
||||
wellGroupHelpers::setGroupControl(group, schedule(), reportStepIdx, /*isInjector*/true, well_state, ss);
|
||||
|
||||
if (!ss.str().empty())
|
||||
deferred_logger.info(ss.str());
|
||||
|
||||
}
|
||||
|
||||
template<typename TypeTag>
|
||||
|
||||
@@ -3146,31 +3146,30 @@ namespace Opm
|
||||
relaxation_factor = std::min(relaxation_factor, relaxation_factor_w);
|
||||
}
|
||||
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||
const double relaxation_factor_g = relaxationFactorFraction(primary_variables[GFrac], dwells[0][GFrac]);
|
||||
relaxation_factor = std::min(relaxation_factor, relaxation_factor_g);
|
||||
}
|
||||
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||
// We need to make sure the even with the relaxation_factor, the sum of F_w and F_g is below one, so there will
|
||||
// not be negative oil fraction later
|
||||
const double original_sum = primary_variables[WFrac] + primary_variables[GFrac];
|
||||
const double relaxed_update = (dwells[0][WFrac] + dwells[0][GFrac]) * relaxation_factor;
|
||||
const double possible_updated_sum = original_sum - relaxed_update;
|
||||
|
||||
if (possible_updated_sum > 1.0) {
|
||||
assert(relaxed_update != 0.);
|
||||
|
||||
const double further_relaxation_factor = std::abs((1. - original_sum) / relaxed_update) * 0.95;
|
||||
relaxation_factor *= further_relaxation_factor;
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||
const double relaxation_factor_g = relaxationFactorFraction(primary_variables[GFrac], dwells[0][GFrac]);
|
||||
relaxation_factor = std::min(relaxation_factor, relaxation_factor_g);
|
||||
}
|
||||
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||
// We need to make sure the even with the relaxation_factor, the sum of F_w and F_g is below one, so there will
|
||||
// not be negative oil fraction later
|
||||
const double original_sum = primary_variables[WFrac] + primary_variables[GFrac];
|
||||
const double relaxed_update = (dwells[0][WFrac] + dwells[0][GFrac]) * relaxation_factor;
|
||||
const double possible_updated_sum = original_sum - relaxed_update;
|
||||
|
||||
if (possible_updated_sum > 1.0) {
|
||||
assert(relaxed_update != 0.);
|
||||
|
||||
const double further_relaxation_factor = std::abs((1. - original_sum) / relaxed_update) * 0.95;
|
||||
relaxation_factor *= further_relaxation_factor;
|
||||
}
|
||||
}
|
||||
|
||||
assert(relaxation_factor >= 0.0 && relaxation_factor <= 1.0);
|
||||
}
|
||||
|
||||
assert(relaxation_factor >= 0.0 && relaxation_factor <= 1.0);
|
||||
|
||||
return relaxation_factor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -56,11 +56,11 @@ namespace Opm {
|
||||
accumulateGroupEfficiencyFactor(schedule.getGroup2(group.parent(), reportStepIdx), schedule, reportStepIdx, factor);
|
||||
}
|
||||
|
||||
inline void setGroupControl(const Group2& group, const Schedule& schedule, const int reportStepIdx, const bool injector, WellStateFullyImplicitBlackoil& wellState) {
|
||||
inline void setGroupControl(const Group2& group, const Schedule& schedule, const int reportStepIdx, const bool injector, WellStateFullyImplicitBlackoil& wellState, std::ostringstream& ss) {
|
||||
|
||||
for (const std::string& groupName : group.groups()) {
|
||||
const Group2& groupTmp = schedule.getGroup2(groupName, reportStepIdx);
|
||||
setGroupControl(groupTmp, schedule, reportStepIdx, injector, wellState);
|
||||
setGroupControl(groupTmp, schedule, reportStepIdx, injector, wellState, ss);
|
||||
if (injector)
|
||||
wellState.setCurrentInjectionGroupControl(groupName, Group2::InjectionCMode::FLD);
|
||||
else
|
||||
@@ -82,11 +82,19 @@ namespace Opm {
|
||||
if (!wellEcl.isAvailableForGroupControl())
|
||||
continue;
|
||||
|
||||
if (wellEcl.isProducer() && !injector)
|
||||
wellState.currentProductionControls()[well_index] = Well2::ProducerCMode::GRUP;
|
||||
if (wellEcl.isProducer() && !injector) {
|
||||
if (wellState.currentProductionControls()[well_index] != Well2::ProducerCMode::GRUP) {
|
||||
wellState.currentProductionControls()[well_index] = Well2::ProducerCMode::GRUP;
|
||||
ss <<"\n Producer " << wellName << " switches to GRUP control limit";
|
||||
}
|
||||
}
|
||||
|
||||
if (wellEcl.isInjector() && injector)
|
||||
wellState.currentInjectionControls()[well_index] = Well2::InjectorCMode::GRUP;
|
||||
if (wellEcl.isInjector() && injector) {
|
||||
if (wellState.currentInjectionControls()[well_index] != Well2::InjectorCMode::GRUP) {
|
||||
wellState.currentInjectionControls()[well_index] = Well2::InjectorCMode::GRUP;
|
||||
ss <<"\n Injector " << wellName << " switches to GRUP control limit";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user