25#ifndef DUMUX_H2O_AIR_SYSTEM_HH
26#define DUMUX_H2O_AIR_SYSTEM_HH
44namespace FluidSystems {
49template<
bool fastButSimplifiedRelations = false>
68template <
class Scalar,
70 class Policy = H2OAirDefaultPolicy<>,
71 bool useKelvinVaporPressure =
false>
73:
public Base<Scalar, H2OAir<Scalar, H2Otype, Policy> >
105 assert(0 <= phaseIdx && phaseIdx <
numPhases);
111 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
125 static constexpr bool isGas(
int phaseIdx)
127 assert(0 <= phaseIdx && phaseIdx <
numPhases);
147 assert(0 <= phaseIdx && phaseIdx <
numPhases);
165 assert(0 <= phaseIdx && phaseIdx <
numPhases);
170 return H2O::liquidIsCompressible();
183 return H2O::liquidViscosityIsConstant();
185 else if (phaseIdx ==
gasPhaseIdx && Policy::useAirViscosityAsGasMixtureViscosity())
200 assert(0 <= phaseIdx && phaseIdx <
numPhases);
220 case H2OIdx:
return H2O::name();
223 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << compIdx);
235 case H2OIdx:
return H2O::molarMass();
238 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << compIdx);
248 static const Scalar TCrit[] = {
249 H2O::criticalTemperature(),
254 return TCrit[compIdx];
264 static const Scalar pCrit[] = {
265 H2O::criticalPressure(),
270 return pCrit[compIdx];
279 template <
class Flu
idState>
284 const auto t = fluidState.temperature(
H2OIdx);
285 if (!useKelvinVaporPressure)
286 return H2O::vaporPressure(t);
289 const auto pc = (fluidState.wettingPhase() == (int)
H2OIdx)
290 ? fluidState.pressure(
AirIdx)-fluidState.pressure(
H2OIdx)
291 : fluidState.pressure(
H2OIdx)-fluidState.pressure(
AirIdx);
297 else if (compIdx ==
AirIdx)
299 DUNE_THROW(Dune::NotImplemented,
"Air::vaporPressure(t)");
301 DUNE_THROW(Dune::NotImplemented,
"Invalid component index " << compIdx);
311 DUNE_THROW(Dune::NotImplemented,
312 "H2OAirFluidSystem::criticalMolarVolume()");
322 static const Scalar accFac[] = {
323 H2O::acentricFactor(),
324 Air::acentricFactor()
328 return accFac[compIdx];
365 std::cout <<
"The H2O-air fluid system was configured with the following policy:\n";
366 std::cout <<
" - use H2O density as liquid mixture density: " << std::boolalpha << Policy::useH2ODensityAsLiquidMixtureDensity() <<
"\n";
367 std::cout <<
" - use ideal gas density: " << std::boolalpha << Policy::useIdealGasDensity() <<
"\n";
368 std::cout <<
" - use air viscosity as gas mixture viscosity: " << std::boolalpha << Policy::useAirViscosityAsGasMixtureViscosity() << std::endl;
370 if (H2O::isTabulated)
372 H2O::init(tempMin, tempMax, nTemp,
373 pressMin, pressMax, nPress);
391 template <
class Flu
idState>
395 assert(0 <= phaseIdx && phaseIdx <
numPhases);
397 const Scalar T = fluidState.temperature(phaseIdx);
398 const Scalar p = fluidState.pressure(phaseIdx);
402 if (Policy::useH2ODensityAsLiquidMixtureDensity())
404 return H2O::liquidDensity(T, p);
410 return H2O::liquidMolarDensity(T, p)
417 if (Policy::useIdealGasDensity())
427 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
440 template <
class Flu
idState>
443 assert(0 <= phaseIdx && phaseIdx <
numPhases);
445 const Scalar T = fluidState.temperature(phaseIdx);
446 const Scalar p = fluidState.pressure(phaseIdx);
452 return H2O::liquidMolarDensity(T, p);
456 if (Policy::useIdealGasDensity())
460 return H2O::gasMolarDensity(T, fluidState.partialPressure(
phase1Idx,
H2OIdx))
463 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
479 template <
class Flu
idState>
483 assert(0 <= phaseIdx && phaseIdx <
numPhases);
485 Scalar T = fluidState.temperature(phaseIdx);
486 Scalar p = fluidState.pressure(phaseIdx);
491 return H2O::liquidViscosity(T, p);
495 if(Policy::useAirViscosityAsGasMixtureViscosity()){
520 Scalar phiIJ = 1 + sqrt(mu[i]/mu[j] * sqrt(M[j]/M[i]));
521 phiIJ = phiIJ * phiIJ / sqrt(8*(1 + M[i]/M[j]));
522 divisor += fluidState.moleFraction(phaseIdx, j)*phiIJ;
524 muResult += fluidState.moleFraction(phaseIdx, i)*mu[i] / divisor;
529 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
551 template <
class Flu
idState>
556 assert(0 <= phaseIdx && phaseIdx <
numPhases);
559 Scalar T = fluidState.temperature(phaseIdx);
560 Scalar p = fluidState.pressure(phaseIdx);
579 template <
class Flu
idState>
583 / H2O::vaporPressure(fluidState.temperature(
gasPhaseIdx));
587 template <
class Flu
idState>
592 DUNE_THROW(Dune::NotImplemented,
"FluidSystems::H2OAir::diffusionCoefficient()");
606 template <
class Flu
idState>
613 if (compIIdx > compJIdx)
614 swap(compIIdx, compJIdx);
616 Scalar T = fluidState.temperature(phaseIdx);
617 Scalar p = fluidState.pressure(phaseIdx);
625 DUNE_THROW(Dune::InvalidStateException,
626 "Binary diffusion coefficient of components "
627 << compIIdx <<
" and " << compJIdx
628 <<
" in phase " << phaseIdx <<
" is undefined!\n");
637 DUNE_THROW(Dune::InvalidStateException,
638 "Binary diffusion coefficient of components "
639 << compIIdx <<
" and " << compJIdx
640 <<
" in phase " << phaseIdx <<
" is undefined!\n");
643 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
664 template <
class Flu
idState>
668 const Scalar T = fluidState.temperature(phaseIdx);
669 const Scalar p = fluidState.pressure(phaseIdx);
672 return H2O::liquidEnthalpy(T, p);
678 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
688 template <
class Flu
idState>
693 const Scalar T = fluidState.temperature(phaseIdx);
694 const Scalar p = fluidState.pressure(phaseIdx);
699 return H2O::liquidEnthalpy(T, p);
703 if (componentIdx ==
H2OIdx)
705 return H2O::gasEnthalpy(T, p);
707 else if (componentIdx ==
AirIdx)
711 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << componentIdx);
713 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
726 template <
class Flu
idState>
730 assert(0 <= phaseIdx && phaseIdx <
numPhases);
743 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
757 template <
class Flu
idState>
774 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
Some exceptions thrown in DuMux
A collection of input/output field names for common physical quantities.
Binary coefficients for water and air.
Material properties of pure water .
A simple class for the air fluid properties.
Tabulates all thermodynamic properties of a given untabulated chemical species.
Relations valid for an ideal gas.
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
std::string gaseousPhase() noexcept
I/O name of gaseous phase.
Definition: name.hh:123
std::string liquidPhase() noexcept
I/O name of liquid phase.
Definition: name.hh:119
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
Scalar h2oGasViscosityInMixture(Scalar temperature, Scalar pressure)
The dynamic viscosity of steam in a gas mixture.
Definition: h2o.hh:977
static Scalar henry(Scalar temperature)
Henry coefficient for air in liquid water.
Definition: h2o_air.hh:48
static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure)
Binary diffusion coefficient for molecular water and air.
Definition: h2o_air.hh:68
static Scalar liquidDiffCoeff(Scalar temperature, Scalar pressure)
Diffusion coefficient for molecular nitrogen in liquid water.
Definition: h2o_air.hh:101
A class for the air fluid properties.
Definition: air.hh:47
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of Air at a given pressure and temperature.
Definition: air.hh:85
static constexpr Scalar molarMass()
The molar mass in of Air.
Definition: air.hh:62
static const Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of pure air.
Definition: air.hh:313
static Scalar criticalPressure()
Returns the critical pressure of Air.
Definition: air.hh:74
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of Air at a given pressure and temperature.
Definition: air.hh:193
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of air.
Definition: air.hh:351
static constexpr bool gasViscosityIsConstant()
Returns true if the gas phase viscosity is constant.
Definition: air.hh:115
static constexpr bool gasIsIdeal()
Returns true, the gas phase is assumed to be ideal.
Definition: air.hh:109
static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of Air with 273.15 as basis.
Definition: air.hh:276
static Scalar criticalTemperature()
Returns the critical temperature of Air.
Definition: air.hh:68
static std::string name()
A human readable name for Air.
Definition: air.hh:54
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of air in , depending on pressure and temperature.
Definition: air.hh:97
Tabulates all thermodynamic properties of a given untabulated chemical species.
Definition: tabulatedcomponent.hh:82
A central place for various physical constants occuring in some equations.
Definition: constants.hh:39
Fluid system base class.
Definition: fluidsystems/base.hh:45
Scalar Scalar
export the scalar type
Definition: fluidsystems/base.hh:48
static Scalar density(const FluidState &fluidState, int phaseIdx)
Calculate the density of a fluid phase.
Definition: fluidsystems/base.hh:134
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: fluidsystems/base.hh:390
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: fluidsystems/base.hh:197
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: fluidsystems/base.hh:278
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: fluidsystems/base.hh:326
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition: fluidsystems/base.hh:363
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: fluidsystems/base.hh:160
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: fluidsystems/base.hh:236
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: fluidsystems/base.hh:424
Policy for the H2O-air fluid system.
Definition: h2oair.hh:51
static constexpr bool useAirViscosityAsGasMixtureViscosity()
Definition: h2oair.hh:54
static constexpr bool useIdealGasDensity()
Definition: h2oair.hh:53
static constexpr bool useH2ODensityAsLiquidMixtureDensity()
Definition: h2oair.hh:52
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
Definition: h2oair.hh:74
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: h2oair.hh:480
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition: h2oair.hh:125
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature and pressure, return its specific enthalpy .
Definition: h2oair.hh:665
static Scalar criticalMolarVolume(int compIdx)
Molar volume of a component at the critical point .
Definition: h2oair.hh:309
static Scalar vaporPressure(const FluidState &fluidState, int compIdx)
Vapor pressure of a component .
Definition: h2oair.hh:280
static constexpr int comp1Idx
index of the second component
Definition: h2oair.hh:94
static constexpr bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: h2oair.hh:198
static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp, Scalar pressMin, Scalar pressMax, unsigned nPress)
Initialize the fluid system's static parameters using problem specific temperature and pressure range...
Definition: h2oair.hh:362
static std::string componentName(int compIdx)
Return the human readable name of a component.
Definition: h2oair.hh:216
static constexpr int numComponents
Number of components in the fluid system.
Definition: h2oair.hh:84
static constexpr int liquidPhaseIdx
index of the liquid phase
Definition: h2oair.hh:86
static constexpr int gasPhaseIdx
index of the gas phase
Definition: h2oair.hh:87
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase. .
Definition: h2oair.hh:758
static std::string phaseName(int phaseIdx)
Return the human readable name of a phase.
Definition: h2oair.hh:103
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: h2oair.hh:727
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in a specific phase.
Definition: h2oair.hh:689
static constexpr bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: h2oair.hh:145
static Scalar criticalPressure(int compIdx)
Critical pressure of a component .
Definition: h2oair.hh:262
static constexpr int phase1Idx
index of the second phase
Definition: h2oair.hh:89
static constexpr int comp0Idx
index of the frist component
Definition: h2oair.hh:93
static constexpr int numPhases
Number of phases in the fluid system.
Definition: h2oair.hh:83
static constexpr bool isCompressible(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: h2oair.hh:163
static constexpr int H2OIdx
index of the frist component
Definition: h2oair.hh:91
static constexpr bool viscosityIsConstant(int phaseIdx)
Returns true if and only if a fluid phase is assumed to have a constant viscosity.
Definition: h2oair.hh:179
H2Otype H2O
Definition: h2oair.hh:80
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Returns the fugacity coefficient of a component in a phase.
Definition: h2oair.hh:552
static Scalar relativeHumidity(const FluidState &fluidState)
Returns the relative humidity of the gas phase.
Definition: h2oair.hh:580
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
The molar density of a fluid phase in .
Definition: h2oair.hh:441
static constexpr int liquidCompIdx
index of the liquid component
Definition: h2oair.hh:95
static void init()
Initialize the fluid system's static parameters generically.
Definition: h2oair.hh:341
static Scalar density(const FluidState &fluidState, const int phaseIdx)
Given a phase's composition, temperature, pressure, and the partial pressures of all components,...
Definition: h2oair.hh:392
static constexpr int AirIdx
index of the second component
Definition: h2oair.hh:92
static Scalar acentricFactor(int compIdx)
The acentric factor of a component .
Definition: h2oair.hh:320
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: h2oair.hh:607
static constexpr int phase0Idx
index of the first phase
Definition: h2oair.hh:88
static constexpr int gasCompIdx
index of the gas component
Definition: h2oair.hh:96
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: h2oair.hh:117
static Scalar criticalTemperature(int compIdx)
Critical temperature of a component .
Definition: h2oair.hh:246
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Definition: h2oair.hh:588
static Scalar molarMass(int compIdx)
Return the molar mass of a component .
Definition: h2oair.hh:231
Relations valid for an ideal gas.
Definition: idealgas.hh:37
static constexpr Scalar density(Scalar avgMolarMass, Scalar temperature, Scalar pressure)
The density of the gas in , depending on pressure, temperature and average molar mass of the gas.
Definition: idealgas.hh:49
static constexpr Scalar molarDensity(Scalar temperature, Scalar pressure)
The molar density of the gas , depending on pressure and temperature.
Definition: idealgas.hh:70