25#ifndef DUMUX_RICHARDS_VOLUME_VARIABLES_HH
26#define DUMUX_RICHARDS_VOLUME_VARIABLES_HH
30#include <dune/common/exceptions.hh>
60template <
class Traits>
64,
public std::conditional_t<Traits::ModelTraits::enableMolecularDiffusion(),
65 Detail::VolVarsWithPVSwitch, Detail::VolVarsWithOutPVSwitch>
69 using Scalar =
typename Traits::PrimaryVariables::value_type;
70 using PermeabilityType =
typename Traits::PermeabilityType;
71 using ModelTraits =
typename Traits::ModelTraits;
76 using EffDiffModel =
typename Traits::EffectiveDiffusivityModel;
88 using Indices =
typename Traits::ModelTraits::Indices;
101 template<
class ElemSol,
class Problem,
class Element,
class Scv>
103 const Problem &problem,
104 const Element &element,
108 const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol);
109 const auto&
priVars = elemSol[scv.localDofIndex()];
114 using MaterialLaw =
typename Problem::SpatialParams::MaterialLaw;
115 minPc_ = MaterialLaw::endPointPc(materialParams);
117 typename FluidSystem::ParameterCache paramCache;
118 auto getEffectiveDiffusionCoefficient = [&](
int phaseIdx,
int compIIdx,
int compJIdx)
120 return EffDiffModel::effectiveDiffusionCoefficient(*
this, phaseIdx, compIIdx, compJIdx);
129 const auto averageMolarMassGasPhase = (
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)) +
130 ((1-
moleFraction_[FluidSystem::gasPhaseIdx])*FluidSystem::molarMass(FluidSystem::gasPhaseIdx));
133 massFraction_[FluidSystem::gasPhaseIdx] =
priVars[Indices::switchIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)/averageMolarMassGasPhase;
135 fluidState_.setSaturation(FluidSystem::liquidPhaseIdx, 0.0);
136 fluidState_.setSaturation(FluidSystem::gasPhaseIdx, 1.0);
141 const Scalar pc = MaterialLaw::pc(materialParams, 0.0);
144 fluidState_.setPressure(FluidSystem::liquidPhaseIdx, problem.nonWettingReferencePressure() - pc);
145 fluidState_.setPressure(FluidSystem::gasPhaseIdx, problem.nonWettingReferencePressure());
150 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
161 fluidState_.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(
fluidState_, paramCache, FluidSystem::liquidPhaseIdx));
162 fluidState_.setEnthalpy(FluidSystem::gasPhaseIdx, EnergyVolVars::enthalpy(
fluidState_, paramCache, FluidSystem::gasPhaseIdx));
167 FluidSystem::comp1Idx,
168 FluidSystem::comp0Idx);
178 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
182 moleFraction_[FluidSystem::gasPhaseIdx] = FluidSystem::H2O::vaporPressure(
temperature()) / problem.nonWettingReferencePressure();
184 const auto averageMolarMassGasPhase = (
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)) +
185 ((1-
moleFraction_[FluidSystem::gasPhaseIdx])*FluidSystem::molarMass(FluidSystem::gasPhaseIdx));
188 massFraction_[FluidSystem::gasPhaseIdx] =
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)/averageMolarMassGasPhase;
193 FluidSystem::comp1Idx,
194 FluidSystem::comp0Idx);
203 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
220 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv,
solidState_);
221 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
222 EnergyVolVars::updateEffectiveThermalConductivity();
239 template<
class ElemSol,
class Problem,
class Element,
class Scv>
241 const Problem& problem,
242 const Element& element,
249 const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol);
250 const auto&
priVars = elemSol[scv.localDofIndex()];
254 using MaterialLaw =
typename Problem::SpatialParams::MaterialLaw;
255 Scalar minPc = MaterialLaw::pc(materialParams, 1.0);
256 fluidState.setPressure(FluidSystem::liquidPhaseIdx,
priVars[Indices::pressureIdx]);
257 fluidState.setPressure(FluidSystem::gasPhaseIdx, max(problem.nonWettingReferencePressure(),
fluidState.pressure(FluidSystem::liquidPhaseIdx) + minPc));
263 const Scalar pc = max(MaterialLaw::endPointPc(materialParams),
264 problem.nonWettingReferencePressure() -
fluidState.pressure(FluidSystem::liquidPhaseIdx));
265 const Scalar sw = MaterialLaw::sw(materialParams, pc);
266 fluidState.setSaturation(FluidSystem::liquidPhaseIdx, sw);
267 fluidState.setSaturation(FluidSystem::gasPhaseIdx, 1.0-sw);
270 typename FluidSystem::ParameterCache paramCache;
272 fluidState.setDensity(FluidSystem::liquidPhaseIdx,
274 fluidState.setDensity(FluidSystem::gasPhaseIdx,
277 fluidState.setViscosity(FluidSystem::liquidPhaseIdx,
281 fluidState.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(
fluidState, paramCache, FluidSystem::liquidPhaseIdx));
282 fluidState.setEnthalpy(FluidSystem::gasPhaseIdx, EnergyVolVars::enthalpy(
fluidState, paramCache, FluidSystem::gasPhaseIdx));
329 Scalar
saturation(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
338 Scalar
density(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
352 Scalar
pressure(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
366 Scalar
mobility(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
376 Scalar
viscosity(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
377 {
return phaseIdx == FluidSystem::liquidPhaseIdx ?
fluidState_.viscosity(FluidSystem::liquidPhaseIdx) : 0.0; }
419 Scalar
pressureHead(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
432 Scalar
waterContent(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
445 if (compIdx != FluidSystem::comp0Idx)
446 DUNE_THROW(Dune::InvalidStateException,
"There is only one component for Richards!");
460 if (compIdx != FluidSystem::comp0Idx)
461 DUNE_THROW(Dune::InvalidStateException,
"There is only one component for Richards!");
483 [[deprecated(
"Will be removed after release 3.2. Use diffusionCoefficient(phaseIdx, compIIdx, compJIdx)!")]]
496 assert(phaseIdx == FluidSystem::gasPhaseIdx);
497 assert(compIIdx != compJIdx);
498 typename FluidSystem::ParameterCache paramCache;
500 return FluidSystem::binaryDiffusionCoefficient(
fluidState_, paramCache, phaseIdx, compIIdx, compJIdx);
509 assert(phaseIdx == FluidSystem::gasPhaseIdx);
510 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:45
Definition: porousmediumflow/richards/volumevariables.hh:50
Volume averaged quantities required by the Richards model.
Definition: porousmediumflow/richards/volumevariables.hh:66
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:338
FluidState fluidState_
the fluid state
Definition: porousmediumflow/richards/volumevariables.hh:515
Scalar relativePermeabilityWetting_
the relative permeability of the wetting phase
Definition: porousmediumflow/richards/volumevariables.hh:517
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:316
Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: porousmediumflow/richards/volumevariables.hh:493
Scalar porosity() const
Returns the average porosity [] within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:310
Scalar pressureHead(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the pressureHead of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:419
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:442
SolidState solidState_
Definition: porousmediumflow/richards/volumevariables.hh:516
Scalar diffusionCoefficient(int phaseIdx, int compIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: porousmediumflow/richards/volumevariables.hh:484
const FluidState & fluidState() const
Returns the fluid configuration at the given primary variables.
Definition: porousmediumflow/richards/volumevariables.hh:289
static constexpr bool enableWaterDiffusionInAir()
If water diffusion in air is enabled.
Definition: porousmediumflow/richards/volumevariables.hh:90
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:102
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:399
PermeabilityType permeability_
the instrinsic permeability
Definition: porousmediumflow/richards/volumevariables.hh:518
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/richards/volumevariables.hh:87
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:352
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:432
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:376
Scalar massFraction_[numPhases]
The water mass fractions in water and air.
Definition: porousmediumflow/richards/volumevariables.hh:521
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the effective diffusion coefficients for a phase in .
Definition: porousmediumflow/richards/volumevariables.hh:506
Scalar molarDensity_[numPhases]
The molar density of water and air.
Definition: porousmediumflow/richards/volumevariables.hh:522
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:366
typename Traits::ModelTraits::Indices Indices
Definition: porousmediumflow/richards/volumevariables.hh:88
Scalar relativePermeability(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns relative permeability [-] of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:385
Scalar moleFraction_[numPhases]
The water mole fractions in water and air.
Definition: porousmediumflow/richards/volumevariables.hh:520
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:295
typename Traits::SolidState SolidState
Definition: porousmediumflow/richards/volumevariables.hh:85
Scalar effectiveDiffCoeff_
Definition: porousmediumflow/richards/volumevariables.hh:525
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:329
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:240
Scalar molarDensity(const int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:471
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:457
typename Traits::FluidSystem FluidSystem
Export type of the fluid system.
Definition: porousmediumflow/richards/volumevariables.hh:80
typename Traits::FluidState FluidState
Export type of the fluid state.
Definition: porousmediumflow/richards/volumevariables.hh:82
Scalar temperature() const
Returns the temperature.
Definition: porousmediumflow/richards/volumevariables.hh:301
Scalar minPc_
the minimum capillary pressure (entry pressure)
Definition: porousmediumflow/richards/volumevariables.hh:519
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.