diff --git a/test/material/components/CMakeLists.txt b/test/material/components/CMakeLists.txt index 602a9a406f5d27aab36ef36edf49a52135a51a81..5db2de41a365e50fa8ea600b9dbadd7601ff21c6 100644 --- a/test/material/components/CMakeLists.txt +++ b/test/material/components/CMakeLists.txt @@ -7,6 +7,10 @@ dumux_add_test(SOURCES test_componenttraits.cc add_executable(plot_component plotproperties.cc) +dumux_add_test(NAME test_h2o_simpleh2o_consistency + SOURCES test_h2o_simpleh2o_consistency.cc + LABELS unit material) + dumux_add_test(NAME plot_air TARGET plot_component COMMAND ./plot_component diff --git a/test/material/components/test_h2o_simpleh2o_consistency.cc b/test/material/components/test_h2o_simpleh2o_consistency.cc new file mode 100644 index 0000000000000000000000000000000000000000..050ec92677e5835162e84344682bee4f93d16e5c --- /dev/null +++ b/test/material/components/test_h2o_simpleh2o_consistency.cc @@ -0,0 +1,45 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +// +// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder +// SPDX-License-Identifier: GPL-3.0-or-later +// +/*! + * \file + * \ingroup MaterialTests + * \brief Test some components for consistency of their physical properties. + */ + +#include "config.h" + +#include <cmath> +#include <dune/common/exceptions.hh> +#include <dumux/material/components/h2o.hh> +#include <dumux/material/components/simpleh2o.hh> + +int main(int argc, char *argv[]) +{ + using namespace Dumux; + + // See the currently allowed range in simpleh2O.hh + constexpr double lowerTemperatureBound = 273.15 + 0.0; // 0°C + constexpr double upperTemperatureBound = 273.15 + 150.0; // 150°C + constexpr int nTemperatures = 20; + constexpr double pressure = 1.0e5; // 1 bar + + for (int i = 0; i < nTemperatures; ++i) + { + const double temperature = lowerTemperatureBound + (upperTemperatureBound - lowerTemperatureBound) * i / (nTemperatures - 1); + const double simpleH2OGasEnthalpy = Components::SimpleH2O<double>::gasEnthalpy(temperature, pressure); + const double h2OGasEnthalpy = Components::H2O<double>::gasEnthalpy(temperature, pressure); + // compare the two gas enthalpies + const double relDiff = (simpleH2OGasEnthalpy - h2OGasEnthalpy) / h2OGasEnthalpy; + const double relTol = 0.05; // We allow a relative error of 5% + if (std::abs(relDiff) > relTol) { + DUNE_THROW(Dune::Exception, "The gas enthalpy of the simple H2O component is not consistent with the H2O component. " + << "The relative difference " << relDiff << " at temperature " << temperature << " K." + << " is larger than the relative tolerance " << relTol << "."); + } + } + return 0; +}