diff --git a/opm/autodiff/StandardWell.hpp b/opm/autodiff/StandardWell.hpp index 61be4d166..de9581aea 100644 --- a/opm/autodiff/StandardWell.hpp +++ b/opm/autodiff/StandardWell.hpp @@ -179,6 +179,8 @@ namespace Opm using WellInterface::active_; using WellInterface::phase_usage_; using WellInterface::first_perf_; + using WellInterface::ref_depth_; + using WellInterface::perf_depth_; // densities of the fluid in each perforation std::vector perf_densities_; @@ -227,6 +229,8 @@ namespace Opm const std::vector& rsmax_perf, const std::vector& rvmax_perf, const std::vector& surf_dens_perf); + + void computeConnectionPressureDelta(); }; } diff --git a/opm/autodiff/StandardWell_impl.hpp b/opm/autodiff/StandardWell_impl.hpp index 2f6159b03..dd320fbe5 100644 --- a/opm/autodiff/StandardWell_impl.hpp +++ b/opm/autodiff/StandardWell_impl.hpp @@ -1622,4 +1622,44 @@ namespace Opm } } + + + + template + void + StandardWell:: + computeConnectionPressureDelta() + { + // Algorithm: + + // We'll assume the perforations are given in order from top to + // bottom for each well. By top and bottom we do not necessarily + // mean in a geometric sense (depth), but in a topological sense: + // the 'top' perforation is nearest to the surface topologically. + // Our goal is to compute a pressure delta for each perforation. + + // 1. Compute pressure differences between perforations. + // dp_perf will contain the pressure difference between a + // perforation and the one above it, except for the first + // perforation for each well, for which it will be the + // difference to the reference (bhp) depth. + + const int nperf = numberOfPerforations(); + perf_pressure_diffs_.resize(nperf, 0.0); + + for (int perf = 0; perf < nperf; ++perf) { + const double z_above = perf == 0 ? ref_depth_ : perf_depth_[perf - 1]; + const double dz = perf_depth_[perf] - z_above; + perf_pressure_diffs_[perf] = dz * perf_densities_[perf] * gravity_; + } + + // 2. Compute pressure differences to the reference point (bhp) by + // accumulating the already computed adjacent pressure + // differences, storing the result in dp_perf. + // This accumulation must be done per well. + const auto beg = perf_pressure_diffs_.begin(); + const auto end = perf_pressure_diffs_.end(); + std::partial_sum(beg, end, beg); + } + } diff --git a/opm/autodiff/WellInterface.hpp b/opm/autodiff/WellInterface.hpp index 0891b984f..3078304ce 100644 --- a/opm/autodiff/WellInterface.hpp +++ b/opm/autodiff/WellInterface.hpp @@ -180,6 +180,9 @@ namespace Opm // depth for each perforation std::vector perf_depth_; + // reference depth for the BHP + int ref_depth_; + double well_efficiency_factor_; // cell index for each well perforation diff --git a/opm/autodiff/WellInterface_impl.hpp b/opm/autodiff/WellInterface_impl.hpp index a3a5e0b52..a403bdda8 100644 --- a/opm/autodiff/WellInterface_impl.hpp +++ b/opm/autodiff/WellInterface_impl.hpp @@ -60,6 +60,8 @@ namespace Opm well_controls_ = wells->ctrls[index_well]; + ref_depth_ = wells->depth_ref[index_well]; + // perforations related { const int perf_index_begin = wells->well_connpos[index_well];