mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-15 11:21:58 -06:00
Merge pull request #5234 from GitPaean/not_limiting_normal_segments
not using spres_lower_limit limit non-top segments
This commit is contained in:
commit
a9a0ae1eb0
@ -23,7 +23,6 @@
|
||||
#include <opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/MSW/WellSegments.hpp>
|
||||
#include <opm/input/eclipse/Units/Units.hpp>
|
||||
|
||||
#include <opm/material/fluidsystems/BlackOilDefaultIndexTraits.hpp>
|
||||
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
|
||||
@ -38,7 +37,10 @@
|
||||
#include <opm/simulators/wells/WellInterfaceIndices.hpp>
|
||||
#include <opm/simulators/wells/WellState.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -183,10 +185,8 @@ updateNewton(const BVectorWell& dwells,
|
||||
const double dx_limited = sign * std::min(std::abs(dwells[seg][SPres]) * relaxation_factor, max_pressure_change);
|
||||
// some cases might have defaulted bhp constraint of 1 bar, we use a slightly smaller value as the bhp lower limit for Newton update
|
||||
// so that bhp constaint can be an active control when needed.
|
||||
// TODO: we might need to distinguish SPres of the top segment from the SPres of the other segments, since only the top segment
|
||||
// is involved in the well constraints/control checking
|
||||
constexpr double spres_lower_limit = 1. * unit::barsa - 1. * unit::Pascal;
|
||||
value_[seg][SPres] = std::max(old_primary_variables[seg][SPres] - dx_limited, spres_lower_limit);
|
||||
const double lower_limit = (seg == 0) ? bhp_lower_limit : seg_pres_lower_limit;
|
||||
value_[seg][SPres] = std::max(old_primary_variables[seg][SPres] - dx_limited, lower_limit);
|
||||
}
|
||||
|
||||
// update the total rate // TODO: should we have a limitation of the total rate change?
|
||||
@ -257,7 +257,7 @@ copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell,
|
||||
if (scale > 0.) {
|
||||
fractions[p] /= scale;
|
||||
} else {
|
||||
// this should only happens to injection wells
|
||||
// this should only happen to injection wells
|
||||
fractions[p] = 0.;
|
||||
}
|
||||
}
|
||||
@ -628,6 +628,27 @@ getWQTotal() const
|
||||
return evaluation_[0][WQTotal];
|
||||
}
|
||||
|
||||
template<class FluidSystem, class Indices, class Scalar>
|
||||
void
|
||||
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::
|
||||
outputLowLimitPressureSegments(DeferredLogger& deferred_logger) const
|
||||
{
|
||||
std::string msg = fmt::format("outputting the segments for well {} with pressures close to the lower limits "
|
||||
"for debugging purpose \n", this->well_.name());
|
||||
bool any_seg_pressure_close_to_limit = false;
|
||||
for (std::size_t seg = 0; seg < value_.size(); ++seg) {
|
||||
const double lower_limit = (seg == 0) ? bhp_lower_limit : seg_pres_lower_limit;
|
||||
const double pres = Opm::getValue(this->getSegmentPressure(seg));
|
||||
if (pres <= std::numeric_limits<double>::epsilon() + lower_limit) {
|
||||
any_seg_pressure_close_to_limit = true;
|
||||
fmt::format_to(std::back_inserter(msg), "seg {} : pressure {}\n", seg, pres / unit::barsa);
|
||||
}
|
||||
}
|
||||
if (any_seg_pressure_close_to_limit) {
|
||||
deferred_logger.debug(msg);
|
||||
}
|
||||
}
|
||||
|
||||
#define INSTANCE(...) \
|
||||
template class MultisegmentWellPrimaryVariables<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <opm/simulators/wells/MultisegmentWellEquations.hpp>
|
||||
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
|
||||
#include <opm/input/eclipse/Units/Units.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
@ -150,6 +151,9 @@ public:
|
||||
void setValue(const int idx, const std::array<Scalar, numWellEq>& val)
|
||||
{ value_[idx] = val; }
|
||||
|
||||
//! output the segments with pressure close to lower pressure limit for debugging purpose
|
||||
void outputLowLimitPressureSegments(DeferredLogger& deferred_logger) const;
|
||||
|
||||
private:
|
||||
//! \brief Handle non-reasonable fractions due to numerical overshoot.
|
||||
void processFractions(const int seg);
|
||||
@ -167,6 +171,9 @@ private:
|
||||
std::vector<std::array<EvalWell, numWellEq>> evaluation_;
|
||||
|
||||
const WellInterfaceIndices<FluidSystem,Indices,Scalar>& well_; //!< Reference to well interface
|
||||
|
||||
static constexpr double bhp_lower_limit = 1. * unit::barsa - 1. * unit::Pascal;
|
||||
static constexpr double seg_pres_lower_limit = 0.;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1761,6 +1761,7 @@ namespace Opm
|
||||
const std::string message = fmt::format(" Well {} did not converge in {} inner iterations ("
|
||||
"{} control/status switches).", this->name(), it, switch_count);
|
||||
deferred_logger.debug(message);
|
||||
this->primary_variables_.outputLowLimitPressureSegments(deferred_logger);
|
||||
}
|
||||
|
||||
return converged;
|
||||
|
Loading…
Reference in New Issue
Block a user