From 7619cb606188b9f346ff67787648465933f385ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 17 Jan 2012 11:17:40 +0100 Subject: [PATCH] Added class PvtPropertiesBasic. --- Makefile.am | 2 + opm/core/fluid/PvtPropertiesBasic.cpp | 141 ++++++++++++++++++++++++++ opm/core/fluid/PvtPropertiesBasic.hpp | 96 ++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 opm/core/fluid/PvtPropertiesBasic.cpp create mode 100644 opm/core/fluid/PvtPropertiesBasic.hpp diff --git a/Makefile.am b/Makefile.am index af2f39f9..d956879e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ opm/core/fluid/blackoil/SinglePvtLiveGas.cpp \ opm/core/fluid/blackoil/SinglePvtLiveOil.cpp \ opm/core/fluid/blackoil/SinglePvtInterface.cpp \ opm/core/fluid/BlackoilPropertiesFromDeck.cpp \ +opm/core/fluid/PvtPropertiesBasic.cpp \ opm/core/fluid/RockBasic.cpp \ opm/core/fluid/RockFromDeck.cpp \ opm/core/fluid/SaturationPropsBasic.cpp \ @@ -88,6 +89,7 @@ opm/core/eclipse/SpecialEclipseFields.hpp \ opm/core/fluid/BlackoilFluid.hpp \ opm/core/fluid/BlackoilPropertiesInterface.hpp \ opm/core/fluid/BlackoilPropertiesFromDeck.hpp \ +opm/core/fluid/PvtPropertiesBasic.hpp \ opm/core/fluid/RockBasic.hpp \ opm/core/fluid/RockFromDeck.hpp \ opm/core/fluid/SaturationPropsBasic.hpp \ diff --git a/opm/core/fluid/PvtPropertiesBasic.cpp b/opm/core/fluid/PvtPropertiesBasic.cpp new file mode 100644 index 00000000..5cd0f727 --- /dev/null +++ b/opm/core/fluid/PvtPropertiesBasic.cpp @@ -0,0 +1,141 @@ +/* + Copyright 2012 SINTEF ICT, Applied Mathematics. + + 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 . +*/ + + + +#include +#include +#include + + +namespace Opm +{ + + PvtPropertiesBasic::PvtPropertiesBasic() + { + } + + + void PvtPropertiesBasic::init(const Dune::parameter::ParameterGroup& param) + { + int num_phases = param.getDefault("num_phases", 2); + if (num_phases > 3 || num_phases < 1) { + THROW("PvtPropertiesBasic::init() illegal num_phases: " << num_phases); + } + density_.resize(num_phases); + viscosity_.resize(num_phases); + // We currently do not allow the user to set B. + formation_volume_factor_.clear(); + formation_volume_factor_.resize(num_phases, 1.0); + + // Setting mu and rho from parameters + using namespace Dune::prefix; + using namespace Dune::unit; + const double kgpm3 = kilogram/cubic(meter); + const double cP = centi*Poise; + std::string rname[3] = { "rho1", "rho2", "rho3" }; + double rdefault[3] = { 1.0e3, 1.0e3, 1.0e3 }; + std::string vname[3] = { "mu1", "mu2", "mu3" }; + double vdefault[3] = { 1.0, 1.0, 1.0 }; + for (int phase = 0; phase < num_phases; ++phase) { + density_[phase] = kgpm3*param.getDefault(rname[phase], rdefault[phase]); + viscosity_[phase] = cP*param.getDefault(vname[phase], vdefault[phase]); + } + } + + const double* PvtPropertiesBasic::surfaceDensities() const + { + return &density_[0]; + } + + + int PvtPropertiesBasic::numPhases() const + { + return density_.size(); + } + + + + void PvtPropertiesBasic::mu(const int n, + const double* /*p*/, + const double* /*z*/, + double* output_mu) const + { + const int np = numPhases(); + for (int phase = 0; phase < np; ++phase) { +#pragma omp parallel for + for (int i = 0; i < n; ++i) { + output_mu[np*i + phase] = viscosity_[phase]; + } + } + } + + void PvtPropertiesBasic::B(const int n, + const double* /*p*/, + const double* /*z*/, + double* output_B) const + { + const int np = numPhases(); + for (int phase = 0; phase < np; ++phase) { +#pragma omp parallel for + for (int i = 0; i < n; ++i) { + output_B[np*i + phase] = formation_volume_factor_[phase]; + } + } + } + + void PvtPropertiesBasic::dBdp(const int n, + const double* /*p*/, + const double* /*z*/, + double* output_B, + double* output_dBdp) const + { + const int np = numPhases(); + for (int phase = 0; phase < np; ++phase) { +#pragma omp parallel for + for (int i = 0; i < n; ++i) { + output_B[np*i + phase] = formation_volume_factor_[phase]; + output_dBdp[np*i + phase] = 0.0; + } + } + + } + + + void PvtPropertiesBasic::R(const int n, + const double* /*p*/, + const double* /*z*/, + double* output_R) const + { + const int np = numPhases(); + std::fill(output_R, output_R + n*np, 0.0); + } + + void PvtPropertiesBasic::dRdp(const int n, + const double* /*p*/, + const double* /*z*/, + double* output_R, + double* output_dRdp) const + { + const int np = numPhases(); + std::fill(output_R, output_R + n*np, 0.0); + std::fill(output_dRdp, output_dRdp + n*np, 0.0); + } + +} // namespace Opm diff --git a/opm/core/fluid/PvtPropertiesBasic.hpp b/opm/core/fluid/PvtPropertiesBasic.hpp new file mode 100644 index 00000000..9314417d --- /dev/null +++ b/opm/core/fluid/PvtPropertiesBasic.hpp @@ -0,0 +1,96 @@ +/* + Copyright 2012 SINTEF ICT, Applied Mathematics. + + 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 . +*/ + +#ifndef OPM_PVTPROPERTIESBASIC_HEADER_INCLUDED +#define OPM_PVTPROPERTIESBASIC_HEADER_INCLUDED + +#include + +namespace Opm +{ + + /// Class collecting simple pvt properties for 1-3 phases. + /// All phases are incompressible and have constant viscosities. + /// For all the methods, the following apply: p and z are unused. + /// Output arrays shall be of size n*numPhases(), and must be valid + /// before calling the method. + /// NOTE: This class is intentionally similar to BlackoilPvtProperties. + class PvtPropertiesBasic + { + public: + /// Default constructor. + PvtPropertiesBasic(); + + /// Initialize from parameters. + /// The following parameters are accepted (defaults): + /// num_phases (2) Must be 1, 2 or 3. + /// rho1 [rho2, rho3] (1.0e3) Density in kg/m^3 + /// mu1 [mu2, mu3] (1.0) Viscosity in cP + void init(const Dune::parameter::ParameterGroup& param); + + /// Number of active phases. + int numPhases() const; + + /// Densities of stock components at surface conditions. + /// \return Array of size numPhases(). + const double* surfaceDensities() const; + + /// Viscosity as a function of p and z. + void mu(const int n, + const double* p, + const double* z, + double* output_mu) const; + + /// Formation volume factor as a function of p and z. + void B(const int n, + const double* p, + const double* z, + double* output_B) const; + + /// Formation volume factor and p-derivative as functions of p and z. + void dBdp(const int n, + const double* p, + const double* z, + double* output_B, + double* output_dBdp) const; + + /// Solution factor as a function of p and z. + void R(const int n, + const double* p, + const double* z, + double* output_R) const; + + /// Solution factor and p-derivative as functions of p and z. + void dRdp(const int n, + const double* p, + const double* z, + double* output_R, + double* output_dRdp) const; + + private: + std::vector density_; + std::vector viscosity_; + std::vector formation_volume_factor_; + }; + +} + + + +#endif // OPM_PVTPROPERTIESBASIC_HEADER_INCLUDED