diff --git a/opm/input/eclipse/Schedule/Well/WDFAC.hpp b/opm/input/eclipse/Schedule/Well/WDFAC.hpp index 36818e953..3364d91f5 100644 --- a/opm/input/eclipse/Schedule/Well/WDFAC.hpp +++ b/opm/input/eclipse/Schedule/Well/WDFAC.hpp @@ -50,6 +50,7 @@ namespace Opm { //void updateWDFACOR(const RestartIO::RstWell& rst_well); void updateWDFACType(const WellConnections& connections); + void updateTotalCF(const WellConnections& connections); bool useDFactor() const; bool operator==(const WDFAC& other) const; diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index a68e62fa4..7bfaa6909 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -1634,6 +1634,7 @@ File {} line {}.)", wname, location.keyword, location.filename, location.lineno) auto well = this->snapshots.back().wells.get(well_name); auto wdfac = std::make_shared(well.getWDFAC()); wdfac->updateWDFAC( record ); + wdfac->updateTotalCF(well.getConnections()); if (well.updateWDFAC(std::move(wdfac))) this->snapshots.back().wells.update( std::move(well) ); } diff --git a/src/opm/input/eclipse/Schedule/Well/WDFAC.cpp b/src/opm/input/eclipse/Schedule/Well/WDFAC.cpp index a55136b30..51a3b7850 100644 --- a/src/opm/input/eclipse/Schedule/Well/WDFAC.cpp +++ b/src/opm/input/eclipse/Schedule/Well/WDFAC.cpp @@ -81,23 +81,27 @@ namespace Opm { // non-trivial dfactors detected use connection D factors if (non_trivial_dfactor) { m_type = WDFACTYPE::CON_DFACTOR; + updateTotalCF(connections); } + } + void WDFAC::updateTotalCF(const WellConnections& connections) { m_total_cf = std::accumulate(connections.begin(), connections.end(), 0.0, [](const double tot_cf, const auto& conn) { return tot_cf + conn.CF(); }); } double WDFAC::getDFactor(const Connection& connection, double mu, double rho, double phi) const { - if (m_total_cf < 0.0) { - throw std::invalid_argument { "Total connection factor is not set" }; - } switch (m_type) { case WDFACTYPE::NONE: return 0.0; - case WDFACTYPE::DFACTOR: - return m_d * m_total_cf / connection.CF(); + case WDFACTYPE::DFACTOR: { + if (m_total_cf < 0.0) { + throw std::invalid_argument { "Total connection factor is not set" }; + } + return m_d * m_total_cf / connection.CF(); + } case WDFACTYPE::CON_DFACTOR: { double d = connection.dFactor(); // If a negative d factor is set in COMPDAT individual connection d factors should be used directly. @@ -105,6 +109,10 @@ namespace Opm { 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 + if (m_total_cf < 0.0) { + throw std::invalid_argument { "Total connection factor is not set" }; + } + return d * m_total_cf / connection.CF(); } case WDFACTYPE::DAKEMODEL: @@ -113,7 +121,6 @@ namespace Opm { double Ke = connection.Ke(); double h = Kh / Ke; double rw = connection.rw(); - const auto k_md = unit::convert::to(Ke, prefix::milli*unit::darcy); double beta = m_a * (std::pow(k_md, m_b) * std::pow(phi, m_c)); double specific_gravity = rho / 1.225; // divide by density of air at standard conditions. diff --git a/src/opm/input/eclipse/Schedule/Well/Well.cpp b/src/opm/input/eclipse/Schedule/Well/Well.cpp index 2db6b0500..37d77dfaa 100644 --- a/src/opm/input/eclipse/Schedule/Well/Well.cpp +++ b/src/opm/input/eclipse/Schedule/Well/Well.cpp @@ -1390,7 +1390,6 @@ bool Well::handleWPIMULT(const DeckRecord& record) { new_connections->add(c); } - return this->updateConnections(std::move(new_connections), false); }