12#ifndef DUMUX_H2O_N2_FLUID_SYSTEM_HH
13#define DUMUX_H2O_N2_FLUID_SYSTEM_HH
32namespace FluidSystems {
38template<
bool fastButSimplifiedRelations = false>
54template <
class Scalar,
class Policy = H2ON2DefaultPolicy<>>
56 :
public Base<Scalar, H2ON2<Scalar, Policy> >
94 assert(0 <= phaseIdx && phaseIdx <
numPhases);
100 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
114 static constexpr bool isGas(
int phaseIdx)
116 assert(0 <= phaseIdx && phaseIdx <
numPhases);
136 assert(0 <= phaseIdx && phaseIdx <
numPhases);
154 assert(0 <= phaseIdx && phaseIdx <
numPhases);
170 assert(0 <= phaseIdx && phaseIdx <
numPhases);
194 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << compIdx);
204 static const Scalar M[] = {
220 static const Scalar Tcrit[] = {
226 return Tcrit[compIdx];
236 static const Scalar pcrit[] = {
242 return pcrit[compIdx];
254 template <
class Flu
idState>
263 * fluidState.pressure(phaseIdx)
265 /
density(fluidState, phaseIdx)
267 / fluidState.temperature());
277 DUNE_THROW(Dune::NotImplemented,
278 "H2ON2FluidSystem::criticalMolarVolume()");
288 static const Scalar accFac[] = {
289 H2O::acentricFactor(),
294 return accFac[compIdx];
331 std::cout <<
"The H2O-N2 fluid system was configured with the following policy:\n";
332 std::cout <<
" - use H2O density as liquid mixture density: " << std::boolalpha << Policy::useH2ODensityAsLiquidMixtureDensity() <<
"\n";
333 std::cout <<
" - use ideal gas density: " << std::boolalpha << Policy::useIdealGasDensity() <<
"\n";
334 std::cout <<
" - use N2 viscosity as gas mixture viscosity: " << std::boolalpha << Policy::useN2ViscosityAsGasMixtureViscosity() <<
"\n";
335 std::cout <<
" - use N2 heat conductivity as gas mixture heat conductivity: " << std::boolalpha << Policy::useN2HeatConductivityAsGasMixtureHeatConductivity() <<
"\n";
336 std::cout <<
" - use ideal gas heat capacities: " << std::boolalpha << Policy::useIdealGasHeatCapacities() << std::endl;
339 H2O::init(tempMin, tempMax, nTemp, pressMin, pressMax, nPress);
355 template <
class Flu
idState>
359 assert(0 <= phaseIdx && phaseIdx <
numPhases);
361 Scalar T = fluidState.temperature(phaseIdx);
362 Scalar p = fluidState.pressure(phaseIdx);
366 if (Policy::useH2ODensityAsLiquidMixtureDensity())
382 if (Policy::useIdealGasDensity())
392 return (rho_gH2O + rho_gN2);
397 template <
class Flu
idState>
400 assert(0 <= phaseIdx && phaseIdx <
numPhases);
402 Scalar T = fluidState.temperature(phaseIdx);
403 Scalar p = fluidState.pressure(phaseIdx);
415 if (Policy::useIdealGasDensity())
424 return rho_gH2O + rho_gN2;
440 template <
class Flu
idState>
444 assert(0 <= phaseIdx && phaseIdx <
numPhases);
446 Scalar T = fluidState.temperature(phaseIdx);
447 Scalar p = fluidState.pressure(phaseIdx);
456 if (Policy::useN2ViscosityAsGasMixtureViscosity())
473 sumx += fluidState.moleFraction(phaseIdx, compIdx);
474 sumx = max(1e-10, sumx);
484 divisor += fluidState.moleFraction(phaseIdx, j)/sumx * phiIJ;
486 muResult += fluidState.moleFraction(phaseIdx, i)/sumx * mu[i] / divisor;
495 template <
class Flu
idState>
500 assert(0 <= phaseIdx && phaseIdx <
numPhases);
503 Scalar T = fluidState.temperature(phaseIdx);
504 Scalar p = fluidState.pressure(phaseIdx);
520 template <
class Flu
idState>
525 DUNE_THROW(Dune::NotImplemented,
"Diffusion coefficients");
530 template <
class Flu
idState>
537 if (compIIdx > compJIdx)
540 swap(compIIdx, compJIdx);
543 const Scalar T = fluidState.temperature(phaseIdx);
544 const Scalar p = fluidState.pressure(phaseIdx);
553 DUNE_THROW(Dune::InvalidStateException,
554 "Binary diffusion coefficient of components "
555 << compIIdx <<
" and " << compJIdx
556 <<
" in phase " << phaseIdx <<
" is unavailable!\n");
572 template <
class Flu
idState>
576 const Scalar T = fluidState.temperature(phaseIdx);
577 const Scalar p = fluidState.pressure(phaseIdx);
604 template <
class Flu
idState>
609 const Scalar T = fluidState.temperature(phaseIdx);
610 const Scalar p = fluidState.pressure(phaseIdx);
614 if (componentIdx ==
H2OIdx)
616 else if (componentIdx ==
N2Idx)
617 DUNE_THROW(Dune::NotImplemented,
"Component enthalpy of nitrogen in liquid phase");
619 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << componentIdx);
623 if (componentIdx ==
H2OIdx)
625 else if (componentIdx ==
N2Idx)
628 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << componentIdx);
631 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
643 template <
class Flu
idState>
647 assert(0 <= phaseIdx && phaseIdx <
numPhases);
658 if (!Policy::useN2HeatConductivityAsGasMixtureHeatConductivity())
660 Scalar xN2 = fluidState.moleFraction(phaseIdx,
N2Idx);
661 Scalar xH2O = fluidState.moleFraction(phaseIdx,
H2OIdx);
662 Scalar lambdaN2 = xN2 * lambdaPureN2;
665 return lambdaN2 + lambdaH2O;
674 template <
class Flu
idState>
680 fluidState.pressure(phaseIdx));
687 if (!Policy::useIdealGasHeatCapacities()) {
689 fluidState.pressure(phaseIdx)
690 * fluidState.moleFraction(phaseIdx,
N2Idx));
693 fluidState.pressure(phaseIdx)
694 * fluidState.moleFraction(phaseIdx,
H2OIdx));
static Scalar liquidDiffCoeff(Scalar temperature, Scalar pressure)
Diffusion coefficient for molecular nitrogen in liquid water.
Definition: h2o_n2.hh:85
static Scalar henry(Scalar temperature)
Henry coefficient for molecular nitrogen in liquid water.
Definition: h2o_n2.hh:36
static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure)
Binary diffusion coefficient for molecular water and nitrogen.
Definition: h2o_n2.hh:54
Properties of pure molecular nitrogen .
Definition: n2.hh:36
static Scalar criticalTemperature()
Returns the critical temperature of molecular nitrogen.
Definition: n2.hh:57
static Scalar criticalPressure()
Returns the critical pressure of molecular nitrogen.
Definition: n2.hh:63
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of at a given pressure and temperature.
Definition: n2.hh:221
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of gas in at a given pressure and temperature.
Definition: n2.hh:134
static std::string name()
A human readable name for nitrogen.
Definition: n2.hh:45
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of gas at a given pressure and temperature.
Definition: n2.hh:121
static constexpr Scalar molarMass()
The molar mass in of molecular nitrogen.
Definition: n2.hh:51
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of nitrogen.
Definition: n2.hh:259
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: n2.hh:146
static const Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of pure nitrogen gas. Shomate Equation is used for a temperature range of 100K to ...
Definition: n2.hh:168
static const Scalar gasHeatCapacity(Scalar T, Scalar pressure)
Specific isobaric heat capacity of pure nitrogen gas. Shomate Equation is used for a temperature ran...
Definition: n2.hh:201
Tabulates all thermodynamic properties of a given component.
Definition: tabulatedcomponent.hh:672
static const Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the gas .
Definition: tabulatedcomponent.hh:817
static Scalar criticalTemperature()
Returns the critical temperature in of the component.
Definition: tabulatedcomponent.hh:763
static const Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the gas .
Definition: tabulatedcomponent.hh:853
static std::string name()
A human readable name for the component.
Definition: tabulatedcomponent.hh:751
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
The thermal conductivity of liquid water .
Definition: tabulatedcomponent.hh:1081
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of gas at a given pressure and temperature .
Definition: tabulatedcomponent.hh:967
static const Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the liquid .
Definition: tabulatedcomponent.hh:835
static Scalar criticalPressure()
Returns the critical pressure in of the component.
Definition: tabulatedcomponent.hh:769
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density of liquid in at a given pressure and temperature.
Definition: tabulatedcomponent.hh:1018
static constexpr Scalar molarMass()
The molar mass in of the component.
Definition: tabulatedcomponent.hh:757
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of liquid.
Definition: tabulatedcomponent.hh:1045
static constexpr bool liquidIsCompressible()
Returns true if the liquid phase is assumed to be compressible.
Definition: tabulatedcomponent.hh:950
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
The density of liquid at a given pressure and temperature .
Definition: tabulatedcomponent.hh:997
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
The thermal conductivity of gaseous water .
Definition: tabulatedcomponent.hh:1063
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of gas in at a given pressure and temperature.
Definition: tabulatedcomponent.hh:987
static constexpr bool isTabulated
state that we are tabulated
Definition: tabulatedcomponent.hh:716
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the component at a given temperature.
Definition: tabulatedcomponent.hh:790
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:728
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: tabulatedcomponent.hh:956
static const Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the liquid .
Definition: tabulatedcomponent.hh:871
A central place for various physical constants occurring in some equations.
Definition: constants.hh:27
Fluid system base class.
Definition: fluidsystems/base.hh:33
Scalar Scalar
export the scalar type
Definition: fluidsystems/base.hh:36
A two-phase fluid system with two components water Nitrogen for non-equilibrium models.
Definition: h2on2.hh:57
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition: h2on2.hh:114
static constexpr int liquidPhaseIdx
index of the liquid phase
Definition: h2on2.hh:72
static bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: h2on2.hh:134
static Scalar molarMass(int compIdx)
Return the molar mass of a component in .
Definition: h2on2.hh:202
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: h2on2.hh:675
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: h2on2.hh:644
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: h2on2.hh:531
static constexpr int phase1Idx
index of the second phase
Definition: h2on2.hh:75
static constexpr int liquidCompIdx
index of the liquid component
Definition: h2on2.hh:81
static Scalar criticalMolarVolume(int compIdx)
Molar volume of a component at the critical point .
Definition: h2on2.hh:275
static constexpr int N2Idx
Definition: h2on2.hh:78
static constexpr bool isCompressible(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: h2on2.hh:152
static constexpr int comp1Idx
index of the second component
Definition: h2on2.hh:80
static constexpr int gasPhaseIdx
index of the gas phase
Definition: h2on2.hh:73
static std::string componentName(int compIdx)
Return the human readable name of a component.
Definition: h2on2.hh:186
static constexpr int H2OIdx
Definition: h2on2.hh:77
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: h2on2.hh:328
static void init()
Initialize the fluid system's static parameters generically.
Definition: h2on2.hh:307
static constexpr int comp0Idx
index of the first component
Definition: h2on2.hh:79
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in the specified phase.
Definition: h2on2.hh:605
static Scalar acentricFactor(int compIdx)
The acentric factor of a component .
Definition: h2on2.hh:286
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: h2on2.hh:496
static constexpr int phase0Idx
index of the first phase
Definition: h2on2.hh:74
static Scalar density(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure, and the partial pressures of all components,...
Definition: h2on2.hh:356
static Scalar kelvinVaporPressure(const FluidState &fluidState, const int phaseIdx, const int compIdx)
Vapor pressure including the Kelvin equation in .
Definition: h2on2.hh:255
static Scalar criticalPressure(int compIdx)
Critical pressure of a component .
Definition: h2on2.hh:234
static constexpr int numComponents
Number of components in the fluid system.
Definition: h2on2.hh:70
static constexpr int numPhases
Number of phases in the fluid system.
Definition: h2on2.hh:69
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: h2on2.hh:106
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: h2on2.hh:398
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition: h2on2.hh:573
static constexpr int gasCompIdx
index of the gas component
Definition: h2on2.hh:82
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: h2on2.hh:521
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: h2on2.hh:441
static bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: h2on2.hh:168
static Scalar criticalTemperature(int compIdx)
Critical temperature of a component .
Definition: h2on2.hh:218
static std::string phaseName(int phaseIdx)
Return the human readable name of a fluid phase.
Definition: h2on2.hh:92
Relations valid for an ideal gas.
Definition: idealgas.hh:25
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:37
static constexpr Scalar molarDensity(Scalar temperature, Scalar pressure)
The molar density of the gas , depending on pressure and temperature.
Definition: idealgas.hh:58
Some exceptions thrown in DuMux
Material properties of pure water .
Binary coefficients for water and nitrogen.
Relations valid for an ideal gas.
Properties of pure molecular nitrogen .
A collection of input/output field names for common physical quantities.
Scalar h2oGasViscosityInMixture(Scalar temperature, Scalar pressure)
The dynamic viscosity of steam in a gas mixture.
Definition: h2o.hh:961
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
std::string gaseousPhase() noexcept
I/O name of gaseous phase.
Definition: name.hh:111
std::string liquidPhase() noexcept
I/O name of liquid phase.
Definition: name.hh:107
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:22
Policy for the H2O-N2 fluid system.
Definition: h2on2.hh:40
static constexpr bool useIdealGasHeatCapacities()
Definition: h2on2.hh:45
static constexpr bool useN2HeatConductivityAsGasMixtureHeatConductivity()
Definition: h2on2.hh:44
static constexpr bool useIdealGasDensity()
Definition: h2on2.hh:42
static constexpr bool useH2ODensityAsLiquidMixtureDensity()
Definition: h2on2.hh:41
static constexpr bool useN2ViscosityAsGasMixtureViscosity()
Definition: h2on2.hh:43
Tabulates all thermodynamic properties of a given untabulated chemical species.