mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
MultisegmentWellSegments: use Scalar type
This commit is contained in:
parent
caf4bc1de2
commit
791d83b31a
@ -100,7 +100,7 @@ MultisegmentWellSegments(const int numSegments,
|
||||
}
|
||||
perforations_[segment_index].push_back(i_perf_wells);
|
||||
well.perfDepth()[i_perf_wells] = connection.depth();
|
||||
const double segment_depth = segment_set[segment_index].depth();
|
||||
const Scalar segment_depth = segment_set[segment_index].depth();
|
||||
perforation_depth_diffs_[i_perf_wells] = well_.perfDepth()[i_perf_wells] - segment_depth;
|
||||
i_perf_wells++;
|
||||
}
|
||||
@ -120,10 +120,10 @@ MultisegmentWellSegments(const int numSegments,
|
||||
// calculating the depth difference between the segment and its oulet_segments
|
||||
// for the top segment, we will make its zero unless we find other purpose to use this value
|
||||
for (int seg = 1; seg < numSegments; ++seg) {
|
||||
const double segment_depth = segment_set[seg].depth();
|
||||
const Scalar segment_depth = segment_set[seg].depth();
|
||||
const int outlet_segment_number = segment_set[seg].outletSegment();
|
||||
const Segment& outlet_segment = segment_set[segment_set.segmentNumberToIndex(outlet_segment_number)];
|
||||
const double outlet_depth = outlet_segment.depth();
|
||||
const Scalar outlet_depth = outlet_segment.depth();
|
||||
depth_diffs_[seg] = segment_depth - outlet_depth;
|
||||
}
|
||||
}
|
||||
@ -136,7 +136,7 @@ computeFluidProperties(const EvalWell& temperature,
|
||||
int pvt_region_index,
|
||||
DeferredLogger& deferred_logger)
|
||||
{
|
||||
std::vector<double> surf_dens(well_.numComponents());
|
||||
std::vector<Scalar> surf_dens(well_.numComponents());
|
||||
// Surface density.
|
||||
for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
|
||||
if (!FluidSystem::phaseIsActive(phaseIdx)) {
|
||||
@ -490,7 +490,7 @@ getSurfaceVolume(const EvalWell& temperature,
|
||||
}
|
||||
|
||||
// We increase the segment volume with a factor 10 to stabilize the system.
|
||||
const double volume = well_.wellEcl().getSegments()[seg_idx].volume();
|
||||
const Scalar volume = well_.wellEcl().getSegments()[seg_idx].volume();
|
||||
|
||||
return volume / vol_ratio;
|
||||
}
|
||||
@ -536,13 +536,13 @@ getFrictionPressureLoss(const int seg,
|
||||
|
||||
const auto& segment_set = well_.wellEcl().getSegments();
|
||||
const int outlet_segment_index = segment_set.segmentNumberToIndex(segment_set[seg].outletSegment());
|
||||
const double length = segment_set[seg].totalLength() - segment_set[outlet_segment_index].totalLength();
|
||||
const Scalar length = segment_set[seg].totalLength() - segment_set[outlet_segment_index].totalLength();
|
||||
assert(length > 0.);
|
||||
const double roughness = segment_set[seg].roughness();
|
||||
const double area = segment_set[seg].crossArea();
|
||||
const double diameter = segment_set[seg].internalDiameter();
|
||||
const Scalar roughness = segment_set[seg].roughness();
|
||||
const Scalar area = segment_set[seg].crossArea();
|
||||
const Scalar diameter = segment_set[seg].internalDiameter();
|
||||
|
||||
const double sign = mass_rate < 0. ? 1.0 : - 1.0;
|
||||
const Scalar sign = mass_rate < 0. ? 1.0 : - 1.0;
|
||||
|
||||
return sign * mswellhelpers::frictionPressureLoss(length, diameter, area, roughness, density, mass_rate, visc);
|
||||
}
|
||||
@ -632,11 +632,11 @@ pressureDropSpiralICD(const int seg,
|
||||
|
||||
const EvalWell reservoir_rate_icd = reservoir_rate * sicd.scalingFactor();
|
||||
|
||||
const double viscosity_cali = sicd.viscosityCalibration();
|
||||
const Scalar viscosity_cali = sicd.viscosityCalibration();
|
||||
|
||||
using MathTool = MathToolbox<EvalWell>;
|
||||
|
||||
const double density_cali = sicd.densityCalibration();
|
||||
const Scalar density_cali = sicd.densityCalibration();
|
||||
// make sure we don't pass negative base to powers
|
||||
const EvalWell temp_value1 = density > 0.0 ? MathTool::pow(density / density_cali, 0.75) : 0.0;
|
||||
const EvalWell temp_value2 = mixture_viscosity > 0.0 ? MathTool::pow(mixture_viscosity / viscosity_cali, 0.25) : 0.0;
|
||||
@ -644,9 +644,9 @@ pressureDropSpiralICD(const int seg,
|
||||
// formulation before 2016, base_strength is used
|
||||
// const double base_strength = sicd.strength() / density_cali;
|
||||
// formulation since 2016, strength is used instead
|
||||
const double strength = sicd.strength();
|
||||
const Scalar strength = sicd.strength();
|
||||
|
||||
const double sign = reservoir_rate_icd <= 0. ? 1.0 : -1.0;
|
||||
const Scalar sign = reservoir_rate_icd <= 0. ? 1.0 : -1.0;
|
||||
|
||||
return sign * temp_value1 * temp_value2 * strength * reservoir_rate_icd * reservoir_rate_icd;
|
||||
}
|
||||
@ -737,7 +737,7 @@ pressureDropAutoICD(const int seg,
|
||||
|
||||
using MathTool = MathToolbox<EvalWell>;
|
||||
// make sure we don't pass negative base to powers
|
||||
auto safe_pow = [](const auto& a, const double b) {
|
||||
auto safe_pow = [](const auto& a, const Scalar b) {
|
||||
return a > 0.0 ? MathTool::pow(a,b) : 0.0;
|
||||
};
|
||||
|
||||
@ -749,13 +749,13 @@ pressureDropAutoICD(const int seg,
|
||||
+ safe_pow(oil_fraction, aicd.oilDensityExponent()) * oil_density
|
||||
+ safe_pow(gas_fraction, aicd.gasDensityExponent()) * gas_density;
|
||||
|
||||
const double rho_reference = aicd.densityCalibration();
|
||||
const double visc_reference = aicd.viscosityCalibration();
|
||||
const Scalar rho_reference = aicd.densityCalibration();
|
||||
const Scalar visc_reference = aicd.viscosityCalibration();
|
||||
const auto volume_rate_icd = mass_rate * aicd.scalingFactor() / mixture_density;
|
||||
const double sign = volume_rate_icd <= 0. ? 1.0 : -1.0;
|
||||
const Scalar sign = volume_rate_icd <= 0. ? 1.0 : -1.0;
|
||||
// convert 1 unit volume rate
|
||||
using M = UnitSystem::measure;
|
||||
const double unit_volume_rate = unit_system.to_si(M::geometric_volume_rate, 1.);
|
||||
const Scalar unit_volume_rate = unit_system.to_si(M::geometric_volume_rate, 1.);
|
||||
|
||||
// TODO: we did not consider the maximum allowed rate here
|
||||
const auto result = sign / rho_reference * mixture_density * mixture_density
|
||||
@ -807,22 +807,22 @@ pressureDropValve(const int seg,
|
||||
}
|
||||
}
|
||||
|
||||
const double additional_length = valve.pipeAdditionalLength();
|
||||
const double roughness = valve.pipeRoughness();
|
||||
const double diameter = valve.pipeDiameter();
|
||||
const double area = valve.pipeCrossArea();
|
||||
const Scalar additional_length = valve.pipeAdditionalLength();
|
||||
const Scalar roughness = valve.pipeRoughness();
|
||||
const Scalar diameter = valve.pipeDiameter();
|
||||
const Scalar area = valve.pipeCrossArea();
|
||||
|
||||
const EvalWell friction_pressure_loss =
|
||||
mswellhelpers::frictionPressureLoss(additional_length, diameter, area, roughness, density, mass_rate, visc);
|
||||
|
||||
const ValveUDAEval uda_eval {summary_state, this->well_.name(), static_cast<std::size_t>(segment_set[seg].segmentNumber())};
|
||||
const double area_con = valve.conCrossArea(uda_eval);
|
||||
const double cv = valve.conFlowCoefficient();
|
||||
const Scalar area_con = valve.conCrossArea(uda_eval);
|
||||
const Scalar cv = valve.conFlowCoefficient();
|
||||
|
||||
const EvalWell constriction_pressure_loss =
|
||||
mswellhelpers::valveContrictionPressureLoss(mass_rate, density, area_con, cv);
|
||||
|
||||
const double sign = mass_rate <= 0. ? 1.0 : -1.0;
|
||||
const Scalar sign = mass_rate <= 0. ? 1.0 : -1.0;
|
||||
return sign * (friction_pressure_loss + constriction_pressure_loss);
|
||||
}
|
||||
|
||||
@ -830,7 +830,7 @@ template<class FluidSystem, class Indices>
|
||||
typename MultisegmentWellSegments<FluidSystem,Indices>::EvalWell
|
||||
MultisegmentWellSegments<FluidSystem,Indices>::
|
||||
accelerationPressureLossContribution(const int seg,
|
||||
const double area,
|
||||
const Scalar area,
|
||||
const bool extra_reverse_flow_derivatives /*false*/) const
|
||||
{
|
||||
// Compute the *signed* velocity head for given segment (sign is positive for flow towards surface, i.e., negative rate)
|
||||
@ -856,7 +856,7 @@ accelerationPressureLossContribution(const int seg,
|
||||
mass_rate.clearDerivatives();
|
||||
}
|
||||
}
|
||||
const double sign = mass_rate > 0 ? -1.0 : 1.0;
|
||||
const Scalar sign = mass_rate > 0 ? -1.0 : 1.0;
|
||||
return sign*mswellhelpers::velocityHead(area, mass_rate, density);
|
||||
}
|
||||
|
||||
@ -900,7 +900,7 @@ void
|
||||
MultisegmentWellSegments<FluidSystem,Indices>::
|
||||
copyPhaseDensities(const unsigned phaseIdx,
|
||||
const std::size_t stride,
|
||||
double* dens) const
|
||||
Scalar* dens) const
|
||||
{
|
||||
const auto compIdx = Indices::canonicalToActiveComponentIndex
|
||||
(FluidSystem::solventComponentIndex(phaseIdx));
|
||||
@ -912,7 +912,7 @@ copyPhaseDensities(const unsigned phaseIdx,
|
||||
}
|
||||
|
||||
template <class FluidSystem, class Indices>
|
||||
double
|
||||
typename MultisegmentWellSegments<FluidSystem,Indices>::Scalar
|
||||
MultisegmentWellSegments<FluidSystem,Indices>::
|
||||
mixtureDensity(const int seg) const
|
||||
{
|
||||
@ -941,7 +941,7 @@ mixtureDensity(const int seg) const
|
||||
}
|
||||
|
||||
template <class FluidSystem, class Indices>
|
||||
double
|
||||
typename MultisegmentWellSegments<FluidSystem,Indices>::Scalar
|
||||
MultisegmentWellSegments<FluidSystem,Indices>::
|
||||
mixtureDensityWithExponents(const int seg) const
|
||||
{
|
||||
@ -957,7 +957,7 @@ mixtureDensityWithExponents(const int seg) const
|
||||
}
|
||||
|
||||
template <class FluidSystem, class Indices>
|
||||
double
|
||||
typename MultisegmentWellSegments<FluidSystem,Indices>::Scalar
|
||||
MultisegmentWellSegments<FluidSystem,Indices>::
|
||||
mixtureDensityWithExponents(const AutoICD& aicd, const int seg) const
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
|
||||
// pressure loss contribution due to acceleration
|
||||
EvalWell accelerationPressureLossContribution(const int seg,
|
||||
const double area,
|
||||
const Scalar area,
|
||||
const bool extra_reverse_flow_derivatives = false) const;
|
||||
|
||||
const std::vector<std::vector<int>>& inlets() const
|
||||
@ -176,11 +176,11 @@ private:
|
||||
|
||||
void copyPhaseDensities(const unsigned phaseIdx,
|
||||
const std::size_t stride,
|
||||
double* dens) const;
|
||||
Scalar* dens) const;
|
||||
|
||||
double mixtureDensity(const int seg) const;
|
||||
double mixtureDensityWithExponents(const int seg) const;
|
||||
double mixtureDensityWithExponents(const AutoICD& aicd, const int seg) const;
|
||||
Scalar mixtureDensity(const int seg) const;
|
||||
Scalar mixtureDensityWithExponents(const int seg) const;
|
||||
Scalar mixtureDensityWithExponents(const AutoICD& aicd, const int seg) const;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
Loading…
Reference in New Issue
Block a user