mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Simplified using fmt::format()
Simplified debug output formatting by using fmt::format(). Also switched off glift debug output by default.
This commit is contained in:
@@ -306,7 +306,7 @@ namespace Opm {
|
|||||||
std::vector<double> depth_;
|
std::vector<double> depth_;
|
||||||
bool initial_step_;
|
bool initial_step_;
|
||||||
bool report_step_starts_;
|
bool report_step_starts_;
|
||||||
bool glift_debug = true;
|
bool glift_debug = false;
|
||||||
std::unique_ptr<RateConverterType> rateConverter_;
|
std::unique_ptr<RateConverterType> rateConverter_;
|
||||||
std::unique_ptr<VFPProperties<VFPInjProperties,VFPProdProperties>> vfp_properties_;
|
std::unique_ptr<VFPProperties<VFPInjProperties,VFPProdProperties>> vfp_properties_;
|
||||||
|
|
||||||
@@ -331,10 +331,6 @@ namespace Opm {
|
|||||||
const std::string &msg,
|
const std::string &msg,
|
||||||
Opm::DeferredLogger& deferred_logger) const;
|
Opm::DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
void gliftDebug(
|
|
||||||
std::ostringstream &ss,
|
|
||||||
Opm::DeferredLogger& deferred_logger) const;
|
|
||||||
|
|
||||||
// compute the well fluxes and assemble them in to the reservoir equations as source terms
|
// compute the well fluxes and assemble them in to the reservoir equations as source terms
|
||||||
// and in the well equations.
|
// and in the well equations.
|
||||||
void assemble(const int iterationIdx,
|
void assemble(const int iterationIdx,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
@@ -402,23 +403,11 @@ namespace Opm {
|
|||||||
void
|
void
|
||||||
BlackoilWellModel<TypeTag>::gliftDebug(
|
BlackoilWellModel<TypeTag>::gliftDebug(
|
||||||
const std::string &msg, Opm::DeferredLogger &deferred_logger) const
|
const std::string &msg, Opm::DeferredLogger &deferred_logger) const
|
||||||
{
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << msg;
|
|
||||||
gliftDebug(ss, deferred_logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename TypeTag>
|
|
||||||
void
|
|
||||||
BlackoilWellModel<TypeTag>::gliftDebug(
|
|
||||||
std::ostringstream &ss, Opm::DeferredLogger &deferred_logger) const
|
|
||||||
{
|
{
|
||||||
if (this->glift_debug) {
|
if (this->glift_debug) {
|
||||||
std::string message = ss.str();
|
const std::string message = fmt::format(
|
||||||
if (message.empty()) return;
|
" GLIFT (DEBUG) : BlackoilWellModel : {}", msg);
|
||||||
std::ostringstream ss2;
|
deferred_logger.info(message);
|
||||||
ss2 << " GLIFT (DEBUG) : BlackoilWellModel : " << message;
|
|
||||||
deferred_logger.info(ss2.str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,9 +830,9 @@ namespace Opm {
|
|||||||
|
|
||||||
Opm::DeferredLogger local_deferredLogger;
|
Opm::DeferredLogger local_deferredLogger;
|
||||||
if (this->glift_debug) {
|
if (this->glift_debug) {
|
||||||
std::ostringstream os;
|
const std::string msg = fmt::format(
|
||||||
os << "assemble() : iteration = " << iterationIdx;
|
"assemble() : iteration {}" , iterationIdx);
|
||||||
gliftDebug(os, local_deferredLogger);
|
gliftDebug(msg, local_deferredLogger);
|
||||||
}
|
}
|
||||||
last_report_ = SimulatorReportSingle();
|
last_report_ = SimulatorReportSingle();
|
||||||
Dune::Timer perfTimer;
|
Dune::Timer perfTimer;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace Opm {
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
@@ -76,7 +77,7 @@ namespace Opm
|
|||||||
void computeWellRates_(double bhp, std::vector<double> &potentials);
|
void computeWellRates_(double bhp, std::vector<double> &potentials);
|
||||||
void debugShowIterationInfo_(OptimizeState &state, double alq);
|
void debugShowIterationInfo_(OptimizeState &state, double alq);
|
||||||
void debugShowStartIteration_(double alq, bool increase);
|
void debugShowStartIteration_(double alq, bool increase);
|
||||||
void displayDebugMessage_(std::ostringstream &ss);
|
void displayDebugMessage_(const std::string &msg);
|
||||||
void displayWarning_();
|
void displayWarning_();
|
||||||
void displayWarning_(std::string warning);
|
void displayWarning_(std::string warning);
|
||||||
double getGasRateWithLimit_(std::vector<double> &potentials);
|
double getGasRateWithLimit_(std::vector<double> &potentials);
|
||||||
@@ -100,7 +101,6 @@ namespace Opm
|
|||||||
const WellState &well_state_;
|
const WellState &well_state_;
|
||||||
std::string well_name_;
|
std::string well_name_;
|
||||||
bool debug; // extra debug output
|
bool debug; // extra debug output
|
||||||
bool debug_disable; // act as glift optimization is disabled
|
|
||||||
|
|
||||||
double alpha_w_;
|
double alpha_w_;
|
||||||
double alpha_g_;
|
double alpha_g_;
|
||||||
|
|||||||
@@ -46,8 +46,7 @@ GasLiftRuntime(
|
|||||||
std_well_{std_well},
|
std_well_{std_well},
|
||||||
summary_state_{summary_state},
|
summary_state_{summary_state},
|
||||||
well_state_{well_state},
|
well_state_{well_state},
|
||||||
debug{true}, // extra debugging output
|
debug{false} // extra debugging output
|
||||||
debug_disable{false} // act as glift optimization is disabled
|
|
||||||
{
|
{
|
||||||
int well_index = this->std_well_.indexOfWell();
|
int well_index = this->std_well_.indexOfWell();
|
||||||
const Well::ProducerCMode& control_mode
|
const Well::ProducerCMode& control_mode
|
||||||
@@ -77,10 +76,7 @@ GasLiftRuntime(
|
|||||||
this->eco_grad_ = glo.min_eco_gradient();
|
this->eco_grad_ = glo.min_eco_gradient();
|
||||||
auto& gl_well = glo.well(this->well_name_);
|
auto& gl_well = glo.well(this->well_name_);
|
||||||
|
|
||||||
if (this->debug_disable) {
|
if(useFixedAlq_(gl_well)) {
|
||||||
this->optimize_ = false;
|
|
||||||
}
|
|
||||||
else if(useFixedAlq_(gl_well)) {
|
|
||||||
updateWellStateAlqFixedValue_(gl_well);
|
updateWellStateAlqFixedValue_(gl_well);
|
||||||
this->optimize_ = false; // lift gas supply is fixed
|
this->optimize_ = false; // lift gas supply is fixed
|
||||||
}
|
}
|
||||||
@@ -155,9 +151,8 @@ void
|
|||||||
Opm::GasLiftRuntime<TypeTag>::
|
Opm::GasLiftRuntime<TypeTag>::
|
||||||
debugShowIterationInfo_(OptimizeState &state, double alq)
|
debugShowIterationInfo_(OptimizeState &state, double alq)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
const std::string msg = fmt::format("iteration {}, ALQ = {}", state.it, alq);
|
||||||
ss << "iteration " << state.it << ", ALQ = " << alq;
|
this->displayDebugMessage_(msg);
|
||||||
this->displayDebugMessage_(ss);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
@@ -165,25 +160,23 @@ void
|
|||||||
Opm::GasLiftRuntime<TypeTag>::
|
Opm::GasLiftRuntime<TypeTag>::
|
||||||
debugShowStartIteration_(double alq, bool increase)
|
debugShowStartIteration_(double alq, bool increase)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
const std::string msg =
|
||||||
auto oil_rate = -this->potentials_[this->oil_pos_];
|
fmt::format("starting {} iteration, ALQ = {}, oilrate = {}",
|
||||||
std::string dir = increase ? "increase" : "decrease";
|
(increase ? "increase" : "decrease"),
|
||||||
ss << "starting " << dir << " iteration, ALQ = " << alq
|
alq,
|
||||||
<< ", oilrate = " << oil_rate;
|
-this->potentials_[this->oil_pos_]);
|
||||||
this->displayDebugMessage_(ss);
|
this->displayDebugMessage_(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
Opm::GasLiftRuntime<TypeTag>::
|
Opm::GasLiftRuntime<TypeTag>::
|
||||||
displayDebugMessage_(std::ostringstream &ss)
|
displayDebugMessage_(const std::string &msg)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string message = ss.str();
|
const std::string message = fmt::format(
|
||||||
if (message.empty()) return;
|
" GLIFT (DEBUG) : Well {} : {}", this->well_name_, msg);
|
||||||
std::ostringstream ss2;
|
this->deferred_logger_.info(message);
|
||||||
ss2 << " GLIFT (DEBUG) : Well " << this->well_name_ << " : " << message;
|
|
||||||
this->deferred_logger_.info(ss2.str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
@@ -191,9 +184,9 @@ void
|
|||||||
Opm::GasLiftRuntime<TypeTag>::
|
Opm::GasLiftRuntime<TypeTag>::
|
||||||
displayWarning_(std::string msg)
|
displayWarning_(std::string msg)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
const std::string message = fmt::format(
|
||||||
ss << "GAS LIFT OPTIMIZATION, WELL: " << this->well_name_ << " : " << msg;
|
"GAS LIFT OPTIMIZATION, WELL {} : {}", this->well_name_, msg);
|
||||||
this->deferred_logger_.warning("WARNING", ss.str());
|
this->deferred_logger_.warning("WARNING", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: what if the gas_rate_target_ has been defaulted
|
// TODO: what if the gas_rate_target_ has been defaulted
|
||||||
@@ -252,12 +245,13 @@ Opm::GasLiftRuntime<TypeTag>::
|
|||||||
logSuccess_()
|
logSuccess_()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::ostringstream ss;
|
const std::string message = fmt::format(
|
||||||
std::string dir;
|
"GLIFT, WELL {} {} ALQ from {} to {}",
|
||||||
dir = (this->new_alq_ > this->orig_alq_) ? "increased" : "decreased";
|
this->well_name_,
|
||||||
ss << "GLIFT, WELL " << this->well_name_ << " " << dir << " ALQ from "
|
((this->new_alq_ > this->orig_alq_) ? "increased" : "decreased"),
|
||||||
<< this->orig_alq_ << " to " << this->new_alq_;
|
this->orig_alq_,
|
||||||
this->deferred_logger_.info(ss.str());
|
this->new_alq_);
|
||||||
|
this->deferred_logger_.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* - At this point we know that this is a production well, and that its current
|
/* - At this point we know that this is a production well, and that its current
|
||||||
@@ -648,7 +642,7 @@ checkAlqOutsideLimits(double alq, double oil_rate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this->parent.debug) this->parent.displayDebugMessage_(ss);
|
if (this->parent.debug) this->parent.displayDebugMessage_(ss.str());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,7 +677,7 @@ checkEcoGradient(double gradient)
|
|||||||
if (this->parent.debug) ss << "false";
|
if (this->parent.debug) ss << "false";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this->parent.debug) this->parent.displayDebugMessage_(ss);
|
if (this->parent.debug) this->parent.displayDebugMessage_(ss.str());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,11 +689,10 @@ checkRate(double rate, double limit, const std::string rate_str)
|
|||||||
|
|
||||||
if (limit < rate ) {
|
if (limit < rate ) {
|
||||||
if (this->parent.debug) {
|
if (this->parent.debug) {
|
||||||
std::ostringstream ss;
|
const std::string msg = fmt::format(
|
||||||
ss << "iteration " << this->it << " : " << rate_str << " rate "
|
"iteration {} : rate {} exceeds target rate {}. Stopping iteration",
|
||||||
<< rate << " exceeds target rate "
|
this->it, rate_str, rate, limit);
|
||||||
<< limit << ". Stopping iteration";
|
this->parent.displayDebugMessage_(msg);
|
||||||
this->parent.displayDebugMessage_(ss);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -753,11 +746,11 @@ computeBhpAtThpLimit(double alq)
|
|||||||
this->parent.deferred_logger_,
|
this->parent.deferred_logger_,
|
||||||
alq);
|
alq);
|
||||||
if (!bhp_at_thp_limit) {
|
if (!bhp_at_thp_limit) {
|
||||||
std::ostringstream ss;
|
const std::string msg = fmt::format(
|
||||||
ss << "Failed in getting converged bhp potential for well "
|
"Failed in getting converged bhp potential for well {}",
|
||||||
<< this->parent.well_name_;
|
this->parent.well_name_);
|
||||||
this->parent.deferred_logger_.warning(
|
this->parent.deferred_logger_.warning(
|
||||||
"FAILURE_GETTING_CONVERGED_POTENTIAL", ss.str());
|
"FAILURE_GETTING_CONVERGED_POTENTIAL", msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this->bhp = *bhp_at_thp_limit;
|
this->bhp = *bhp_at_thp_limit;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <dune/common/dynmatrix.hh>
|
#include <dune/common/dynmatrix.hh>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
@@ -256,10 +257,6 @@ namespace Opm
|
|||||||
const std::string &msg,
|
const std::string &msg,
|
||||||
Opm::DeferredLogger& deferred_logger) const;
|
Opm::DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
void gliftDebug(
|
|
||||||
std::ostringstream &ss,
|
|
||||||
Opm::DeferredLogger& deferred_logger) const;
|
|
||||||
|
|
||||||
void gasLiftOptimizeProduction(
|
void gasLiftOptimizeProduction(
|
||||||
const Simulator& ebosSimulator,
|
const Simulator& ebosSimulator,
|
||||||
const SummaryState& summaryState,
|
const SummaryState& summaryState,
|
||||||
@@ -378,7 +375,7 @@ namespace Opm
|
|||||||
|
|
||||||
bool changed_to_stopped_this_step_ = false;
|
bool changed_to_stopped_this_step_ = false;
|
||||||
// Enable GLIFT debug mode. This will enable output of logging messages.
|
// Enable GLIFT debug mode. This will enable output of logging messages.
|
||||||
bool glift_debug = true;
|
bool glift_debug = false;
|
||||||
|
|
||||||
const EvalWell& getBhp() const;
|
const EvalWell& getBhp() const;
|
||||||
|
|
||||||
|
|||||||
@@ -2589,10 +2589,10 @@ namespace Opm
|
|||||||
// turned off by entering a zero or negative number."
|
// turned off by entering a zero or negative number."
|
||||||
if (increment <= 0) {
|
if (increment <= 0) {
|
||||||
if (this->glift_debug) {
|
if (this->glift_debug) {
|
||||||
std::ostringstream ss;
|
const std::string msg = fmt::format(
|
||||||
ss << "Gas Lift switched off in LIFTOPT item 1 due to non-positive "
|
"Gas Lift switched off in LIFTOPT item 1 due to non-positive "
|
||||||
<< "value: " << increment;
|
"value: {}", increment);
|
||||||
gliftDebug(ss, deferred_logger);
|
gliftDebug(msg, deferred_logger);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2615,21 +2615,21 @@ namespace Opm
|
|||||||
if (glo.all_newton()) {
|
if (glo.all_newton()) {
|
||||||
const int nupcol = schedule.getNupcol(report_step_idx);
|
const int nupcol = schedule.getNupcol(report_step_idx);
|
||||||
if (this->glift_debug) {
|
if (this->glift_debug) {
|
||||||
std::ostringstream ss;
|
const std::string msg = fmt::format(
|
||||||
ss << "LIFTOPT item4 == YES, it = " << iteration_idx
|
"LIFTOPT item4 == YES, it = {}, nupcol = {} --> GLIFT optimize = {}",
|
||||||
<< ", nupcol = " << nupcol << " -> " << " --> GLIFT optimize = "
|
iteration_idx,
|
||||||
<< ((iteration_idx <= nupcol) ? "TRUE" : "FALSE");
|
nupcol,
|
||||||
gliftDebug(ss, deferred_logger);
|
((iteration_idx <= nupcol) ? "TRUE" : "FALSE"));
|
||||||
|
gliftDebug(msg, deferred_logger);
|
||||||
}
|
}
|
||||||
return iteration_idx <= nupcol;
|
return iteration_idx <= nupcol;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this->glift_debug) {
|
if (this->glift_debug) {
|
||||||
std::ostringstream ss;
|
const std::string msg = fmt::format(
|
||||||
ss << "LIFTOPT item4 == NO, it = " << iteration_idx
|
"LIFTOPT item4 == NO, it = {} --> GLIFT optimize = {}",
|
||||||
<< " --> GLIFT optimize = "
|
iteration_idx, ((iteration_idx == 1) ? "TRUE" : "FALSE"));
|
||||||
<< ((iteration_idx == 1) ? "TRUE" : "FALSE");
|
gliftDebug(msg, deferred_logger);
|
||||||
gliftDebug(ss, deferred_logger);
|
|
||||||
}
|
}
|
||||||
return iteration_idx == 1;
|
return iteration_idx == 1;
|
||||||
}
|
}
|
||||||
@@ -2641,22 +2641,11 @@ namespace Opm
|
|||||||
gliftDebug(
|
gliftDebug(
|
||||||
const std::string &msg, DeferredLogger& deferred_logger) const
|
const std::string &msg, DeferredLogger& deferred_logger) const
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
if (this->glift_debug) {
|
||||||
ss << msg;
|
const std::string message = fmt::format(
|
||||||
gliftDebug(ss, deferred_logger);
|
" GLIFT (DEBUG) : Well {} : {}", this->name(), msg);
|
||||||
}
|
deferred_logger.info(message);
|
||||||
|
}
|
||||||
template<typename TypeTag>
|
|
||||||
void
|
|
||||||
StandardWell<TypeTag>::
|
|
||||||
gliftDebug(
|
|
||||||
std::ostringstream &ss, DeferredLogger& deferred_logger) const
|
|
||||||
{
|
|
||||||
std::string message = ss.str();
|
|
||||||
if (message.empty()) return;
|
|
||||||
std::ostringstream ss2;
|
|
||||||
ss2 << " GLIFT (DEBUG) : Well " << this->name() << " : " << message;
|
|
||||||
deferred_logger.info(ss2.str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
|
|||||||
Reference in New Issue
Block a user