diff --git a/dumux/material/fluidsystems/brineco2.hh b/dumux/material/fluidsystems/brineco2.hh index 6adc767dc064908cc9c7406b4ae14650a48de3e1..800cecd550a9a7e0d011cd105ab8c53c661629fc 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 857ed169829e9a099c955e90906dbaa2b4e15297..3e972f2fefb8b4be6eabd6f494b737dda9ada7d4 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 4befb937b0c47dad1d62991f35c06920e55b61f9..5ce0d7d5f4b67861b929d8c786880c46f87acbf8 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>;