13#ifndef DUMUX_FLUX_PNM_FICKS_LAW_HH
14#define DUMUX_FLUX_PNM_FICKS_LAW_HH
16#include <dune/common/fvector.hh>
27template<
class Scalar,
int numPhases,
int numComponents,
36 {
return referenceSystem; }
38 template<
class Problem,
class Element,
class FVElementGeometry,
39 class ElementVolumeVariables,
class ElementFluxVariablesCache>
40 static Dune::FieldVector<Scalar, numComponents>
41 flux(
const Problem& problem,
42 const Element& element,
43 const FVElementGeometry& fvGeometry,
44 const ElementVolumeVariables& elemVolVars,
45 const typename FVElementGeometry::SubControlVolumeFace& scvf,
47 const ElementFluxVariablesCache& elemFluxVarsCache)
49 Dune::FieldVector<Scalar, numComponents> componentFlux(0.0);
52 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
53 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
55 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
58 const Scalar throatLength = fluxVarsCache.throatLength();
59 const Scalar phaseCrossSectionalArea = fluxVarsCache.throatCrossSectionalArea(phaseIdx);
61 for (
int compIdx = 0; compIdx < numComponents; compIdx++)
63 if(compIdx == phaseIdx)
66 auto insideDiffCoeff = getDiffusionCoefficient_(phaseIdx, compIdx, insideVolVars);
67 auto outsideDiffCoeff = getDiffusionCoefficient_(phaseIdx, compIdx, outsideVolVars);
70 insideDiffCoeff *= insideVolVars.extrusionFactor();
71 outsideDiffCoeff *= outsideVolVars.extrusionFactor();
74 const auto diffCoeff =
harmonicMean(insideDiffCoeff, outsideDiffCoeff);
76 const Scalar insideMoleFraction =
massOrMoleFraction(insideVolVars, referenceSystem, phaseIdx, compIdx);
77 const Scalar outsideMoleFraction =
massOrMoleFraction(outsideVolVars, referenceSystem, phaseIdx, compIdx);
79 componentFlux[compIdx] =
density * (insideMoleFraction - outsideMoleFraction) / throatLength * diffCoeff * phaseCrossSectionalArea;
80 componentFlux[phaseIdx] -= componentFlux[compIdx];
86 template<
class VolumeVariables>
87 static Scalar getDiffusionCoefficient_(
const int phaseIdx,
const int compIdx,
88 const VolumeVariables& volVars)
90 using FluidSystem =
typename VolumeVariables::FluidSystem;
92 if constexpr (!FluidSystem::isTracerFluidSystem())
94 const auto mainCompIdx = FluidSystem::getMainComponent(phaseIdx);
95 return volVars.diffusionCoefficient(phaseIdx, mainCompIdx, compIdx);
98 return volVars.diffusionCoefficient(0, 0, compIdx);
Container storing the diffusion coefficients required by Fick's law. Uses the minimal possible contai...
Definition: fickiandiffusioncoefficients.hh:32
Specialization of Fick's Law for the pore-network model.
Definition: flux/porenetwork/fickslaw.hh:30
static constexpr ReferenceSystemFormulation referenceSystemFormulation()
Definition: flux/porenetwork/fickslaw.hh:35
static Dune::FieldVector< Scalar, numComponents > flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVariablesCache &elemFluxVarsCache)
Definition: flux/porenetwork/fickslaw.hh:41
Container storing the diffusion coefficients required by Fick's law. Uses the minimal possible contai...
constexpr Scalar harmonicMean(Scalar x, Scalar y, Scalar wx=1.0, Scalar wy=1.0) noexcept
Calculate the (weighted) harmonic mean of two scalar values.
Definition: math.hh:57
VolumeVariables::PrimaryVariables::value_type massOrMoleFraction(const VolumeVariables &volVars, ReferenceSystemFormulation referenceSys, const int phaseIdx, const int compIdx)
returns the mass or mole fraction to be used in Fick's law based on the reference system
Definition: referencesystemformulation.hh:54
VolumeVariables::PrimaryVariables::value_type massOrMolarDensity(const VolumeVariables &volVars, ReferenceSystemFormulation referenceSys, const int phaseIdx)
evaluates the density to be used in Fick's law based on the reference system
Definition: referencesystemformulation.hh:43
ReferenceSystemFormulation
The formulations available for Fick's law related to the reference system.
Definition: referencesystemformulation.hh:33
Define some often used mathematical functions.
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: discretization/porenetwork/fvelementgeometry.hh:24