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,
109 const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
111 const auto&
priVars = elemSol[scv.localDofIndex()];
112 const auto phasePresence =
priVars.state();
116 minPc_ = fluidMatrixInteraction.endPointPc();
118 typename FluidSystem::ParameterCache paramCache;
119 auto getEffectiveDiffusionCoefficient = [&](
int phaseIdx,
int compIIdx,
int compJIdx)
121 return EffDiffModel::effectiveDiffusionCoefficient(*
this, phaseIdx, compIIdx, compJIdx);
124 if (phasePresence == Indices::gasPhaseOnly)
130 const auto averageMolarMassGasPhase = (
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)) +
131 ((1-
moleFraction_[FluidSystem::gasPhaseIdx])*FluidSystem::molarMass(FluidSystem::gasPhaseIdx));
134 massFraction_[FluidSystem::gasPhaseIdx] =
priVars[Indices::switchIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)/averageMolarMassGasPhase;
136 fluidState_.setSaturation(FluidSystem::liquidPhaseIdx, 0.0);
137 fluidState_.setSaturation(FluidSystem::gasPhaseIdx, 1.0);
142 const Scalar pc = fluidMatrixInteraction.pc(0.0);
145 fluidState_.setPressure(FluidSystem::liquidPhaseIdx, problem.nonwettingReferencePressure() - pc);
146 fluidState_.setPressure(FluidSystem::gasPhaseIdx, problem.nonwettingReferencePressure());
151 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
157 fluidState_.setDensity(FluidSystem::liquidPhaseIdx, FluidSystem::density(
fluidState_, paramCache, FluidSystem::liquidPhaseIdx));
158 fluidState_.setDensity(FluidSystem::gasPhaseIdx, FluidSystem::density(
fluidState_, paramCache, FluidSystem::gasPhaseIdx));
159 fluidState_.setViscosity(FluidSystem::liquidPhaseIdx, FluidSystem::viscosity(
fluidState_, paramCache, FluidSystem::liquidPhaseIdx));
162 fluidState_.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(
fluidState_, paramCache, FluidSystem::liquidPhaseIdx));
163 fluidState_.setEnthalpy(FluidSystem::gasPhaseIdx, EnergyVolVars::enthalpy(
fluidState_, paramCache, FluidSystem::gasPhaseIdx));
168 FluidSystem::comp1Idx,
169 FluidSystem::comp0Idx);
171 else if (phasePresence == Indices::bothPhases)
179 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
183 moleFraction_[FluidSystem::gasPhaseIdx] = FluidSystem::H2O::vaporPressure(
temperature()) / problem.nonwettingReferencePressure();
185 const auto averageMolarMassGasPhase = (
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)) +
186 ((1-
moleFraction_[FluidSystem::gasPhaseIdx])*FluidSystem::molarMass(FluidSystem::gasPhaseIdx));
189 massFraction_[FluidSystem::gasPhaseIdx] =
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)/averageMolarMassGasPhase;
194 FluidSystem::comp1Idx,
195 FluidSystem::comp0Idx);
198 else if (phasePresence == Indices::liquidPhaseOnly)
204 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
221 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv,
solidState_);
222 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
223 EnergyVolVars::updateEffectiveThermalConductivity();
240 template<
class ElemSol,
class Problem,
class Element,
class Scv>
242 const Problem& problem,
243 const Element& element,
250 const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
252 const auto&
priVars = elemSol[scv.localDofIndex()];
256 Scalar minPc = fluidMatrixInteraction.pc(1.0);
257 fluidState.setPressure(FluidSystem::liquidPhaseIdx,
priVars[Indices::pressureIdx]);
258 fluidState.setPressure(FluidSystem::gasPhaseIdx, max(problem.nonwettingReferencePressure(),
fluidState.pressure(FluidSystem::liquidPhaseIdx) + minPc));
264 const Scalar pc = max(fluidMatrixInteraction.endPointPc(),
265 problem.nonwettingReferencePressure() -
fluidState.pressure(FluidSystem::liquidPhaseIdx));
266 const Scalar sw = fluidMatrixInteraction.sw(pc);
267 fluidState.setSaturation(FluidSystem::liquidPhaseIdx, sw);
268 fluidState.setSaturation(FluidSystem::gasPhaseIdx, 1.0-sw);
271 typename FluidSystem::ParameterCache paramCache;
273 fluidState.setDensity(FluidSystem::liquidPhaseIdx,
274 FluidSystem::density(
fluidState, paramCache, FluidSystem::liquidPhaseIdx));
275 fluidState.setDensity(FluidSystem::gasPhaseIdx,
276 FluidSystem::density(
fluidState, paramCache, FluidSystem::gasPhaseIdx));
278 fluidState.setViscosity(FluidSystem::liquidPhaseIdx,
279 FluidSystem::viscosity(
fluidState, paramCache, FluidSystem::liquidPhaseIdx));
282 fluidState.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(
fluidState, paramCache, FluidSystem::liquidPhaseIdx));
283 fluidState.setEnthalpy(FluidSystem::gasPhaseIdx, EnergyVolVars::enthalpy(
fluidState, paramCache, FluidSystem::gasPhaseIdx));
330 Scalar
saturation(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
339 Scalar
density(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
353 Scalar
pressure(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
367 Scalar
mobility(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
377 Scalar
viscosity(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
378 {
return phaseIdx == FluidSystem::liquidPhaseIdx ?
fluidState_.viscosity(FluidSystem::liquidPhaseIdx) : 0.0; }
420 Scalar
pressureHead(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
433 Scalar
waterContent(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
446 if (compIdx != FluidSystem::comp0Idx)
447 DUNE_THROW(Dune::InvalidStateException,
"There is only one component for Richards!");
461 if (compIdx != FluidSystem::comp0Idx)
462 DUNE_THROW(Dune::InvalidStateException,
"There is only one component for Richards!");
484 assert(phaseIdx == FluidSystem::gasPhaseIdx);
485 assert(compIIdx != compJIdx);
486 typename FluidSystem::ParameterCache paramCache;
488 return FluidSystem::binaryDiffusionCoefficient(
fluidState_, paramCache, phaseIdx, compIIdx, compJIdx);
497 assert(phaseIdx == FluidSystem::gasPhaseIdx);
498 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.
EnergyVolumeVariablesImplementation< IsothermalTraits, Impl, IsothermalTraits::ModelTraits::enableEnergyBalance()> EnergyVolumeVariables
Base class for the model specific class which provides access to all volume averaged quantities.
Definition porousmediumflow/nonisothermal/volumevariables.hh:85
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
Definition gridcapabilities.hh:60
static constexpr Scalar molarDensity(Scalar temperature, Scalar pressure)
The molar density of the gas , depending on pressure and temperature.
Definition idealgas.hh:70
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
ExtendedRichardsPrimaryVariableSwitch PrimaryVariableSwitch
Definition porousmediumflow/richards/volumevariables.hh:46
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:339
FluidState fluidState_
Definition porousmediumflow/richards/volumevariables.hh:503
Scalar relativePermeabilityWetting_
Definition porousmediumflow/richards/volumevariables.hh:505
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition porousmediumflow/richards/volumevariables.hh:317
Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition porousmediumflow/richards/volumevariables.hh:481
Scalar porosity() const
Returns the average porosity [] within the control volume.
Definition porousmediumflow/richards/volumevariables.hh:311
Scalar pressureHead(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the pressureHead of a given phase within the control volume.
Definition porousmediumflow/richards/volumevariables.hh:420
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:443
SolidState solidState_
Definition porousmediumflow/richards/volumevariables.hh:504
const FluidState & fluidState() const
Definition porousmediumflow/richards/volumevariables.hh:290
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:400
PermeabilityType permeability_
Definition porousmediumflow/richards/volumevariables.hh:506
typename NITraits< BaseTraits, ETCM >::SolidSystem SolidSystem
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:353
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:433
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:377
Scalar massFraction_[numPhases]
Definition porousmediumflow/richards/volumevariables.hh:509
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the effective diffusion coefficients for a phase in .
Definition porousmediumflow/richards/volumevariables.hh:494
Scalar molarDensity_[numPhases]
Definition porousmediumflow/richards/volumevariables.hh:510
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:367
typename NITraits< BaseTraits, ETCM >::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:386
Scalar moleFraction_[numPhases]
Definition porousmediumflow/richards/volumevariables.hh:508
const SolidState & solidState() const
Definition porousmediumflow/richards/volumevariables.hh:296
typename NITraits< BaseTraits, ETCM >::SolidState SolidState
Definition porousmediumflow/richards/volumevariables.hh:85
Scalar effectiveDiffCoeff_
Definition porousmediumflow/richards/volumevariables.hh:513
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:330
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:241
Scalar molarDensity(const int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition porousmediumflow/richards/volumevariables.hh:472
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:458
typename NITraits< BaseTraits, ETCM >::FluidSystem FluidSystem
Definition porousmediumflow/richards/volumevariables.hh:80
typename NITraits< BaseTraits, ETCM >::FluidState FluidState
Definition porousmediumflow/richards/volumevariables.hh:82
Scalar temperature() const
Returns the temperature.
Definition porousmediumflow/richards/volumevariables.hh:302
Scalar minPc_
Definition porousmediumflow/richards/volumevariables.hh:507
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
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.