From 878f53a149e5efee0ee91cbf22635b0e3bc120fe Mon Sep 17 00:00:00 2001 From: Simon Scholz <simon.scholz@iws.uni-stuttgart.de> Date: Wed, 29 Aug 2018 12:25:51 +0200 Subject: [PATCH] [brineco2][tests] disable brineco2-test phase restriction and make brineco2 non-ideal mixture --- dumux/material/fluidsystems/brineco2.hh | 4 ++-- .../material/fluidsystems/checkfluidsystem.hh | 19 +++++++++++++------ .../fluidsystems/test_fluidsystems.cc | 16 ++++++++++------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dumux/material/fluidsystems/brineco2.hh b/dumux/material/fluidsystems/brineco2.hh index 6adc767dc0..800cecd550 100644 --- a/dumux/material/fluidsystems/brineco2.hh +++ b/dumux/material/fluidsystems/brineco2.hh @@ -250,8 +250,8 @@ public: static bool isIdealMixture(int phaseIdx) { assert(0 <= phaseIdx && phaseIdx < numPhases); - if (!useConstantSalinity && phaseIdx == liquidPhaseIdx) - return VariableSalinityBrine::isIdealMixture(VariableSalinityBrine::liquidPhaseIdx); + if (phaseIdx == liquidPhaseIdx) + return false; return true; } diff --git a/test/material/fluidsystems/checkfluidsystem.hh b/test/material/fluidsystems/checkfluidsystem.hh index 857ed16982..3e972f2fef 100644 --- a/test/material/fluidsystems/checkfluidsystem.hh +++ b/test/material/fluidsystems/checkfluidsystem.hh @@ -89,10 +89,7 @@ public: BaseFluidState::setMolarDensity(phaseIdx, 1.0); for (int compIdx = 0; compIdx < numComponents; ++compIdx) - { BaseFluidState::setMoleFraction(phaseIdx, compIdx, 1.0 / numComponents); - - } } // initially, do not allow anything @@ -398,8 +395,16 @@ int checkFluidState(const BaseFluidState &fs) } } +/*! + * \brief This is a consistency check for FluidSystems. + * \param enablePhaseRestriction Parameter passed to the fluidState. If set to true, + * the fluidState will only allow calls to properties of the current phase. + * \note While this is very common, it is not necessarily the case for all FluidSystems. + * We keep this, because it might help finding mistakes in FluidSystems that have this invariant. + * If you verified that a fluid system does not have this invariant you can set this option to false. + */ template<class Scalar, class FluidSystem> -int checkFluidSystem() +int checkFluidSystem(bool enablePhaseRestriction = true) { int success = 0; std::cout << "Testing fluid system '" << Dune::className<FluidSystem>() << "'\n"; @@ -460,7 +465,8 @@ int checkFluidSystem() for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - fs.restrictToPhase(phaseIdx); + if (enablePhaseRestriction) + fs.restrictToPhase(phaseIdx); try { paramCache.updatePhase(fs, phaseIdx); @@ -519,10 +525,11 @@ int checkFluidSystem() // actually check the fluid system API for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - fs.restrictToPhase(phaseIdx); fs.allowPressure(FluidSystem::isCompressible(phaseIdx)); fs.allowComposition(true); fs.allowDensity(false); + if (enablePhaseRestriction) + fs.restrictToPhase(phaseIdx); try { val = FluidSystem::density(fs, paramCache, phaseIdx); diff --git a/test/material/fluidsystems/test_fluidsystems.cc b/test/material/fluidsystems/test_fluidsystems.cc index 4befb937b0..5ce0d7d5f4 100644 --- a/test/material/fluidsystems/test_fluidsystems.cc +++ b/test/material/fluidsystems/test_fluidsystems.cc @@ -149,30 +149,34 @@ int main() success += checkFluidSystem<Scalar, FluidSystem>(); } // Brine -- CO2 + // BrineCO2 does not fulfill the restrictToPhase-assertion where we assume that for all + // functions depending on a phase index only fluid properties of this phase are used + // that is why checkFluidSystem() needs to be called with "false" here + // see checkFLuidSystem documentation! { using H2OType = Components::SimpleH2O<Scalar>; using FluidSystem = FluidSystems::BrineCO2< Scalar, HeterogeneousCO2Tables::CO2Tables, H2OType, FluidSystems::BrineCO2DefaultPolicy</*useConstantSalinity=*/true> >; - success += checkFluidSystem<Scalar, FluidSystem>(); } + success += checkFluidSystem<Scalar, FluidSystem>( false ); } { using H2OType = Components::SimpleH2O<Scalar>; using FluidSystem = FluidSystems::BrineCO2< Scalar, HeterogeneousCO2Tables::CO2Tables, H2OType, FluidSystems::BrineCO2DefaultPolicy</*useConstantSalinity=*/false> >; - success += checkFluidSystem<Scalar, FluidSystem>(); } + success += checkFluidSystem<Scalar, FluidSystem>( false ); } { using H2OType = Components::H2O<Scalar>; using FluidSystem = FluidSystems::BrineCO2< Scalar, HeterogeneousCO2Tables::CO2Tables, H2OType, FluidSystems::BrineCO2DefaultPolicy</*useConstantSalinity=*/true> >; - success += checkFluidSystem<Scalar, FluidSystem>(); } + success += checkFluidSystem<Scalar, FluidSystem>( false ); } { using H2OType = Components::H2O<Scalar>; using FluidSystem = FluidSystems::BrineCO2< Scalar, HeterogeneousCO2Tables::CO2Tables, H2OType, FluidSystems::BrineCO2DefaultPolicy</*useConstantSalinity=*/false> >; - success += checkFluidSystem<Scalar, FluidSystem>(); } + success += checkFluidSystem<Scalar, FluidSystem>( false ); } { using H2OType = Components::TabulatedComponent<Components::H2O<Scalar>>; using FluidSystem = FluidSystems::BrineCO2< Scalar, HeterogeneousCO2Tables::CO2Tables, H2OType, FluidSystems::BrineCO2DefaultPolicy</*useConstantSalinity=*/true> >; - success += checkFluidSystem<Scalar, FluidSystem>(); } + success += checkFluidSystem<Scalar, FluidSystem>( false ); } { using H2OType = Components::TabulatedComponent<Components::H2O<Scalar>>; using FluidSystem = FluidSystems::BrineCO2< Scalar, HeterogeneousCO2Tables::CO2Tables, H2OType, FluidSystems::BrineCO2DefaultPolicy</*useConstantSalinity=*/false> >; - success += checkFluidSystem<Scalar, FluidSystem>(); } + success += checkFluidSystem<Scalar, FluidSystem>( false ); } // H2O -- Air { using H2OType = Components::SimpleH2O<Scalar>; -- GitLab