Loading...
Searching...
No Matches
RegularizedBrooksCorey.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
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 2 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/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef REGULARIZED_BROOKS_COREY_HPP
#define REGULARIZED_BROOKS_COREY_HPP
#include "BrooksCorey.hpp"
#include "RegularizedBrooksCoreyParams.hpp"
#include <opm/material/common/Spline.hpp>
namespace Opm {
template <class TraitsT, class ParamsT = RegularizedBrooksCoreyParams<TraitsT> >
class RegularizedBrooksCorey : public TraitsT
{
typedef ::Opm::BrooksCorey<TraitsT, ParamsT> BrooksCorey;
public:
typedef TraitsT Traits;
typedef ParamsT Params;
typedef typename Traits::Scalar Scalar;
using Traits::numPhases;
static_assert(numPhases == 2,
"The regularized Brooks-Corey capillary pressure law only "
"applies to the case of two fluid phases");
static const bool implementsTwoPhaseApi = true;
static const bool implementsTwoPhaseSatApi = true;
static const bool isSaturationDependent = true;
static const bool isPressureDependent = false;
static const bool isTemperatureDependent = false;
static const bool isCompositionDependent = false;
static_assert(Traits::numPhases == 2,
"The number of fluid phases must be two if you want to use "
"this material law!");
template <class Container, class FluidState>
static void capillaryPressures(Container& values, const Params& params, const FluidState& fs)
{
typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
values[Traits::wettingPhaseIdx] = 0.0; // reference phase
values[Traits::nonWettingPhaseIdx] = pcnw<FluidState, Evaluation>(params, fs);
}
template <class Container, class FluidState>
static void saturations(Container& values, const Params& params, const FluidState& fs)
{
typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
values[Traits::wettingPhaseIdx] = Sw<FluidState, Evaluation>(params, fs);
values[Traits::nonWettingPhaseIdx] = 1 - values[Traits::wettingPhaseIdx];
}
template <class Container, class FluidState>
static void relativePermeabilities(Container& values, const Params& params, const FluidState& fs)
{
typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
values[Traits::wettingPhaseIdx] = krw<FluidState, Evaluation>(params, fs);
values[Traits::nonWettingPhaseIdx] = krn<FluidState, Evaluation>(params, fs);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation pcnw(const Params& params, const FluidState& fs)
{
const auto& Sw = decay<Evaluation>(fs.saturation(Traits::wettingPhaseIdx));
return twoPhaseSatPcnw(params, Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatPcnw(const Params& params, const Evaluation& Sw)
{
const Scalar Sthres = params.pcnwLowSw();
if (Sw <= Sthres) {
Scalar m = params.pcnwSlopeLow();
Scalar pcnw_SwLow = params.pcnwLow();
return pcnw_SwLow + m*(Sw - Sthres);
}
else if (Sw >= 1.0) {
Scalar m = params.pcnwSlopeHigh();
Scalar pcnw_SwHigh = params.pcnwHigh();
return pcnw_SwHigh + m*(Sw - 1.0);
}
// if the effective saturation is in an 'reasonable'
// range, we use the real Brooks-Corey law...
return BrooksCorey::twoPhaseSatPcnw(params, Sw);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sw(const Params& params, const FluidState& fs)
{
const Evaluation& pC =
decay<Evaluation>(fs.pressure(Traits::nonWettingPhaseIdx))
- decay<Evaluation>(fs.pressure(Traits::wettingPhaseIdx));
return twoPhaseSatSw(params, pC);
}
template <class Evaluation>
static Evaluation twoPhaseSatSw(const Params& params, const Evaluation& pcnw)
{
const Scalar Sthres = params.pcnwLowSw();
// calculate the saturation which corrosponds to the
// saturation in the non-regularized version of the
// Brooks-Corey law. If the input capillary pressure is
// smaller than the entry pressure, make sure that we will
// regularize.
Evaluation sw = 1.5;
if (pcnw >= params.entryPressure()) {
sw = BrooksCorey::twoPhaseSatSw(params, pcnw);
}
// make sure that the capilary pressure observes a
// derivative != 0 for 'illegal' saturations. This is
// required for example by newton solvers (if the
// derivative calculated numerically) in order to get the
// saturation moving to the right direction if it
// temporarily is in an 'illegal' range.
if (sw <= Sthres) {
// invert the low saturation regularization of pcnw()
Scalar m = params.pcnwSlopeLow();
Scalar pcnw_SwLow = params.pcnwLow();
return Sthres + (pcnw - pcnw_SwLow)/m;
}
else if (sw > 1.0) {
Scalar m = params.pcnwSlopeHigh();
Scalar pcnw_SwHigh = params.pcnwHigh();
return 1.0 + (pcnw - pcnw_SwHigh)/m;;
}
return BrooksCorey::twoPhaseSatSw(params, pcnw);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sn(const Params& params, const FluidState& fs)
{ return 1 - Sw<FluidState, Evaluation>(params, fs); }
template <class Evaluation>
static Evaluation twoPhaseSatSn(const Params& params, const Evaluation& pcnw)
{ return 1 - twoPhaseSatSw(params, pcnw); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krw(const Params& params, const FluidState& fs)
{
const auto& sw = decay<Evaluation>(fs.saturation(Traits::wettingPhaseIdx));
return twoPhaseSatKrw(params, sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrw(const Params& params, const Evaluation& Sw)
{
if (Sw <= 0.0)
return 0.0;
else if (Sw >= 1.0)
return 1.0;
return BrooksCorey::twoPhaseSatKrw(params, Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrwInv(const Params& params, const Evaluation& krw)
{
if (krw <= 0.0)
return 0.0;
else if (krw >= 1.0)
return 1.0;
return BrooksCorey::twoPhaseSatKrwInv(params, krw);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krn(const Params& params, const FluidState& fs)
{
const Evaluation& sw =
1.0 - decay<Evaluation>(fs.saturation(Traits::nonWettingPhaseIdx));
return twoPhaseSatKrn(params, sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrn(const Params& params, const Evaluation& Sw)
{
if (Sw >= 1.0)
return 0.0;
else if (Sw <= 0.0)
return 1.0;
return BrooksCorey::twoPhaseSatKrn(params, Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrnInv(const Params& params, const Evaluation& krn)
{
if (krn <= 0.0)
return 1.0;
else if (krn >= 1.0)
return 0.0;
return BrooksCorey::twoPhaseSatKrnInv(params, krn);
}
};
} // namespace Opm
#endif
BrooksCorey.hpp
Implementation of the Brooks-Corey capillary pressure <-> saturation relation.
RegularizedBrooksCoreyParams.hpp
Parameters that are necessary for the regularization of the Brooks-Corey capillary pressure model.
Spline.hpp
Class implementing cubic splines.
Opm::RegularizedBrooksCorey
Implementation of the regularized Brooks-Corey capillary pressure / relative permeability <-> saturat...
Definition RegularizedBrooksCorey.hpp:66
Opm::RegularizedBrooksCorey::krn
static Evaluation krn(const Params &params, const FluidState &fs)
Regularized version of the relative permeability of the non-wetting phase of the Brooks-Corey curves.
Definition RegularizedBrooksCorey.hpp:322
Opm::RegularizedBrooksCorey::implementsTwoPhaseApi
static const bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition RegularizedBrooksCorey.hpp:82
Opm::RegularizedBrooksCorey::implementsTwoPhaseSatApi
static const bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition RegularizedBrooksCorey.hpp:86
Opm::RegularizedBrooksCorey::capillaryPressures
static void capillaryPressures(Container &values, const Params &params, const FluidState &fs)
The capillary pressure-saturation curves depending on absolute saturations.
Definition RegularizedBrooksCorey.hpp:119
Opm::RegularizedBrooksCorey::isPressureDependent
static const bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition RegularizedBrooksCorey.hpp:94
Opm::RegularizedBrooksCorey::Sn
static Evaluation Sn(const Params &params, const FluidState &fs)
Calculate the non-wetting phase saturations depending on the phase pressures.
Definition RegularizedBrooksCorey.hpp:257
Opm::RegularizedBrooksCorey::pcnw
static Evaluation pcnw(const Params &params, const FluidState &fs)
A regularized Brooks-Corey capillary pressure-saturation curve.
Definition RegularizedBrooksCorey.hpp:174
Opm::RegularizedBrooksCorey::relativePermeabilities
static void relativePermeabilities(Container &values, const Params &params, const FluidState &fs)
The relative permeability-saturation curves depending on absolute saturations.
Definition RegularizedBrooksCorey.hpp:151
Opm::RegularizedBrooksCorey::isCompositionDependent
static const bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition RegularizedBrooksCorey.hpp:102
Opm::RegularizedBrooksCorey::isTemperatureDependent
static const bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition RegularizedBrooksCorey.hpp:98
Opm::RegularizedBrooksCorey::krw
static Evaluation krw(const Params &params, const FluidState &fs)
Regularized version of the relative permeability of the wetting phase of the Brooks-Corey curves.
Definition RegularizedBrooksCorey.hpp:279
Opm::RegularizedBrooksCorey::saturations
static void saturations(Container &values, const Params &params, const FluidState &fs)
Calculate the saturations of the phases starting from their pressure differences.
Definition RegularizedBrooksCorey.hpp:132
Opm::RegularizedBrooksCorey::isSaturationDependent
static const bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition RegularizedBrooksCorey.hpp:90
Opm::RegularizedBrooksCorey::Sw
static Evaluation Sw(const Params &params, const FluidState &fs)
A regularized Brooks-Corey saturation-capillary pressure curve.
Definition RegularizedBrooksCorey.hpp:208
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30