diff --git a/dumux/material/components/nacl.hh b/dumux/material/components/nacl.hh index c2ccceacfceb6ed4159c41656d127a50bfd2ff69..cb7d7d62528c013eb8e974aa39575b518f37f573 100644 --- a/dumux/material/components/nacl.hh +++ b/dumux/material/components/nacl.hh @@ -88,6 +88,17 @@ public: { return 50.50; } + + /*! + * \brief Thermal conductivity of the component \f$\mathrm{[W/(m*K)]}\f$ as a solid. + * \param temperature temperature of component in \f$\mathrm{[K]}\f$ + */ + static Scalar solidThermalConductivity(Scalar temperature) + { + return 6.49; + } + + }; } // end namespace Components diff --git a/dumux/material/solidsystems/compositionalsolidphase.hh b/dumux/material/solidsystems/compositionalsolidphase.hh index 2e8f47a444dda7ec4f3d8d3849532150ecf771f4..a65ffab1769c29feff8df30fe79a856d4e6b604b 100644 --- a/dumux/material/solidsystems/compositionalsolidphase.hh +++ b/dumux/material/solidsystems/compositionalsolidphase.hh @@ -24,6 +24,9 @@ #ifndef DUMUX_SOLIDSYSTEMS_COMPOSITIONAL_SOLID_PHASE_HH #define DUMUX_SOLIDSYSTEMS_COMPOSITIONAL_SOLID_PHASE_HH +#include <string> +#include <dune/common/exceptions.hh> + namespace Dumux { namespace SolidSystems { @@ -62,8 +65,8 @@ public: { case comp0Idx: return ComponentOne::name(); case comp1Idx: return ComponentTwo::name(); + default: DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx); } - DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx); } /*! @@ -93,8 +96,8 @@ public: { case comp0Idx: return ComponentOne::molarMass(); case comp1Idx: return ComponentTwo::molarMass(); + default: DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx); } - DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx); } /*! @@ -122,8 +125,8 @@ public: { case comp0Idx: return ComponentOne::solidDensity(solidState.temperature()); case comp1Idx: return ComponentTwo::solidDensity(solidState.temperature()); + default: DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx); } - DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx); } /*! @@ -136,8 +139,8 @@ public: { case comp0Idx: return ComponentOne::solidDensity(solidState.temperature())/ComponentOne::molarMass(); case comp1Idx: return ComponentTwo::solidDensity(solidState.temperature())/ComponentTwo::molarMass(); + default: DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx); } - DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx); } /*! diff --git a/dumux/material/solidsystems/inertsolidphase.hh b/dumux/material/solidsystems/inertsolidphase.hh index 6bc676eb6b428788ce3ac53ad4c50c46b62c65b9..d93028eb4355e66a9e3faab863630c21f7e07b2d 100644 --- a/dumux/material/solidsystems/inertsolidphase.hh +++ b/dumux/material/solidsystems/inertsolidphase.hh @@ -24,6 +24,9 @@ #ifndef DUMUX_SOLIDSYSTEMS_INERT_SOLID_PHASE_HH #define DUMUX_SOLIDSYSTEMS_INERT_SOLID_PHASE_HH +#include <string> +#include <dune/common/exceptions.hh> + namespace Dumux { namespace SolidSystems { diff --git a/test/material/CMakeLists.txt b/test/material/CMakeLists.txt index eb5c90ff7b890e80a219fc9283da8f38ea24304b..5abaffabd3ab265815723a27eccabe2976be36bc 100644 --- a/test/material/CMakeLists.txt +++ b/test/material/CMakeLists.txt @@ -4,5 +4,6 @@ add_subdirectory("fluidmatrixinteractions") add_subdirectory("immiscibleflash") add_subdirectory("ncpflash") add_subdirectory("pengrobinson") +add_subdirectory("solidsystems") add_subdirectory("tabulation") diff --git a/test/material/solidsystems/CMakeLists.txt b/test/material/solidsystems/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..58662ab8fb8cdde02ccde5ca17e6bae6af5d3767 --- /dev/null +++ b/test/material/solidsystems/CMakeLists.txt @@ -0,0 +1,7 @@ +dune_add_test(SOURCES test_solidsystems.cc) + +#install sources +install(FILES +checksolidsystem.hh +test_solidsystems.cc +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/test/material/solidsystems) diff --git a/test/material/solidsystems/checksolidsystem.hh b/test/material/solidsystems/checksolidsystem.hh new file mode 100644 index 0000000000000000000000000000000000000000..30b7752c30c9e9d2de9f65965867d0d0032f9069 --- /dev/null +++ b/test/material/solidsystems/checksolidsystem.hh @@ -0,0 +1,140 @@ +// -*- 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 + * + * \brief This file provides the actual code for the solid systems + * test. + * + * It is not directly in test_solidsystems.cc so that external modules + * like dumux-devel can use it easily + */ +#ifndef DUMUX_CHECK_SOLIDSYSTEM_HH +#define DUMUX_CHECK_SOLIDSYSTEM_HH + +#include <type_traits> + +#include <dune/common/classname.hh> +#include <dune/common/unused.hh> +#include <dune/common/exceptions.hh> + +// include all solid states +#include <dumux/material/solidstates/inertsolidstate.hh> +#include <dumux/material/solidstates/compositionalsolidstate.hh> + +namespace Dumux { + +template<class Scalar, class SolidSystem> +int checkSolidSystem() +{ + static_assert((SolidSystem::isInert() && SolidSystem::numInertComponents == SolidSystem::numComponents) + || !SolidSystem::isInert(), "numInertComponents == numComponents has to be equal to SolidSystem::isInert()"); + + // inert solid state + using Solidstate = std::conditional_t<SolidSystem::isInert(), + InertSolidState<Scalar, SolidSystem>, + CompositionalSolidState<Scalar, SolidSystem>>; + Solidstate sst; + + int success = 0; + std::cout << "Testing solid system '" << Dune::className<SolidSystem>() << "'\n"; + + // output strings + std::string collectedErrors; + std::string collectedWarnings; + + // make sure the solid system provides the number of phases and + // the number of components + enum + { + numComponents = SolidSystem::numComponents + }; + + // some value to make sure the return values of the solid system + // are convertible to scalars + Scalar DUNE_UNUSED val; + + // test for componentName and isCompressible + for (int phaseIdx = 0; phaseIdx < numComponents; ++phaseIdx) + { + std::string name DUNE_UNUSED= SolidSystem::componentName(phaseIdx); + bool DUNE_UNUSED bVal = SolidSystem::isCompressible(phaseIdx); + val = SolidSystem::molarMass(phaseIdx); + } + + // test for componentName + for (int compIdx = 0; compIdx < numComponents; ++compIdx) + { + std::string name DUNE_UNUSED= SolidSystem::componentName(compIdx); + } + + // test for name + std::string name DUNE_UNUSED = SolidSystem::name(); + + try + { + val = SolidSystem::heatCapacity(sst); + } catch (Dune::NotImplemented) + { + collectedWarnings += "warning: SolidSystem::heatCapacity() is not implemented\n"; + } catch (...) + { + collectedErrors += "error: SolidSystem::heatCapacity() throws exception!\n"; + } + + try + { + val = SolidSystem::thermalConductivity(sst); + } catch (Dune::NotImplemented) + { + collectedWarnings += "warning: SolidSystem::thermalConductivity() is not implemented\n"; + } catch (...) + { + collectedErrors += "error: SolidSystem::thermalConductivity() throws exception!\n"; + } + + try + { + val = SolidSystem::density(sst); + } catch (Dune::Exception e) + { + collectedErrors += "error: SolidSystem::density() throws exception!\n"; + } + + std::cout << collectedErrors; + std::cout << collectedWarnings; + if (collectedErrors.empty()) // success + { + std::cout << "... successful" << std::endl; + std::cout << "----------------------------------" << std::endl; + return 0; + } + else + { + std::cout << "... failed" << std::endl; + std::cout << "----------------------------------" << std::endl; + return 1; + } + std::cout << "----------------------------------\n"; + return success; +} + +} // end namespace Dumux + +#endif // DUMUX_CHECK_SOLIDSYSTEM_HH diff --git a/test/material/solidsystems/test_solidsystems.cc b/test/material/solidsystems/test_solidsystems.cc new file mode 100644 index 0000000000000000000000000000000000000000..c3f63b8748b34c719ee8109dccc6202024e5f2d8 --- /dev/null +++ b/test/material/solidsystems/test_solidsystems.cc @@ -0,0 +1,109 @@ +// -*- 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 + * + * \brief This test makes sure that the programming interface is + * observed by all solid systems + */ +#include <config.h> +#include <iostream> +#include <vector> + +#include "checksolidsystem.hh" + +// include all solid systems +#include <dumux/material/solidsystems/inertsolidphase.hh> +#include <dumux/material/solidsystems/compositionalsolidphase.hh> + +// include all solid components +#include <dumux/material/components/cao.hh> +#include <dumux/material/components/cao2h2.hh> +#include <dumux/material/components/granite.hh> +#include <dumux/material/components/nacl.hh> +#include <dumux/material/components/solid.hh> + +int main(int argc, char** argv) try +{ + using namespace Dumux; + using Scalar = double; + + int success = 0; + + /////////////////////////////////////////////////////////// + // check all solid systems + // with the solid components CaO, Ca(OH)2, Granite, NaCl + /////////////////////////////////////////////////////////// + + // check SolidSystems::InertSolidPhase + { + using ComponentT = Components::CaO<Scalar>; + using SolidSystem = SolidSystems::InertSolidPhase<Scalar, ComponentT>; + success += checkSolidSystem<Scalar, SolidSystem>(); + } + { + using ComponentT = Components::CaO2H2<Scalar>; + using SolidSystem = SolidSystems::InertSolidPhase<Scalar, ComponentT>; + success += checkSolidSystem<Scalar, SolidSystem>(); + } + { + using ComponentT = Components::Granite<Scalar>; + using SolidSystem = SolidSystems::InertSolidPhase<Scalar, ComponentT>; + success += checkSolidSystem<Scalar, SolidSystem>(); + } + { + using ComponentT = Components::NaCl<Scalar>; + using SolidSystem = SolidSystems::InertSolidPhase<Scalar, ComponentT>; + success += checkSolidSystem<Scalar, SolidSystem>(); + } + + // check SolidSystems::CompositionalSolidPhase + { + using Component1 = Components::CaO<Scalar>; + using Component2 = Components::CaO2H2<Scalar>; + using SolidSystem = SolidSystems::CompositionalSolidPhase<Scalar, Component1, Component2, 2>; + success += checkSolidSystem<Scalar, SolidSystem>(); + } + { + using Component1 = Components::Granite<Scalar>; + using Component2 = Components::NaCl<Scalar>; + using SolidSystem = SolidSystems::CompositionalSolidPhase<Scalar, Component1, Component2, 1>; + success += checkSolidSystem<Scalar, SolidSystem>(); + } + { + using Component1 = Components::Granite<Scalar>; + using Component2 = Components::NaCl<Scalar>; + using SolidSystem = SolidSystems::CompositionalSolidPhase<Scalar, Component1, Component2, 0>; + success += checkSolidSystem<Scalar, SolidSystem>(); + } + + return success; + +} // end main + +catch (Dune::Exception &e) +{ + std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; + return 3; +} +catch (...) +{ + std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; + return 4; +}