25#ifndef DUMUX_DISCRETIZATION_BOX_MAXWELL_STEFAN_LAW_HH
26#define DUMUX_DISCRETIZATION_BOX_MAXWELL_STEFAN_LAW_HH
28#include <dune/common/float_cmp.hh>
29#include <dune/common/fmatrix.hh>
44template <
class TypeTag,
class DiscretizationMethod, ReferenceSystemFormulation referenceSystem>
51template <
class TypeTag, ReferenceSystemFormulation referenceSystem>
59 using FVElementGeometry =
typename GridGeometry::LocalView;
60 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
65 using Element =
typename GridView::template Codim<0>::Entity;
70 using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>;
71 using ReducedComponentVector = Dune::FieldVector<Scalar, numComponents-1>;
72 using ReducedComponentMatrix = Dune::FieldMatrix<Scalar, numComponents-1, numComponents-1>;
81 {
return referenceSystem; }
88 static ComponentFluxVector
flux(
const Problem& problem,
89 const Element& element,
90 const FVElementGeometry& fvGeometry,
91 const ElementVolumeVariables& elemVolVars,
92 const SubControlVolumeFace& scvf,
94 const ElementFluxVariablesCache& elemFluxVarsCache)
98 ComponentFluxVector componentFlux(0.0);
99 ReducedComponentMatrix reducedDiffusionMatrix(0.0);
100 ReducedComponentVector reducedFlux(0.0);
101 ComponentFluxVector moleFrac(0.0);
102 ReducedComponentVector normalX(0.0);
105 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
106 const auto& shapeValues = fluxVarsCache.shapeValues();
109 Scalar avgMolarMass(0.0);
110 for (
auto&& scv : scvs(fvGeometry))
112 const auto& volVars = elemVolVars[scv];
115 rho += volVars.density(phaseIdx)*shapeValues[scv.indexInElement()][0];
117 avgMolarMass += volVars.averageMolarMass(phaseIdx)*shapeValues[scv.indexInElement()][0];
119 for (
int compIdx = 0; compIdx < numComponents; compIdx++)
121 moleFrac[compIdx] += volVars.moleFraction(phaseIdx, compIdx)*shapeValues[scv.indexInElement()][0];
125 reducedDiffusionMatrix = setupMSMatrix_(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx, moleFrac, avgMolarMass);
127 for (
int compIdx = 0; compIdx < numComponents-1; compIdx++)
129 Dune::FieldVector<Scalar, GridView::dimensionworld> gradX(0.0);
130 for (
auto&& scv : scvs(fvGeometry))
132 const auto& volVars = elemVolVars[scv];
135 gradX.axpy(volVars.moleFraction(phaseIdx, compIdx), fluxVarsCache.gradN(scv.indexInElement()));
138 normalX[compIdx] = gradX *scvf.unitOuterNormal();
140 reducedDiffusionMatrix.solve(reducedFlux,normalX);
141 reducedFlux *= -1.0*rho*Extrusion::area(fvGeometry, scvf);
143 for (
int compIdx = 0; compIdx < numComponents-1; compIdx++)
145 componentFlux[compIdx] = reducedFlux[compIdx];
146 componentFlux[numComponents-1] -= reducedFlux[compIdx];
148 return componentFlux ;
153 static ReducedComponentMatrix setupMSMatrix_(
const Problem& problem,
154 const Element& element,
155 const FVElementGeometry& fvGeometry,
156 const ElementVolumeVariables& elemVolVars,
157 const SubControlVolumeFace& scvf,
159 const ComponentFluxVector moleFrac,
160 const Scalar avgMolarMass)
162 ReducedComponentMatrix reducedDiffusionMatrix(0.0);
164 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
165 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
168 if(Dune::FloatCmp::eq<Scalar>(insideVolVars.saturation(phaseIdx), 0) || Dune::FloatCmp::eq<Scalar>(outsideVolVars.saturation(phaseIdx), 0))
169 return reducedDiffusionMatrix;
171 for (
int compIIdx = 0; compIIdx < numComponents-1; compIIdx++)
174 const auto xi = moleFrac[compIIdx];
175 const auto Mn = FluidSystem::molarMass(numComponents-1);
177 auto tinInside = insideVolVars.effectiveDiffusionCoefficient(phaseIdx, compIIdx, numComponents-1);
178 auto tinOutside = outsideVolVars.effectiveDiffusionCoefficient(phaseIdx, compIIdx, numComponents-1);
181 tinInside *= insideVolVars.extrusionFactor();
182 tinOutside *= outsideVolVars.extrusionFactor();
185 const auto tin =
faceTensorAverage(tinInside, tinOutside, scvf.unitOuterNormal());
188 reducedDiffusionMatrix[compIIdx][compIIdx] += xi*avgMolarMass/(tin*Mn);
191 for (
int compJIdx = 0; compJIdx < numComponents; compJIdx++)
194 if (compIIdx == compJIdx)
198 const auto xj = moleFrac[compJIdx];
199 const auto Mi = FluidSystem::molarMass(compIIdx);
200 const auto Mj = FluidSystem::molarMass(compJIdx);
203 auto tijInside = insideVolVars.effectiveDiffusionCoefficient(phaseIdx, compIIdx, compJIdx);
204 auto tijOutside = outsideVolVars.effectiveDiffusionCoefficient(phaseIdx, compIIdx, compJIdx);
207 tijInside *= insideVolVars.extrusionFactor();
208 tijOutside *= outsideVolVars.extrusionFactor();
211 const auto tij =
faceTensorAverage(tijInside, tijOutside, scvf.unitOuterNormal());
213 reducedDiffusionMatrix[compIIdx][compIIdx] += xj*avgMolarMass/(tij*Mi);
214 if (compJIdx < numComponents-1)
215 reducedDiffusionMatrix[compIIdx][compJIdx] +=xi*(avgMolarMass/(tin*Mn) - avgMolarMass/(tij*Mj));
218 return reducedDiffusionMatrix;
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
The reference frameworks and formulations available for splitting total fluxes into a advective and d...
Container storing the diffusion coefficients required by the Maxwell- Stefan diffusion law....
Classes related to flux variables caching.
A free function to average a Tensor at an interface.
ReferenceSystemFormulation
The formulations available for Fick's law related to the reference system.
Definition: referencesystemformulation.hh:45
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:251
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
Scalar faceTensorAverage(const Scalar T1, const Scalar T2, const Dune::FieldVector< Scalar, dim > &normal)
Average of a discontinuous scalar field at discontinuity interface (for compatibility reasons with th...
Definition: facetensoraverage.hh:41
CVFE< CVFEMethods::PQ1 > Box
Definition: method.hh:83
Definition: box/maxwellstefanslaw.hh:45
static constexpr ReferenceSystemFormulation referenceSystemFormulation()
Definition: box/maxwellstefanslaw.hh:80
static ComponentFluxVector flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVariablesCache &elemFluxVarsCache)
Returns the diffusive fluxes of all components within a fluid phase across the given sub-control volu...
Definition: box/maxwellstefanslaw.hh:88
Container storing the diffusion coefficients required by the Maxwell- Stefan diffusion law....
Definition: maxwellstefandiffusioncoefficients.hh:45
Declares all properties used in Dumux.