diff --git a/dumux/material/fluidstates/adapter.hh b/dumux/material/fluidstates/adapter.hh index 4dae36fef463cebfff08a42a6259c662157251a7..36d8c6097f0d4e71006a222389febac5ee47a779 100644 --- a/dumux/material/fluidstates/adapter.hh +++ b/dumux/material/fluidstates/adapter.hh @@ -24,7 +24,6 @@ #ifndef DUMUX_MATERIAL_FLUID_STATE_ADAPTER_HH #define DUMUX_MATERIAL_FLUID_STATE_ADAPTER_HH -#include <array> #include <dune/common/exceptions.hh> namespace Dumux { @@ -103,6 +102,12 @@ public: Scalar pressure(int phaseIdx) const { return fluidState_.pressure(AdapterPolicy::phaseIdx(phaseIdx)); } + Scalar partialPressure(int phaseIdx, int compIdx) const + { + assert(FluidSystem::isGas(phaseIdx)); + return pressure(phaseIdx)*moleFraction(phaseIdx, compIdx); + } + Scalar temperature(int phaseIdx) const { return fluidState_.temperature(AdapterPolicy::phaseIdx(phaseIdx)); } diff --git a/dumux/material/fluidsystems/1padapter.hh b/dumux/material/fluidsystems/1padapter.hh new file mode 100644 index 0000000000000000000000000000000000000000..a7e4f40d27e04cab47948ab03107dc57f3f1d56c --- /dev/null +++ b/dumux/material/fluidsystems/1padapter.hh @@ -0,0 +1,319 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/***************************************************************************** + * See the file COPYING for full copying permissions. * + * * + * This program 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. * + * * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. * + *****************************************************************************/ +/*! + * \file + * \ingroup Fluidsystems + * \brief @copybrief Dumux::FluidSystems::OnePAdapter + */ +#ifndef DUMUX_FLUIDSYTEMS_ONEP_ADAPTER_HH +#define DUMUX_FLUIDSYTEMS_ONEP_ADAPTER_HH + +#include <cassert> + +#include <dune/common/exceptions.hh> + +#include <dumux/material/fluidsystems/base.hh> +#include <dumux/material/fluidstates/adapter.hh> + +namespace Dumux { +namespace FluidSystems { + +/*! + * \ingroup Fluidsystems + * \brief An adapter for multi-phase fluid systems to be used with compositional one-phase models + * \tparam MPFluidSystem the multi-phase fluid system to be adapted + * \tparam phase the index of the phase we choose from the multi-phase fluid system + */ +template <class MPFluidSystem, int phase = 0> +class OnePAdapter +: public BaseFluidSystem<typename MPFluidSystem::Scalar, OnePAdapter<MPFluidSystem, phase>> +{ + using ThisType = OnePAdapter<MPFluidSystem, phase>; + using Base = BaseFluidSystem<typename MPFluidSystem::Scalar, ThisType>; + + struct AdapterPolicy + { + using FluidSystem = MPFluidSystem; + + // the phase index is always zero, other phases than the chosen phase should never be called + static int phaseIdx(int mpFluidPhaseIdx) + { + if (mpFluidPhaseIdx == phase) + return 0; + else + DUNE_THROW(Dune::InvalidStateException, "Only phase " << phase << " is available!"); + } + + // the main component is currently excepted to have the same index as it's phase + // (see Fluidsystems::Base::getMainComponent for more information) + // so we swap the main component with the first component + // this mapping works in both ways since we are only swapping components + static constexpr int compIdx(int compIdx) + { + if (compIdx == 0) + return phase; + else if (compIdx == phase) + return 0; + else + return compIdx; + } + }; + + template<class FluidState> + static auto adaptFluidState(const FluidState& fluidState) + { return FluidStateAdapter<FluidState, AdapterPolicy>(fluidState); } + +public: + using Scalar = typename Base::Scalar; + using ParameterCache = NullParameterCache; + + //! export the wrapped MultiPhaseFluidSystem type + using MultiPhaseFluidSystem = MPFluidSystem; + + //! number of phases in the fluid system + static constexpr int numPhases = 1; + //! number of components has to be the same as in the multi-phase fluid system as the composition needs to be defined + static constexpr int numComponents = MultiPhaseFluidSystem::numComponents; + //! number of components has to be the same as in the multi-phase fluid system as the composition needs to be defined + static constexpr int phase0Idx = 0; //!< index of the only phase + + //! convert a component index of the multi-phase component index to the actual component index + static constexpr int compIdx(int multiPhaseFluidSystemCompIdx) + { return AdapterPolicy::compIdx(multiPhaseFluidSystemCompIdx); } + + /*! + * \brief Initialize the fluid system's static parameters generically + */ + static void init() + { MultiPhaseFluidSystem::init(); } + + /**************************************** + * Fluid phase related static parameters + ****************************************/ + /*! + * \brief Return the human readable name of a fluid phase + * + * \param phaseIdx The index of the fluid phase to consider + */ + static std::string phaseName(int phaseIdx = 0) + { return MultiPhaseFluidSystem::phaseName(phase); } + + /*! + * \brief A human readable name for the component. + * + * \param compIdx The index of the component to consider + */ + static std::string componentName(int compIdx) + { return MultiPhaseFluidSystem::componentName(AdapterPolicy::compIdx(compIdx)); } + + /*! + * \brief A human readable name for the component. + */ + static std::string name() + { return MultiPhaseFluidSystem::phaseName(phase); } + + /*! + * \brief There is only one phase, so not mass transfer between phases can occur + */ + static constexpr bool isMiscible() + { return false; } + + /*! + * \brief Returns whether the fluid is a liquid + */ + static constexpr bool isLiquid(int phaseIdx = 0) + { return MultiPhaseFluidSystem::isLiquid(phase); } + + /*! + * \brief Returns true if and only if a fluid phase is assumed to + * be an ideal mixture. + * + * We define an ideal mixture as a fluid phase where the fugacity + * coefficients of all components times the pressure of the phase + * are independent on the fluid composition. This assumption is true + * if only a single component is involved. If you are unsure what + * this function should return, it is safe to return false. The + * only damage done will be (slightly) increased computation times + * in some cases. + * + * \param phaseIdx The index of the fluid phase to consider + */ + static constexpr bool isIdealMixture(int phaseIdx = 0) + { return MultiPhaseFluidSystem::isIdealMixture(phase); } + + /*! + * \brief Returns true if the fluid is assumed to be compressible + */ + static constexpr bool isCompressible(int phaseIdx = 0) + { return MultiPhaseFluidSystem::isCompressible(phase); } + + /*! + * \brief Returns true if the fluid viscosity is constant + */ + static constexpr bool viscosityIsConstant(int phaseIdx = 0) + { return MultiPhaseFluidSystem::viscosityIsConstant(phase); } + + /*! + * \brief Returns true if the fluid is assumed to be an ideal gas + */ + static constexpr bool isIdealGas(int phaseIdx = 0) + { return MultiPhaseFluidSystem::isIdealGas(phase); } + + /*! + * \brief The mass in \f$\mathrm{[kg]}\f$ of one mole of the component. + */ + static Scalar molarMass(int compIdx) + { return MultiPhaseFluidSystem::molarMass(AdapterPolicy::compIdx(compIdx)); } + + using Base::density; + /*! + * \brief The density \f$\mathrm{[kg/m^3]}\f$ of the component at a given pressure and temperature. + */ + template <class FluidState> + static Scalar density(const FluidState &fluidState, int phaseIdx = 0) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::density(adaptFluidState(fluidState), phase); + } + + using Base::molarDensity; + /*! + * \brief The molar density \f$\rho_{mol,\alpha}\f$ + * of a fluid phase \f$\alpha\f$ in \f$\mathrm{[mol/m^3]}\f$ + * + * The molar density is defined by the + * mass density \f$\rho_\alpha\f$ and the main component molar mass \f$M_\alpha\f$: + * + * \f[\rho_{mol,\alpha} = \frac{\rho_\alpha}{M_\alpha} \;.\f] + */ + template <class FluidState> + static Scalar molarDensity(const FluidState &fluidState, int phaseIdx = 0) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::molarDensity(adaptFluidState(fluidState), phase); + } + + using Base::enthalpy; + /*! + * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ the pure component as a liquid. + */ + template <class FluidState> + static Scalar enthalpy(const FluidState &fluidState, int phaseIdx = 0) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::enthalpy(adaptFluidState(fluidState), phase); + } + + using Base::viscosity; + /*! + * \brief The dynamic liquid viscosity \f$\mathrm{[N/m^3*s]}\f$ of the pure component. + */ + template <class FluidState> + static Scalar viscosity(const FluidState &fluidState, int phaseIdx = 0) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::viscosity(adaptFluidState(fluidState), phase); + } + + using Base::fugacityCoefficient; + /*! + * \copybrief Base::fugacityCoefficient + * + * \param fluidState An arbitrary fluid state + * \param phaseIdx The index of the fluid phase to consider + * \param compIdx The index of the component to consider + */ + template <class FluidState> + static Scalar fugacityCoefficient(const FluidState &fluidState, + int phaseIdx, + int compIdx) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::fugacityCoefficient(adaptFluidState(fluidState), phase, + AdapterPolicy::compIdx(compIdx)); + } + + using Base::diffusionCoefficient; + /*! + * \copybrief Base::diffusionCoefficient + * + * \param fluidState An arbitrary fluid state + * \param phaseIdx The index of the fluid phase to consider + * \param compIdx The index of the component to consider + */ + template <class FluidState> + static Scalar diffusionCoefficient(const FluidState &fluidState, + int phaseIdx, + int compIdx) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::diffusionCoefficient(adaptFluidState(fluidState), phase, + AdapterPolicy::compIdx(compIdx)); + } + + using Base::binaryDiffusionCoefficient; + /*! + * \copybrief Base::binaryDiffusionCoefficient + * + * \param fluidState An arbitrary fluid state + * \param phaseIdx The index of the fluid phase to consider + * \param compIIdx The index of the component to consider + * \param compJIdx The index of the component to consider + */ + template <class FluidState> + static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, + int phaseIdx, + int compIIdx, + int compJIdx) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::binaryDiffusionCoefficient(adaptFluidState(fluidState), phase, + AdapterPolicy::compIdx(compIIdx), + AdapterPolicy::compIdx(compJIdx)); + } + + using Base::thermalConductivity; + /*! + * \brief Thermal conductivity of the fluid \f$\mathrm{[W/(m K)]}\f$. + */ + template <class FluidState> + static Scalar thermalConductivity(const FluidState &fluidState, + int phaseIdx = 0) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::thermalConductivity(adaptFluidState(fluidState), phase); + } + + using Base::heatCapacity; + /*! + * \brief Specific isobaric heat capacity of the fluid \f$\mathrm{[J/(kg K)]}\f$. + */ + template <class FluidState> + static Scalar heatCapacity(const FluidState &fluidState, + int phaseIdx = 0) + { + assert(phaseIdx == 0); + return MultiPhaseFluidSystem::heatCapacity(adaptFluidState(fluidState), phase); + } +}; + +} // namespace FluidSystems +} // namespace + +#endif diff --git a/dumux/material/fluidsystems/1pgas.hh b/dumux/material/fluidsystems/1pgas.hh index 02bf9567faedcbdedca594bac27306dba8189519..39086ca859b9a8fd8cf59a6caf3a2125ff751116 100644 --- a/dumux/material/fluidsystems/1pgas.hh +++ b/dumux/material/fluidsystems/1pgas.hh @@ -139,25 +139,25 @@ public: /*! * \brief Returns the critical temperature in \f$\mathrm{[K]}\f$ of the component */ - static Scalar criticalTemperature() + static Scalar criticalTemperature(int compIdx = 0) { return Component::criticalTemperature(); } /*! * \brief Returns the critical pressure in \f$\mathrm{[Pa]}\f$ of the component */ - static Scalar criticalPressure() + static Scalar criticalPressure(int compIdx = 0) { return Component::criticalPressure(); } /*! * \brief Returns the temperature in \f$\mathrm{[K]}\f$ at the component's triple point. */ - static Scalar tripleTemperature() + static Scalar tripleTemperature(int compIdx = 0) { return Component::tripleTemperature(); } /*! * \brief Returns the pressure in \f$\mathrm{[Pa]}\f$ at the component's triple point. */ - static Scalar triplePressure() + static Scalar triplePressure(int compIdx = 0) { return Component::triplePressure(); } /*! diff --git a/dumux/material/fluidsystems/1pliquid.hh b/dumux/material/fluidsystems/1pliquid.hh index e676331df3c372f922e6816adbf2986cc12710d9..e828093dc29246d1f808f47577fd02546b2eb28c 100644 --- a/dumux/material/fluidsystems/1pliquid.hh +++ b/dumux/material/fluidsystems/1pliquid.hh @@ -145,25 +145,25 @@ public: /*! * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of the component */ - static Scalar criticalTemperature() + static Scalar criticalTemperature(int compIdx = 0) { return Component::criticalTemperature(); } /*! * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of the component */ - static Scalar criticalPressure() + static Scalar criticalPressure(int compIdx = 0) { return Component::criticalPressure(); } /*! * \brief Returns the temperature \f$\mathrm{[K]}\f$ at the component's triple point. */ - static Scalar tripleTemperature() + static Scalar tripleTemperature(int compIdx = 0) { return Component::tripleTemperature(); } /*! * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at the component's triple point. */ - static Scalar triplePressure() + static Scalar triplePressure(int compIdx = 0) { return Component::triplePressure(); } /*! diff --git a/dumux/material/fluidsystems/CMakeLists.txt b/dumux/material/fluidsystems/CMakeLists.txt index 6a0a87ff75ffb8f54b20cc0f2ce0e336bdd86463..589e0bb25893a179b58f1458ea75ac5748176731 100644 --- a/dumux/material/fluidsystems/CMakeLists.txt +++ b/dumux/material/fluidsystems/CMakeLists.txt @@ -1,4 +1,5 @@ install(FILES +1padapter.hh 1pgas.hh 1pliquid.hh 2p1c.hh diff --git a/dumux/material/fluidsystems/base.hh b/dumux/material/fluidsystems/base.hh index e2ab7ecf8c8c917838e136f9c82ee5446daba413..0768dfc6a7be0bee62a366a906cdc446c819af1e 100644 --- a/dumux/material/fluidsystems/base.hh +++ b/dumux/material/fluidsystems/base.hh @@ -27,23 +27,23 @@ #include <string> #include "nullparametercache.hh" -namespace Dumux -{ - -namespace FluidSystems +namespace Dumux { +namespace FluidSystems { -{ - /*! - * \ingroup Fluidsystems - * \brief Fluid system base class. - * - * \note Always derive your fluid system from this class to be sure - * that all basic functionality is available! - */ - template <class Scalar, class Implementation> +/*! +* \ingroup Fluidsystems +* \brief Fluid system base class. +* +* \note Always derive your fluid system from this class to be sure +* that all basic functionality is available! +*/ +template <class ScalarType, class Implementation> class BaseFluidSystem { public: + //! export the scalar type + using Scalar = ScalarType; + //! The type of parameter cache objects using ParameterCache = NullParameterCache; @@ -60,8 +60,11 @@ public: * \brief Get the main component of a given phase if possible * * \param phaseIdx The index of the fluid phase to consider - * \note This method has to can throw at compile time if the fluid system doesn't assume a + * \note This method has to can assert at compile time if the fluid system doesn't assume a * main phase. Then using e.g. Fick's law will fail compiling. + * \todo Unfortunately we currently still have the assumption in some volume variables (e.g. 1pnc, 2pnc) + * that the main component index of a phase is equal to the phase index of that phase. This means + * changing this only works if the volume variables are written accordingly. */ static constexpr int getMainComponent(int phaseIdx) { return phaseIdx; } diff --git a/dumux/material/fluidsystems/h2on2o2.hh b/dumux/material/fluidsystems/h2on2o2.hh index 1a144ee486a379d2f383892613b19be768a69024..e20979cd8e7208584740b8fd02de2d4e92a21b99 100644 --- a/dumux/material/fluidsystems/h2on2o2.hh +++ b/dumux/material/fluidsystems/h2on2o2.hh @@ -455,34 +455,39 @@ public: Scalar p = fluidState.pressure(phaseIdx); // liquid phase - if (phaseIdx == liquidPhaseIdx) { + if (phaseIdx == liquidPhaseIdx) + { + // assume pure water if (Policy::useH2ODensityAsLiquidMixtureDensity()) - // assume pure water return H2O::liquidDensity(T, p); + + // See: Eq. (7) in Class et al. (2002a) + // This assumes each gas molecule displaces exactly one + // molecule in the liquid. else - { - // See: Eq. (7) in Class et al. (2002a) - // This assumes each gas molecule displaces exactly one - // molecule in the liquid. return H2O::liquidMolarDensity(T, p) * (fluidState.moleFraction(liquidPhaseIdx, H2OIdx)*H2O::molarMass() + fluidState.moleFraction(liquidPhaseIdx, N2Idx)*N2::molarMass() + fluidState.moleFraction(liquidPhaseIdx, O2Idx)*O2::molarMass()); - } } // gas phase - using std::max; - if (Policy::useIdealGasDensity()) + else if (phaseIdx == gasPhaseIdx) + { + // for the gas phase assume an ideal gas - return IdealGas::molarDensity(T, p) - * fluidState.averageMolarMass(gasPhaseIdx); - - // assume ideal mixture: steam, nitrogen and oxygen don't "see" each - // other - return H2O::gasDensity(T, fluidState.partialPressure(gasPhaseIdx, H2OIdx)) - + N2::gasDensity(T, fluidState.partialPressure(gasPhaseIdx, N2Idx)) - + O2::gasDensity(T, fluidState.partialPressure(gasPhaseIdx, O2Idx)); + using std::max; + if (Policy::useIdealGasDensity()) + return IdealGas::molarDensity(T, p) * fluidState.averageMolarMass(gasPhaseIdx); + + // assume ideal mixture: steam, nitrogen and oxygen don't "see" each other + else + return H2O::gasDensity(T, fluidState.partialPressure(gasPhaseIdx, H2OIdx)) + + N2::gasDensity(T, fluidState.partialPressure(gasPhaseIdx, N2Idx)) + + O2::gasDensity(T, fluidState.partialPressure(gasPhaseIdx, O2Idx)); + } + + DUNE_THROW(Dune::InvalidStateException, "Unknown phase index " << phaseIdx); } using Base::molarDensity; diff --git a/dumux/porousmediumflow/1pnc/indices.hh b/dumux/porousmediumflow/1pnc/indices.hh index 8cc311402979ae78dfc8430f27b8d395dd777ca5..385e3c63aeb7e6c8d7983bd4aca11cabc1b03146 100644 --- a/dumux/porousmediumflow/1pnc/indices.hh +++ b/dumux/porousmediumflow/1pnc/indices.hh @@ -34,15 +34,12 @@ namespace Dumux { * * \tparam phaseIdx The index of the fluid phase in the fluid system */ -template<int phaseIdx> struct OnePNCIndices { //! Reference index for mass conservation equation. static constexpr int conti0EqIdx = 0; //! Index for wetting/non-wetting phase pressure (depending on formulation) in a solution vector - static constexpr int pressureIdx = phaseIdx; - //! The index of the fluid phase in the fluid system - static constexpr int fluidSystemPhaseIdx = phaseIdx; + static constexpr int pressureIdx = 0; }; } // end namespace Dumux diff --git a/dumux/porousmediumflow/1pnc/model.hh b/dumux/porousmediumflow/1pnc/model.hh index 38ecb146255363bb06674ff4610fb287220cb2ec..80471fa7971af7c1de7fc6fe69501cf6daafaf1f 100644 --- a/dumux/porousmediumflow/1pnc/model.hh +++ b/dumux/porousmediumflow/1pnc/model.hh @@ -82,12 +82,11 @@ namespace Dumux { * consider a single-phase with multiple components. * * \tparam nComp the number of components to be considered. - * \tparam fluidSystemPhaseIdx The index of the fluid phase in the fluid system */ -template<int nComp, int fluidSystemPhaseIdx, bool useM, int repCompEqIdx = nComp> +template<int nComp, bool useM, int repCompEqIdx = nComp> struct OnePNCModelTraits { - using Indices = OnePNCIndices<fluidSystemPhaseIdx>; + using Indices = OnePNCIndices; static constexpr int numEq() { return nComp; } static constexpr int numPhases() { return 1; } @@ -145,7 +144,7 @@ SET_PROP(OnePNC, ModelTraits) private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); public: - using type = OnePNCModelTraits<FluidSystem::numComponents, GET_PROP_VALUE(TypeTag, PhaseIdx), GET_PROP_VALUE(TypeTag, UseMoles), GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx)>; + using type = OnePNCModelTraits<FluidSystem::numComponents, GET_PROP_VALUE(TypeTag, UseMoles), GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx)>; }; @@ -155,7 +154,8 @@ public: * appropriately for the model ((non-)isothermal, equilibrium, ...). * This can be done in the problem. */ -SET_PROP(OnePNC, FluidState){ +SET_PROP(OnePNC, FluidState) +{ private: using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); @@ -171,8 +171,8 @@ SET_TYPE_PROP(OnePNC, EffectiveDiffusivityModel, //! Use mole fractions in the balance equations by default SET_BOOL_PROP(OnePNC, UseMoles, true); -SET_INT_PROP(OnePNC, PhaseIdx, 0); //!< The default phase index -SET_TYPE_PROP(OnePNC, LocalResidual, CompositionalLocalResidual<TypeTag>); //!< The local residual function +//! The local residual function +SET_TYPE_PROP(OnePNC, LocalResidual, CompositionalLocalResidual<TypeTag>); //! Set the volume variables property SET_PROP(OnePNC, VolumeVariables) @@ -187,6 +187,8 @@ private: using PT = typename GET_PROP_TYPE(TypeTag, SpatialParams)::PermeabilityType; static_assert(FSY::numComponents == MT::numComponents(), "Number of components mismatch between model and fluid system"); static_assert(FST::numComponents == MT::numComponents(), "Number of components mismatch between model and fluid state"); + static_assert(FSY::numPhases == MT::numPhases(), "Number of phases mismatch between model and fluid system"); + static_assert(FST::numPhases == MT::numPhases(), "Number of phases mismatch between model and fluid state"); using Traits = OnePNCVolumeVariablesTraits<PV, FSY, FST, SSY, SST, PT, MT>; public: @@ -213,7 +215,7 @@ SET_PROP(OnePNCNI, ModelTraits) { private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); - using IsothermalTraits = OnePNCModelTraits<FluidSystem::numComponents, GET_PROP_VALUE(TypeTag, PhaseIdx), GET_PROP_VALUE(TypeTag, UseMoles), GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx)>; + using IsothermalTraits = OnePNCModelTraits<FluidSystem::numComponents, GET_PROP_VALUE(TypeTag, UseMoles), GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx)>; public: using type = PorousMediumFlowNIModelTraits<IsothermalTraits>; }; diff --git a/dumux/porousmediumflow/1pnc/volumevariables.hh b/dumux/porousmediumflow/1pnc/volumevariables.hh index b5b9f1eca8250d14de67d885b3e82f2ca7e90dbe..ca23fde92f897c24b4b6adbbb8feb9ec90ddde4d 100644 --- a/dumux/porousmediumflow/1pnc/volumevariables.hh +++ b/dumux/porousmediumflow/1pnc/volumevariables.hh @@ -56,13 +56,8 @@ class OnePNCVolumeVariables enum { - fluidSystemPhaseIdx = Idx::fluidSystemPhaseIdx, - // pressure primary variable index - pressureIdx = Idx::pressureIdx, - - // main component index - mainCompMoleOrMassFracIdx = fluidSystemPhaseIdx + pressureIdx = Idx::pressureIdx }; public: @@ -104,24 +99,11 @@ public: // Could be avoided if diffusion coefficients also // became part of the fluid state. typename FluidSystem::ParameterCache paramCache; - paramCache.updatePhase(fluidState_, fluidSystemPhaseIdx); + paramCache.updatePhase(fluidState_, 0); - int compIIdx = mainCompMoleOrMassFracIdx; - for (unsigned int compJIdx = 0; compJIdx < numFluidComps; ++compJIdx) - { - diffCoeff_[compJIdx] = 0.0; - if(compIIdx != compJIdx) - diffCoeff_[compJIdx] = FluidSystem::binaryDiffusionCoefficient(fluidState_, - paramCache, - fluidSystemPhaseIdx, - compIIdx, - compJIdx); - } - // The diffusion coefficients are swapped, the general procedure for the flux - // calculation always goes form phaseIdx = 0 to numPhaseIdx. - // Swapping the coefficients ensures that the diffusion coefficient for compIdx == 0 - // is always defined. - std::swap(diffCoeff_[0],diffCoeff_[mainCompMoleOrMassFracIdx]); + diffCoeff_[0] = 0.0; // the main component with itself doesn't have a binary diffusion coefficient + for (unsigned int compJIdx = 1; compJIdx < numFluidComps; ++compJIdx) + diffCoeff_[compJIdx] = FluidSystem::binaryDiffusionCoefficient(fluidState_, paramCache, 0, 0, compJIdx); } /*! @@ -144,45 +126,34 @@ public: { EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState); - fluidState.setSaturation(fluidSystemPhaseIdx, 1.); + fluidState.setSaturation(0, 1.0); const auto& priVars = elemSol[scv.localDofIndex()]; - fluidState.setPressure(fluidSystemPhaseIdx, priVars[pressureIdx]); - - // calculate the phase composition - Dune::FieldVector<Scalar, numFluidComps> moleFrac; - - Scalar sumMoleFracNotMainComp = 0; - for (int compIdx = 0; compIdx < numFluidComps; ++compIdx) - { - if (compIdx != mainCompMoleOrMassFracIdx) - { - moleFrac[compIdx] = priVars[compIdx]; - sumMoleFracNotMainComp += moleFrac[compIdx]; - } - } - moleFrac[mainCompMoleOrMassFracIdx] = 1- sumMoleFracNotMainComp; + fluidState.setPressure(0, priVars[pressureIdx]); // Set fluid state mole fractions - for (int compIdx = 0; compIdx < numFluidComps; ++compIdx) + Scalar sumMoleFracNotMainComp = 0; + for (int compIdx = 1; compIdx < numFluidComps; ++compIdx) { - fluidState.setMoleFraction(fluidSystemPhaseIdx, compIdx, moleFrac[compIdx]); + fluidState.setMoleFraction(0, compIdx, priVars[compIdx]); + sumMoleFracNotMainComp += priVars[compIdx]; } + fluidState.setMoleFraction(0, 0, 1.0 - sumMoleFracNotMainComp); typename FluidSystem::ParameterCache paramCache; paramCache.updateAll(fluidState); - Scalar rho = FluidSystem::density(fluidState, paramCache, fluidSystemPhaseIdx); - Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, fluidSystemPhaseIdx); - Scalar mu = FluidSystem::viscosity(fluidState, paramCache, fluidSystemPhaseIdx); + Scalar rho = FluidSystem::density(fluidState, paramCache, 0); + Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, 0); + Scalar mu = FluidSystem::viscosity(fluidState, paramCache, 0); - fluidState.setDensity(fluidSystemPhaseIdx, rho); - fluidState.setMolarDensity(fluidSystemPhaseIdx, rhoMolar); - fluidState.setViscosity(fluidSystemPhaseIdx, mu); + fluidState.setDensity(0, rho); + fluidState.setMolarDensity(0, rhoMolar); + fluidState.setViscosity(0, mu); // compute and set the enthalpy - Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, fluidSystemPhaseIdx); - fluidState.setEnthalpy(fluidSystemPhaseIdx, h); + Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, 0); + fluidState.setEnthalpy(0, h); } /*! @@ -204,9 +175,9 @@ public: * \note the phase index passed to this function is for compatibility reasons * with multiphasic models. */ - Scalar density(int phaseIdx = fluidSystemPhaseIdx) const + Scalar density(int phaseIdx = 0) const { - return fluidState_.density(fluidSystemPhaseIdx); + return fluidState_.density(0); } /*! @@ -215,9 +186,9 @@ public: * \note the phase index passed to this function is for compatibility reasons * with multiphasic models. */ - Scalar molarDensity(int phaseIdx = fluidSystemPhaseIdx) const + Scalar molarDensity(int phaseIdx = 0) const { - return fluidState_.molarDensity(fluidSystemPhaseIdx); + return fluidState_.molarDensity(0); } /*! @@ -226,7 +197,7 @@ public: * This method is here for compatibility reasons with other models. The saturation * is always 1.0 in a one-phasic context. */ - Scalar saturation(int phaseIdx = fluidSystemPhaseIdx) const + Scalar saturation(int phaseIdx = 0) const { return 1.0; } /*! @@ -242,7 +213,7 @@ public: { // make sure this is only called with admissible indices assert(compIdx < numFluidComps); - return fluidState_.moleFraction(fluidSystemPhaseIdx, compIdx); + return fluidState_.moleFraction(0, compIdx); } /*! @@ -258,7 +229,7 @@ public: { // make sure this is only called with admissible indices assert(compIdx < numFluidComps); - return fluidState_.massFraction(fluidSystemPhaseIdx, compIdx); + return fluidState_.massFraction(0, compIdx); } /*! @@ -270,9 +241,9 @@ public: * \note the phase index passed to this function is for compatibility reasons * with multiphasic models. */ - Scalar pressure(int phaseIdx = fluidSystemPhaseIdx) const + Scalar pressure(int phaseIdx = 0) const { - return fluidState_.pressure(fluidSystemPhaseIdx); + return fluidState_.pressure(0); } /*! @@ -294,9 +265,9 @@ public: * \note the phase index passed to this function is for compatibility reasons * with multiphasic models. */ - Scalar mobility(int phaseIdx = fluidSystemPhaseIdx) const + Scalar mobility(int phaseIdx = 0) const { - return 1.0/fluidState_.viscosity(fluidSystemPhaseIdx); + return 1.0/fluidState_.viscosity(0); } /*! @@ -306,9 +277,9 @@ public: * \note the phase index passed to this function is for compatibility reasons * with multiphasic models. */ - Scalar viscosity(int phaseIdx = fluidSystemPhaseIdx) const + Scalar viscosity(int phaseIdx = 0) const { - return fluidState_.viscosity(fluidSystemPhaseIdx); + return fluidState_.viscosity(0); } /*! @@ -319,9 +290,6 @@ public: /*! * \brief Return the binary diffusion coefficient \f$\mathrm{[m^2/s]}\f$ in the fluid. - * - * \note For fluidSystemPhaseIdx > 0, the diffusion coefficients - * diffCoeff_[0] and diffCoeff_[mainCompMoleOrMassFracIdx] are swapped */ Scalar diffusionCoefficient(int phaseIdx, int compIdx) const { @@ -337,7 +305,7 @@ public: Scalar molarity(int compIdx) const // [moles/m^3] { assert(compIdx < numFluidComps); - return fluidState_.molarity(fluidSystemPhaseIdx, compIdx); + return fluidState_.molarity(0, compIdx); } /*! @@ -348,7 +316,7 @@ public: Scalar massFraction(int compIdx) const { assert(compIdx < numFluidComps); - return this->fluidState_.massFraction(fluidSystemPhaseIdx, compIdx); + return this->fluidState_.massFraction(0, compIdx); } /*! @@ -362,10 +330,9 @@ protected: SolidState solidState_; private: - Scalar porosity_; //!< Effective porosity within the control volume - PermeabilityType permeability_; - Scalar density_; - Dune::FieldVector<Scalar, numFluidComps> diffCoeff_; + Scalar porosity_; //!< Effective porosity within the control volume + PermeabilityType permeability_; //!< Effective permeability within the control volume + Dune::FieldVector<Scalar, numFluidComps> diffCoeff_; //!< Binary diffusion coefficients }; } // end namespace Dumux diff --git a/dumux/porousmediumflow/1pnc/vtkoutputfields.hh b/dumux/porousmediumflow/1pnc/vtkoutputfields.hh index c2b3b3b1a3235488164d54b4f36049b9e1fd94dc..7ac20b20b52838652d0fc3e9ab415cb6dc0f424b 100644 --- a/dumux/porousmediumflow/1pnc/vtkoutputfields.hh +++ b/dumux/porousmediumflow/1pnc/vtkoutputfields.hh @@ -40,20 +40,19 @@ public: { using VolumeVariables = typename VtkOutputModule::VolumeVariables; using FluidSystem = typename VolumeVariables::FluidSystem; - using Indices = typename VolumeVariables::Indices; - vtk.addVolumeVariable([](const auto& volVars){ return volVars.pressure(Indices::fluidSystemPhaseIdx); }, "p"); - vtk.addVolumeVariable([](const auto& volVars){ return volVars.density(Indices::fluidSystemPhaseIdx); }, "rho"); - vtk.addVolumeVariable([](const auto& volVars){ return volVars.viscosity(Indices::fluidSystemPhaseIdx); }, "mu"); - vtk.addVolumeVariable([](const auto& volVars){ return volVars.pressure(Indices::fluidSystemPhaseIdx) - 1e5; }, "delp"); + vtk.addVolumeVariable([](const auto& volVars){ return volVars.pressure(0); }, "p"); + vtk.addVolumeVariable([](const auto& volVars){ return volVars.density(0); }, "rho"); + vtk.addVolumeVariable([](const auto& volVars){ return volVars.viscosity(0); }, "mu"); + vtk.addVolumeVariable([](const auto& volVars){ return volVars.pressure(0) - 1e5; }, "delp"); for (int i = 0; i < VolumeVariables::numComponents(); ++i) - vtk.addVolumeVariable([i](const auto& volVars){ return volVars.moleFraction(Indices::fluidSystemPhaseIdx, i); }, - "x^" + std::string(FluidSystem::componentName(i)) + "_" + std::string(FluidSystem::phaseName(Indices::fluidSystemPhaseIdx))); + vtk.addVolumeVariable([i](const auto& volVars){ return volVars.moleFraction(0, i); }, + "x^" + std::string(FluidSystem::componentName(i)) + "_" + std::string(FluidSystem::phaseName(0))); for (int i = 0; i < VolumeVariables::numComponents(); ++i) - vtk.addVolumeVariable([i](const auto& volVars){ return volVars.massFraction(Indices::fluidSystemPhaseIdx, i); }, - "X^" + std::string(FluidSystem::componentName(i))+ "_" + std::string(FluidSystem::phaseName(Indices::fluidSystemPhaseIdx))); + vtk.addVolumeVariable([i](const auto& volVars){ return volVars.massFraction(0, i); }, + "X^" + std::string(FluidSystem::componentName(i))+ "_" + std::string(FluidSystem::phaseName(0))); } }; diff --git a/test/material/fluidsystems/checkfluidsystem.hh b/test/material/fluidsystems/checkfluidsystem.hh index 7f8bb33017709a33b278681af3dce6b0279593f3..4643fa5a2ee4e8194b95195994d1df8c503dbf42 100644 --- a/test/material/fluidsystems/checkfluidsystem.hh +++ b/test/material/fluidsystems/checkfluidsystem.hh @@ -28,6 +28,9 @@ #ifndef DUMUX_CHECK_FLUIDSYSTEM_HH #define DUMUX_CHECK_FLUIDSYSTEM_HH +#include <exception> +#include <string> + #include <dune/common/classname.hh> // include all fluid systems in dumux-stable @@ -523,25 +526,25 @@ int checkFluidSystem() try { val = FluidSystem::density(fs, paramCache, phaseIdx); - } catch (Dune::Exception& e) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::density() throws exception!\n"; + collectedErrors += "error: FluidSystem::density() throws exception: " + std::string(e.what()) + "\n"; } try { val = FluidSystem::molarDensity(fs, paramCache, phaseIdx); - } catch (Dune::Exception& e) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::molarDensity() throws exception!\n"; + collectedErrors += "error: FluidSystem::molarDensity() throws exception: " + std::string(e.what()) + "\n"; } fs.allowPressure(true); fs.allowDensity(true); try { val = FluidSystem::viscosity(fs, paramCache, phaseIdx); - } catch (...) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::viscosity() throws exception!\n"; + collectedErrors += "error: FluidSystem::viscosity() throws exception: " + std::string(e.what()) + "\n"; } try { @@ -549,9 +552,9 @@ int checkFluidSystem() } catch (Dune::NotImplemented&) { collectedWarnings += "warning: FluidSystem::enthalpy() is not implemented\n"; - } catch (...) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::enthalpy() throws exception!\n"; + collectedErrors += "error: FluidSystem::enthalpy() throws exception: " + std::string(e.what()) + "\n"; } try { @@ -559,9 +562,9 @@ int checkFluidSystem() } catch (Dune::NotImplemented&) { collectedWarnings += "warning: FluidSystem::heatCapacity() is not implemented\n"; - } catch (...) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::heatCapacity() throws exception!\n"; + collectedErrors += "error: FluidSystem::heatCapacity() throws exception: " + std::string(e.what()) + "\n"; } try { @@ -569,9 +572,9 @@ int checkFluidSystem() } catch (Dune::NotImplemented&) { collectedWarnings += "warning: FluidSystem::thermalConductivity() is not implemented\n"; - } catch (...) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::thermalConductivity() throws exception!\n"; + collectedErrors += "error: FluidSystem::thermalConductivity() throws exception: " + std::string(e.what()) + "\n"; } for (int compIdx = 0; compIdx < numComponents; ++compIdx) @@ -583,9 +586,9 @@ int checkFluidSystem() } catch (Dune::NotImplemented&) { collectedWarnings += "warning: FluidSystem::fugacityCoefficient() is not implemented\n"; - } catch (...) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::fugacityCoefficient() throws exception!\n"; + collectedErrors += "error: FluidSystem::fugacityCoefficient() throws exception: " + std::string(e.what()) + "\n"; } fs.allowComposition(true); try @@ -597,9 +600,9 @@ int checkFluidSystem() } catch (Dune::InvalidStateException&) { collectedWarnings += "warning: FluidSystem::diffusionCoefficient() gives invalid state exception\n"; - } catch (...) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::diffusionCoefficient() throws exception!\n"; + collectedErrors += "error: FluidSystem::diffusionCoefficient() throws exception: " + std::string(e.what()) + "\n"; } for (int comp2Idx = 0; comp2Idx < numComponents; ++comp2Idx) { @@ -612,9 +615,9 @@ int checkFluidSystem() } catch (Dune::InvalidStateException&) { collectedWarnings += "warning: FluidSystem::binaryDiffusionCoefficient() gives invalid state exception\n"; - } catch (...) + } catch (const std::exception& e) { - collectedErrors += "error: FluidSystem::binaryDiffusionCoefficient() throws exception!\n"; + collectedErrors += "error: FluidSystem::binaryDiffusionCoefficient() throws exception: " + std::string(e.what()) + "\n"; } } } diff --git a/test/material/fluidsystems/test_fluidsystems.cc b/test/material/fluidsystems/test_fluidsystems.cc index 3c514c2e14fbd24dff71d93a81fadc338675027d..89bcf647907fab134eff9fa9b40104c2addcd74e 100644 --- a/test/material/fluidsystems/test_fluidsystems.cc +++ b/test/material/fluidsystems/test_fluidsystems.cc @@ -28,18 +28,19 @@ // include all fluid systems in dumux-stable #include <dumux/material/fluidsystems/2pimmiscible.hh> +#include <dumux/material/fluidsystems/1padapter.hh> +#include <dumux/material/fluidsystems/1pgas.hh> +#include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/fluidsystems/base.hh> #include <dumux/material/fluidsystems/brine.hh> #include <dumux/material/fluidsystems/brineair.hh> #include <dumux/material/fluidsystems/brineco2.hh> -#include <dumux/material/fluidsystems/1pgas.hh> #include <dumux/material/fluidsystems/h2oair.hh> #include <dumux/material/fluidsystems/h2oairmesitylene.hh> #include <dumux/material/fluidsystems/h2oairxylene.hh> #include <dumux/material/fluidsystems/h2on2.hh> #include <dumux/material/fluidsystems/h2on2kinetic.hh> #include <dumux/material/fluidsystems/h2on2o2.hh> -#include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/fluidsystems/spe5.hh> // include all fluid states @@ -204,5 +205,16 @@ int main() { using FluidSystem = FluidSystems::Spe5<Scalar>; success += checkFluidSystem<Scalar, FluidSystem>(); } + // 1p adapter + { using FluidSystem = FluidSystems::OnePAdapter<FluidSystems::TwoPImmiscible<Scalar, Gas, Liquid>, 0>; + success += checkFluidSystem<Scalar, FluidSystem>(); } + { using FluidSystem = FluidSystems::OnePAdapter<FluidSystems::TwoPImmiscible<Scalar, Gas, Liquid>, 1>; + success += checkFluidSystem<Scalar, FluidSystem>(); } + { using H2OType = Components::TabulatedComponent<Components::H2O<Scalar>>; + using FluidSystem = FluidSystems::OnePAdapter<FluidSystems::H2OAir<Scalar, H2OType>, 0>; + success += checkFluidSystem<Scalar, FluidSystem>(); } + { using FluidSystem = FluidSystems::OnePAdapter<FluidSystems::H2ON2O2<Scalar>, 1>; + success += checkFluidSystem<Scalar, FluidSystem>(); } + return success; } diff --git a/test/porousmediumflow/1pnc/implicit/1p2cniconductionproblem.hh b/test/porousmediumflow/1pnc/implicit/1p2cniconductionproblem.hh index aebaf03ff26638561ac4e413b6bee723b044dc58..e720bbccf4bf8a52ed035e6c95972b991b6af810 100644 --- a/test/porousmediumflow/1pnc/implicit/1p2cniconductionproblem.hh +++ b/test/porousmediumflow/1pnc/implicit/1p2cniconductionproblem.hh @@ -37,6 +37,7 @@ #include <dumux/porousmediumflow/1pnc/model.hh> #include <dumux/porousmediumflow/problem.hh> +#include <dumux/material/fluidsystems/1padapter.hh> #include <dumux/material/fluidsystems/h2on2.hh> #include <dumux/material/components/h2o.hh> #include "1pnctestspatialparams.hh" @@ -65,9 +66,12 @@ SET_TYPE_PROP(OnePTwoCNIConductionTypeTag, Grid, Dune::YaspGrid<2>); SET_TYPE_PROP(OnePTwoCNIConductionTypeTag, Problem, OnePTwoCNIConductionProblem<TypeTag>); // Set fluid configuration -SET_TYPE_PROP(OnePTwoCNIConductionTypeTag, - FluidSystem, - FluidSystems::H2ON2<typename GET_PROP_TYPE(TypeTag, Scalar)>); +SET_PROP(OnePTwoCNIConductionTypeTag, FluidSystem) +{ + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + using H2ON2 = FluidSystems::H2ON2<Scalar, FluidSystems::H2ON2DefaultPolicy</*simplified=*/true>>; + using type = FluidSystems::OnePAdapter<H2ON2, H2ON2::liquidPhaseIdx>; +}; // Set the spatial parameters SET_TYPE_PROP(OnePTwoCNIConductionTypeTag, SpatialParams, OnePNCTestSpatialParams<TypeTag>); @@ -126,6 +130,8 @@ class OnePTwoCNIConductionProblem : public PorousMediumFlowProblem<TypeTag> // indices of the primary variables pressureIdx = Indices::pressureIdx, temperatureIdx = Indices::temperatureIdx, + + N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx) }; //! property that defines whether mole or mass fractions are used @@ -304,7 +310,7 @@ private: { PrimaryVariables priVars; priVars[pressureIdx] = 1e5; // initial condition for the pressure - priVars[FluidSystem::N2Idx] = 1e-5; // initial condition for the N2 molefraction + priVars[N2Idx] = 1e-5; // initial condition for the N2 molefraction priVars[temperatureIdx] = 290.; return priVars; } diff --git a/test/porousmediumflow/1pnc/implicit/1p2cniconvectionproblem.hh b/test/porousmediumflow/1pnc/implicit/1p2cniconvectionproblem.hh index a3a76a8afc7700169d947a63d67f48c2f132f312..52b75eaf85a70c71947c2b5afdc41ec0b4a9df86 100644 --- a/test/porousmediumflow/1pnc/implicit/1p2cniconvectionproblem.hh +++ b/test/porousmediumflow/1pnc/implicit/1p2cniconvectionproblem.hh @@ -37,6 +37,7 @@ #include <dumux/porousmediumflow/1pnc/model.hh> #include <dumux/porousmediumflow/problem.hh> +#include <dumux/material/fluidsystems/1padapter.hh> #include <dumux/material/fluidsystems/h2on2.hh> #include <dumux/material/components/h2o.hh> #include "1pnctestspatialparams.hh" @@ -65,9 +66,12 @@ SET_TYPE_PROP(OnePTwoCNIConvectionTypeTag, Grid, Dune::YaspGrid<2>); SET_TYPE_PROP(OnePTwoCNIConvectionTypeTag, Problem, OnePTwoCNIConvectionProblem<TypeTag>); // Set fluid configuration -SET_TYPE_PROP(OnePTwoCNIConvectionTypeTag, - FluidSystem, - FluidSystems::H2ON2<typename GET_PROP_TYPE(TypeTag, Scalar)>); +SET_PROP(OnePTwoCNIConvectionTypeTag, FluidSystem) +{ + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + using H2ON2 = FluidSystems::H2ON2<Scalar, FluidSystems::H2ON2DefaultPolicy</*simplified=*/true>>; + using type = FluidSystems::OnePAdapter<H2ON2, H2ON2::liquidPhaseIdx>; +}; // Set the spatial parameters SET_TYPE_PROP(OnePTwoCNIConvectionTypeTag, SpatialParams, OnePNCTestSpatialParams<TypeTag>); @@ -129,9 +133,13 @@ class OnePTwoCNIConvectionProblem : public PorousMediumFlowProblem<TypeTag> pressureIdx = Indices::pressureIdx, temperatureIdx = Indices::temperatureIdx, - // equation indices - contiH2OIdx = Indices::conti0EqIdx + FluidSystem::H2OIdx, - contiN2Idx = Indices::conti0EqIdx + FluidSystem::N2Idx, + // component indices + H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx), + N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx), + + // indices of the equations + contiH2OEqIdx = Indices::conti0EqIdx + H2OIdx, + contiN2EqIdx = Indices::conti0EqIdx + N2Idx, energyEqIdx = Indices::energyEqIdx }; @@ -295,8 +303,8 @@ public: if(globalPos[0] < eps_) { - flux[contiH2OIdx] = -darcyVelocity_*elemVolVars[scv].molarDensity(); - flux[contiN2Idx] = -darcyVelocity_*elemVolVars[scv].molarDensity()*elemVolVars[scv].moleFraction(0, FluidSystem::N2Idx); + flux[contiH2OEqIdx] = -darcyVelocity_*elemVolVars[scv].molarDensity(); + flux[contiN2EqIdx] = -darcyVelocity_*elemVolVars[scv].molarDensity()*elemVolVars[scv].moleFraction(0, N2Idx); flux[energyEqIdx] = -darcyVelocity_ *elemVolVars[scv].density() *IapwsH2O::liquidEnthalpy(temperatureHigh_, elemVolVars[scv].pressure()); @@ -345,7 +353,7 @@ private: { PrimaryVariables priVars; priVars[pressureIdx] = pressureLow_; // initial condition for the pressure - priVars[FluidSystem::N2Idx] = 1e-10; // initial condition for the N2 molefraction + priVars[N2Idx] = 1e-10; // initial condition for the N2 molefraction priVars[temperatureIdx] = temperatureLow_; return priVars; } diff --git a/test/porousmediumflow/1pnc/implicit/1p2ctestproblem.hh b/test/porousmediumflow/1pnc/implicit/1p2ctestproblem.hh index cd01f340f71c855906fba2286ce989bc6434fee0..9f76cef50cc93e510dff0ce669a286e43203a9b5 100644 --- a/test/porousmediumflow/1pnc/implicit/1p2ctestproblem.hh +++ b/test/porousmediumflow/1pnc/implicit/1p2ctestproblem.hh @@ -39,16 +39,17 @@ #include <dumux/porousmediumflow/problem.hh> #include <dumux/material/fluidsystems/h2on2.hh> +#include <dumux/material/fluidsystems/1padapter.hh> + #include "1pnctestspatialparams.hh" -namespace Dumux -{ +namespace Dumux { template <class TypeTag> class OnePTwoCTestProblem; -namespace Properties -{ +namespace Properties { + NEW_TYPE_TAG(OnePTwoCTestTypeTag, INHERITS_FROM(OnePNC)); NEW_TYPE_TAG(OnePTwoCTestBoxTypeTag, INHERITS_FROM(BoxModel, OnePTwoCTestTypeTag)); NEW_TYPE_TAG(OnePTwoCTestCCTpfaTypeTag, INHERITS_FROM(CCTpfaModel, OnePTwoCTestTypeTag)); @@ -65,9 +66,12 @@ SET_TYPE_PROP(OnePTwoCTestTypeTag, Grid, Dune::YaspGrid<2>); SET_TYPE_PROP(OnePTwoCTestTypeTag, Problem, OnePTwoCTestProblem<TypeTag>); // Set fluid configuration -SET_TYPE_PROP(OnePTwoCTestTypeTag, - FluidSystem, - FluidSystems::H2ON2<typename GET_PROP_TYPE(TypeTag, Scalar), FluidSystems::H2ON2DefaultPolicy</*fastButSimplifiedRelations=*/true>>); +SET_PROP(OnePTwoCTestTypeTag, FluidSystem) +{ + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + using H2ON2 = FluidSystems::H2ON2<Scalar, FluidSystems::H2ON2DefaultPolicy</*simplified=*/true>>; + using type = FluidSystems::OnePAdapter<H2ON2, H2ON2::liquidPhaseIdx>; +}; // Set the spatial parameters SET_TYPE_PROP(OnePTwoCTestTypeTag, SpatialParams, OnePNCTestSpatialParams<TypeTag>); @@ -125,9 +129,13 @@ class OnePTwoCTestProblem : public PorousMediumFlowProblem<TypeTag> // indices of the primary variables pressureIdx = Indices::pressureIdx, + // component indices + H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx), + N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx), + // indices of the equations - contiH2OEqIdx = Indices::conti0EqIdx + FluidSystem::H2OIdx, - contiN2EqIdx = Indices::conti0EqIdx + FluidSystem::N2Idx + contiH2OEqIdx = Indices::conti0EqIdx + H2OIdx, + contiN2EqIdx = Indices::conti0EqIdx + N2Idx }; //! property that defines whether mole or mass fractions are used @@ -202,7 +210,7 @@ public: // condition for the N2 molefraction at left boundary if (globalPos[0] < eps_ ) { - values[FluidSystem::N2Idx] = 2.0e-5; + values[N2Idx] = 2.0e-5; } return values; @@ -248,8 +256,8 @@ public: if(isBox && useNitscheTypeBc_) { flux[contiH2OEqIdx] = (volVars.pressure() - dirichletPressure) * 1e7; - flux[contiN2EqIdx] = flux[contiH2OEqIdx] * (useMoles ? volVars.moleFraction(0, FluidSystem::N2Idx) : - volVars.massFraction(0, FluidSystem::N2Idx)); + flux[contiN2EqIdx] = flux[contiH2OEqIdx] * (useMoles ? volVars.moleFraction(0, N2Idx) : + volVars.massFraction(0, N2Idx)); return flux; } @@ -296,7 +304,7 @@ public: flux[contiH2OEqIdx] = tpfaFlux; // emulate an outflow condition for the component transport on the right side - flux[contiN2EqIdx] = tpfaFlux * (useMoles ? volVars.moleFraction(0, FluidSystem::N2Idx) : volVars.massFraction(0, FluidSystem::N2Idx)); + flux[contiN2EqIdx] = tpfaFlux * (useMoles ? volVars.moleFraction(0, N2Idx) : volVars.massFraction(0, N2Idx)); return flux; } @@ -341,7 +349,7 @@ private: { PrimaryVariables priVars; priVars[pressureIdx] = 2e5 - 1e5*globalPos[0]; // initial condition for the pressure - priVars[FluidSystem::N2Idx] = 0.0; // initial condition for the N2 molefraction + priVars[N2Idx] = 0.0; // initial condition for the N2 molefraction return priVars; } static constexpr Scalar eps_ = 1e-6; diff --git a/test/porousmediumflow/1pnc/implicit/test_1p2c_fv.cc b/test/porousmediumflow/1pnc/implicit/test_1p2c_fv.cc index 9d795a197585ee7d9ab56bcceea73036fa8b8051..2259a2af781a7e873a24afa3bcfaf34cef339124 100644 --- a/test/porousmediumflow/1pnc/implicit/test_1p2c_fv.cc +++ b/test/porousmediumflow/1pnc/implicit/test_1p2c_fv.cc @@ -111,7 +111,7 @@ int main(int argc, char** argv) try auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); // intialize the vtk output module - VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); + VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); VtkOutputFields::init(vtkWriter); //!< Add model specific output fields vtkWriter.write(0.0); diff --git a/test/porousmediumflow/1pnc/implicit/test_1p2cni_conduction_fv.cc b/test/porousmediumflow/1pnc/implicit/test_1p2cni_conduction_fv.cc index f61f996cc770a3f09b52bfc78af7b6da0ffd5cd0..52bf9985fedd9652bcd66fd185d2d3581012407b 100644 --- a/test/porousmediumflow/1pnc/implicit/test_1p2cni_conduction_fv.cc +++ b/test/porousmediumflow/1pnc/implicit/test_1p2cni_conduction_fv.cc @@ -110,7 +110,7 @@ int main(int argc, char** argv) try auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); // intialize the vtk output module - VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); + VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); VtkOutputFields::init(vtkWriter); //!< Add model specific output fields vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); diff --git a/test/porousmediumflow/1pnc/implicit/test_1p2cni_convection_fv.cc b/test/porousmediumflow/1pnc/implicit/test_1p2cni_convection_fv.cc index 1a555df69cff3ad1f2b8d70860e3ecf3ca3ef261..418edee9af223d02821644a78bb7177270b87dfb 100644 --- a/test/porousmediumflow/1pnc/implicit/test_1p2cni_convection_fv.cc +++ b/test/porousmediumflow/1pnc/implicit/test_1p2cni_convection_fv.cc @@ -110,7 +110,7 @@ int main(int argc, char** argv) try auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); // intialize the vtk output module - VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); + VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); VtkOutputFields::init(vtkWriter); //!< Add model specific output fields vtkWriter.addField(problem->getExactTemperature(), "temperatureExact");