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;
96 template<
class ElemSol,
class Problem,
class Element,
class Scv>
98 const Problem &problem,
99 const Element &element,
103 const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol);
104 const auto&
priVars = elemSol[scv.localDofIndex()];
109 using MaterialLaw =
typename Problem::SpatialParams::MaterialLaw;
110 minPc_ = MaterialLaw::endPointPc(materialParams);
120 const auto averageMolarMassGasPhase = (
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)) +
121 ((1-
moleFraction_[FluidSystem::gasPhaseIdx])*FluidSystem::molarMass(FluidSystem::gasPhaseIdx));
124 massFraction_[FluidSystem::gasPhaseIdx] =
priVars[Indices::switchIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)/averageMolarMassGasPhase;
126 fluidState_.setSaturation(FluidSystem::liquidPhaseIdx, 0.0);
127 fluidState_.setSaturation(FluidSystem::gasPhaseIdx, 1.0);
132 const Scalar pc = MaterialLaw::pc(materialParams, 0.0);
135 fluidState_.setPressure(FluidSystem::liquidPhaseIdx, problem.nonWettingReferencePressure() - pc);
136 fluidState_.setPressure(FluidSystem::gasPhaseIdx, problem.nonWettingReferencePressure());
141 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
146 typename FluidSystem::ParameterCache paramCache;
153 fluidState_.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(
fluidState_, paramCache, FluidSystem::liquidPhaseIdx));
154 fluidState_.setEnthalpy(FluidSystem::gasPhaseIdx, EnergyVolVars::enthalpy(
fluidState_, paramCache, FluidSystem::gasPhaseIdx));
164 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
168 moleFraction_[FluidSystem::gasPhaseIdx] = FluidSystem::H2O::vaporPressure(
temperature()) / problem.nonWettingReferencePressure();
170 const auto averageMolarMassGasPhase = (
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)) +
171 ((1-
moleFraction_[FluidSystem::gasPhaseIdx])*FluidSystem::molarMass(FluidSystem::gasPhaseIdx));
174 massFraction_[FluidSystem::gasPhaseIdx] =
moleFraction_[FluidSystem::gasPhaseIdx]*FluidSystem::molarMass(FluidSystem::liquidPhaseIdx)/averageMolarMassGasPhase;
177 typename FluidSystem::ParameterCache paramCache;
179 diffCoeff_ = FluidSystem::binaryDiffusionCoefficient(
fluidState_, paramCache, FluidSystem::gasPhaseIdx, FluidSystem::comp0Idx, FluidSystem::comp1Idx);
188 molarDensity_[FluidSystem::liquidPhaseIdx] = FluidSystem::H2O::liquidDensity(
temperature(),
pressure(FluidSystem::liquidPhaseIdx))/FluidSystem::H2O::molarMass();
196 typename FluidSystem::ParameterCache paramCache;
198 diffCoeff_ = FluidSystem::binaryDiffusionCoefficient(
fluidState_, paramCache, FluidSystem::gasPhaseIdx, FluidSystem::comp0Idx, FluidSystem::comp1Idx);
207 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv,
solidState_);
208 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
225 template<
class ElemSol,
class Problem,
class Element,
class Scv>
227 const Problem& problem,
228 const Element& element,
235 const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol);
236 const auto&
priVars = elemSol[scv.localDofIndex()];
240 using MaterialLaw =
typename Problem::SpatialParams::MaterialLaw;
241 Scalar minPc = MaterialLaw::pc(materialParams, 1.0);
242 fluidState.setPressure(FluidSystem::liquidPhaseIdx,
priVars[Indices::pressureIdx]);
243 fluidState.setPressure(FluidSystem::gasPhaseIdx, max(problem.nonWettingReferencePressure(),
fluidState.pressure(FluidSystem::liquidPhaseIdx) + minPc));
249 const Scalar pc = max(MaterialLaw::endPointPc(materialParams),
250 problem.nonWettingReferencePressure() -
fluidState.pressure(FluidSystem::liquidPhaseIdx));
251 const Scalar sw = MaterialLaw::sw(materialParams, pc);
252 fluidState.setSaturation(FluidSystem::liquidPhaseIdx, sw);
253 fluidState.setSaturation(FluidSystem::gasPhaseIdx, 1.0-sw);
256 typename FluidSystem::ParameterCache paramCache;
258 fluidState.setDensity(FluidSystem::liquidPhaseIdx,
260 fluidState.setDensity(FluidSystem::gasPhaseIdx,
263 fluidState.setViscosity(FluidSystem::liquidPhaseIdx,
267 fluidState.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(
fluidState, paramCache, FluidSystem::liquidPhaseIdx));
268 fluidState.setEnthalpy(FluidSystem::gasPhaseIdx, EnergyVolVars::enthalpy(
fluidState, paramCache, FluidSystem::gasPhaseIdx));
315 Scalar
saturation(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
324 Scalar
density(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
338 Scalar
pressure(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
352 Scalar
mobility(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
362 Scalar
viscosity(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
363 {
return phaseIdx == FluidSystem::liquidPhaseIdx ?
fluidState_.viscosity(FluidSystem::liquidPhaseIdx) : 0.0; }
405 Scalar
pressureHead(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
418 Scalar
waterContent(
const int phaseIdx = FluidSystem::liquidPhaseIdx)
const
431 if (compIdx != FluidSystem::comp0Idx)
432 DUNE_THROW(Dune::InvalidStateException,
"There is only one component for Richards!");
446 if (compIdx != FluidSystem::comp0Idx)
447 DUNE_THROW(Dune::InvalidStateException,
"There is only one component for Richards!");
Relations valid for an ideal gas.
A central place for various physical constants occuring in some equations.
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.
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
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
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:324
FluidState fluidState_
the fluid state
Definition: porousmediumflow/richards/volumevariables.hh:476
Scalar relativePermeabilityWetting_
the relative permeability of the wetting phase
Definition: porousmediumflow/richards/volumevariables.hh:478
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:302
Scalar molarDensity_[ParentType::numFluidPhases()]
The molar density of water and air.
Definition: porousmediumflow/richards/volumevariables.hh:483
Scalar massFraction_[ParentType::numFluidPhases()]
The water mass fractions in water and air.
Definition: porousmediumflow/richards/volumevariables.hh:482
Scalar porosity() const
Returns the average porosity [] within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:296
Scalar pressureHead(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns the pressureHead of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:405
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:428
SolidState solidState_
Definition: porousmediumflow/richards/volumevariables.hh:477
Scalar diffusionCoefficient(int phaseIdx, int compIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: porousmediumflow/richards/volumevariables.hh:469
const FluidState & fluidState() const
Returns the fluid configuration at the given primary variables.
Definition: porousmediumflow/richards/volumevariables.hh:275
static constexpr bool enableWaterDiffusionInAir()
If water diffusion in air is enabled.
Definition: porousmediumflow/richards/volumevariables.hh:85
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:97
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:385
PermeabilityType permeability_
the instrinsic permeability
Definition: porousmediumflow/richards/volumevariables.hh:479
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/richards/volumevariables.hh:82
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:338
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:418
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:362
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:352
typename Traits::ModelTraits::Indices Indices
Definition: porousmediumflow/richards/volumevariables.hh:83
Scalar relativePermeability(const int phaseIdx=FluidSystem::liquidPhaseIdx) const
Returns relative permeability [-] of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:371
Scalar diffCoeff_
The binary diffusion coefficient of water in air.
Definition: porousmediumflow/richards/volumevariables.hh:484
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:281
typename Traits::SolidState SolidState
Definition: porousmediumflow/richards/volumevariables.hh:80
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:315
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:226
Scalar molarDensity(const int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:457
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:443
Scalar moleFraction_[ParentType::numFluidPhases()]
The water mole fractions in water and air.
Definition: porousmediumflow/richards/volumevariables.hh:481
typename Traits::FluidSystem FluidSystem
Export type of the fluid system.
Definition: porousmediumflow/richards/volumevariables.hh:75
typename Traits::FluidState FluidState
Export type of the fluid state.
Definition: porousmediumflow/richards/volumevariables.hh:77
Scalar temperature() const
Returns the temperature.
Definition: porousmediumflow/richards/volumevariables.hh:287
Scalar minPc_
the minimum capillary pressure (entry pressure)
Definition: porousmediumflow/richards/volumevariables.hh:480
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.