25#ifndef DUMUX_H2O_N2_O2_FLUID_SYSTEM_HH
26#define DUMUX_H2O_N2_O2_FLUID_SYSTEM_HH
50namespace FluidSystems {
55template<
bool fastButSimplifiedRelations = false>
75template <
class Scalar,
class Policy = H2ON2O2DefaultPolicy<>>
77 :
public Base<Scalar, H2ON2O2<Scalar, Policy> >
126 assert(0 <= phaseIdx && phaseIdx <
numPhases);
132 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
140 static constexpr bool isGas(
int phaseIdx)
142 assert(0 <= phaseIdx && phaseIdx <
numPhases);
162 assert(0 <= phaseIdx && phaseIdx <
numPhases);
180 assert(0 <= phaseIdx && phaseIdx <
numPhases);
196 assert(0 <= phaseIdx && phaseIdx <
numPhases);
226 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << compIdx);
236 static const Scalar M[] = {
253 static const Scalar Tcrit[] = {
260 return Tcrit[compIdx];
270 static const Scalar pcrit[] = {
277 return pcrit[compIdx];
287 DUNE_THROW(Dune::NotImplemented,
288 "H2ON2O2FluidSystem::criticalMolarVolume()");
298 static const Scalar accFac[] = {
299 H2O::acentricFactor(),
300 N2::acentricFactor(),
305 return accFac[compIdx];
319 template <
class Flu
idState>
328 Scalar T = fluidState.temperature(phaseIdx);
348 template <
class Flu
idState>
357 * fluidState.pressure(phaseIdx)
359 /
density(fluidState, phaseIdx)
361 / fluidState.temperature());
371 template <
class Flu
idState>
374 const Scalar T = fluidState.temperature();
418 std::cout <<
"The H2O-N2-O2 fluid system was configured with the following policy:\n";
419 std::cout <<
" - use H2O density as liquid mixture density: " << std::boolalpha << Policy::useH2ODensityAsLiquidMixtureDensity() <<
"\n";
420 std::cout <<
" - use ideal gas density: " << std::boolalpha << Policy::useIdealGasDensity() <<
"\n";
421 std::cout <<
" - use N2 viscosity as gas mixture viscosity: " << std::boolalpha << Policy::useN2ViscosityAsGasMixtureViscosity() <<
"\n";
422 std::cout <<
" - use N2 heat conductivity as gas mixture heat conductivity: " << std::boolalpha << Policy::useN2HeatConductivityAsGasMixtureHeatConductivity() <<
"\n";
423 std::cout <<
" - use ideal gas heat capacities: " << std::boolalpha << Policy::useIdealGasHeatCapacities() << std::endl;
428 pressMin, pressMax, nPress);
445 template <
class Flu
idState>
449 assert(0 <= phaseIdx && phaseIdx <
numPhases);
451 Scalar T = fluidState.temperature(phaseIdx);
452 Scalar p = fluidState.pressure(phaseIdx);
458 if (Policy::useH2ODensityAsLiquidMixtureDensity())
477 if (Policy::useIdealGasDensity())
487 DUNE_THROW(Dune::InvalidStateException,
"Unknown phase index " << phaseIdx);
503 template <
class Flu
idState>
506 const Scalar T = fluidState.temperature(phaseIdx);
507 const Scalar p = fluidState.pressure(phaseIdx);
517 if (Policy::useIdealGasDensity())
541 template <
class Flu
idState>
545 assert(0 <= phaseIdx && phaseIdx <
numPhases);
547 Scalar T = fluidState.temperature(phaseIdx);
548 Scalar p = fluidState.pressure(phaseIdx);
557 if (Policy::useN2ViscosityAsGasMixtureViscosity())
575 sumx += fluidState.moleFraction(phaseIdx, compIdx);
576 sumx = max(1e-10, sumx);
586 divisor += fluidState.moleFraction(phaseIdx, j)/sumx * phiIJ;
588 muResult += fluidState.moleFraction(phaseIdx, i)/sumx * mu[i] / divisor;
613 template <
class Flu
idState>
618 assert(0 <= phaseIdx && phaseIdx <
numPhases);
621 Scalar T = fluidState.temperature(phaseIdx);
622 Scalar p = fluidState.pressure(phaseIdx);
663 template <
class Flu
idState>
668 DUNE_THROW(Dune::NotImplemented,
"Diffusion coefficients");
682 template <
class Flu
idState>
689 if (compIIdx > compJIdx)
692 swap(compIIdx, compJIdx);
696 if (compIIdx == compJIdx ||
700 DUNE_THROW(Dune::InvalidStateException,
701 "Binary diffusion coefficient of components "
702 << compIIdx <<
" and " << compJIdx
703 <<
" in phase " << phaseIdx <<
" is undefined!\n");
707 Scalar T = fluidState.temperature(phaseIdx);
708 Scalar p = fluidState.pressure(phaseIdx);
716 DUNE_THROW(Dune::InvalidStateException,
717 "Binary diffusion coefficient of components "
718 << compIIdx <<
" and " << compJIdx
719 <<
" in phase " << phaseIdx <<
" is undefined!\n");
729 DUNE_THROW(Dune::InvalidStateException,
730 "Binary diffusion coefficient of components "
731 << compIIdx <<
" and " << compJIdx
732 <<
" in phase " << phaseIdx <<
" is undefined!\n");
735 DUNE_THROW(Dune::InvalidStateException,
736 "Binary diffusion coefficient of components "
737 << compIIdx <<
" and " << compJIdx
738 <<
" in phase " << phaseIdx <<
" is undefined!\n");
754 template <
class Flu
idState>
758 Scalar T = fluidState.temperature(phaseIdx);
759 Scalar p = fluidState.pressure(phaseIdx);
782 return hH2O + hN2 + hO2;
785 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
790 template <
class Flu
idState>
795 const Scalar T = fluidState.temperature(phaseIdx);
796 const Scalar p = fluidState.pressure(phaseIdx);
800 if (componentIdx ==
H2OIdx)
802 else if (componentIdx ==
N2Idx)
803 DUNE_THROW(Dune::NotImplemented,
"Component enthalpy of nitrogen in liquid phase");
804 else if (componentIdx ==
O2Idx)
805 DUNE_THROW(Dune::NotImplemented,
"Component enthalpy of oxygen in liquid phase");
807 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << componentIdx);
811 if (componentIdx ==
H2OIdx)
813 else if (componentIdx ==
N2Idx)
815 else if (componentIdx ==
O2Idx)
817 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << componentIdx);
819 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
832 template <
class Flu
idState>
836 assert(0 <= phaseIdx && phaseIdx <
numPhases);
848 if (!Policy::useN2HeatConductivityAsGasMixtureHeatConductivity())
850 Scalar xN2 = fluidState.moleFraction(phaseIdx,
N2Idx);
851 Scalar xO2 = fluidState.moleFraction(phaseIdx,
O2Idx);
852 Scalar xH2O = fluidState.moleFraction(phaseIdx,
H2OIdx);
853 Scalar lambdaN2 = xN2 * lambdaPureN2;
854 Scalar lambdaO2 = xO2 * lambdaPureO2;
857 return lambdaN2 + lambdaH2O + lambdaO2;
872 template <
class Flu
idState>
878 fluidState.pressure(phaseIdx));
885 if (!Policy::useIdealGasHeatCapacities()) {
887 fluidState.pressure(phaseIdx)
888 * fluidState.moleFraction(phaseIdx,
N2Idx));
891 fluidState.pressure(phaseIdx)
892 * fluidState.moleFraction(phaseIdx,
H2OIdx));
894 fluidState.pressure(phaseIdx)
895 * fluidState.moleFraction(phaseIdx,
O2Idx));
Some exceptions thrown in DuMux
Some templates to wrap the valgrind macros.
A collection of input/output field names for common physical quantities.
Binary coefficients for water and nitrogen.
Binary coefficients for water and oxygen.
Binary coefficients for nitrogen and oxygen.
Material properties of pure water .
Properties of pure molecular oxygen .
Tabulates all thermodynamic properties of a given untabulated chemical species.
Properties of pure molecular nitrogen .
A central place for various physical constants occuring in some equations.
Relations valid for an ideal gas.
bool CheckDefined(const T &value)
Make valgrind complain if the object occupied by an object is undefined.
Definition: valgrind.hh:72
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
static Scalar liquidDiffCoeff(Scalar temperature, Scalar pressure)
Diffusion coefficient for molecular nitrogen in liquid water.
Definition: h2o_n2.hh:97
static Scalar henry(Scalar temperature)
Henry coefficient for molecular nitrogen in liquid water.
Definition: h2o_n2.hh:48
static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure)
Binary diffusion coefficient for molecular water and nitrogen.
Definition: h2o_n2.hh:66
static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure)
Binary diffusion coefficient for molecular water and oxygen.
Definition: h2o_o2.hh:66
static Scalar henry(Scalar temperature)
Henry coefficient for molecular oxygen in liquid water.
Definition: h2o_o2.hh:48
static Scalar liquidDiffCoeff(Scalar temperature, Scalar pressure)
Diffusion coefficient for molecular oxygen in liquid water.
Definition: h2o_o2.hh:97
static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure)
Binary diffusion coefficient for molecular oxygen in liquid nitrogen.
Definition: n2_o2.hh:61
Properties of pure molecular nitrogen .
Definition: n2.hh:47
static Scalar criticalTemperature()
Returns the critical temperature of molecular nitrogen.
Definition: n2.hh:66
static Scalar criticalPressure()
Returns the critical pressure of molecular nitrogen.
Definition: n2.hh:72
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of at a given pressure and temperature.
Definition: n2.hh:243
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of gas in at a given pressure and temperature.
Definition: n2.hh:143
static std::string name()
A human readable name for nitrogen.
Definition: n2.hh:54
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of gas at a given pressure and temperature.
Definition: n2.hh:130
static constexpr Scalar molarMass()
The molar mass in of molecular nitrogen.
Definition: n2.hh:60
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of nitrogen.
Definition: n2.hh:281
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: n2.hh:155
static const Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of pure nitrogen gas.
Definition: n2.hh:176
static const Scalar gasHeatCapacity(Scalar T, Scalar pressure)
Specific isobaric heat capacity of pure nitrogen gas.
Definition: n2.hh:213
Properties of pure molecular oxygen .
Definition: o2.hh:47
static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of pure oxygen gas.
Definition: o2.hh:173
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of pure in , depending on pressure and temperature.
Definition: o2.hh:146
static constexpr Scalar criticalTemperature()
Returns the critical temperature in of molecular oxygen.
Definition: o2.hh:66
static std::string name()
A human readable name for the .
Definition: o2.hh:54
static constexpr Scalar molarMass()
The molar mass in of molecular oxygen.
Definition: o2.hh:60
static Scalar gasHeatCapacity(Scalar T, Scalar pressure)
Specific isobaric heat capacity of pure oxygen gas.
Definition: o2.hh:190
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of at a given pressure and temperature.
Definition: o2.hh:217
static constexpr Scalar criticalPressure()
Returns the critical pressure in of molecular oxygen.
Definition: o2.hh:72
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: o2.hh:152
static constexpr Scalar gasDensity(Scalar temperature, Scalar pressure)
The density in of pure at a given pressure and temperature.
Definition: o2.hh:134
static constexpr Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of nitrogen.
Definition: o2.hh:256
Tabulates all thermodynamic properties of a given untabulated chemical species.
Definition: tabulatedcomponent.hh:82
static const Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the gas .
Definition: tabulatedcomponent.hh:238
static Scalar criticalTemperature()
Returns the critical temperature in of the component.
Definition: tabulatedcomponent.hh:184
static const Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the gas .
Definition: tabulatedcomponent.hh:292
static std::string name()
A human readable name for the component.
Definition: tabulatedcomponent.hh:172
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
The thermal conductivity of liquid water .
Definition: tabulatedcomponent.hh:619
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of gas at a given pressure and temperature .
Definition: tabulatedcomponent.hh:456
static const Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the liquid .
Definition: tabulatedcomponent.hh:265
static Scalar criticalPressure()
Returns the critical pressure in of the component.
Definition: tabulatedcomponent.hh:190
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density of liquid in at a given pressure and temperature.
Definition: tabulatedcomponent.hh:529
static constexpr Scalar molarMass()
The molar mass in of the component.
Definition: tabulatedcomponent.hh:178
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of liquid.
Definition: tabulatedcomponent.hh:565
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of gas.
Definition: tabulatedcomponent.hh:538
static constexpr bool liquidIsCompressible()
Returns true if the liquid phase is assumed to be compressible.
Definition: tabulatedcomponent.hh:439
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
The density of liquid at a given pressure and temperature .
Definition: tabulatedcomponent.hh:495
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
The thermal conductivity of gaseous water .
Definition: tabulatedcomponent.hh:592
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of gas in at a given pressure and temperature.
Definition: tabulatedcomponent.hh:485
static constexpr bool isTabulated
state that we are tabulated
Definition: tabulatedcomponent.hh:88
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the component at a given temperature.
Definition: tabulatedcomponent.hh:211
static void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp, Scalar pressMin, Scalar pressMax, std::size_t nPress)
Initialize the tables.
Definition: tabulatedcomponent.hh:100
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: tabulatedcomponent.hh:445
static const Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the liquid .
Definition: tabulatedcomponent.hh:319
A central place for various physical constants occuring in some equations.
Definition: constants.hh:39
static constexpr Scalar R
The ideal gas constant .
Definition: constants.hh:44
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-N2-O2 fluid system.
Definition: h2on2o2.hh:57
static constexpr bool useIdealGasDensity()
Definition: h2on2o2.hh:59
static constexpr bool useIdealGasHeatCapacities()
Definition: h2on2o2.hh:62
static constexpr bool useH2ODensityAsLiquidMixtureDensity()
Definition: h2on2o2.hh:58
static constexpr bool useN2ViscosityAsGasMixtureViscosity()
Definition: h2on2o2.hh:60
static constexpr bool useN2HeatConductivityAsGasMixtureHeatConductivity()
Definition: h2on2o2.hh:61
A two-phase (water and air) fluid system with water, nitrogen and oxygen as components.
Definition: h2on2o2.hh:78
static std::string phaseName(int phaseIdx)
Return the human readable name of a fluid phase.
Definition: h2on2o2.hh:124
static constexpr int comp1Idx
Definition: h2on2o2.hh:109
static Scalar criticalTemperature(int compIdx)
Critical temperature of a component .
Definition: h2on2o2.hh:251
static constexpr int numSPhases
Definition: h2on2o2.hh:97
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition: h2on2o2.hh:140
static constexpr int N2Idx
Definition: h2on2o2.hh:105
static constexpr int H2OIdx
Definition: h2on2o2.hh:104
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: h2on2o2.hh:683
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in a specific phase.
Definition: h2on2o2.hh:791
static Scalar molarMass(int compIdx)
Return the molar mass of a component in .
Definition: h2on2o2.hh:234
static bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: h2on2o2.hh:194
static constexpr int phase1Idx
index of the second phase
Definition: h2on2o2.hh:102
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: h2on2o2.hh:206
static std::string componentName(int compIdx)
Return the human readable name of a component.
Definition: h2on2o2.hh:217
static constexpr int liquidPhaseIdx
index of the liquid phase
Definition: h2on2o2.hh:99
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Returns the fugacity coefficient of a component in a phase.
Definition: h2on2o2.hh:614
static constexpr int gasPhaseMainCompIdx
Definition: h2on2o2.hh:114
static constexpr bool isCompressible(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: h2on2o2.hh:178
static Scalar kelvinVaporPressure(const FluidState &fluidState, const int phaseIdx, const int compIdx, const Scalar radius)
Kelvin equation in .
Definition: h2on2o2.hh:320
static Scalar density(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure, and the partial pressures of all components,...
Definition: h2on2o2.hh:446
static Scalar acentricFactor(int compIdx)
The acentric factor of a component .
Definition: h2on2o2.hh:296
static constexpr int phase0Idx
index of the first phase
Definition: h2on2o2.hh:101
static void init()
Initialize the fluid system's static parameters generically.
Definition: h2on2o2.hh:394
static constexpr int numPhases
Number of phases in the fluid system.
Definition: h2on2o2.hh:95
static constexpr int liquidPhaseMainCompIdx
Definition: h2on2o2.hh:113
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
The molar density of a fluid phase in .
Definition: h2on2o2.hh:504
static Scalar kelvinVaporPressure(const FluidState &fluidState, const int phaseIdx, const int compIdx)
Vapor pressure including the Kelvin equation in .
Definition: h2on2o2.hh:349
static bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: h2on2o2.hh:160
static constexpr int gasPhaseIdx
index of the gas phase
Definition: h2on2o2.hh:100
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase. .
Definition: h2on2o2.hh:873
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: h2on2o2.hh:833
static Scalar criticalPressure(int compIdx)
Critical pressure of a component .
Definition: h2on2o2.hh:268
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the molecular diffusion coefficient for a component in a fluid phase .
Definition: h2on2o2.hh:664
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: h2on2o2.hh:542
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition: h2on2o2.hh:755
static constexpr int O2Idx
Definition: h2on2o2.hh:106
static constexpr int comp0Idx
Definition: h2on2o2.hh:108
static Scalar surfaceTension(const FluidState &fluidState)
Calculate the surface tension between water and air in , according to IAPWS Release on Surface Tensio...
Definition: h2on2o2.hh:372
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: h2on2o2.hh:415
static constexpr int comp2Idx
Definition: h2on2o2.hh:110
static constexpr int numComponents
Number of components in the fluid system.
Definition: h2on2o2.hh:96
static Scalar criticalMolarVolume(int compIdx)
Molar volume of a component at the critical point .
Definition: h2on2o2.hh:285
Relations valid for an ideal gas.
Definition: idealgas.hh:37
static constexpr Scalar molarDensity(Scalar temperature, Scalar pressure)
The molar density of the gas , depending on pressure and temperature.
Definition: idealgas.hh:70