From ecd99302255ca89476247d51864ea54111c36421 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 20 Nov 2023 11:22:06 +0100 Subject: [PATCH 1/3] dont scale d factor from wdfaccor --- opm/simulators/wells/WellInterface_impl.hpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index 3dfa9f939..d96859ffc 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -1368,8 +1368,10 @@ namespace Opm } auto& perf_data = ws.perf_data; double tot_tw = 0.0; - for (const auto& c : this->well_ecl_.getConnections()) { - tot_tw += c.CF(); + if (wdfac.getType() == WDFACTYPE::CON_DFACTOR || wdfac.getType() == WDFACTYPE::DFACTOR) { + for (const auto& c : this->well_ecl_.getConnections()) { + tot_tw += c.CF(); + } } for (int perf = 0; perf < this->number_of_perforations_; ++perf) { const int cell_idx = this->well_cells_[perf]; @@ -1398,18 +1400,19 @@ namespace Opm double h = Kh / Ke; double rw = connection.rw(); const auto& wdfac = this->well_ecl_.getWDFAC(); - if (wdfac.useConnectionDFactor()) { + if (wdfac.getType() == WDFACTYPE::CON_DFACTOR) { double d = connection.dFactor(); // If a negative d factor is set in COMPDAT individual connection d factors should be used directly. if (d < 0) return -d; // If a positive d factor is set in COMPDAT the connection d factors is treated like a well d factor. - // and thus scaled with the well index - return d * total_tw / connection.CF(); - } else { - - double d = wdfac.getDFactor(rho, mu, Ke, phi, rw, h); + // and thus scaled with the connection index return d * total_tw / connection.CF(); + } else if (wdfac.getType() == WDFACTYPE::DFACTOR) { + // scale with the connection index + return wdfac.getDFactor(rho, mu, Ke, phi, rw, h) * total_tw / connection.CF(); + } else { // WDFACCOR + return wdfac.getDFactor(rho, mu, Ke, phi, rw, h); } } From 4879896789aebf6fc16028f9cb38262dbc96375b Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 22 Nov 2023 09:17:28 +0100 Subject: [PATCH 2/3] adapt to refactoring of getDFactor --- opm/simulators/wells/WellInterface.hpp | 2 +- opm/simulators/wells/WellInterface_impl.hpp | 36 +++------------------ 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/opm/simulators/wells/WellInterface.hpp b/opm/simulators/wells/WellInterface.hpp index e13c0cdb5..b9f115c63 100644 --- a/opm/simulators/wells/WellInterface.hpp +++ b/opm/simulators/wells/WellInterface.hpp @@ -447,7 +447,7 @@ protected: double* connII, DeferredLogger& deferred_logger) const; - double computeConnectionDFactor(const int perf, const IntensiveQuantities& intQuants, const double trans_mult, const double total_tw, const SingleWellState& ws) const; + double computeConnectionDFactor(const int perf, const IntensiveQuantities& intQuants, const double trans_mult, const SingleWellState& ws) const; }; diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index d96859ffc..bc5e3a2b1 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -1341,12 +1341,7 @@ namespace Opm if (this->well_index_[perf] == 0) return std::vector(this->num_components_, 0.0); - double tot_tw = 0.0; - for (const auto& c : this->well_ecl_.getConnections()) { - tot_tw += c.CF(); - } - - double d = computeConnectionDFactor(perf, intQuants, trans_mult, tot_tw, ws); + double d = computeConnectionDFactor(perf, intQuants, trans_mult, ws); const PhaseUsage& pu = this->phaseUsage(); double Q = std::abs(ws.perf_data.phase_rates[perf*pu.num_phases + pu.phase_pos[Gas]]); const auto& connection = this->well_ecl_.getConnections()[ws.perf_data.ecl_index[perf]]; @@ -1367,24 +1362,18 @@ namespace Opm return; } auto& perf_data = ws.perf_data; - double tot_tw = 0.0; - if (wdfac.getType() == WDFACTYPE::CON_DFACTOR || wdfac.getType() == WDFACTYPE::DFACTOR) { - for (const auto& c : this->well_ecl_.getConnections()) { - tot_tw += c.CF(); - } - } for (int perf = 0; perf < this->number_of_perforations_; ++perf) { const int cell_idx = this->well_cells_[perf]; const auto& intQuants = simulator.model().intensiveQuantities(cell_idx, /*timeIdx=*/ 0); const double trans_mult = simulator.problem().template rockCompTransMultiplier(intQuants, cell_idx); - perf_data.connection_d_factor[perf] = computeConnectionDFactor(perf, intQuants, trans_mult, tot_tw, ws); + perf_data.connection_d_factor[perf] = computeConnectionDFactor(perf, intQuants, trans_mult, ws); } } template double WellInterface:: - computeConnectionDFactor(const int perf, const IntensiveQuantities& intQuants, const double trans_mult, const double total_tw, const SingleWellState& ws) const { + computeConnectionDFactor(const int perf, const IntensiveQuantities& intQuants, const double trans_mult, const SingleWellState& ws) const { const double connection_pressure = ws.perf_data.pressure[perf]; // viscosity is evaluated at connection pressure const auto& rv = getValue(intQuants.fluidState().Rv()); @@ -1395,25 +1384,8 @@ namespace Opm double rho = FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, this->pvtRegionIdx()); const double phi = getValue(intQuants.porosity()); const auto& connection = this->well_ecl_.getConnections()[ws.perf_data.ecl_index[perf]]; - double Kh = connection.Kh()* trans_mult; - double Ke = connection.Ke()* trans_mult; - double h = Kh / Ke; - double rw = connection.rw(); const auto& wdfac = this->well_ecl_.getWDFAC(); - if (wdfac.getType() == WDFACTYPE::CON_DFACTOR) { - double d = connection.dFactor(); - // If a negative d factor is set in COMPDAT individual connection d factors should be used directly. - if (d < 0) - return -d; - // If a positive d factor is set in COMPDAT the connection d factors is treated like a well d factor. - // and thus scaled with the connection index - return d * total_tw / connection.CF(); - } else if (wdfac.getType() == WDFACTYPE::DFACTOR) { - // scale with the connection index - return wdfac.getDFactor(rho, mu, Ke, phi, rw, h) * total_tw / connection.CF(); - } else { // WDFACCOR - return wdfac.getDFactor(rho, mu, Ke, phi, rw, h); - } + return wdfac.getDFactor(connection, mu, rho, phi, trans_mult); } From be06132702db44c5d2554964fad7d19869ab2edf Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 22 Nov 2023 13:59:06 +0100 Subject: [PATCH 3/3] remove trans multiplier from dake --- opm/simulators/wells/WellInterface.hpp | 2 +- opm/simulators/wells/WellInterface_impl.hpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/opm/simulators/wells/WellInterface.hpp b/opm/simulators/wells/WellInterface.hpp index b9f115c63..3f914ea3f 100644 --- a/opm/simulators/wells/WellInterface.hpp +++ b/opm/simulators/wells/WellInterface.hpp @@ -447,7 +447,7 @@ protected: double* connII, DeferredLogger& deferred_logger) const; - double computeConnectionDFactor(const int perf, const IntensiveQuantities& intQuants, const double trans_mult, const SingleWellState& ws) const; + double computeConnectionDFactor(const int perf, const IntensiveQuantities& intQuants, const SingleWellState& ws) const; }; diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index bc5e3a2b1..9648715e3 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -1341,11 +1341,11 @@ namespace Opm if (this->well_index_[perf] == 0) return std::vector(this->num_components_, 0.0); - double d = computeConnectionDFactor(perf, intQuants, trans_mult, ws); + double d = computeConnectionDFactor(perf, intQuants, ws); const PhaseUsage& pu = this->phaseUsage(); double Q = std::abs(ws.perf_data.phase_rates[perf*pu.num_phases + pu.phase_pos[Gas]]); const auto& connection = this->well_ecl_.getConnections()[ws.perf_data.ecl_index[perf]]; - double Kh = connection.Kh()* trans_mult; + double Kh = connection.Kh(); double scaling = 3.141592653589 * Kh; const unsigned gas_comp_idx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); wi[gas_comp_idx] = 1.0/(1.0/(trans_mult * this->well_index_[perf]) + (Q/2 * d / scaling)); @@ -1365,15 +1365,14 @@ namespace Opm for (int perf = 0; perf < this->number_of_perforations_; ++perf) { const int cell_idx = this->well_cells_[perf]; const auto& intQuants = simulator.model().intensiveQuantities(cell_idx, /*timeIdx=*/ 0); - const double trans_mult = simulator.problem().template rockCompTransMultiplier(intQuants, cell_idx); - perf_data.connection_d_factor[perf] = computeConnectionDFactor(perf, intQuants, trans_mult, ws); + perf_data.connection_d_factor[perf] = computeConnectionDFactor(perf, intQuants, ws); } } template double WellInterface:: - computeConnectionDFactor(const int perf, const IntensiveQuantities& intQuants, const double trans_mult, const SingleWellState& ws) const { + computeConnectionDFactor(const int perf, const IntensiveQuantities& intQuants, const SingleWellState& ws) const { const double connection_pressure = ws.perf_data.pressure[perf]; // viscosity is evaluated at connection pressure const auto& rv = getValue(intQuants.fluidState().Rv()); @@ -1385,7 +1384,7 @@ namespace Opm const double phi = getValue(intQuants.porosity()); const auto& connection = this->well_ecl_.getConnections()[ws.perf_data.ecl_index[perf]]; const auto& wdfac = this->well_ecl_.getWDFAC(); - return wdfac.getDFactor(connection, mu, rho, phi, trans_mult); + return wdfac.getDFactor(connection, mu, rho, phi); }