mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
added: RatioCalculator
will move some of the the ratio calculations from StandardWell into it. start by moving gasOilVolumeRatio
This commit is contained in:
parent
5b002b2a77
commit
a2d5a505b3
@ -186,6 +186,7 @@ list (APPEND MAIN_SOURCE_FILES
|
||||
opm/simulators/wells/ParallelWellInfo.cpp
|
||||
opm/simulators/wells/PerfData.cpp
|
||||
opm/simulators/wells/RateConverter.cpp
|
||||
opm/simulators/wells/RatioCalculator.cpp
|
||||
opm/simulators/wells/SegmentState.cpp
|
||||
opm/simulators/wells/SingleWellState.cpp
|
||||
opm/simulators/wells/StandardWellAssemble.cpp
|
||||
@ -988,6 +989,7 @@ list (APPEND PUBLIC_HEADER_FILES
|
||||
opm/simulators/wells/PerfData.hpp
|
||||
opm/simulators/wells/PerforationData.hpp
|
||||
opm/simulators/wells/RateConverter.hpp
|
||||
opm/simulators/wells/RatioCalculator.hpp
|
||||
opm/simulators/wells/RegionAttributeHelpers.hpp
|
||||
opm/simulators/wells/RegionAverageCalculator.hpp
|
||||
opm/simulators/wells/SingleWellState.hpp
|
||||
|
109
opm/simulators/wells/RatioCalculator.cpp
Normal file
109
opm/simulators/wells/RatioCalculator.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/simulators/wells/RatioCalculator.hpp>
|
||||
|
||||
#include <opm/material/densead/Evaluation.hpp>
|
||||
#include <opm/material/densead/EvaluationFormat.hpp>
|
||||
|
||||
#include <opm/simulators/utils/DeferredLogger.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace {
|
||||
template<class dValue, class Value>
|
||||
auto dValueError(const dValue& d,
|
||||
const std::string& name,
|
||||
const std::string& methodName,
|
||||
const Value& Rs,
|
||||
const Value& Rv,
|
||||
const Value& pressure)
|
||||
{
|
||||
return fmt::format("Problematic d value {} obtained for well {}"
|
||||
" during {} calculations with rs {}"
|
||||
", rv {} and pressure {}."
|
||||
" Continue as if no dissolution (rs = 0) and vaporization (rv = 0) "
|
||||
" for this connection.", d, name, methodName, Rs, Rv, pressure);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template<class Value>
|
||||
RatioCalculator<Value>::
|
||||
RatioCalculator(unsigned gasCompIdx,
|
||||
unsigned oilCompIdx,
|
||||
unsigned waterCompIdx,
|
||||
std::string_view name)
|
||||
: gasComp_{gasCompIdx}
|
||||
, oilComp_(oilCompIdx)
|
||||
, waterComp_{waterCompIdx}
|
||||
, name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
template<class Value>
|
||||
void
|
||||
RatioCalculator<Value>::
|
||||
gasOilVolumeRatio(Value& volumeRatio,
|
||||
const Value& rv,
|
||||
const Value& rs,
|
||||
const Value& pressure,
|
||||
const std::vector<Value>& cmix_s,
|
||||
const std::vector<Value>& b_perfcells_dense,
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
// Incorporate RS/RV factors if both oil and gas active
|
||||
const Value d = 1.0 - rv * rs;
|
||||
|
||||
if (d <= 0.0) {
|
||||
deferred_logger.debug(dValueError(d, name_,
|
||||
"gasOilVolumeRatio",
|
||||
rs, rv, pressure));
|
||||
}
|
||||
const Value tmp_oil = d > 0.0 ? (cmix_s[oilComp_] - rv * cmix_s[gasComp_]) / d
|
||||
: cmix_s[oilComp_];
|
||||
volumeRatio += tmp_oil / b_perfcells_dense[oilComp_];
|
||||
|
||||
const Value tmp_gas = d > 0.0 ? (cmix_s[gasComp_] - rs * cmix_s[oilComp_]) / d
|
||||
: cmix_s[gasComp_];
|
||||
volumeRatio += tmp_gas / b_perfcells_dense[gasComp_];
|
||||
}
|
||||
|
||||
#define INSTANTIATE_TYPE(T) \
|
||||
template class RatioCalculator<T>; \
|
||||
template class RatioCalculator<DenseAd::Evaluation<T, -1, 4u>>; \
|
||||
template class RatioCalculator<DenseAd::Evaluation<T, -1, 5u>>; \
|
||||
template class RatioCalculator<DenseAd::Evaluation<T, -1, 6u>>; \
|
||||
template class RatioCalculator<DenseAd::Evaluation<T, -1, 7u>>; \
|
||||
template class RatioCalculator<DenseAd::Evaluation<T, -1, 8u>>; \
|
||||
template class RatioCalculator<DenseAd::Evaluation<T, -1, 9u>>; \
|
||||
template class RatioCalculator<DenseAd::Evaluation<T, -1, 10u>>; \
|
||||
template class RatioCalculator<DenseAd::Evaluation<T, -1, 11u>>;
|
||||
|
||||
INSTANTIATE_TYPE(double)
|
||||
|
||||
#if FLOW_INSTANTIATE_FLOAT
|
||||
INSTANTIATE_TYPE(float)
|
||||
#endif
|
||||
|
||||
}
|
59
opm/simulators/wells/RatioCalculator.hpp
Normal file
59
opm/simulators/wells/RatioCalculator.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef RATIO_CALCULATOR_HPP
|
||||
#define RATIO_CALCULATOR_HPP
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class DeferredLogger;
|
||||
|
||||
template<class Value>
|
||||
class RatioCalculator
|
||||
{
|
||||
public:
|
||||
RatioCalculator(unsigned gasCompIdx,
|
||||
unsigned oilCompIdx,
|
||||
unsigned waterCompIdx,
|
||||
std::string_view name);
|
||||
|
||||
void gasOilVolumeRatio(Value& volumeRatio,
|
||||
const Value& rv,
|
||||
const Value& rs,
|
||||
const Value& pressure,
|
||||
const std::vector<Value>& cmix_s,
|
||||
const std::vector<Value>& b_perfcells_dense,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
private:
|
||||
unsigned gasComp_;
|
||||
unsigned oilComp_;
|
||||
unsigned waterComp_;
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // RATIO_CALCULATOR_HPP
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
|
||||
#include <opm/simulators/wells/RateConverter.hpp>
|
||||
#include <opm/simulators/wells/RatioCalculator.hpp>
|
||||
#include <opm/simulators/wells/VFPInjProperties.hpp>
|
||||
#include <opm/simulators/wells/VFPProdProperties.hpp>
|
||||
#include <opm/simulators/wells/WellInterface.hpp>
|
||||
@ -505,15 +506,6 @@ namespace Opm
|
||||
const std::vector<Value>& cmix_s,
|
||||
const std::vector<Value>& b_perfcells_dense,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
template<class Value>
|
||||
void gasOilVolumeRatio(Value& volumeRatio,
|
||||
const Value& rv,
|
||||
const Value& rs,
|
||||
const Value& pressure,
|
||||
const std::vector<Value>& cmix_s,
|
||||
const std::vector<Value>& b_perfcells_dense,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <config.h>
|
||||
#include <opm/simulators/wells/StandardWellEval.hpp>
|
||||
|
||||
#include <opm/material/densead/EvaluationFormat.hpp>
|
||||
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
|
||||
|
||||
#include <opm/models/blackoil/blackoilindices.hh>
|
||||
@ -39,8 +40,9 @@
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template<class FluidSystem, class Indices>
|
||||
StandardWellEval<FluidSystem,Indices>::
|
||||
@ -208,7 +210,7 @@ init(std::vector<Scalar>& perf_depth,
|
||||
template<class Scalar>
|
||||
using FS = BlackOilFluidSystem<Scalar,BlackOilDefaultIndexTraits>;
|
||||
|
||||
#define INSTANTIATE(T,...) \
|
||||
#define INSTANTIATE(T,...) \
|
||||
template class StandardWellEval<FS<T>,__VA_ARGS__>;
|
||||
|
||||
#define INSTANTIATE_TYPE(T) \
|
||||
|
@ -19,7 +19,6 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OPM_STANDARDWELL_EVAL_HEADER_INCLUDED
|
||||
#define OPM_STANDARDWELL_EVAL_HEADER_INCLUDED
|
||||
|
||||
|
@ -246,6 +246,19 @@ namespace Opm
|
||||
drawdown += skin_pressure;
|
||||
}
|
||||
|
||||
RatioCalculator<Value> ratioCalc{
|
||||
FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)
|
||||
? Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)
|
||||
: -1,
|
||||
FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)
|
||||
? Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx)
|
||||
: -1,
|
||||
FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)
|
||||
? Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx)
|
||||
: -1,
|
||||
this->name()
|
||||
};
|
||||
|
||||
// producing perforations
|
||||
if (drawdown > 0) {
|
||||
// Do nothing if crossflow is not allowed
|
||||
@ -299,9 +312,12 @@ namespace Opm
|
||||
volumeRatio += cmix_s[Indices::contiSolventEqIdx] / b_perfcells_dense[Indices::contiSolventEqIdx];
|
||||
}
|
||||
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||
gasOilVolumeRatio(volumeRatio, rv, rs, pressure,
|
||||
cmix_s, b_perfcells_dense, deferred_logger);
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) &&
|
||||
FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx))
|
||||
{
|
||||
ratioCalc.gasOilVolumeRatio(volumeRatio, rv, rs, pressure,
|
||||
cmix_s, b_perfcells_dense,
|
||||
deferred_logger);
|
||||
} else {
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
||||
const unsigned oilCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx);
|
||||
@ -2812,34 +2828,4 @@ namespace Opm
|
||||
volumeRatio += tmp_gas / b_perfcells_dense[gasCompIdx];
|
||||
}
|
||||
|
||||
|
||||
template <typename TypeTag>
|
||||
template<class Value>
|
||||
void
|
||||
StandardWell<TypeTag>::
|
||||
gasOilVolumeRatio(Value& volumeRatio,
|
||||
const Value& rv,
|
||||
const Value& rs,
|
||||
const Value& pressure,
|
||||
const std::vector<Value>& cmix_s,
|
||||
const std::vector<Value>& b_perfcells_dense,
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
const unsigned oilCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx);
|
||||
const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx);
|
||||
// Incorporate RS/RV factors if both oil and gas active
|
||||
const Value d = 1.0 - rv * rs;
|
||||
|
||||
if (d <= 0.0) {
|
||||
deferred_logger.debug(dValueError(d, this->name(),
|
||||
"gasOilVolumeRatio",
|
||||
rs, rv, pressure));
|
||||
}
|
||||
const Value tmp_oil = d > 0.0? (cmix_s[oilCompIdx] - rv * cmix_s[gasCompIdx]) / d : cmix_s[oilCompIdx];
|
||||
volumeRatio += tmp_oil / b_perfcells_dense[oilCompIdx];
|
||||
|
||||
const Value tmp_gas = d > 0.0? (cmix_s[gasCompIdx] - rs * cmix_s[oilCompIdx]) / d : cmix_s[gasCompIdx];
|
||||
volumeRatio += tmp_gas / b_perfcells_dense[gasCompIdx];
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
|
Loading…
Reference in New Issue
Block a user