/* Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. Copyright 2017 Statoil ASA. Copyright 2016 - 2017 IRIS AS. This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OPM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OPM. If not, see . */ #ifndef OPM_STANDARDWELL_CONNECTIONS_HEADER_INCLUDED #define OPM_STANDARDWELL_CONNECTIONS_HEADER_INCLUDED #include #include #include #include #include #include namespace Opm { class DeferredLogger; enum class Phase; template class WellInterfaceIndices; template class WellState; template class PerfData; template class StandardWellConnections { public: using Scalar = typename FluidSystem::Scalar; StandardWellConnections(const WellInterfaceIndices& well); struct Properties { std::vector b_perf{}; std::vector rsmax_perf{}; std::vector rvmax_perf{}; std::vector rvwmax_perf{}; std::vector rswmax_perf{}; std::vector surf_dens_perf{}; }; struct PressurePropertyFunctions { std::function getTemperature{}; std::function getSaltConcentration{}; std::function pvtRegionIdx{}; std::function solventInverseFormationVolumeFactor{}; std::function solventRefDensity{}; }; struct DensityPropertyFunctions { std::function&, std::vector&)> mobility{}; std::function&, std::vector&)> densityInCell{}; }; Properties computePropertiesForPressures(const WellState& well_state, const PressurePropertyFunctions& propFunc) const; //! \brief Compute connection properties (densities, pressure drop, ...) void computeProperties(const bool stop_or_zero_rate_target, const WellState& well_state, const DensityPropertyFunctions& prop_func, const Properties& props, DeferredLogger& deferred_logger); //! \brief Returns density for first perforation. Scalar rho() const { return this->rho(0); } //! \brief Returns density for specific perforation/connection. //! //! \param[in] i Connection index //! //! \return Mixture density at connection \p i. Scalar rho(const typename std::vector::size_type i) const { return (i < this->perf_densities_.size()) ? this->perf_densities_[i] : 0.0; } //! \brief Returns pressure drop for a given perforation. Scalar pressure_diff(const unsigned perf) const { return perf_pressure_diffs_[perf]; } using Eval = typename WellInterfaceIndices::Eval; using EvalWell = typename StandardWellPrimaryVariables::EvalWell; Eval connectionRateBrine(Scalar& rate, const Scalar vap_wat_rate, const std::vector& cq_s, const std::variant& saltConcentration) const; Eval connectionRateFoam(const std::vector& cq_s, const std::variant& foamConcentration, const Phase transportPhase, DeferredLogger& deferred_logger) const; std::tuple connectionRatePolymer(Scalar& rate, const std::vector& cq_s, const std::variant& polymerConcentration) const; std::tuple connectionRatesMICP(const std::vector& cq_s, const std::variant& microbialConcentration, const std::variant& oxygenConcentration, const std::variant& ureaConcentration) const; std::tuple connectionRatezFraction(Scalar& rate, const Scalar dis_gas_rate, const std::vector& cq_s, const std::variant>& solventConcentration) const; private: void computePressureDelta(); // TODO: not total sure whether it is a good idea to put this function here // the major reason to put here is to avoid the usage of Wells struct void computeDensities(const std::vector& perfComponentRates, const Properties& props, DeferredLogger& deferred_logger); void computeDensitiesForStoppedProducer(const DensityPropertyFunctions& prop_func); std::vector calculatePerforationOutflow(const std::vector& perfComponentRates) const; void initialiseConnectionMixture(const int num_comp, const int perf, const std::vector& q_out_perf, const std::vector& currentMixture, std::vector& previousMixture) const; std::vector copyInPerforationRates(const Properties& props, const PerfData& perf_data) const; const WellInterfaceIndices& well_; //!< Reference to well interface std::vector perf_densities_; //!< densities of the fluid in each perforation std::vector perf_pressure_diffs_; //!< // pressure drop between different perforations }; } #endif // OPM_STANDARDWELL_CONNECTIONS_HEADER_INCLUDED