Commit 99e17f17 authored by Thomas Fetzer's avatar Thomas Fetzer
Browse files

[components][h2o][iapws] Move check of validity range to the IAPWS region files

parent c0fa8df8
......@@ -171,12 +171,7 @@ public:
static const Scalar gasEnthalpy(Scalar temperature,
Scalar pressure)
{
if (!Region2::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Enthalpy of steam is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region2::checkValidityRange(temperature, pressure, "Enthalpy");
// regularization
if (pressure < triplePressure() - 100) {
......@@ -221,12 +216,7 @@ public:
static const Scalar liquidEnthalpy(Scalar temperature,
Scalar pressure)
{
if (!Region1::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Enthalpy of water is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region1::checkValidityRange(temperature, pressure, "Enthalpy");
// regularization
Scalar pv = vaporPressure(temperature);
......@@ -262,12 +252,7 @@ public:
static const Scalar gasHeatCapacity(Scalar temperature,
Scalar pressure)
{
if (!Region2::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Heat capacity of steam is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region2::checkValidityRange(temperature, pressure, "Heat capacity");
// regularization
if (pressure < triplePressure() - 100) {
......@@ -297,12 +282,7 @@ public:
static const Scalar liquidHeatCapacity(Scalar temperature,
Scalar pressure)
{
if (!Region1::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"heat Capacity of water is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region1::checkValidityRange(temperature, pressure, "Heat capacity");
// regularization
Scalar pv = vaporPressure(temperature);
......@@ -329,13 +309,7 @@ public:
static const Scalar liquidInternalEnergy(Scalar temperature,
Scalar pressure)
{
if (!Region1::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Internal Energy of water is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region1::checkValidityRange(temperature, pressure, "Internal energy");
// regularization
Scalar pv = vaporPressure(temperature);
......@@ -385,12 +359,7 @@ public:
*/
static Scalar gasInternalEnergy(Scalar temperature, Scalar pressure)
{
if (!Region2::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Internal Energy of steam is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region2::checkValidityRange(temperature, pressure, "Internal energy");
// regularization
if (pressure < triplePressure() - 100) {
......@@ -459,13 +428,7 @@ public:
static const Scalar liquidHeatCapacityConstVolume(Scalar temperature,
Scalar pressure)
{
if (!Region1::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Heat capacity of water is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region1::checkValidityRange(temperature, pressure, "Heat capacity for a constant volume");
// regularization
Scalar pv = vaporPressure(temperature);
......@@ -492,12 +455,7 @@ public:
*/
static Scalar gasHeatCapacityConstVolume(Scalar temperature, Scalar pressure)
{
if (!Region2::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Heat capacity of steam is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region2::checkValidityRange(temperature, pressure, "Heat capacity for a constant volume");
// regularization
if (pressure < triplePressure() - 100) {
......@@ -538,12 +496,7 @@ public:
*/
static Scalar gasDensity(Scalar temperature, Scalar pressure)
{
if (!Region2::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Density of steam is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region2::checkValidityRange(temperature, pressure, "Density");
// regularization
if (pressure < triplePressure() - 100) {
......@@ -659,12 +612,7 @@ public:
*/
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
{
if (!Region1::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Density of water is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region1::checkValidityRange(temperature, pressure, "Density");
// regularization
Scalar pv = vaporPressure(temperature);
......@@ -758,12 +706,7 @@ public:
*/
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
{
if (!Region2::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Viscosity of steam is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region2::checkValidityRange(temperature, pressure, "Viscosity");
Scalar rho = gasDensity(temperature, pressure);
return Common::viscosity(temperature, rho);
......@@ -782,12 +725,7 @@ public:
*/
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
{
if (!Region1::isValid(temperature, pressure))
{
DUNE_THROW(NumericalProblem,
"Viscosity of water is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
Region1::checkValidityRange(temperature, pressure, "Viscosity");
Scalar rho = liquidDensity(temperature, pressure);
return Common::viscosity(temperature, rho);
......
......@@ -34,6 +34,7 @@
#include <cmath>
#include <iostream>
#include <dune/common/deprecated.hh>
namespace Dumux
{
......@@ -63,6 +64,7 @@ public:
* \param temperature temperature of component in \f$\mathrm{[K]}\f$
* \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
*/
DUNE_DEPRECATED_MSG("isValid is deprecated. Use checkValidityRange instead.")
static constexpr bool isValid(Scalar temperature, Scalar pressure)
{
return
......@@ -81,6 +83,30 @@ public:
*/
}
/*!
* \brief Returns true if IAPWS region 1 applies for a
* (temperature in \f$\mathrm{[K]}\f$, pressure in \f$\mathrm{[Pa]}\f$) pair.
*
* \param temperature temperature of component in \f$\mathrm{[K]}\f$
* \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
* \param propertyName the name for which property the check is performed
*/
static void checkValidityRange(Scalar temperature, Scalar pressure,
std::string propertyName = "This property")
{
// actually this is:
/* 273.15 <= temperature &&
temperature <= 623.15 &&
pressure >= vaporPressure(temperature) &&
pressure <= 100e6 */
if (temperature <= 623.15 && pressure <= 100e6)
return;
DUNE_THROW(Dune::NotImplemented,
propertyName << " of water is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
/*!
* \brief Returns the reduced temperature for IAPWS region 1.
*
......
......@@ -35,6 +35,7 @@
#include <cmath>
#include <iostream>
#include <dune/common/deprecated.hh>
namespace Dumux
{
......@@ -65,6 +66,7 @@ public:
* \param temperature temperature of component in \f$\mathrm{[K]}\f$
* \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
*/
DUNE_DEPRECATED_MSG("isValid is deprecated. Use checkValidityRange instead.")
static constexpr bool isValid(Scalar temperature, Scalar pressure)
{
return temperature <= 623.15 && pressure <= 100e6;
......@@ -78,6 +80,29 @@ public:
*/
}
/*!
* \brief Returns true if IAPWS region 2 applies for a
* (temperature, pressure) pair.
*
* \param temperature temperature of component in \f$\mathrm{[K]}\f$
* \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
* \param propertyName the name for which property the check is performed
*/
static void checkValidityRange(Scalar temperature, Scalar pressure,
std::string propertyName = "This property")
{
// actually this is:
/* (273.15 <= temperature && temperature <= 623.15 && pressure <= vaporPressure(temperature)) ||
(623.15 < temperature && temperature <= 863.15 && pressure <= auxPressure(temperature)) ||
(863.15 < temperature && temperature <= 1073.15 && pressure < 100e6); */
if (temperature <= 623.15 && pressure <= 100e6)
return;
DUNE_THROW(Dune::NotImplemented,
propertyName << " of steam is only implemented for temperatures below 623.15K and "
"pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
}
/*!
* \brief Returns the reduced temperature (dimensionless) for IAPWS region 2.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment