From c86023a9adc0735d7315c9e26b04bf46e43c7691 Mon Sep 17 00:00:00 2001 From: Andreas Lauser <and@poware.org> Date: Thu, 2 Jun 2011 12:36:39 +0000 Subject: [PATCH] material system: add a file containing physical constants note that currently the selection of constants is pretty arbitrary and far from exhaustive. git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@5943 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/material/components/h2o.hh | 36 +++++------ dumux/material/components/iapws/common.hh | 4 +- dumux/material/constants.hh | 76 +++++++++++++++++++++++ dumux/material/idealgas.hh | 6 +- 4 files changed, 101 insertions(+), 21 deletions(-) create mode 100644 dumux/material/constants.hh diff --git a/dumux/material/components/h2o.hh b/dumux/material/components/h2o.hh index 4f7c843570..7fc3ed0d12 100644 --- a/dumux/material/components/h2o.hh +++ b/dumux/material/components/h2o.hh @@ -66,7 +66,7 @@ class H2O : public Component<Scalar, H2O<Scalar> > typedef IAPWS::Region2<Scalar> Region2; typedef IAPWS::Region4<Scalar> Region4; - static constexpr Scalar R = Common::R; // specific gas constant of water + static constexpr Scalar Rs = Common::Rs; // specific gas constant of water public: /*! * \brief A human readable name for the water. @@ -175,7 +175,7 @@ public: // the pressure is too high, in this case we use the slope // of the enthalpy at the vapor pressure to regularize Scalar dh_dp = - R*temperature* + Rs*temperature* Region2::tau(temperature)* Region2::dpi_dp(pv)* Region2::ddgamma_dtaudpi(temperature, pv); @@ -216,7 +216,7 @@ public: // the pressure is too low, in this case we use the slope // of the enthalpy at the vapor pressure to regularize Scalar dh_dp = - R*temperature* + Rs * temperature* Region1::tau(temperature)* Region1::dpi_dp(pv)* Region1::ddgamma_dtaudpi(temperature, pv); @@ -337,7 +337,7 @@ public: Scalar pi = Region1::pi(pv); Scalar dpi_dp = Region1::dpi_dp(pv); Scalar du_dp = - R*temperature* + Rs*temperature* (tau*dpi_dp*ddgamma_dtaudpi + dpi_dp*dpi_dp*dgamma_dpi + pi*dpi_dp*ddgamma_ddpi); */ @@ -388,7 +388,7 @@ public: return enthalpyRegion2_(temperature, triplePressure() - 100) - - R*temperature; // = p*v for an ideal gas! + Rs*temperature; // = p*v for an ideal gas! } Scalar pv = vaporPressure(temperature); if (pressure > pv) { @@ -406,7 +406,7 @@ public: Scalar pi = Region2::pi(pv); Scalar dpi_dp = Region2::dpi_dp(pv); Scalar du_dp = - R*temperature* + Rs*temperature* (tau*dpi_dp*ddgamma_dtaudpi + dpi_dp*dpi_dp*dgamma_dpi + pi*dpi_dp*ddgamma_ddpi); // use a straight line for extrapolation @@ -549,7 +549,7 @@ public: Scalar dgamma_dpi = Region2::dgamma_dpi(temperature, pv); Scalar ddgamma_ddpi = Region2::ddgamma_ddpi(temperature, pv); - Scalar RT = R*temperature; + Scalar RT = Rs*temperature; Scalar dv_dp = RT/(dp_dpi*pv) * @@ -651,7 +651,7 @@ public: Scalar dgamma_dpi = Region1::dgamma_dpi(temperature, pv); Scalar ddgamma_ddpi = Region1::ddgamma_ddpi(temperature, pv); - Scalar RT = R*temperature; + Scalar RT = Rs*temperature; Scalar dv_dp = RT/(dp_dpi*pv) * @@ -765,7 +765,7 @@ private: return Region1::tau(temperature) * Region1::dgamma_dtau(temperature, pressure) * - R*temperature; + Rs*temperature; }; // the unregularized specific isobaric heat capacity @@ -774,7 +774,7 @@ private: return - pow(Region1::tau(temperature), 2 ) * Region1::ddgamma_ddtau(temperature, pressure) * - R; + Rs; }; // the unregularized specific isochoric heat capacity @@ -786,7 +786,7 @@ private: return - pow(tau, 2 ) * - Region1::ddgamma_ddtau(temperature, pressure) * R + + Region1::ddgamma_ddtau(temperature, pressure) * Rs + diff; }; @@ -794,7 +794,7 @@ private: static Scalar internalEnergyRegion1_(Scalar temperature, Scalar pressure) { return - R * temperature * + Rs * temperature * ( Region1::tau(temperature)*Region1::dgamma_dtau(temperature, pressure) - Region1::pi(pressure)*Region1::dgamma_dpi(temperature, pressure)); }; @@ -805,7 +805,7 @@ private: return Region1::pi(pressure)* Region1::dgamma_dpi(temperature, pressure) * - R * temperature / pressure; + Rs * temperature / pressure; }; // the unregularized specific enthalpy for steam @@ -814,14 +814,14 @@ private: return Region2::tau(temperature) * Region2::dgamma_dtau(temperature, pressure) * - R*temperature; + Rs*temperature; }; // the unregularized specific internal energy for steam static Scalar internalEnergyRegion2_(Scalar temperature, Scalar pressure) { return - R * temperature * + Rs * temperature * ( Region2::tau(temperature)*Region2::dgamma_dtau(temperature, pressure) - Region2::pi(pressure)*Region2::dgamma_dpi(temperature, pressure)); }; @@ -832,7 +832,7 @@ private: return - pow(Region2::tau(temperature), 2 ) * Region2::ddgamma_ddtau(temperature, pressure) * - R; + Rs; }; // the unregularized specific isochoric heat capacity @@ -844,7 +844,7 @@ private: double diff = num * num / (1 - pi * pi * Region2::ddgamma_ddpi(temperature, pressure)); return - pow(tau, 2 ) * - Region2::ddgamma_ddtau(temperature, pressure) * R + Region2::ddgamma_ddtau(temperature, pressure) * Rs - diff; }; @@ -854,7 +854,7 @@ private: return Region2::pi(pressure)* Region2::dgamma_dpi(temperature, pressure) * - R * temperature / pressure; + Rs * temperature / pressure; }; }; // end class diff --git a/dumux/material/components/iapws/common.hh b/dumux/material/components/iapws/common.hh index 81d139100c..77e7aa676a 100644 --- a/dumux/material/components/iapws/common.hh +++ b/dumux/material/components/iapws/common.hh @@ -34,6 +34,8 @@ #ifndef DUMUX_IAPWS_COMMON_HH #define DUMUX_IAPWS_COMMON_HH +#include <dumux/material/constants.hh> + #include <cmath> #include <iostream> @@ -65,7 +67,7 @@ public: static constexpr Scalar molarMass = 18.01518e-3; //! Specific gas constant of water \f$\mathrm{[J/(kg*K)]}\f$ - static constexpr Scalar R = 461.526; + static constexpr Scalar Rs = Dumux::Constants<Scalar>::R/molarMass; //! Critical temperature of water \f$\mathrm{[K]}\f$ static constexpr Scalar criticalTemperature = 647.096; diff --git a/dumux/material/constants.hh b/dumux/material/constants.hh new file mode 100644 index 0000000000..64b15c4334 --- /dev/null +++ b/dumux/material/constants.hh @@ -0,0 +1,76 @@ +/***************************************************************************** + * Copyright (C) 2011 by Andreas Lauser * + * Institute of Hydraulic Engineering * + * University of Stuttgart, Germany * + * email: <givenname>.<name>@iws.uni-stuttgart.de * + * * + * 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 A central place for various physical constants occuring in + * some equations. + */ +#ifndef DUMUX_CONSTANTS_HH +#define DUMUX_CONSTANTS_HH + +namespace Dumux +{ + +/*! + * \brief A central place for various physical constants occuring in + * some equations. + */ +template<class Scalar> +class Constants +{ public: + /*! + * \brief The ideal gas constant [J/(mol K)] + */ + static constexpr Scalar R = 8.314472; + + /*! + * \brief The Avogadro constant [1/mol] + */ + static constexpr Scalar Na = 6.02214179e23; + + /*! + * \brief The Boltzmann constant [J/K] + */ + static constexpr Scalar kb = R/Na; + + /*! + * \brief Speed of light in vacuum [m/s] + */ + static constexpr Scalar c = 299792458; + + /*! + * \brief Newtonian constant of gravitation [m^3/(kg s^2)] + */ + static constexpr Scalar G = 6.67428e-11; + + /*! + * \brief Planck constant [J s] + */ + static constexpr Scalar h = 6.62606896e-34; + + /*! + * \brief Reduced Planck constant [J s] + */ + static constexpr Scalar hRed = h / (2 * M_PI); +}; +} + +#endif diff --git a/dumux/material/idealgas.hh b/dumux/material/idealgas.hh index a0977a84fe..ad4dd2c361 100644 --- a/dumux/material/idealgas.hh +++ b/dumux/material/idealgas.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_IDEAL_GAS_HH #define DUMUX_IDEAL_GAS_HH +#include <dumux/material/constants.hh> + namespace Dumux { @@ -34,10 +36,10 @@ namespace Dumux template <class Scalar> class IdealGas { -public: //! The ideal gas constant \f$\mathrm{[J/mol/K]}\f$ - static constexpr Scalar R = 8.3144; + static constexpr Scalar R = Dumux::Constants<Scalar>::R; +public: /*! * \brief The density of the gas in \f$\mathrm{[kg/m^3]}\f$, depending on * pressure, temperature and average molar mass of the gas. -- GitLab