From afad4d23add23c88f8f85ca548d7dc491ef41f27 Mon Sep 17 00:00:00 2001 From: Trine Mykkeltvedt Date: Wed, 22 Jun 2022 14:35:55 +0200 Subject: [PATCH] moved the components to opm/material/components, and made subsequent changes for checking of the components --- opm/material/components/Brine.hpp | 12 + opm/material/components/C1.hpp | 96 ++++++ opm/material/components/C10.hpp | 94 ++++++ opm/material/components/H2O.hpp | 6 + opm/material/components/N2.hpp | 10 + opm/material/components/SimpleCO2.hpp | 11 + opm/material/components/iapws/Common.hpp | 5 + opm/material/fluidsystems/BaseFluidSystem.hpp | 10 + .../chifluid/co2brinefluidsystem.hh | 15 +- .../fluidsystems/chifluid/components.hh | 292 ------------------ .../chifluid/threecomponentfluidsystem.hh | 10 +- tests/checkComponent.hpp | 2 + tests/test_components.cpp | 3 + 13 files changed, 261 insertions(+), 305 deletions(-) create mode 100644 opm/material/components/C1.hpp create mode 100644 opm/material/components/C10.hpp delete mode 100644 opm/material/fluidsystems/chifluid/components.hh diff --git a/opm/material/components/Brine.hpp b/opm/material/components/Brine.hpp index 90e1148a3..eb5695fec 100644 --- a/opm/material/components/Brine.hpp +++ b/opm/material/components/Brine.hpp @@ -97,6 +97,18 @@ public: static Scalar criticalPressure() { return H2O::criticalPressure(); /* [N/m^2] */ } + /*! + * \copydoc H2O::criticalVolume + */ + static Scalar criticalVolume() + { return H2O::criticalVolume(); /* [m3/kmol] */ } + + /*! + * \copydoc H20::acentricFactor + */ + static Scalar acentricFactor() + { return H2O::acentricFactor(); } + /*! * \copydoc H2O::tripleTemperature */ diff --git a/opm/material/components/C1.hpp b/opm/material/components/C1.hpp new file mode 100644 index 000000000..22d4e3a8b --- /dev/null +++ b/opm/material/components/C1.hpp @@ -0,0 +1,96 @@ +// -*- 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 . + + 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. +*/ +/*! + * \file + * \copydoc Opm::C1 + */ +#ifndef OPM_C1_HPP +#define OPM_C1_HPP + +#include "Component.hpp" + +#include +#include + +#include + +#include + +namespace Opm +{ + +/*! + * \ingroup Components + * + * \brief Properties of pure molecular methane \f$C_1\f$. + * + * \tparam Scalar The type used for scalar values + */ +template +class C1 : public Component > +{ + typedef ::Opm::IdealGas IdealGas; + +public: + /*! + * \brief A human readable name for NDecane. + */ + static const char* name() + { return "C1"; } + + /*! + * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of molecular methane. + */ + static Scalar molarMass() + { return 0.0160;} + + /*! + * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of molecular methane + */ + static Scalar criticalTemperature() + { return 190.6; /* [K] */ } + + /*! + * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of molecular methane. + */ + static Scalar criticalPressure() + { return 4.60e6; /* [N/m^2] */ } + + /*! + * \brief Critical volume of \f$C_1\f$ [m2/kmol]. + */ + static Scalar criticalVolume() {return 9.863e-5; } + + /*! + * \brief Acentric factor of \f$C_1\f$. + */ + static Scalar acentricFactor() { return 0.011; } + + + + +}; + +} // namespace Opm + +#endif diff --git a/opm/material/components/C10.hpp b/opm/material/components/C10.hpp new file mode 100644 index 000000000..770032f4a --- /dev/null +++ b/opm/material/components/C10.hpp @@ -0,0 +1,94 @@ +// -*- 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 . + + 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. +*/ +/*! + * \file + * \copydoc Opm::C10 + */ +#ifndef OPM_C10_HPP +#define OPM_C10_HPP + +#include "Component.hpp" + +#include +#include + +#include + +#include + +namespace Opm +{ + +/*! + * \ingroup Components + * + * \brief Properties of pure molecular n-Decane \f$C_10\f$. + * + * \tparam Scalar The type used for scalar values + */ +template +class C10 : public Component > +{ + typedef ::Opm::IdealGas IdealGas; + +public: + /*! + * \brief A human readable name for NDecane. + */ + static const char* name() + { return "C10"; } + + /*! + * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of molecular n-Decane. + */ + static Scalar molarMass() + { return 0.0142;} + + /*! + * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of molecular n-Decane. + */ + static Scalar criticalTemperature() + { return 617.7; /* [K] */ } + + /*! + * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of molecular n-Decane. + */ + static Scalar criticalPressure() + { return 2.10e6; /* [N/m^2] */ } + + /*! + * \brief Critical volume of \f$C_10\f$ [m2/kmol]. + */ + static Scalar criticalVolume() {return 6.098e-4; } + + /*! + * \brief Acentric factor of \f$C_10\f$. + */ + static Scalar acentricFactor() { return 0.488; } + + +}; + +} // namespace Opm + +#endif diff --git a/opm/material/components/H2O.hpp b/opm/material/components/H2O.hpp index f5504a960..2a395c4b6 100644 --- a/opm/material/components/H2O.hpp +++ b/opm/material/components/H2O.hpp @@ -98,6 +98,12 @@ public: static const Scalar criticalPressure() { return Common::criticalPressure; } + /*! + * \brief Returns the critical volume \f$\mathrm{[m^3/kmol]}\f$ of water. + */ + static const Scalar criticalVolume() + { return Common::criticalVolume; } + /*! * \brief Returns the molar volume \f$\mathrm{[m^3/mol]}\f$ of water at the critical point */ diff --git a/opm/material/components/N2.hpp b/opm/material/components/N2.hpp index 27e2c98b2..8ec5ce098 100644 --- a/opm/material/components/N2.hpp +++ b/opm/material/components/N2.hpp @@ -76,6 +76,16 @@ public: static Scalar criticalPressure() { return 3.39858e6; /* [N/m^2] */ } + /*! + * \brief Critical volume of \f$N_2\f$ [m2/kmol]. + */ + static Scalar criticalVolume() {return 8.94e-2; } + + /*! + * \brief Acentric factor of \f$N_2\f$. + */ + static Scalar acentricFactor() { return 0.039; } + /*! * \brief Returns the temperature \f$\mathrm{[K]}\f$ at molecular nitrogen's triple point. */ diff --git a/opm/material/components/SimpleCO2.hpp b/opm/material/components/SimpleCO2.hpp index 0982a565f..6ae6ee066 100644 --- a/opm/material/components/SimpleCO2.hpp +++ b/opm/material/components/SimpleCO2.hpp @@ -82,6 +82,17 @@ public: static Scalar tripleTemperature() { return 273.15 - 56.35; /* [K] */ } + /*! + * \brief Acentric factor of \f$CO_2\f$. + */ + static Scalar acentricFactor() { return 0.224; } + + /*! + * \brief Critical volume of \f$CO_2\f$ [m2/kmol]. + */ + // Critical volume [m3/kmol] + static Scalar criticalVolume() {return 9.412e-5; } + /*! * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at the triple point of \f$CO_2\f$. */ diff --git a/opm/material/components/iapws/Common.hpp b/opm/material/components/iapws/Common.hpp index 36d6c9615..0490595bb 100644 --- a/opm/material/components/iapws/Common.hpp +++ b/opm/material/components/iapws/Common.hpp @@ -69,6 +69,9 @@ public: //! Density of water at the critical point \f$\mathrm{[kg/m^3]}\f$ static const Scalar criticalDensity; + //! Critical volume of water \f$\mathrm{[m^3/kmol]}\f$ + static const Scalar criticalVolume; + //! Critical molar volume of water \f$\mathrm{[m^3/mol]}\f$ static const Scalar criticalMolarVolume; @@ -242,6 +245,8 @@ const Scalar Common::criticalDensity = 322.0; template const Scalar Common::criticalMolarVolume = molarMass/criticalDensity; template +const Scalar Common::criticalVolume = 5.595e-2; +template const Scalar Common::acentricFactor = 0.344; template const Scalar Common::tripleTemperature = 273.16; diff --git a/opm/material/fluidsystems/BaseFluidSystem.hpp b/opm/material/fluidsystems/BaseFluidSystem.hpp index cf2091e7f..e5111ce83 100644 --- a/opm/material/fluidsystems/BaseFluidSystem.hpp +++ b/opm/material/fluidsystems/BaseFluidSystem.hpp @@ -150,6 +150,16 @@ public: throw std::runtime_error("Not implemented: The fluid system '"+Dune::className()+"' does not provide a molarMass() method!"); } + /*! + * \brief Return the acetntric factor of a component. + * + * \copydoc Doxygen::compIdxParam + */ + static Scalar acentricFactor(unsigned /*compIdx*/) + { + throw std::runtime_error("Not implemented: The fluid system '"+Dune::className()+"' does not provide a acentricFactor() method!"); + } + /*! * \brief Initialize the fluid system's static parameters */ diff --git a/opm/material/fluidsystems/chifluid/co2brinefluidsystem.hh b/opm/material/fluidsystems/chifluid/co2brinefluidsystem.hh index e06d8feb7..6a808d28f 100644 --- a/opm/material/fluidsystems/chifluid/co2brinefluidsystem.hh +++ b/opm/material/fluidsystems/chifluid/co2brinefluidsystem.hh @@ -2,7 +2,9 @@ #define OPM_CO2BRINEFLUIDSYSTEM_HH #include -#include +#include +#include +#include #include "ChiParameterCache.hpp" #include "LBCviscosity.hpp" @@ -23,18 +25,14 @@ namespace Opm { static constexpr int numComponents = 2; static constexpr int numMisciblePhases=2; static constexpr int numMiscibleComponents = 2; - // TODO: phase location should be more general static constexpr int oilPhaseIdx = 0; static constexpr int gasPhaseIdx = 1; static constexpr int Comp0Idx = 0; static constexpr int Comp1Idx = 1; - //static constexpr int Comp2Idx = 2; - // TODO: needs to be more general - using Comp0 = Opm::JuliaCO2; - using Comp1 = Opm::ChiwomsBrine; - //using Comp2 = Opm::JuliaC10; + using Comp0 = Opm::SimpleCO2; + using Comp1 = Opm::Brine>; template using ParameterCache = Opm::ChiParameterCache>; @@ -51,7 +49,6 @@ namespace Opm { switch (compIdx) { case Comp0Idx: return Comp0::acentricFactor(); case Comp1Idx: return Comp1::acentricFactor(); - // case Comp2Idx: return Comp2::acentricFactor(); default: throw std::runtime_error("Illegal component index for acentricFactor"); } } @@ -65,7 +62,6 @@ namespace Opm { switch (compIdx) { case Comp0Idx: return Comp0::criticalTemperature(); case Comp1Idx: return Comp1::criticalTemperature(); - // case Comp2Idx: return Comp2::criticalTemperature(); default: throw std::runtime_error("Illegal component index for criticalTemperature"); } } @@ -78,7 +74,6 @@ namespace Opm { switch (compIdx) { case Comp0Idx: return Comp0::criticalPressure(); case Comp1Idx: return Comp1::criticalPressure(); - // case Comp2Idx: return Comp2::criticalPressure(); default: throw std::runtime_error("Illegal component index for criticalPressure"); } } diff --git a/opm/material/fluidsystems/chifluid/components.hh b/opm/material/fluidsystems/chifluid/components.hh deleted file mode 100644 index 91a6f992a..000000000 --- a/opm/material/fluidsystems/chifluid/components.hh +++ /dev/null @@ -1,292 +0,0 @@ -#ifndef COMPONENTS_HH -#define COMPONENTS_HH - -#include -#include -#include -#include -#include - -namespace Opm { -/*! - * \ingroup Components - * - * \brief A simple representation of linear octane - * - * \tparam Scalar The type used for scalar values - */ -template -class Octane : public Opm::Component > -{ -public: - /// Chemical name - static const char* name() { return "C8"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.11423; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 568.7; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 2.49e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.398; } - - // Critical volume [m3/kmol] (same as [L/mol]) - static Scalar criticalVolume() {return 4.92e-1; } -}; - -template -class NDekane : public Opm::Component > -{ -public: - /// Chemical name - static const char* name() { return "C10"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.1423; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 617.7; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 2.103e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.4884; } - - // Critical volume [m3/kmol] (same as [L/mol]) - static Scalar criticalVolume() {return 6.0976e-1; } -}; - -template -class Methane : public Opm::Component > -{ -public: - /// Chemical name - static const char* name() { return "CH4"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.0160; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 190.5640; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 4.599e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.0114; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 9.8628e-2; } -}; - - -template -class Hydrogen : public Opm::Component > -{ -public: - /// Chemical name - static const char* name() { return "H2"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.0020156; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 33.2; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 1.297e6; } - - /// Acentric factor - static Scalar acentricFactor() { return -0.22; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 6.45e-2; } - -}; - -template -class Nitrogen : public Opm::Component > -{ -public: - /// Chemical name - static const char* name() { return "N2"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.0280134; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 126.192; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 3.3958e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.039; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 8.94e-2; } -}; - -template -class Water : public Opm::Component > -{ -public: - /// Chemical name - static const char* name() { return "H20"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.01801528; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 647; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 22.064e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.344; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 5.595e-2; } -}; - -template -class ChiwomsCO2 : public Opm::SimpleCO2 -{ -public: - /// Chemical name - static const char* name() { return "CO2"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.0440095; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 304.1; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 7.38e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.225; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 9.4118e-2; } -}; - -template -class ChiwomsBrine : public Opm::H2O -{ -public: - /// Chemical name - static const char* name() { return "H20-NaCl"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.0180158; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 647.096; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 2.21e7; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.344; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 5.595e-2; } -}; - -// TODO: creating some fluid components to debugging against the examples from the Julia test -// TODO: to make the parameter exactly same, we create some temporary component here - -template -class JuliaCO2 : public Opm::Component> -{ -public: - /// Chemical name - static const char* name() { return "CO2"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.0440; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 304.1; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 7.38e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.224; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 9.412e-5; } - // OLD :static Scalar criticalVolume() {return 9.4118e-2; } -}; - -template -class JuliaC1: public Opm::Component> -{ -public: - /// Chemical name - static const char* name() { return "C1"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.0160; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 190.6; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 4.60e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.011; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 9.863e-5; } -}; - -template -class JuliaC10: public Opm::Component> -{ -public: - /// Chemical name - static const char* name() { return "C10"; } - - /// Molar mass in \f$\mathrm{[kg/mol]}\f$ - static Scalar molarMass() { return 0.0142; } - - /// Critical temperature in \f$\mathrm[K]}\f$ - static Scalar criticalTemperature() { return 617.7; } - - /// Critical pressure in \f$\mathrm[Pa]}\f$ - static Scalar criticalPressure() { return 2.10e6; } - - /// Acentric factor - static Scalar acentricFactor() { return 0.488; } - - // Critical volume [m3/kmol] - static Scalar criticalVolume() {return 6.098e-4; } -}; - -struct EOS -{ - template - static LhsEval oleic_enthalpy(LhsEval T, LhsEval p, LhsEval x) { - return 0; - } - - template - static LhsEval aqueous_enthalpy(LhsEval T, LhsEval p, LhsEval x) { - return 0; - } -}; - -} // namespace opm - -#endif // COMPONENTS_HH diff --git a/opm/material/fluidsystems/chifluid/threecomponentfluidsystem.hh b/opm/material/fluidsystems/chifluid/threecomponentfluidsystem.hh index 8d7aa81a7..3127c4803 100644 --- a/opm/material/fluidsystems/chifluid/threecomponentfluidsystem.hh +++ b/opm/material/fluidsystems/chifluid/threecomponentfluidsystem.hh @@ -3,6 +3,10 @@ #include #include +#include +#include +#include + // TODO: this is something else need to check #include "ChiParameterCache.hpp" @@ -34,9 +38,9 @@ namespace Opm { static constexpr int Comp2Idx = 2; // TODO: needs to be more general - using Comp0 = Opm::JuliaCO2; - using Comp1 = Opm::JuliaC1; - using Comp2 = Opm::JuliaC10; + using Comp0 = Opm::SimpleCO2; + using Comp1 = Opm::C1; + using Comp2 = Opm::C10; template using ParameterCache = Opm::ChiParameterCache>; diff --git a/tests/checkComponent.hpp b/tests/checkComponent.hpp index bb2687eb6..f59a23d92 100644 --- a/tests/checkComponent.hpp +++ b/tests/checkComponent.hpp @@ -60,8 +60,10 @@ void checkComponent() { Scalar M OPM_UNUSED = Component::molarMass(); } { Scalar Tc OPM_UNUSED = Component::criticalTemperature(); } { Scalar pc OPM_UNUSED = Component::criticalPressure(); } + { Scalar Vc OPM_UNUSED = Component::criticalVolume(); } { Scalar Tt OPM_UNUSED = Component::tripleTemperature(); } { Scalar pt OPM_UNUSED = Component::triplePressure(); } + { Evaluation omega OPM_UNUSED = Component::acentricFactor(); } { Evaluation pv OPM_UNUSED = Component::vaporPressure(T); } { Evaluation rho OPM_UNUSED = Component::gasDensity(T, p); } { Evaluation rho OPM_UNUSED = Component::liquidDensity(T, p); } diff --git a/tests/test_components.cpp b/tests/test_components.cpp index 0a9d66251..248842f56 100644 --- a/tests/test_components.cpp +++ b/tests/test_components.cpp @@ -101,8 +101,11 @@ void testAllComponents() checkComponent, Evaluation>(); checkComponent, Evaluation>(); checkComponent, Evaluation>(); + checkComponent, Evaluation>(); + checkComponent, Evaluation>(); checkComponent, Evaluation>(); checkComponent, Evaluation>(); + checkComponent, Evaluation>(); checkComponent, Evaluation>(); checkComponent, Evaluation>(); checkComponent, Evaluation>();