mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
MultisegmentWellGeneric: use Scalar type
This commit is contained in:
parent
b151cbabac
commit
caf4bc1de2
@ -58,8 +58,8 @@ scaleSegmentRatesWithWellRates(const std::vector<std::vector<int>>& segment_inle
|
|||||||
auto& segments = ws.segments;
|
auto& segments = ws.segments;
|
||||||
auto& segment_rates = segments.rates;
|
auto& segment_rates = segments.rates;
|
||||||
for (int phase = 0; phase < baseif_.numPhases(); ++phase) {
|
for (int phase = 0; phase < baseif_.numPhases(); ++phase) {
|
||||||
const double unscaled_top_seg_rate = segment_rates[phase];
|
const Scalar unscaled_top_seg_rate = segment_rates[phase];
|
||||||
const double well_phase_rate = ws.surface_rates[phase];
|
const Scalar well_phase_rate = ws.surface_rates[phase];
|
||||||
if (std::abs(unscaled_top_seg_rate) > 1e-12) {
|
if (std::abs(unscaled_top_seg_rate) > 1e-12) {
|
||||||
for (int seg = 0; seg < numberOfSegments(); ++seg) {
|
for (int seg = 0; seg < numberOfSegments(); ++seg) {
|
||||||
segment_rates[baseif_.numPhases() * seg + phase] *= well_phase_rate / unscaled_top_seg_rate;
|
segment_rates[baseif_.numPhases() * seg + phase] *= well_phase_rate / unscaled_top_seg_rate;
|
||||||
@ -67,20 +67,20 @@ scaleSegmentRatesWithWellRates(const std::vector<std::vector<int>>& segment_inle
|
|||||||
} else {
|
} else {
|
||||||
// Due to various reasons, the well/top segment rate can be zero for this phase.
|
// Due to various reasons, the well/top segment rate can be zero for this phase.
|
||||||
// We can not scale this rate directly. The following approach is used to initialize the segment rates.
|
// We can not scale this rate directly. The following approach is used to initialize the segment rates.
|
||||||
double sumTw = 0;
|
Scalar sumTw = 0;
|
||||||
for (int perf = 0; perf < baseif_.numPerfs(); ++perf) {
|
for (int perf = 0; perf < baseif_.numPerfs(); ++perf) {
|
||||||
sumTw += baseif_.wellIndex()[perf];
|
sumTw += baseif_.wellIndex()[perf];
|
||||||
}
|
}
|
||||||
|
|
||||||
// only handling this specific phase
|
// only handling this specific phase
|
||||||
constexpr double num_single_phase = 1;
|
constexpr Scalar num_single_phase = 1;
|
||||||
std::vector<double> perforation_rates(num_single_phase * baseif_.numPerfs(), 0.0);
|
std::vector<Scalar> perforation_rates(num_single_phase * baseif_.numPerfs(), 0.0);
|
||||||
const double perf_phaserate_scaled = ws.surface_rates[phase] / sumTw;
|
const Scalar perf_phaserate_scaled = ws.surface_rates[phase] / sumTw;
|
||||||
for (int perf = 0; perf < baseif_.numPerfs(); ++perf) {
|
for (int perf = 0; perf < baseif_.numPerfs(); ++perf) {
|
||||||
perforation_rates[perf] = baseif_.wellIndex()[perf] * perf_phaserate_scaled;
|
perforation_rates[perf] = baseif_.wellIndex()[perf] * perf_phaserate_scaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> rates;
|
std::vector<Scalar> rates;
|
||||||
WellState<Scalar>::calculateSegmentRates(segment_inlets,
|
WellState<Scalar>::calculateSegmentRates(segment_inlets,
|
||||||
segment_perforations,
|
segment_perforations,
|
||||||
perforation_rates,
|
perforation_rates,
|
||||||
@ -137,7 +137,7 @@ segmentNumberToIndex(const int segment_number) const
|
|||||||
template<typename Scalar>
|
template<typename Scalar>
|
||||||
void
|
void
|
||||||
MultisegmentWellGeneric<Scalar>::
|
MultisegmentWellGeneric<Scalar>::
|
||||||
detectOscillations(const std::vector<double>& measure_history, bool& oscillate, bool& stagnate) const
|
detectOscillations(const std::vector<Scalar>& measure_history, bool& oscillate, bool& stagnate) const
|
||||||
{
|
{
|
||||||
const auto it = measure_history.size() - 1;
|
const auto it = measure_history.size() - 1;
|
||||||
if ( it < 2 ) {
|
if ( it < 2 ) {
|
||||||
@ -147,16 +147,16 @@ detectOscillations(const std::vector<double>& measure_history, bool& oscillate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
stagnate = true;
|
stagnate = true;
|
||||||
const double F0 = measure_history[it];
|
const Scalar F0 = measure_history[it];
|
||||||
const double F1 = measure_history[it - 1];
|
const Scalar F1 = measure_history[it - 1];
|
||||||
const double F2 = measure_history[it - 2];
|
const Scalar F2 = measure_history[it - 2];
|
||||||
const double d1 = std::abs((F0 - F2) / F0);
|
const Scalar d1 = std::abs((F0 - F2) / F0);
|
||||||
const double d2 = std::abs((F0 - F1) / F0);
|
const Scalar d2 = std::abs((F0 - F1) / F0);
|
||||||
|
|
||||||
const double oscillaton_rel_tol = 0.2;
|
const Scalar oscillaton_rel_tol = 0.2;
|
||||||
oscillate = (d1 < oscillaton_rel_tol) && (oscillaton_rel_tol < d2);
|
oscillate = (d1 < oscillaton_rel_tol) && (oscillaton_rel_tol < d2);
|
||||||
|
|
||||||
const double stagnation_rel_tol = 1.e-2;
|
const Scalar stagnation_rel_tol = 1.e-2;
|
||||||
stagnate = std::abs((F1 - F2) / F2) <= stagnation_rel_tol;
|
stagnate = std::abs((F1 - F2) / F2) <= stagnation_rel_tol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,15 +179,15 @@ accelerationalPressureLossConsidered() const
|
|||||||
|
|
||||||
|
|
||||||
template<class Scalar>
|
template<class Scalar>
|
||||||
double
|
Scalar
|
||||||
MultisegmentWellGeneric<Scalar>::getSegmentDp(const int seg,
|
MultisegmentWellGeneric<Scalar>::getSegmentDp(const int seg,
|
||||||
const double density,
|
const Scalar density,
|
||||||
const std::vector<double>& seg_dp) const
|
const std::vector<Scalar>& seg_dp) const
|
||||||
{
|
{
|
||||||
const double segment_depth = this->segmentSet()[seg].depth();
|
const Scalar segment_depth = this->segmentSet()[seg].depth();
|
||||||
const int outlet_segment_index = this->segmentNumberToIndex(this->segmentSet()[seg].outletSegment());
|
const int outlet_segment_index = this->segmentNumberToIndex(this->segmentSet()[seg].outletSegment());
|
||||||
const double segment_depth_outlet = seg == 0 ? baseif_.refDepth() : this->segmentSet()[outlet_segment_index].depth();
|
const Scalar segment_depth_outlet = seg == 0 ? baseif_.refDepth() : this->segmentSet()[outlet_segment_index].depth();
|
||||||
double dp = wellhelpers::computeHydrostaticCorrection(segment_depth_outlet, segment_depth,
|
Scalar dp = wellhelpers::computeHydrostaticCorrection(segment_depth_outlet, segment_depth,
|
||||||
density, baseif_.gravity());
|
density, baseif_.gravity());
|
||||||
// we add the hydrostatic correction from the outlet segment
|
// we add the hydrostatic correction from the outlet segment
|
||||||
// in order to get the correction all the way to the bhp ref depth.
|
// in order to get the correction all the way to the bhp ref depth.
|
||||||
|
@ -64,16 +64,16 @@ protected:
|
|||||||
WellSegmentCompPressureDrop compPressureDrop() const;
|
WellSegmentCompPressureDrop compPressureDrop() const;
|
||||||
|
|
||||||
/// Detect oscillation or stagnation based on the residual measure history
|
/// Detect oscillation or stagnation based on the residual measure history
|
||||||
void detectOscillations(const std::vector<double>& measure_history,
|
void detectOscillations(const std::vector<Scalar>& measure_history,
|
||||||
bool& oscillate,
|
bool& oscillate,
|
||||||
bool& stagnate) const;
|
bool& stagnate) const;
|
||||||
|
|
||||||
bool accelerationalPressureLossConsidered() const;
|
bool accelerationalPressureLossConsidered() const;
|
||||||
bool frictionalPressureLossConsidered() const;
|
bool frictionalPressureLossConsidered() const;
|
||||||
|
|
||||||
double getSegmentDp(const int seg,
|
Scalar getSegmentDp(const int seg,
|
||||||
const double density,
|
const Scalar density,
|
||||||
const std::vector<double>& seg_dp) const;
|
const std::vector<Scalar>& seg_dp) const;
|
||||||
|
|
||||||
const WellInterfaceGeneric<Scalar>& baseif_;
|
const WellInterfaceGeneric<Scalar>& baseif_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user