24#ifndef DUMUX_H2O_N2_FLUID_SYSTEM_HH
25#define DUMUX_H2O_N2_FLUID_SYSTEM_HH
50template<
bool fastButSimplifiedRelations = false>
66template <
class Scalar,
class Policy = H2ON2DefaultPolicy<>>
68 :
public Base<Scalar, H2ON2<Scalar, Policy> >
79 using H2O = TabulatedH2O;
107 assert(0 <= phaseIdx && phaseIdx <
numPhases);
113 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
127 static constexpr bool isGas(
int phaseIdx)
129 assert(0 <= phaseIdx && phaseIdx <
numPhases);
149 assert(0 <= phaseIdx && phaseIdx <
numPhases);
167 assert(0 <= phaseIdx && phaseIdx <
numPhases);
183 assert(0 <= phaseIdx && phaseIdx <
numPhases);
207 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << compIdx);
217 static const Scalar M[] = {
233 static const Scalar Tcrit[] = {
239 return Tcrit[compIdx];
249 static const Scalar pcrit[] = {
255 return pcrit[compIdx];
267 template <
class Flu
idState>
276 * fluidState.pressure(phaseIdx)
278 /
density(fluidState, phaseIdx)
280 / fluidState.temperature());
290 DUNE_THROW(Dune::NotImplemented,
291 "H2ON2FluidSystem::criticalMolarVolume()");
301 static const Scalar accFac[] = {
302 H2O::acentricFactor(),
307 return accFac[compIdx];
344 std::cout <<
"The H2O-N2 fluid system was configured with the following policy:\n";
345 std::cout <<
" - use H2O density as liquid mixture density: " << std::boolalpha << Policy::useH2ODensityAsLiquidMixtureDensity() <<
"\n";
346 std::cout <<
" - use ideal gas density: " << std::boolalpha << Policy::useIdealGasDensity() <<
"\n";
347 std::cout <<
" - use N2 viscosity as gas mixture viscosity: " << std::boolalpha << Policy::useN2ViscosityAsGasMixtureViscosity() <<
"\n";
348 std::cout <<
" - use N2 heat conductivity as gas mixture heat conductivity: " << std::boolalpha << Policy::useN2HeatConductivityAsGasMixtureHeatConductivity() <<
"\n";
349 std::cout <<
" - use ideal gas heat capacities: " << std::boolalpha << Policy::useIdealGasHeatCapacities() << std::endl;
354 pressMin, pressMax, nPress);
371 template <
class Flu
idState>
375 assert(0 <= phaseIdx && phaseIdx <
numPhases);
377 Scalar T = fluidState.temperature(phaseIdx);
378 Scalar p = fluidState.pressure(phaseIdx);
382 if (Policy::useH2ODensityAsLiquidMixtureDensity())
398 if (Policy::useIdealGasDensity())
408 return (rho_gH2O + rho_gN2);
424 template <
class Flu
idState>
427 assert(0 <= phaseIdx && phaseIdx <
numPhases);
429 Scalar T = fluidState.temperature(phaseIdx);
430 Scalar p = fluidState.pressure(phaseIdx);
442 if (Policy::useIdealGasDensity())
451 return rho_gH2O + rho_gN2;
467 template <
class Flu
idState>
471 assert(0 <= phaseIdx && phaseIdx <
numPhases);
473 Scalar T = fluidState.temperature(phaseIdx);
474 Scalar p = fluidState.pressure(phaseIdx);
483 if (Policy::useN2ViscosityAsGasMixtureViscosity())
500 sumx += fluidState.moleFraction(phaseIdx, compIdx);
501 sumx = max(1e-10, sumx);
511 divisor += fluidState.moleFraction(phaseIdx, j)/sumx * phiIJ;
513 muResult += fluidState.moleFraction(phaseIdx, i)/sumx * mu[i] / divisor;
548 template <
class Flu
idState>
553 assert(0 <= phaseIdx && phaseIdx <
numPhases);
556 Scalar T = fluidState.temperature(phaseIdx);
557 Scalar p = fluidState.pressure(phaseIdx);
595 template <
class Flu
idState>
600 DUNE_THROW(Dune::NotImplemented,
"Diffusion coefficients");
614 template <
class Flu
idState>
621 static Scalar undefined(1e10);
624 if (compIIdx > compJIdx)
627 swap(compIIdx, compJIdx);
631 if (compIIdx == compJIdx ||
635 DUNE_THROW(Dune::InvalidStateException,
636 "Binary diffusion coefficient of components "
637 << compIIdx <<
" and " << compJIdx
638 <<
" in phase " << phaseIdx <<
" is undefined!\n");
642 Scalar T = fluidState.temperature(phaseIdx);
643 Scalar p = fluidState.pressure(phaseIdx);
671 template <
class Flu
idState>
675 Scalar T = fluidState.temperature(phaseIdx);
676 Scalar p = fluidState.pressure(phaseIdx);
705 template <
class Flu
idState>
710 const Scalar T = fluidState.temperature(phaseIdx);
711 const Scalar p = fluidState.pressure(phaseIdx);
715 if (componentIdx ==
H2OIdx)
717 else if (componentIdx ==
N2Idx)
718 DUNE_THROW(Dune::NotImplemented,
"Component enthalpy of nitrogen in liquid phase");
720 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << componentIdx);
724 if (componentIdx ==
H2OIdx)
726 else if (componentIdx ==
N2Idx)
729 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << componentIdx);
732 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
744 template <
class Flu
idState>
748 assert(0 <= phaseIdx && phaseIdx <
numPhases);
750 const Scalar temperature = fluidState.temperature(phaseIdx) ;
751 const Scalar pressure = fluidState.pressure(phaseIdx);
759 if (!Policy::useN2HeatConductivityAsGasMixtureHeatConductivity())
761 Scalar xN2 = fluidState.moleFraction(phaseIdx,
N2Idx);
762 Scalar xH2O = fluidState.moleFraction(phaseIdx,
H2OIdx);
763 Scalar lambdaN2 = xN2 * lambdaPureN2;
764 Scalar partialPressure = pressure * xH2O;
766 return lambdaN2 + lambdaH2O;
781 template <
class Flu
idState>
787 fluidState.pressure(phaseIdx));
794 if (!Policy::useIdealGasHeatCapacities()) {
796 fluidState.pressure(phaseIdx)
797 * fluidState.moleFraction(phaseIdx,
N2Idx));
800 fluidState.pressure(phaseIdx)
801 * fluidState.moleFraction(phaseIdx,
H2OIdx));
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.
Material properties of pure water .
Tabulates all thermodynamic properties of a given untabulated chemical species.
Properties of pure molecular nitrogen .
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
void SetUndefined(const T &value)
Make the memory on which an object resides undefined.
Definition valgrind.hh:102
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
Definition 1padapter.hh:35
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
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
Tabulates all thermodynamic properties of a given untabulated chemical species.
Definition tabulatedcomponent.hh:82
static const Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:238
static Scalar criticalTemperature()
Definition tabulatedcomponent.hh:184
static const Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:292
static std::string name()
Definition tabulatedcomponent.hh:172
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:619
static Scalar gasDensity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:456
static const Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:265
static Scalar criticalPressure()
Definition tabulatedcomponent.hh:190
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:529
static constexpr Scalar molarMass()
Definition tabulatedcomponent.hh:178
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:565
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:538
static constexpr bool liquidIsCompressible()
Definition tabulatedcomponent.hh:439
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:495
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:592
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:485
static constexpr bool isTabulated
Definition tabulatedcomponent.hh:88
static Scalar vaporPressure(Scalar T)
Definition tabulatedcomponent.hh:211
static void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp, Scalar pressMin, Scalar pressMax, std::size_t nPress)
Definition tabulatedcomponent.hh:100
static constexpr bool gasIsIdeal()
Definition tabulatedcomponent.hh:445
static const Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Definition tabulatedcomponent.hh:319
static constexpr Scalar R
The ideal gas constant .
Definition constants.hh:44
Fluid system base class.
Definition fluidsystems/base.hh:45
Scalar Scalar
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 fluid system.
Definition h2on2.hh:52
static constexpr bool useIdealGasHeatCapacities()
Definition h2on2.hh:57
static constexpr bool useN2HeatConductivityAsGasMixtureHeatConductivity()
Definition h2on2.hh:56
static constexpr bool useIdealGasDensity()
Definition h2on2.hh:54
static constexpr bool useH2ODensityAsLiquidMixtureDensity()
Definition h2on2.hh:53
static constexpr bool useN2ViscosityAsGasMixtureViscosity()
Definition h2on2.hh:55
A two-phase fluid system with two components water Nitrogen for non-equilibrium models.
Definition h2on2.hh:69
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition h2on2.hh:127
static constexpr int liquidPhaseIdx
Definition h2on2.hh:85
static bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition h2on2.hh:147
static Scalar molarMass(int compIdx)
Return the molar mass of a component in .
Definition h2on2.hh:215
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase. .
Definition h2on2.hh:782
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of a fluid phase .
Definition h2on2.hh:745
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:615
static constexpr int phase1Idx
Definition h2on2.hh:88
static constexpr int liquidCompIdx
Definition h2on2.hh:94
static Scalar criticalMolarVolume(int compIdx)
Molar volume of a component at the critical point .
Definition h2on2.hh:288
static constexpr int N2Idx
Definition h2on2.hh:91
static constexpr bool isCompressible(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition h2on2.hh:165
static constexpr int comp1Idx
Definition h2on2.hh:93
static constexpr int gasPhaseIdx
Definition h2on2.hh:86
static std::string componentName(int compIdx)
Return the human readable name of a component.
Definition h2on2.hh:199
static constexpr int H2OIdx
Definition h2on2.hh:90
TabulatedH2O H2O
Definition h2on2.hh:79
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:341
static void init()
Initialize the fluid system's static parameters generically.
Definition h2on2.hh:320
static constexpr int comp0Idx
Definition h2on2.hh:92
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in the specified phase.
Definition h2on2.hh:706
static Scalar acentricFactor(int compIdx)
The acentric factor of a component .
Definition h2on2.hh:299
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:549
static constexpr int phase0Idx
Definition h2on2.hh:87
static Scalar density(const FluidState &fluidState, int phaseIdx)
Definition h2on2.hh:372
static Scalar kelvinVaporPressure(const FluidState &fluidState, const int phaseIdx, const int compIdx)
Vapor pressure including the Kelvin equation in .
Definition h2on2.hh:268
static Scalar criticalPressure(int compIdx)
Critical pressure of a component .
Definition h2on2.hh:247
static constexpr int numComponents
Definition h2on2.hh:83
static constexpr int numPhases
Definition h2on2.hh:82
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition h2on2.hh:119
SimpleN2 N2
Definition h2on2.hh:80
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
The molar density of a fluid phase in .
Definition h2on2.hh:425
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition h2on2.hh:672
static constexpr int gasCompIdx
Definition h2on2.hh:95
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the molecular diffusion coefficient for a component in a fluid phase .
Definition h2on2.hh:596
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition h2on2.hh:468
static bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition h2on2.hh:181
static Scalar criticalTemperature(int compIdx)
Critical temperature of a component .
Definition h2on2.hh:231
static std::string phaseName(int phaseIdx)
Return the human readable name of a fluid phase.
Definition h2on2.hh:105
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