22#ifndef OPM_RATECONVERTER_HPP_HEADER_INCLUDED
23#define OPM_RATECONVERTER_HPP_HEADER_INCLUDED
25#include <opm/grid/utility/RegionMapping.hpp>
27#include <opm/simulators/wells/RegionAttributeHelpers.hpp>
29#include <opm/simulators/utils/BlackoilPhases.hpp>
30#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
31#include <opm/simulators/utils/ParallelCommunication.hpp>
33#include <dune/grid/common/gridenums.hh>
34#include <dune/grid/common/rangegenerators.hh>
38#include <unordered_map>
53 namespace RateConverter {
70 template <
class Flu
idSystem,
class Region>
73 using Scalar =
typename FluidSystem::Scalar;
85 , attr_ (rmap_, Attributes())
96 template <
typename ElementContext,
class Simulator>
101 for (
const auto&
reg : rmap_.activeRegions()) {
102 auto&
ra = attr_.attributes(
reg);
104 ra.temperature = 0.0;
108 ra.saltConcentration = 0.0;
119 for (
const auto&
reg : rmap_.activeRegions()) {
124 ElementContext elemCtx( simulator );
125 const auto& gridView = simulator.
gridView();
126 const auto& comm = gridView.comm();
128 OPM_BEGIN_PARALLEL_TRY_CATCH();
129 for (
const auto&
elem :
elements(gridView, Dune::Partitions::interior)) {
130 elemCtx.updatePrimaryStencil(
elem);
131 elemCtx.updatePrimaryIntensiveQuantities(0);
132 const unsigned cellIdx = elemCtx.globalSpaceIndex(0, 0);
133 const auto& intQuants = elemCtx.intensiveQuantities(0, 0);
134 const auto& fs = intQuants.fluidState();
138 * intQuants.porosity().value();
142 const auto& pu = phaseUsage_;
144 hydrocarbon -= fs.saturation(FluidSystem::waterPhaseIdx).value();
161 attr.temperature += fs.temperature(FluidSystem::oilPhaseIdx).value() *
hydrocarbonPV;
165 attr.temperature += fs.temperature(FluidSystem::gasPhaseIdx).value() *
hydrocarbonPV;
168 if (FluidSystem::enableDissolvedGasInWater()) {
171 if (FluidSystem::enableVaporizedWater()) {
184 attr.pressure += fs.pressure(FluidSystem::oilPhaseIdx).value() *
pv_cell;
185 attr.temperature += fs.temperature(FluidSystem::oilPhaseIdx).value() *
pv_cell;
187 attr.pressure += fs.pressure(FluidSystem::gasPhaseIdx).value() *
pv_cell;
188 attr.temperature += fs.temperature(FluidSystem::gasPhaseIdx).value() *
pv_cell;
191 attr.pressure += fs.pressure(FluidSystem::waterPhaseIdx).value() *
pv_cell;
192 attr.temperature += fs.temperature(FluidSystem::waterPhaseIdx).value() *
pv_cell;
194 attr.saltConcentration += fs.saltConcentration().value() *
pv_cell;
195 if (FluidSystem::enableDissolvedGasInWater()) {
198 if (FluidSystem::enableVaporizedWater()) {
204 OPM_END_PARALLEL_TRY_CATCH(
"SurfaceToReservoirVoidage::defineState() failed: ", simulator.
vanguard().grid().comm());
216 using RegionId =
typename RegionMapping<Region>::RegionId;
245 template <
class Coeff>
249 template <
class Coeff ,
class Rates>
253 template <
class Coeff>
262 const Scalar saltConcentration,
265 template <
class Coeff>
291 template <
class Rates>
293 const int pvtRegionIdx,
294 const Rates& surface_rates,
331 template <
typename SurfaceRates,
typename Vo
idageRates>
339 const Scalar saltConcentration,
343 template <
class Rates>
344 std::pair<Scalar, Scalar>
345 inferDissolvedVaporisedRatio(
const Scalar
rsMax,
347 const Rates& surface_rates)
const;
361 template <
class SolventModule>
365 const auto&
ra = attr_.attributes(
r);
366 const Scalar
p =
ra.pressure;
367 const Scalar T =
ra.temperature;
368 const auto& solventPvt = SolventModule::solventPvt();
369 const Scalar
bs = solventPvt.inverseFormationVolumeFactor(pvtRegionIdx, T,
p);
391 , temperature(data[1])
397 , saltConcentration(data[7])
400 Attributes(
const Attributes& rhs)
403 this->data = rhs.data;
406 Attributes& operator=(
const Attributes& rhs)
408 this->data = rhs.data;
412 std::array<Scalar,8> data;
420 Scalar& saltConcentration;
423 void sumRates(std::unordered_map<RegionId,Attributes>&
attributes_hpv,
425 Parallel::Communication comm);
427 RegionAttributeHelpers::RegionAttributes<RegionId, Attributes> attr_;
Convert component rates at surface conditions to phase (voidage) rates at reservoir conditions.
Definition RateConverter.hpp:71
SurfaceToReservoirVoidage(const PhaseUsage &phaseUsage, const Region ®ion)
Constructor.
Definition RateConverter.hpp:81
void calcReservoirVoidageRates(const RegionId r, const int pvtRegionIdx, const Rates &surface_rates, Rates &voidage_rates) const
Convert surface volume flow rates to reservoir voidage flow rates.
Definition RateConverter.cpp:343
void calcCoeff(const RegionId r, const int pvtRegionIdx, Coeff &coeff) const
Compute coefficients for surface-to-reservoir voidage conversion.
Definition RateConverter.cpp:140
void defineState(const Simulator &simulator)
Compute pore volume averaged hydrocarbon state pressure, rs and rv.
Definition RateConverter.hpp:97
typename RegionMapping< Region >::RegionId RegionId
Region identifier.
Definition RateConverter.hpp:216
void calcCoeffSolvent(const RegionId r, const int pvtRegionIdx, Scalar &coeff) const
Compute coefficients for surface-to-reservoir voidage conversion for solvent.
Definition RateConverter.hpp:363
Manages the initializing and running of time dependent problems.
Definition simulator.hh:92
Vanguard & vanguard()
Return a reference to the grid manager of simulation.
Definition simulator.hh:273
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition simulator.hh:285
Model & model()
Return the physical model used in the simulation.
Definition simulator.hh:291
bool water(const PhaseUsage &pu)
Active water predicate.
Definition RegionAttributeHelpers.hpp:309
bool oil(const PhaseUsage &pu)
Active oil predicate.
Definition RegionAttributeHelpers.hpp:322
bool gas(const PhaseUsage &pu)
Active gas predicate.
Definition RegionAttributeHelpers.hpp:335
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
PhaseUsage phaseUsage(const Phases &phases)
Determine the active phases.
Definition phaseUsageFromDeck.cpp:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
Definition BlackoilPhases.hpp:46