Commit 0099b83c authored by Andreas Lauser's avatar Andreas Lauser
Browse files

fluid systems: add isIdealGas(phaseIdx) methods

this is primary to allow models to check whether their assumptions are
valid for the given fluidsystem

also add the H2O-Air fluid system to the fluid systems test. this
caught a few issues!

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@7537 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent 177b4bde
......@@ -59,8 +59,7 @@ public:
* Taken from constrelair.hh.
*/
static Scalar molarMass()
{ return 0.02896; // [kg/mole]
; }
{ return 0.02896; /* [kg/mol] */ }
/*!
* \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of \f$AIR\f$.
......@@ -72,7 +71,7 @@ public:
* \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of \f$AIR\f$.
*/
static Scalar criticalPressure()
{ return 37.86e5; /* [N/m^2] */ }
{ return 37.86e5; /* [Pa] */ }
/*!
* \brief The density of \f$AIR\f$ at a given pressure and temperature [kg/m^3].
......@@ -85,17 +84,18 @@ public:
// Assume an ideal gas
return IdealGas::density(molarMass(), temperature, pressure);
}
//TODO: Holle, Doku!!!
static Scalar molarGasDensity(Scalar temperature, Scalar pressure)
{
if(temperature<250.) temperature=250.; /* ACHTUNG Regularisierung */
if(temperature>500.) temperature=500.; /* ACHTUNG Regularisierung */
if(pressure<1e-4) pressure=1e-4; /* ACHTUNG Regularisierung */
if(pressure>1.E8) pressure=1.E8; /* ACHTUNG Regularisierung */
/*!
* \brief Returns true iff the gas phase is assumed to be compressible
*/
static bool gasIsCompressible()
{ return true; }
return (pressure/(8.314*temperature));
}
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return true; }
/*!
* \brief The pressure of gaseous \f$AIR\f$ at a given density and temperature \f$\mathrm{[Pa]}\f$.
......@@ -108,7 +108,6 @@ public:
// Assume an ideal gas
return IdealGas::pressure(temperature, density/molarMass());
}
/*!
* \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of \f$AIR\f$ at a given pressure and temperature.
*
......@@ -188,13 +187,10 @@ public:
/*!
* \brief Specific internal energy of \f$AIR\f$ \f$\mathrm{[J/kg]}\f$.
*
* Definition of enthalpy: \f$h= u + pv = u + p / \rho\f$.
*
* Rearranging for internal energy yields: \f$u = h - pv\f$.
*
* Exploiting the \emph{Ideal Gas} assumption (\f$pv = R_{\textnormal{specific}} T\f$)gives: \f$u = h - R / M T \f$.
*
* The \emph{universal} gas constant can only be used in the case of molar formulations.
* Definition of enthalpy: \f$h= u + pv = u + p / \rho\f$.
* Rearranging for internal energy yields: \f$u = h - pv\f$.
* Exploiting the \emph{Ideal Gas} assumption
* (\f$pv = R_{\textnormal{specific}} T\f$)gives: \f$u = h - R / M T \f$.
*
* \param temperature temperature of component in \f$\mathrm{[K]}\f$
* \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
......@@ -203,9 +199,10 @@ public:
Scalar pressure)
{
return
gasEnthalpy(temperature, pressure) -
1/molarMass()* // conversion from [J/(mol K)] to [J/(kg K)]
IdealGas::R*temperature; // = pressure * spec. volume for an ideal gas
gasEnthalpy(temperature, pressure)
-
IdealGas::R * temperature // = pressure * molar volume for an ideal gas
/ molarMass(); // conversion from [J/(mol K)] to [J/(kg K)]
}
};
......
......@@ -261,6 +261,12 @@ public:
static Scalar gasDensity(Scalar temperature, Scalar pressure)
{ return H2O::gasDensity(temperature, pressure); }
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return H2O::gasIsIdeal(); }
/*!
* \brief The density of pure brine at a given pressure and temperature \f$\mathrm{[kg/m^3]}\f$.
*
......
......@@ -114,6 +114,12 @@ public:
return IdealGas::density(molarMass(), temperature, pressure);
}
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return true; }
/*!
* \brief The pressure of gaseous \f$CH_4\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
*
......
......@@ -69,6 +69,12 @@ public:
static bool gasIsCompressible()
{ DUNE_THROW(Dune::NotImplemented, "Component::gasIsCompressible()"); }
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ DUNE_THROW(Dune::NotImplemented, "Component::gasIsCompressible()"); }
/*!
* \brief Returns true iff the liquid phase is assumed to be compressible
*/
......
......@@ -128,6 +128,12 @@ public:
static bool gasIsCompressible()
{ return true; }
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return true; }
/*!
* \brief The pressure of gaseous \f$H_2\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
*
......
......@@ -582,6 +582,12 @@ public:
return 1.0/volumeRegion2_(temperature, pressure);
}
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return false; }
/*!
* \brief The pressure of steam in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
*
......
......@@ -125,12 +125,6 @@ public:
sigma*sigma*sigma*N4))));
}
/*!
* \brief Returns true iff the gas phase is assumed to be compressible
*/
static bool gasIsCompressible()
{ return true; }
/*!
* \brief The density \f$\mathrm{[kg/m^3]}\f$ of \f$N_2\f$ gas at a given pressure and temperature.
*
......@@ -143,6 +137,18 @@ public:
return IdealGas::density(molarMass(), temperature, pressure);
}
/*!
* \brief Returns true iff the gas phase is assumed to be compressible
*/
static bool gasIsCompressible()
{ return true; }
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return true; }
/*!
* \brief The pressure of gaseous \f$N_2\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
*
......
......@@ -144,6 +144,12 @@ public:
return IdealGas::density(molarMass(), temperature, pressure);
}
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return true; }
/*!
* \brief The pressure of gaseous \f$O_2\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
*
......
......@@ -147,6 +147,12 @@ public:
return IdealGas::density(molarMass(), temperature, pressure);
}
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return true; }
/*!
* \brief The pressure of gaseous \f$CO_2\f$ at a given density and temperature \f$\mathrm{[Pa]}\f$.
*
......
......@@ -127,6 +127,12 @@ public:
pressure);
};
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return true; }
/*!
* \brief The density of pure TCE at a given pressure and temperature \f$\mathrm{[kg/m^3]}\f$.
*
......
......@@ -207,6 +207,12 @@ public:
return molarMass()*IdealGas::molarDensity(temperature, pressure);
}
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return true; }
/*!
* \brief The pressure of steam in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
*
......
......@@ -427,6 +427,13 @@ public:
static bool liquidIsCompressible()
{ return RawComponent::liquidIsCompressible(); }
/*!
* \brief Returns true iff the gas phase is assumed to be ideal
*/
static bool gasIsIdeal()
{ return RawComponent::gasIsIdeal(); }
/*!
* \brief The density of gas at a given pressure and temperature
* \f$\mathrm{[kg/m^3]}\f$.
......
......@@ -136,6 +136,20 @@ public:
return true;
}
/*!
* \brief Returns true if and only if a fluid phase is assumed to
* be an ideal gas.
*
* \param phaseIdx The index of the fluid phase to consider
*/
static bool isIdealGas(int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
// let the fluid decide
return Fluid::isIdealGas();
}
/****************************************
* Component related static parameters
****************************************/
......
......@@ -150,6 +150,22 @@ public:
return NonwettingPhase::isCompressible();
}
/*!
* \brief Returns true if and only if a fluid phase is assumed to
* be an ideal gas.
*
* \param phaseIdx The index of the fluid phase to consider
*/
static bool isIdealGas(int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
// let the fluids decide
if (phaseIdx == wPhaseIdx)
return WettingPhase::isIdealGas();
return NonwettingPhase::isIdealGas();
}
/****************************************
* Component related static parameters
****************************************/
......
......@@ -56,6 +56,12 @@ public:
static bool isCompressible()
{ return Component::gasIsCompressible(); }
/*!
* \brief Returns true iff the fluid is assumed to be an ideal gas
*/
static bool isIdealGas()
{ return Component::gasIsIdeal(); }
/*!
* \brief The mass in [kg] of one mole of the component.
*/
......
......@@ -70,7 +70,7 @@ namespace FluidSystems
SET_PROP(TestDecTwoPTwoCProblem, FluidSystem)
{
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef Dumux::FluidSystems::H2OAir<Scalar, Dumux::SimpleH2O<Scalar>> type;
typedef Dumux::FluidSystems::H2OAir<Scalar, Dumux::SimpleH2O<Scalar> > type;
};
* Also remember to initialize tabulated components (FluidSystem::init()), while this
......@@ -172,6 +172,21 @@ public:
return H2O::liquidIsCompressible();
}
/*!
* \brief Returns true if and only if a fluid phase is assumed to
* be an ideal gas.
*
* \param phaseIdx The index of the fluid phase to consider
*/
static bool isIdealGas(int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
// let the fluids decide
if (phaseIdx == gPhaseIdx)
return H2O::gasIsIdeal() && Air::gasIsIdeal();
return false; // not a gas
}
/****************************************
* Component related static parameters
......@@ -350,7 +365,16 @@ public:
assert(0 <= phaseIdx && phaseIdx < numPhases);
Scalar T = fluidState.temperature(phaseIdx);
Scalar p = fluidState.pressure(phaseIdx);
Scalar p;
if (isCompressible(phaseIdx))
p = fluidState.pressure(phaseIdx);
else {
// random value which will hopefully cause things to blow
// up if it is used in a calculation!
p = - 1e100;
Valgrind::SetUndefined(p);
}
Scalar sumMoleFrac = 0;
for (int compIdx = 0; compIdx < numComponents; ++compIdx)
......@@ -516,6 +540,15 @@ public:
return 1.0;
}
using Base::diffusionCoefficient;
template <class FluidState>
static Scalar diffusionCoefficient(const FluidState &fluidState,
int phaseIdx,
int compIdx)
{
DUNE_THROW(Dune::NotImplemented, "FluidSystems::H2OAir::diffusionCoefficient()");
}
/*!
* \brief Given a phase's composition, temperature and pressure,
* return the binary diffusion coefficient for components
......@@ -632,6 +665,36 @@ public:
}
DUNE_THROW(Dune::InvalidStateException, "Invalid phase index " << phaseIdx);
}
/*!
* \brief Thermal conductivity of a fluid phase [W/(m K)].
*
* Use the conductivity of air and water as a first approximation.
* Source:
* http://en.wikipedia.org/wiki/List_of_thermal_conductivities
*/
using Base::thermalConductivity;
template <class FluidState>
static Scalar thermalConductivity(const FluidState &fluidState,
int phaseIdx)
{
DUNE_THROW(Dune::NotImplemented, "FluidSystems::H2OAir::thermalConductivity()");
}
/*!
* \brief Specific isobaric heat capacity of a fluid phase.
* \f$\mathrm{[J/kg]}\f$.
*
* \param params mutable parameters
* \param phaseIdx for which phase to give back the heat capacity
*/
using Base::heatCapacity;
template <class FluidState>
static Scalar heatCapacity(const FluidState &fluidState,
int phaseIdx)
{
DUNE_THROW(Dune::NotImplemented, "FluidSystems::H2OAir::heatCapacity()");
}
};
} // end namepace FluidSystems
......
......@@ -65,18 +65,15 @@ namespace FluidSystems
*/
template <class Scalar, bool useComplexRelations = true>
class H2ON2
: public BaseFluidSystem<Scalar, H2ON2<Scalar, useComplexRelations> >
: public BaseFluidSystem<Scalar, H2ON2<Scalar, useComplexRelations> >
{
typedef H2ON2<Scalar, useComplexRelations> ThisType;
typedef BaseFluidSystem<Scalar, ThisType> Base;
// convenience typedefs
typedef Dumux::IdealGas<Scalar> IdealGas;
typedef Dumux::H2O<Scalar> IapwsH2O;
typedef Dumux::TabulatedComponent<Scalar, IapwsH2O > TabulatedH2O;
typedef Dumux::N2<Scalar> SimpleN2;
public:
......@@ -156,13 +153,29 @@ public:
static bool isCompressible(int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
// ideal gases are always compressible
// gases are always compressible
if (phaseIdx == gPhaseIdx)
return true;
// the water component decides for the liquid phase...
return H2O::liquidIsCompressible();
}
/*!
* \brief Returns true if and only if a fluid phase is assumed to
* be an ideal gas.
*
* \param phaseIdx The index of the fluid phase to consider
*/
static bool isIdealGas(int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
if (phaseIdx == gPhaseIdx)
// let the components decide
return H2O::gasIsIdeal() && N2::gasIsIdeal();
return false; // not a gas
}
/****************************************
* Component related static parameters
****************************************/
......@@ -176,7 +189,7 @@ public:
//! The components for pure water
typedef TabulatedH2O H2O;
//typedef SimpleH2O H2O;
// typedef IapwsH2O H2O;
//typedef IapwsH2O H2O;
//! The components for pure nitrogen
typedef SimpleN2 N2;
......
......@@ -57,6 +57,11 @@ public:
static bool isCompressible()
{ return Component::liquidIsCompressible(); }
/*!
* \brief Returns true iff the fluid is assumed to be an ideal gas
*/
static bool isIdealGas()
{ return false; /* we're a liquid! */ }
/*!
* \brief The mass in [kg] of one mole of the component.
......
......@@ -138,6 +138,18 @@ public:
return phaseIdx == wPhaseIdx;
}
/*!
* \brief Returns true if and only if a fluid phase is assumed to
* be an ideal gas.
*
* \param phaseIdx The index of the fluid phase to consider
*/
static bool isIdealGas(int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
return false; // gas is not ideal here!
}
/****************************************
* Component related parameters
****************************************/
......
......@@ -138,6 +138,16 @@ public:
return false;
}
/*!
* \brief Returns true if and only if a fluid phase is assumed to
* be an ideal gas.
*/
static bool isIdealGas(int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
return false; // we assume a incompressible liquid
}
/****************************************
* Component related static parameters
****************************************/
......
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