move gasWaterPerfRateInj to RatioCalculator

This commit is contained in:
Arne Morten Kvarving 2024-11-18 13:44:54 +01:00
parent 725b95a1ac
commit f1ab605fbe
4 changed files with 51 additions and 48 deletions

View File

@ -26,6 +26,7 @@
#include <opm/material/densead/EvaluationFormat.hpp>
#include <opm/simulators/utils/DeferredLogger.hpp>
#include <opm/simulators/wells/PerforationData.hpp>
#include <fmt/format.h>
@ -117,6 +118,35 @@ gasOilVolumeRatio(Value& volumeRatio,
volumeRatio += tmp_gas / b_perfcells_dense[gasComp_];
}
template<class Value>
void
RatioCalculator<Value>::
gasWaterPerfRateInj(const std::vector<Value>& cq_s,
PerforationRates<Scalar>& perf_rates,
const Value& rvw,
const Value& rsw,
const Value& pressure,
DeferredLogger& deferred_logger) const
{
const Scalar dw = 1.0 - getValue(rvw) * getValue(rsw);
if (dw <= 0.0) {
deferred_logger.debug(dValueError(dw, name_,
"gasWaterPerfRateInj",
rsw, rvw, pressure));
} else {
// vaporized water into gas
// rvw * q_gr * b_g = rvw * (q_gs - rsw * q_ws) / dw
perf_rates.vap_wat = getValue(rvw) * (getValue(cq_s[gasComp_]) -
getValue(rsw) * getValue(cq_s[waterComp_])) / dw;
// dissolved gas in water
// rsw * q_wr * b_w = rsw * (q_ws - rvw * q_gs) / dw
perf_rates.dis_gas_in_water = getValue(rsw) * (getValue(cq_s[waterComp_]) -
getValue(rvw) * getValue(cq_s[gasComp_])) / dw;
}
}
#define INSTANTIATE_TYPE(T) \
template class RatioCalculator<T>; \
template class RatioCalculator<DenseAd::Evaluation<T, -1, 4u>>; \

View File

@ -22,6 +22,8 @@
#ifndef RATIO_CALCULATOR_HPP
#define RATIO_CALCULATOR_HPP
#include <opm/material/densead/Math.hpp>
#include <string>
#include <string_view>
#include <vector>
@ -29,16 +31,27 @@
namespace Opm {
class DeferredLogger;
template<class Scalar> struct PerforationRates;
template<class Value>
class RatioCalculator
{
public:
using Scalar = decltype(getValue(Value{}));
RatioCalculator(unsigned gasCompIdx,
unsigned oilCompIdx,
unsigned waterCompIdx,
std::string_view name);
void disOilVapWatVolumeRatio(Value& volumeRatio,
const Value& rvw,
const Value& rsw,
const Value& pressure,
const std::vector<Value>& cmix_s,
const std::vector<Value>& b_perfcells_dense,
DeferredLogger& deferred_logger) const;
void gasOilVolumeRatio(Value& volumeRatio,
const Value& rv,
const Value& rs,
@ -47,13 +60,12 @@ public:
const std::vector<Value>& b_perfcells_dense,
DeferredLogger& deferred_logger) const;
void disOilVapWatVolumeRatio(Value& volumeRatio,
const Value& rvw,
const Value& rsw,
const Value& pressure,
const std::vector<Value>& cmix_s,
const std::vector<Value>& b_perfcells_dense,
DeferredLogger& deferred_logger) const;
void gasWaterPerfRateInj(const std::vector<Value>& cq_s,
PerforationRates<Scalar>& perf_rates,
const Value& rvw,
const Value& rsw,
const Value& pressure,
DeferredLogger& deferred_logger) const;
private:
unsigned gasComp_;

View File

@ -489,14 +489,6 @@ namespace Opm
PerforationRates<Scalar>& perf_rates,
const Value& rvw,
const Value& rsw) const;
template<class Value>
void gasWaterPerfRateInj(const std::vector<Value>& cq_s,
PerforationRates<Scalar>& perf_rates,
const Value& rvw,
const Value& rsw,
const Value& pressure,
DeferredLogger& deferred_logger) const;
};
}

View File

@ -345,8 +345,8 @@ namespace Opm
}
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
//no oil
gasWaterPerfRateInj(cq_s, perf_rates, rvw, rsw,
pressure, deferred_logger);
ratioCalc.gasWaterPerfRateInj(cq_s, perf_rates, rvw, rsw,
pressure, deferred_logger);
}
}
}
@ -2764,35 +2764,4 @@ namespace Opm
}
}
template <typename TypeTag>
template<class Value>
void
StandardWell<TypeTag>::
gasWaterPerfRateInj(const std::vector<Value>& cq_s,
PerforationRates<Scalar>& perf_rates,
const Value& rvw,
const Value& rsw,
const Value& pressure,
DeferredLogger& deferred_logger) const
{
const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx);
const unsigned waterCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx);
const Scalar dw = 1.0 - getValue(rvw) * getValue(rsw);
if (dw <= 0.0) {
deferred_logger.debug(dValueError(dw, this->name(),
"gasWaterPerfRateInj",
rsw, rvw, pressure));
} else {
// vaporized water into gas
// rvw * q_gr * b_g = rvw * (q_gs - rsw * q_ws) / dw
perf_rates.vap_wat = getValue(rvw) * (getValue(cq_s[gasCompIdx]) - getValue(rsw) * getValue(cq_s[waterCompIdx])) / dw;
// dissolved gas in water
// rsw * q_wr * b_w = rsw * (q_ws - rvw * q_gs) / dw
perf_rates.dis_gas_in_water = getValue(rsw) * (getValue(cq_s[waterCompIdx]) - getValue(rvw) * getValue(cq_s[gasCompIdx])) / dw;
}
}
} // namespace Opm