2017-12-04 15:26:53 -06:00
|
|
|
/*
|
|
|
|
Copyright 2017 TNO - Heat Transfer & Fluid Dynamics, Modelling & Optimization of the Subsurface
|
|
|
|
Copyright 2017 Statoil ASA.
|
|
|
|
|
|
|
|
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 OPM_AQUIFERCT_HEADER_INCLUDED
|
|
|
|
#define OPM_AQUIFERCT_HEADER_INCLUDED
|
|
|
|
|
2022-08-11 02:17:53 -05:00
|
|
|
#include <opm/simulators/aquifers/AquiferAnalytical.hpp>
|
2017-12-04 15:26:53 -06:00
|
|
|
|
2023-02-02 03:27:48 -06:00
|
|
|
#include <opm/input/eclipse/EclipseState/Aquifer/AquiferCT.hpp>
|
|
|
|
|
2019-11-28 10:26:58 -06:00
|
|
|
#include <opm/output/data/Aquifer.hpp>
|
|
|
|
|
2019-12-05 06:41:05 -06:00
|
|
|
#include <exception>
|
2021-03-22 09:46:14 -05:00
|
|
|
#include <memory>
|
2019-12-05 06:41:05 -06:00
|
|
|
#include <stdexcept>
|
2021-03-24 12:21:30 -05:00
|
|
|
#include <utility>
|
2019-12-05 06:41:05 -06:00
|
|
|
|
2017-12-04 15:26:53 -06:00
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
template <typename TypeTag>
|
2022-08-11 02:17:53 -05:00
|
|
|
class AquiferCarterTracy : public AquiferAnalytical<TypeTag>
|
2019-12-20 07:30:13 -06:00
|
|
|
{
|
|
|
|
public:
|
2022-08-11 02:17:53 -05:00
|
|
|
using Base = AquiferAnalytical<TypeTag>;
|
2019-12-20 07:30:13 -06:00
|
|
|
|
|
|
|
using typename Base::BlackoilIndices;
|
|
|
|
using typename Base::ElementContext;
|
|
|
|
using typename Base::Eval;
|
|
|
|
using typename Base::FluidState;
|
|
|
|
using typename Base::FluidSystem;
|
|
|
|
using typename Base::IntensiveQuantities;
|
|
|
|
using typename Base::RateVector;
|
|
|
|
using typename Base::Scalar;
|
|
|
|
using typename Base::Simulator;
|
2020-11-24 07:58:15 -06:00
|
|
|
using typename Base::ElementMapper;
|
2019-12-20 07:30:13 -06:00
|
|
|
|
2020-02-10 10:39:04 -06:00
|
|
|
AquiferCarterTracy(const std::vector<Aquancon::AquancCell>& connections,
|
2019-12-20 07:30:13 -06:00
|
|
|
const Simulator& ebosSimulator,
|
|
|
|
const AquiferCT::AQUCT_data& aquct_data)
|
2020-12-08 09:09:01 -06:00
|
|
|
: Base(aquct_data.aquiferID, connections, ebosSimulator)
|
2019-12-20 07:30:13 -06:00
|
|
|
, aquct_data_(aquct_data)
|
2021-05-12 05:16:20 -05:00
|
|
|
{}
|
2017-12-04 15:26:53 -06:00
|
|
|
|
2023-02-02 03:27:48 -06:00
|
|
|
static AquiferCarterTracy serializationTestObject(const Simulator& ebosSimulator)
|
|
|
|
{
|
|
|
|
AquiferCarterTracy result({}, ebosSimulator, {});
|
|
|
|
|
|
|
|
result.pressure_previous_ = {1.0, 2.0, 3.0};
|
|
|
|
result.pressure_current_ = {4.0, 5.0};
|
|
|
|
result.Qai_ = {{6.0}};
|
|
|
|
result.rhow_ = 7.0;
|
|
|
|
result.W_flux_ = 8.0;
|
|
|
|
result.fluxValue_ = 9.0;
|
|
|
|
result.dimensionless_time_ = 10.0;
|
|
|
|
result.dimensionless_pressure_ = 11.0;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
void endTimeStep() override
|
|
|
|
{
|
2020-02-10 10:39:04 -06:00
|
|
|
for (const auto& q : this->Qai_) {
|
|
|
|
this->W_flux_ += q * this->ebos_simulator_.timeStepSize();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2020-12-15 02:01:03 -06:00
|
|
|
this->fluxValue_ = this->W_flux_.value();
|
|
|
|
const auto& comm = this->ebos_simulator_.vanguard().grid().comm();
|
|
|
|
comm.sum(&this->fluxValue_, 1);
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
2022-08-24 08:36:56 -05:00
|
|
|
data::AquiferData aquiferData() const override
|
2020-10-01 16:30:07 -05:00
|
|
|
{
|
|
|
|
data::AquiferData data;
|
2021-05-12 05:16:20 -05:00
|
|
|
data.aquiferID = this->aquiferID();
|
2020-10-01 16:30:07 -05:00
|
|
|
// TODO: not sure how to get this pressure value yet
|
|
|
|
data.pressure = this->pa0_;
|
|
|
|
data.fluxRate = 0.;
|
|
|
|
for (const auto& q : this->Qai_) {
|
|
|
|
data.fluxRate += q.value();
|
|
|
|
}
|
|
|
|
data.volume = this->W_flux_.value();
|
|
|
|
data.initPressure = this->pa0_;
|
2021-06-01 16:20:28 -05:00
|
|
|
|
|
|
|
auto* aquCT = data.typeData.template create<data::AquiferType::CarterTracy>();
|
2021-09-17 08:26:46 -05:00
|
|
|
|
2021-06-01 16:20:28 -05:00
|
|
|
aquCT->dimensionless_time = this->dimensionless_time_;
|
|
|
|
aquCT->dimensionless_pressure = this->dimensionless_pressure_;
|
2021-09-17 08:26:46 -05:00
|
|
|
aquCT->influxConstant = this->aquct_data_.influxConstant();
|
|
|
|
|
|
|
|
if (!this->co2store_()) {
|
|
|
|
aquCT->timeConstant = this->aquct_data_.timeConstant();
|
|
|
|
aquCT->waterDensity = this->aquct_data_.waterDensity();
|
|
|
|
aquCT->waterViscosity = this->aquct_data_.waterViscosity();
|
|
|
|
} else {
|
|
|
|
aquCT->waterDensity = this->rhow_;
|
|
|
|
aquCT->timeConstant = this->Tc_;
|
|
|
|
const auto x = this->aquct_data_.porosity * this->aquct_data_.total_compr * this->aquct_data_.inner_radius * this->aquct_data_.inner_radius;
|
|
|
|
aquCT->waterViscosity = this->Tc_ * this->aquct_data_.permeability / x;
|
|
|
|
}
|
2021-03-22 09:46:14 -05:00
|
|
|
|
2020-10-01 16:30:07 -05:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2023-02-02 03:27:48 -06:00
|
|
|
template<class Serializer>
|
|
|
|
void serializeOp(Serializer& serializer)
|
|
|
|
{
|
|
|
|
serializer(static_cast<Base&>(*this));
|
|
|
|
serializer(fluxValue_);
|
|
|
|
serializer(dimensionless_time_);
|
|
|
|
serializer(dimensionless_pressure_);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const AquiferCarterTracy& rhs) const
|
|
|
|
{
|
|
|
|
return static_cast<const AquiferAnalytical<TypeTag>&>(*this) == rhs &&
|
|
|
|
this->fluxValue_ == rhs.fluxValue_ &&
|
|
|
|
this->dimensionless_time_ == rhs.dimensionless_time_ &&
|
|
|
|
this->dimensionless_pressure_ == rhs.dimensionless_pressure_;
|
|
|
|
}
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
protected:
|
|
|
|
// Variables constants
|
2021-05-12 17:37:10 -05:00
|
|
|
AquiferCT::AQUCT_data aquct_data_;
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
Scalar beta_; // Influx constant
|
|
|
|
// TODO: it is possible it should be a AD variable
|
2021-01-20 09:51:35 -06:00
|
|
|
Scalar fluxValue_{0}; // value of flux
|
2019-12-20 07:30:13 -06:00
|
|
|
|
2021-03-22 09:46:14 -05:00
|
|
|
Scalar dimensionless_time_{0};
|
|
|
|
Scalar dimensionless_pressure_{0};
|
|
|
|
|
2021-06-22 08:31:47 -05:00
|
|
|
void assignRestartData(const data::AquiferData& xaq) override
|
2019-12-20 07:30:13 -06:00
|
|
|
{
|
2021-06-22 08:31:47 -05:00
|
|
|
this->fluxValue_ = xaq.volume;
|
|
|
|
this->rhow_ = this->aquct_data_.waterDensity();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-11-28 10:26:58 -06:00
|
|
|
|
2021-03-24 12:21:30 -05:00
|
|
|
std::pair<Scalar, Scalar>
|
|
|
|
getInfluenceTableValues(const Scalar td_plus_dt)
|
2019-12-20 07:30:13 -06:00
|
|
|
{
|
|
|
|
// We use the opm-common numeric linear interpolator
|
2021-03-22 09:46:14 -05:00
|
|
|
this->dimensionless_pressure_ =
|
2021-05-12 17:37:10 -05:00
|
|
|
linearInterpolation(this->aquct_data_.dimensionless_time,
|
|
|
|
this->aquct_data_.dimensionless_pressure,
|
2021-05-05 04:22:44 -05:00
|
|
|
this->dimensionless_time_);
|
2021-03-22 09:46:14 -05:00
|
|
|
|
2021-03-24 12:21:30 -05:00
|
|
|
const auto PItd =
|
2021-05-12 17:37:10 -05:00
|
|
|
linearInterpolation(this->aquct_data_.dimensionless_time,
|
|
|
|
this->aquct_data_.dimensionless_pressure,
|
|
|
|
td_plus_dt);
|
2021-03-24 12:21:30 -05:00
|
|
|
|
|
|
|
const auto PItdprime =
|
2021-05-12 17:37:10 -05:00
|
|
|
linearInterpolationDerivative(this->aquct_data_.dimensionless_time,
|
|
|
|
this->aquct_data_.dimensionless_pressure,
|
|
|
|
td_plus_dt);
|
2021-03-24 12:21:30 -05:00
|
|
|
|
|
|
|
return std::make_pair(PItd, PItdprime);
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2018-01-04 08:50:04 -06:00
|
|
|
|
2021-03-24 12:21:30 -05:00
|
|
|
Scalar dpai(const int idx) const
|
2019-12-20 07:30:13 -06:00
|
|
|
{
|
2021-05-12 17:37:10 -05:00
|
|
|
const auto gdz =
|
|
|
|
this->gravity_() * (this->cell_depth_.at(idx) - this->aquiferDepth());
|
|
|
|
|
|
|
|
const auto dp = this->pa0_ + this->rhow_*gdz
|
2020-02-10 10:39:04 -06:00
|
|
|
- this->pressure_previous_.at(idx);
|
2021-05-12 17:37:10 -05:00
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
return dp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function implements Eqs 5.8 and 5.9 of the EclipseTechnicalDescription
|
2021-03-24 12:21:30 -05:00
|
|
|
std::pair<Scalar, Scalar>
|
|
|
|
calculateEqnConstants(const int idx, const Simulator& simulator)
|
2019-12-20 07:30:13 -06:00
|
|
|
{
|
2020-02-10 10:39:04 -06:00
|
|
|
const Scalar td_plus_dt = (simulator.timeStepSize() + simulator.time()) / this->Tc_;
|
2021-03-22 09:46:14 -05:00
|
|
|
this->dimensionless_time_ = simulator.time() / this->Tc_;
|
|
|
|
|
2021-03-24 12:21:30 -05:00
|
|
|
const auto [PItd, PItdprime] = this->getInfluenceTableValues(td_plus_dt);
|
2021-03-22 09:46:14 -05:00
|
|
|
|
|
|
|
const auto denom = this->Tc_ * (PItd - this->dimensionless_time_*PItdprime);
|
2021-03-24 12:21:30 -05:00
|
|
|
const auto a = (this->beta_*dpai(idx) - this->fluxValue_*PItdprime) / denom;
|
|
|
|
const auto b = this->beta_ / denom;
|
2021-03-22 09:46:14 -05:00
|
|
|
|
2021-03-24 12:21:30 -05:00
|
|
|
return std::make_pair(a, b);
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
2021-09-17 08:26:46 -05:00
|
|
|
std::size_t pvtRegionIdx() const
|
|
|
|
{
|
|
|
|
return this->aquct_data_.pvttableID - 1;
|
|
|
|
}
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
// This function implements Eq 5.7 of the EclipseTechnicalDescription
|
|
|
|
inline void calculateInflowRate(int idx, const Simulator& simulator) override
|
|
|
|
{
|
2021-03-24 12:21:30 -05:00
|
|
|
const auto [a, b] = this->calculateEqnConstants(idx, simulator);
|
|
|
|
|
|
|
|
this->Qai_.at(idx) = this->alphai_.at(idx) *
|
|
|
|
(a - b*(this->pressure_current_.at(idx) - this->pressure_previous_.at(idx)));
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2018-01-04 08:50:04 -06:00
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
inline void calculateAquiferConstants() override
|
|
|
|
{
|
2021-09-17 08:26:46 -05:00
|
|
|
if(this->co2store_()) {
|
|
|
|
const auto press = this->aquct_data_.initial_pressure.value();
|
|
|
|
Scalar temp = FluidSystem::reservoirTemperature();
|
|
|
|
if (this->aquct_data_.initial_temperature.has_value())
|
|
|
|
temp = this->aquct_data_.initial_temperature.value();
|
|
|
|
|
2023-04-03 05:41:54 -05:00
|
|
|
Scalar waterViscosity = 0.;
|
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
|
|
|
Scalar rs = 0.0; // no dissolved CO2
|
|
|
|
waterViscosity = FluidSystem::oilPvt().viscosity(pvtRegionIdx(), temp, press, rs);
|
|
|
|
} else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
|
|
|
Scalar salt = 0.;
|
|
|
|
Scalar rsw = 0.;
|
|
|
|
waterViscosity = FluidSystem::waterPvt().viscosity(pvtRegionIdx(), temp, press, rsw, salt);
|
|
|
|
} else {
|
|
|
|
OPM_THROW(std::runtime_error, "water or oil phase is needed to run CO2Store.");
|
|
|
|
}
|
2021-09-17 08:26:46 -05:00
|
|
|
const auto x = this->aquct_data_.porosity * this->aquct_data_.total_compr * this->aquct_data_.inner_radius * this->aquct_data_.inner_radius;
|
|
|
|
this->Tc_ = waterViscosity * x / this->aquct_data_.permeability;
|
|
|
|
} else {
|
|
|
|
this->Tc_ = this->aquct_data_.timeConstant();
|
|
|
|
}
|
2021-05-12 17:37:10 -05:00
|
|
|
this->beta_ = this->aquct_data_.influxConstant();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void calculateAquiferCondition() override
|
|
|
|
{
|
2021-06-22 08:31:47 -05:00
|
|
|
if (this->solution_set_from_restart_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-12 17:37:10 -05:00
|
|
|
if (! this->aquct_data_.initial_pressure.has_value()) {
|
|
|
|
this->aquct_data_.initial_pressure =
|
|
|
|
this->calculateReservoirEquilibrium();
|
|
|
|
|
|
|
|
const auto& tables = this->ebos_simulator_.vanguard()
|
|
|
|
.eclState().getTableManager();
|
2018-01-04 08:50:04 -06:00
|
|
|
|
2021-05-12 17:37:10 -05:00
|
|
|
this->aquct_data_.finishInitialisation(tables);
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
2021-05-12 17:37:10 -05:00
|
|
|
this->pa0_ = this->aquct_data_.initial_pressure.value();
|
2022-08-29 03:59:20 -05:00
|
|
|
if (this->aquct_data_.initial_temperature.has_value())
|
|
|
|
this->Ta0_ = this->aquct_data_.initial_temperature.value();
|
|
|
|
|
2021-09-17 08:26:46 -05:00
|
|
|
if(this->co2store_()) {
|
2023-04-03 05:41:54 -05:00
|
|
|
const auto press = this->aquct_data_.initial_pressure.value();
|
|
|
|
|
|
|
|
Scalar temp = FluidSystem::reservoirTemperature();
|
|
|
|
if (this->aquct_data_.initial_temperature.has_value())
|
|
|
|
temp = this->aquct_data_.initial_temperature.value();
|
|
|
|
|
|
|
|
Scalar waterDensity = 0.;
|
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
|
|
|
Scalar rs = 0.0; // no dissolved CO2
|
|
|
|
waterDensity = FluidSystem::oilPvt().inverseFormationVolumeFactor(pvtRegionIdx(), temp, press, rs)
|
|
|
|
* FluidSystem::oilPvt().oilReferenceDensity(pvtRegionIdx());
|
|
|
|
} else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
|
|
|
Scalar salinity = 0.;
|
|
|
|
Scalar rsw = 0.;
|
|
|
|
waterDensity = FluidSystem::waterPvt().inverseFormationVolumeFactor(pvtRegionIdx(), temp, press, rsw, salinity)
|
|
|
|
* FluidSystem::waterPvt().waterReferenceDensity(pvtRegionIdx());
|
|
|
|
} else {
|
|
|
|
OPM_THROW(std::runtime_error, "water or oil phase is needed to run CO2Store.");
|
|
|
|
}
|
|
|
|
this->rhow_ = waterDensity;
|
2021-09-17 08:26:46 -05:00
|
|
|
} else {
|
|
|
|
this->rhow_ = this->aquct_data_.waterDensity();
|
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
2020-09-24 09:09:56 -05:00
|
|
|
virtual Scalar aquiferDepth() const override
|
2019-12-20 07:30:13 -06:00
|
|
|
{
|
2021-05-12 17:37:10 -05:00
|
|
|
return this->aquct_data_.datum_depth;
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
}; // class AquiferCarterTracy
|
2022-08-10 07:27:34 -05:00
|
|
|
|
2017-12-04 15:26:53 -06:00
|
|
|
} // namespace Opm
|
|
|
|
|
2018-10-25 09:47:00 -05:00
|
|
|
#endif
|