24#ifndef DUMUX_BRINE_AIR_FLUID_SYSTEM_HH
25#define DUMUX_BRINE_AIR_FLUID_SYSTEM_HH
48namespace FluidSystems {
54template<
bool fastButSimplifiedRelations = false>
69template <
class Scalar,
71 class Policy = BrineAirDefaultPolicy<>>
73:
public Base<Scalar, BrineAir<Scalar, H2Otype, Policy>>
117 struct BrineAdapterPolicy
119 using FluidSystem =
Brine;
121 static constexpr int phaseIdx(
int brinePhaseIdx) {
return liquidPhaseIdx; }
122 static constexpr int compIdx(
int brineCompIdx)
124 switch (brineCompIdx)
133 template<
class Flu
idState>
148 assert(0 <= phaseIdx && phaseIdx <
numPhases);
154 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
167 static constexpr bool isGas(
int phaseIdx)
169 assert(0 <= phaseIdx && phaseIdx <
numPhases);
189 assert(0 <= phaseIdx && phaseIdx <
numPhases);
207 assert(0 <= phaseIdx && phaseIdx <
numPhases);
222 assert(0 <= phaseIdx && phaseIdx <
numPhases);
235 assert(0 <= phaseIdx && phaseIdx <
numPhases);
254 case H2OIdx:
return H2O::name();
258 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << compIdx);
270 case H2OIdx:
return H2O::molarMass();
274 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << compIdx);
283 template <
class Flu
idState>
291 DUNE_THROW(Dune::NotImplemented,
"NaCl::vaporPressure(t)");
293 DUNE_THROW(Dune::NotImplemented,
"Invalid component index " << compIdx);
326 static void init(Scalar tempMin, Scalar tempMax,
unsigned nTemp,
327 Scalar pressMin, Scalar pressMax,
unsigned nPress)
329 std::cout <<
"The brine-air fluid system was configured with the following policy:\n";
330 std::cout <<
" - use brine density as liquid mixture density: " << std::boolalpha << Policy::useBrineDensityAsLiquidMixtureDensity() <<
"\n";
331 std::cout <<
" - use ideal gas density: " << std::boolalpha << Policy::useIdealGasDensity() << std::endl;
333 if (H2O::isTabulated)
334 H2O::init(tempMin, tempMax, nTemp, pressMin, pressMax, nPress);
351 template <
class Flu
idState>
352 static Scalar
density(
const FluidState &fluidState,
int phaseIdx)
354 assert(0 <= phaseIdx && phaseIdx <
numPhases);
356 const auto T = fluidState.temperature(phaseIdx);
357 const auto p = fluidState.pressure(phaseIdx);
362 if (Policy::useBrineDensityAsLiquidMixtureDensity())
375 if (Policy::useIdealGasDensity())
380 return H2O::gasDensity(T, fluidState.partialPressure(
phase1Idx,
H2OIdx))
384 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
397 template <
class Flu
idState>
404 const Scalar T = fluidState.temperature(phaseIdx);
407 if (Policy::useIdealGasDensity())
412 return H2O::gasMolarDensity(T, fluidState.partialPressure(
phase1Idx,
H2OIdx))
416 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
430 template <
class Flu
idState>
431 static Scalar
viscosity(
const FluidState& fluidState,
int phaseIdx)
433 assert(0 <= phaseIdx && phaseIdx <
numPhases);
438 return Air::gasViscosity(fluidState.temperature(phaseIdx), fluidState.pressure(phaseIdx));
463 template <
class Flu
idState>
466 assert(0 <= phaseIdx && phaseIdx <
numPhases);
469 Scalar T = fluidState.temperature(phaseIdx);
470 Scalar p = fluidState.pressure(phaseIdx);
484 return H2O::vaporPressure(T)/p;
486 else if (compIdx ==
AirIdx)
494 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
498 template <
class Flu
idState>
503 DUNE_THROW(Dune::NotImplemented,
"Diffusion coefficients");
517 template <
class Flu
idState>
523 assert(0 <= phaseIdx && phaseIdx <
numPhases);
527 const auto T = fluidState.temperature(phaseIdx);
528 const auto p = fluidState.pressure(phaseIdx);
530 if (compIIdx > compJIdx)
531 std::swap(compIIdx, compJIdx);
540 DUNE_THROW(Dune::NotImplemented,
"Binary diffusion coefficient of components "
541 << compIIdx <<
" and " << compJIdx
542 <<
" in phase " << phaseIdx);
556 DUNE_THROW(Dune::NotImplemented,
"Binary diffusion coefficient of components "
557 << compIIdx <<
" and " << compJIdx
558 <<
" in phase " << phaseIdx);
561 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
584 template <
class Flu
idState>
585 static Scalar
enthalpy(
const FluidState& fluidState,
int phaseIdx)
587 assert(0 <= phaseIdx && phaseIdx <
numPhases);
589 const Scalar T = fluidState.temperature(phaseIdx);
590 const Scalar p = fluidState.pressure(phaseIdx);
609 template <
class Flu
idState>
612 const Scalar T = fluidState.temperature(
gasPhaseIdx);
616 DUNE_THROW(Dune::NotImplemented,
"The component enthalpies in the liquid phase are not implemented.");
620 if (componentIdx ==
H2OIdx)
621 return H2O::gasEnthalpy(T, p);
622 else if (componentIdx ==
AirIdx)
624 else if (componentIdx ==
NaClIdx)
625 DUNE_THROW(Dune::InvalidStateException,
"Implementation assumes NaCl not to be present in gas phase");
626 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << componentIdx);
628 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
641 template <
class Flu
idState>
649 DUNE_THROW(Dune::InvalidStateException,
"Invalid phase index " << phaseIdx);
663 template <
class Flu
idState>
666 const Scalar T = fluidState.temperature(phaseIdx);
667 const Scalar p = fluidState.pressure(phaseIdx);
677 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 salt .
Tabulates all thermodynamic properties of a given untabulated chemical species.
A simple class for the air fluid properties.
Material properties of pure water .
Adapter class for fluid states with different indices.
Relations valid for an ideal gas.
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
Binary coefficients for water and air.
Definition: h2o_air.hh:37
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:307
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of Air at a given pressure and temperature.
Definition: air.hh:187
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of air.
Definition: air.hh:345
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:270
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
A class for the NaCl properties.
Definition: nacl.hh:47
static std::string name()
A human readable name for the NaCl.
Definition: nacl.hh:52
static constexpr Scalar molarMass()
The molar mass of NaCl in .
Definition: nacl.hh:60
Tabulates all thermodynamic properties of a given untabulated chemical species.
Definition: tabulatedcomponent.hh:82
Adapter class for fluid states with different indices.
Definition: adapter.hh:44
Fluid system base class.
Definition: fluidsystems/base.hh:45
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
A compositional single phase fluid system consisting of two components, which are H2O and NaCl.
Definition: fluidsystems/brine.hh:47
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: fluidsystems/brine.hh:482
static Scalar viscosity(const FluidState &fluidState, int phaseIdx=liquidPhaseIdx)
Return the viscosity of the phase.
Definition: fluidsystems/brine.hh:281
static constexpr int H2OIdx
index of the water component
Definition: fluidsystems/brine.hh:62
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase. .
Definition: fluidsystems/brine.hh:500
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature and pressure, return its specific enthalpy .
Definition: fluidsystems/brine.hh:337
static Scalar vaporPressure(const FluidState &fluidState, int compIdx)
Vapor pressure of a component .
Definition: fluidsystems/brine.hh:308
static constexpr int NaClIdx
index of the NaCl component
Definition: fluidsystems/brine.hh:63
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx=liquidPhaseIdx)
The molar density of the fluid phase in .
Definition: fluidsystems/brine.hh:418
static constexpr int liquidPhaseIdx
The one considered phase is liquid.
Definition: fluidsystems/brine.hh:60
static bool isCompressible(int phaseIdx=liquidPhaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: fluidsystems/brine.hh:125
static Scalar density(const FluidState &fluidState, int phaseIdx=liquidPhaseIdx)
Return the phase density [kg/m^3].
Definition: fluidsystems/brine.hh:225
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/brine.hh:445
Policy for the brine-air fluid system.
Definition: brineair.hh:56
static constexpr bool useIdealGasDensity()
Definition: brineair.hh:58
static constexpr bool useBrineDensityAsLiquidMixtureDensity()
Definition: brineair.hh:57
A compositional two-phase fluid system with a liquid and a gaseous phase and , and (dissolved miner...
Definition: brineair.hh:74
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in a specific phase.
Definition: brineair.hh:610
static Scalar density(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure, and the partial pressures of all components,...
Definition: brineair.hh:352
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: brineair.hh:642
static constexpr int comp0Idx
Definition: brineair.hh:112
static constexpr bool isCompressible(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: brineair.hh:205
static constexpr int liquidPhaseIdx
Definition: brineair.hh:100
static constexpr int AirIdx
Definition: brineair.hh:110
static constexpr int NaClIdx
Definition: brineair.hh:111
static void init()
Initialize the fluid system's static parameters generically.
Definition: brineair.hh:305
static constexpr int numPhases
Definition: brineair.hh:97
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Definition: brineair.hh:664
static constexpr int numComponents
Definition: brineair.hh:98
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: brineair.hh:518
H2Otype H2O
export the involved components
Definition: brineair.hh:81
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: brineair.hh:431
static constexpr int comp2Idx
Definition: brineair.hh:114
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature and pressure, return its specific enthalpy .
Definition: brineair.hh:585
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
The molar density of a fluid phase in .
Definition: brineair.hh:398
static constexpr int getMainComponent(int phaseIdx)
Get the main component of a given phase if possible.
Definition: brineair.hh:233
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition: brineair.hh:167
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Returns the fugacity coefficient of a component in a phase.
Definition: brineair.hh:464
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: brineair.hh:326
static Scalar molarMass(int compIdx)
Return the molar mass of a component in .
Definition: brineair.hh:265
static Scalar vaporPressure(const FluidState &fluidState, int compIdx)
Vapor pressure of a component .
Definition: brineair.hh:284
static std::string componentName(int compIdx)
Return the human readable name of a component.
Definition: brineair.hh:249
static std::string phaseName(int phaseIdx)
Return the human readable name of a fluid phase.
Definition: brineair.hh:146
static constexpr int comp1Idx
Definition: brineair.hh:113
static constexpr int phase1Idx
Definition: brineair.hh:104
static constexpr int phase0Idx
Definition: brineair.hh:103
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: brineair.hh:160
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Definition: brineair.hh:499
static bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: brineair.hh:220
static constexpr int gasPhaseIdx
Definition: brineair.hh:101
static bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: brineair.hh:187
Dumux::FluidSystems::Brine< Scalar, H2Otype > Brine
export the underlying brine fluid system for the liquid phase
Definition: brineair.hh:86
static constexpr int H2OIdx
Definition: brineair.hh:109
The a parameter cache which does nothing.
Definition: nullparametercache.hh:34
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
A fluid system for brine, i.e. H2O with dissolved NaCl.