25#ifndef DUMUX_RICHARDS_VOLUME_VARIABLES_HH
26#define DUMUX_RICHARDS_VOLUME_VARIABLES_HH
30#include <dune/common/exceptions.hh>
62template <
class Traits>
66,
public std::conditional_t<Traits::ModelTraits::enableMolecularDiffusion(),
67 Detail::VolVarsWithPVSwitch, Detail::VolVarsWithOutPVSwitch>
71 using Scalar =
typename Traits::PrimaryVariables::value_type;
72 using PermeabilityType =
typename Traits::PermeabilityType;
73 using ModelTraits =
typename Traits::ModelTraits;
78 using EffDiffModel =
typename Traits::EffectiveDiffusivityModel;
90 using Indices =
typename Traits::ModelTraits::Indices;
103 template<
class ElemSol,
class Problem,
class Element,
class Scv>
105 const Problem &problem,
106 const Element &element,
114 const auto fluidMatrixInteraction = Deprecated::makePcKrSw(Scalar{}, problem.spatialParams(), element, scv, elemSol);
116 const auto&
priVars = elemSol[scv.localDofIndex()];
121 minPc_ = fluidMatrixInteraction.endPointPc();
123 typename FluidSystem::ParameterCache paramCache;
124 auto getEffectiveDiffusionCoefficient = [&](
int phaseIdx,
int compIIdx,
int compJIdx)
126 return EffDiffModel::effectiveDiffusionCoefficient(*
this, phaseIdx, compIIdx, compJIdx);
135 const auto averageMolarMassGasPhase = (
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)) +
136 ((1-
moleFraction_[FluidSystem::gasPhaseIdx])*FluidSystem::molarMass(FluidSystem::gasPhaseIdx));
139 massFraction_[FluidSystem::gasPhaseIdx] =
priVars[Indices::switchIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)/averageMolarMassGasPhase;
141 fluidState_.setSaturation(FluidSystem::liquidPhaseIdx, 0.0);
142 fluidState_.setSaturation(FluidSystem::gasPhaseIdx, 1.0);
147 const Scalar pc = fluidMatrixInteraction.pc(0.0);
150 fluidState_.setPressure(FluidSystem::liquidPhaseIdx, problem.nonwettingReferencePressure() - pc);
151 fluidState_.setPressure(FluidSystem::gasPhaseIdx, problem.nonwettingReferencePressure());
156 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
167 fluidState_.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(
fluidState_, paramCache, FluidSystem::liquidPhaseIdx));
168 fluidState_.setEnthalpy(FluidSystem::gasPhaseIdx, EnergyVolVars::enthalpy(
fluidState_, paramCache, FluidSystem::gasPhaseIdx));
173 FluidSystem::comp1Idx,
174 FluidSystem::comp0Idx);
184 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
188 moleFraction_[FluidSystem::gasPhaseIdx] = FluidSystem::H2O::vaporPressure(
temperature()) / problem.nonwettingReferencePressure();
190 const auto averageMolarMassGasPhase = (
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)) +
191 ((1-
moleFraction_[FluidSystem::gasPhaseIdx])*FluidSystem::molarMass(FluidSystem::gasPhaseIdx));
194 massFraction_[FluidSystem::gasPhaseIdx] =
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)/averageMolarMassGasPhase;
199 FluidSystem::comp1Idx,
200 FluidSystem::comp0Idx);
209 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
226 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv,
solidState_);
227 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
228 EnergyVolVars::updateEffectiveThermalConductivity();
245 template<
class ElemSol,
class Problem,
class Element,
class Scv>
247 const Problem& problem,
248 const Element& element,
258 const auto fluidMatrixInteraction = Deprecated::makePcKrSw(Scalar{}, problem.spatialParams(), element, scv, elemSol);
260 const auto&
priVars = elemSol[scv.localDofIndex()];
264 Scalar minPc = fluidMatrixInteraction.pc(1.0);
265 fluidState.setPressure(FluidSystem::liquidPhaseIdx,
priVars[Indices::pressureIdx]);
266 fluidState.setPressure(FluidSystem::gasPhaseIdx, max(problem.nonwettingReferencePressure(),
fluidState.pressure(FluidSystem::liquidPhaseIdx) + minPc));
272 const Scalar pc = max(fluidMatrixInteraction.endPointPc(),
273 problem.nonwettingReferencePressure() -
fluidState.pressure(FluidSystem::liquidPhaseIdx));
274 const Scalar sw = fluidMatrixInteraction.sw(pc);
275 fluidState.setSaturation(FluidSystem::liquidPhaseIdx, sw);
276 fluidState.setSaturation(FluidSystem::gasPhaseIdx, 1.0-sw);
279 typename FluidSystem::ParameterCache paramCache;
281 fluidState.setDensity(FluidSystem::liquidPhaseIdx,
283 fluidState.setDensity(FluidSystem::gasPhaseIdx,
286 fluidState.setViscosity(FluidSystem::liquidPhaseIdx,
290 fluidState.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(
fluidState, paramCache, FluidSystem::liquidPhaseIdx));
291 fluidState.setEnthalpy(FluidSystem::gasPhaseIdx, EnergyVolVars::enthalpy(
fluidState, paramCache, FluidSystem::gasPhaseIdx));
338 Scalar
saturation(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
347 Scalar
density(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
361 Scalar
pressure(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
375 Scalar
mobility(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
385 Scalar
viscosity(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
386 {
return phaseIdx == FluidSystem::liquidPhaseIdx ?
fluidState_.viscosity(FluidSystem::liquidPhaseIdx) : 0.0; }
428 Scalar
pressureHead(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
441 Scalar
waterContent(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
454 if (compIdx != FluidSystem::comp0Idx)
455 DUNE_THROW(Dune::InvalidStateException,
"There is only one component for Richards!");
469 if (compIdx != FluidSystem::comp0Idx)
470 DUNE_THROW(Dune::InvalidStateException,
"There is only one component for Richards!");
492 assert(phaseIdx == FluidSystem::gasPhaseIdx);
493 assert(compIIdx != compJIdx);
494 typename FluidSystem::ParameterCache paramCache;
496 return FluidSystem::binaryDiffusionCoefficient(
fluidState_, paramCache, phaseIdx, compIIdx, compJIdx);
505 assert(phaseIdx == FluidSystem::gasPhaseIdx);
506 assert(compIIdx != compJIdx);
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.
A central place for various physical constants occuring in some equations.
Relations valid for an ideal gas.
void updateSolidVolumeFractions(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState, const int solidVolFracOffset)
update the solid volume fractions (inert and reacitve) and set them in the solidstate
Definition: updatesolidvolumefractions.hh:36
std::string phasePresence() noexcept
I/O name of phase presence.
Definition: name.hh:147
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
static constexpr Scalar molarDensity(Scalar temperature, Scalar pressure)
The molar density of the gas , depending on pressure and temperature.
Definition: idealgas.hh:70
Definition: porousmediumflow/nonisothermal/volumevariables.hh:75
The primary variable switch controlling the phase presence state variable.
Definition: richards/primaryvariableswitch.hh:41
Helper structs to conditionally use a primary variable switch or not.
Definition: porousmediumflow/richards/volumevariables.hh:47
Definition: porousmediumflow/richards/volumevariables.hh:52
Volume averaged quantities required by the Richards model.
Definition: porousmediumflow/richards/volumevariables.hh:68
Scalar density(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the average mass density of a given fluid phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:347
FluidState fluidState_
the fluid state
Definition: porousmediumflow/richards/volumevariables.hh:511
Scalar relativePermeabilityWetting_
the relative permeability of the wetting phase
Definition: porousmediumflow/richards/volumevariables.hh:513
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:325
Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: porousmediumflow/richards/volumevariables.hh:489
Scalar porosity() const
Returns the average porosity [] within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:319
Scalar pressureHead(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the pressureHead of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:428
Scalar moleFraction(const int phaseIdx, const int compIdx) const
Returns the mole fraction of a given component in a given phase within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:451
SolidState solidState_
Definition: porousmediumflow/richards/volumevariables.hh:512
const FluidState & fluidState() const
Returns the fluid configuration at the given primary variables.
Definition: porousmediumflow/richards/volumevariables.hh:298
static constexpr bool enableWaterDiffusionInAir()
If water diffusion in air is enabled.
Definition: porousmediumflow/richards/volumevariables.hh:92
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/richards/volumevariables.hh:104
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:408
PermeabilityType permeability_
the instrinsic permeability
Definition: porousmediumflow/richards/volumevariables.hh:514
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/richards/volumevariables.hh:89
Scalar pressure(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:361
Scalar waterContent(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the water content of a fluid phase within the finite volume.
Definition: porousmediumflow/richards/volumevariables.hh:441
Scalar viscosity(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the dynamic viscosity of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:385
Scalar massFraction_[numPhases]
The water mass fractions in water and air.
Definition: porousmediumflow/richards/volumevariables.hh:517
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the effective diffusion coefficients for a phase in .
Definition: porousmediumflow/richards/volumevariables.hh:502
Scalar molarDensity_[numPhases]
The molar density of water and air.
Definition: porousmediumflow/richards/volumevariables.hh:518
Scalar mobility(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:375
typename Traits::ModelTraits::Indices Indices
Definition: porousmediumflow/richards/volumevariables.hh:90
Scalar relativePermeability(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns relative permeability [-] of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:394
Scalar moleFraction_[numPhases]
The water mole fractions in water and air.
Definition: porousmediumflow/richards/volumevariables.hh:516
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:304
typename Traits::SolidState SolidState
Definition: porousmediumflow/richards/volumevariables.hh:87
Scalar effectiveDiffCoeff_
Definition: porousmediumflow/richards/volumevariables.hh:521
Scalar saturation(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the average absolute saturation [] of a given fluid phase within the finite volume.
Definition: porousmediumflow/richards/volumevariables.hh:338
void completeFluidState(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Fills the fluid state according to the primary variables.
Definition: porousmediumflow/richards/volumevariables.hh:246
Scalar molarDensity(const int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:480
Scalar massFraction(const int phaseIdx, const int compIdx) const
Returns the mole fraction of a given component in a given phase within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:466
typename Traits::FluidSystem FluidSystem
Export type of the fluid system.
Definition: porousmediumflow/richards/volumevariables.hh:82
typename Traits::FluidState FluidState
Export type of the fluid state.
Definition: porousmediumflow/richards/volumevariables.hh:84
Scalar temperature() const
Returns the temperature.
Definition: porousmediumflow/richards/volumevariables.hh:310
Scalar minPc_
the minimum capillary pressure (entry pressure)
Definition: porousmediumflow/richards/volumevariables.hh:515
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:40
static constexpr int numFluidComponents()
Return number of components considered by the model.
Definition: porousmediumflow/volumevariables.hh:52
const PrimaryVariables & priVars() const
Returns the vector of primary variables.
Definition: porousmediumflow/volumevariables.hh:76
static constexpr int numFluidPhases()
Return number of phases considered by the model.
Definition: porousmediumflow/volumevariables.hh:50
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/volumevariables.hh:64
Base class for the model specific class which provides access to all volume averaged quantities.
Base class for the model specific class which provides access to all volume averaged quantities.
The primary variable switch for the extended Richards model.