Loading...
Searching...
No Matches
BrooksCorey.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 OPM_BROOKS_COREY_HPP
#define OPM_BROOKS_COREY_HPP
#include "BrooksCoreyParams.hpp"
#include <opm/common/Exceptions.hpp>
#include <opm/material/common/MathToolbox.hpp>
#include <algorithm>
#include <cassert>
#include <cmath>
namespace Opm {
template <class TraitsT, class ParamsT = BrooksCoreyParams<TraitsT> >
class BrooksCorey : public TraitsT
{
public:
typedef TraitsT Traits;
typedef ParamsT Params;
typedef typename Traits::Scalar Scalar;
static const int numPhases = Traits::numPhases;
static_assert(numPhases == 2,
"The 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.0 - 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 Evaluation& Sw =
decay<Evaluation>(fs.saturation(Traits::wettingPhaseIdx));
assert(0.0 <= Sw && Sw <= 1.0);
return twoPhaseSatPcnw(params, Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatPcnw(const Params& params, const Evaluation& Sw)
{
assert(0.0 <= Sw && Sw <= 1.0);
return params.entryPressure()*pow(Sw, -1/params.lambda());
}
template <class Evaluation>
static Evaluation twoPhaseSatPcnwInv(const Params& params, const Evaluation& pcnw)
{
assert(pcnw > 0.0);
return pow(params.entryPressure()/pcnw, -params.lambda());
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sw(const Params& params, const FluidState& fs)
{
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& pc)
{
assert(pc > 0.0); // if we don't assume that, std::pow will screw up!
return pow(pc/params.entryPressure(), -params.lambda());
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sn(const Params& params, const FluidState& fs)
{ return 1.0 - Sw<FluidState, Evaluation>(params, fs); }
template <class Evaluation>
static Evaluation twoPhaseSatSn(const Params& params, const Evaluation& pc)
{ return 1.0 - twoPhaseSatSw(params, pc); }
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)
{
assert(0.0 <= Sw && Sw <= 1.0);
return pow(Sw, 2.0/params.lambda() + 3.0);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrwInv(const Params& params, const Evaluation& krw)
{
return pow(krw, 1.0/(2.0/params.lambda() + 3.0));
}
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)
{
assert(0.0 <= Sw && Sw <= 1.0);
Scalar exponent = 2.0/params.lambda() + 1.0;
const Evaluation sn = 1.0 - Sw;
return sn*sn*(1. - pow(Sw, exponent));
}
template <class Evaluation>
static Evaluation twoPhaseSatKrnInv(const Params& params, const Evaluation& krn)
{
// since inverting the formula for krn is hard to do analytically, we use the
// Newton-Raphson method
Evaluation sw = 0.5;
Scalar eps = 1e-10;
for (int i = 0; i < 20; ++i) {
Evaluation f = krn - twoPhaseSatKrn(params, sw);
Evaluation fStar = krn - twoPhaseSatKrn(params, sw + eps);
Evaluation fPrime = (fStar - f) / eps;
Evaluation delta = f / fPrime;
sw -= delta;
if (sw < 0) {
sw = 0.0;
}
if (abs(delta) < 1e-10) {
return sw;
}
}
throw NumericalProblem("Couldn't invert the Brooks-Corey non-wetting phase"
" relperm within 20 iterations");
}
};
} // namespace Opm
#endif // BROOKS_COREY_HPP
BrooksCoreyParams.hpp
Specification of the material parameters for the Brooks-Corey constitutive relations.
Exceptions.hpp
Provides the OPM specific exception classes.
MathToolbox.hpp
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Opm::BrooksCorey
Implementation of the Brooks-Corey capillary pressure <-> saturation relation.
Definition BrooksCorey.hpp:55
Opm::BrooksCorey::saturations
static void saturations(Container &values, const Params &params, const FluidState &fs)
Calculate the saturations of the phases starting from their pressure differences.
Definition BrooksCorey.hpp:112
Opm::BrooksCorey::isPressureDependent
static const bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition BrooksCorey.hpp:81
Opm::BrooksCorey::isSaturationDependent
static const bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition BrooksCorey.hpp:77
Opm::BrooksCorey::numPhases
static const int numPhases
The number of fluid phases to which this material law applies.
Definition BrooksCorey.hpp:62
Opm::BrooksCorey::capillaryPressures
static void capillaryPressures(Container &values, const Params &params, const FluidState &fs)
The capillary pressure-saturation curves.
Definition BrooksCorey.hpp:99
Opm::BrooksCorey::relativePermeabilities
static void relativePermeabilities(Container &values, const Params &params, const FluidState &fs)
The relative permeability-saturation curves.
Definition BrooksCorey.hpp:131
Opm::BrooksCorey::implementsTwoPhaseApi
static const bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition BrooksCorey.hpp:69
Opm::BrooksCorey::Sn
static Evaluation Sn(const Params &params, const FluidState &fs)
Calculate the non-wetting phase saturations depending on the phase pressures.
Definition BrooksCorey.hpp:213
Opm::BrooksCorey::isTemperatureDependent
static const bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition BrooksCorey.hpp:85
Opm::BrooksCorey::Sw
static Evaluation Sw(const Params &params, const FluidState &fs)
The saturation-capillary pressure curve according to Brooks & Corey.
Definition BrooksCorey.hpp:192
Opm::BrooksCorey::krw
static Evaluation krw(const Params &params, const FluidState &fs)
The relative permeability for the wetting phase of the medium implied by the Brooks-Corey parameteriz...
Definition BrooksCorey.hpp:228
Opm::BrooksCorey::krn
static Evaluation krn(const Params &params, const FluidState &fs)
The relative permeability for the non-wetting phase of the medium as implied by the Brooks-Corey para...
Definition BrooksCorey.hpp:259
Opm::BrooksCorey::isCompositionDependent
static const bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition BrooksCorey.hpp:89
Opm::BrooksCorey::pcnw
static Evaluation pcnw(const Params &params, const FluidState &fs)
The capillary pressure-saturation curve according to Brooks and Corey.
Definition BrooksCorey.hpp:153
Opm::BrooksCorey::implementsTwoPhaseSatApi
static const bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition BrooksCorey.hpp:73
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30