24#ifndef DUMUX_SALINIZATION_PROBLEM_HH
25#define DUMUX_SALINIZATION_PROBLEM_HH
27#include <dune/grid/yaspgrid.hh>
49template <
class TypeTag>
50class SalinizationProblem;
61template<
class TypeTag>
62struct Grid<TypeTag, TTag::Salinization>
65 using type = Dune::YaspGrid<2, Dune::TensorProductCoordinates<Scalar, 2>>;
69template<
class TypeTag>
73template<
class TypeTag>
80template<
class TypeTag>
86 static constexpr int numInertComponents = 1;
91template<
class TypeTag>
100template<
class TypeTag>
102template<
class TypeTag>
134template <
class TypeTag>
148 pressureIdx = Indices::pressureIdx,
149 switchIdx = Indices::switchIdx,
154 xwNaClIdx = FluidSystem::NaClIdx,
155 precipNaClIdx = FluidSystem::numComponents,
158 H2OIdx = FluidSystem::H2OIdx,
159 NaClIdx = FluidSystem::NaClIdx,
160 AirIdx = FluidSystem::AirIdx,
163 liquidPhaseIdx = FluidSystem::liquidPhaseIdx,
164 gasPhaseIdx = FluidSystem::gasPhaseIdx,
167 sPhaseIdx = SolidSystem::comp0Idx,
171 conti0EqIdx = Indices::conti0EqIdx,
172 conti1EqIdx = Indices::conti0EqIdx + 1,
173 precipNaClEqIdx = Indices::conti0EqIdx + FluidSystem::numComponents,
174 energyEqIdx = Indices::energyEqIdx,
177 bothPhases = Indices::bothPhases,
180 dim = GridView::dimension,
181 dimWorld = GridView::dimensionworld,
188 using ElementFluxVariablesCache =
typename GridVariables::GridFluxVariablesCache::LocalView;
190 using Element =
typename GridView::template Codim<0>::Entity;
194 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
195 using GlobalPosition =
typename SubControlVolume::GlobalPosition;
196 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
204 nTemperature_ = getParam<int>(
"FluidSystem.NTemperature");
205 nPressure_ = getParam<int>(
"FluidSystem.NPressure");
206 pressureLow_ = getParam<Scalar>(
"FluidSystem.PressureLow");
207 pressureHigh_ = getParam<Scalar>(
"FluidSystem.PressureHigh");
208 temperatureLow_ = getParam<Scalar>(
"FluidSystem.TemperatureLow");
209 temperatureHigh_ = getParam<Scalar>(
"FluidSystem.TemperatureHigh");
210 name_ = getParam<std::string>(
"Problem.Name");
213 name_ = getParam<std::string>(
"Problem.Name");
214 temperature_ = getParam<Scalar>(
"Problem.Temperature");
217 initPressure_ = getParam<Scalar>(
"Problem.InitialPressure");
218 initGasSaturation_ = getParam<Scalar>(
"Problem.InitialGasSaturation");
219 initSalinity_ = getParam<Scalar>(
"Problem.InitialSalinity");
224 FluidSystem::init(temperatureLow_,
247 timeStepSize_ = timeStepSize;
259 const std::string&
name()
const
268 {
return temperature_; }
282 BoundaryTypes bcTypes;
285 bcTypes.setAllNeumann();
295 PrimaryVariables priVars(0.0);
296 priVars.setState(bothPhases);
319 const FVElementGeometry& fvGeometry,
320 const ElementVolumeVariables& elemVolVars,
321 const ElementFluxVariablesCache& elemFluxVarsCache,
322 const SubControlVolumeFace& scvf)
const
324 PrimaryVariables values(0.0);
326 const auto& globalPos = scvf.ipGlobal();
327 const auto& volVars = elemVolVars[scvf.insideScvIdx()];
330 static const Scalar temperatureRef = getParam<Scalar>(
"FreeFlow.RefTemperature");
332 if (globalPos[1] > hmax - eps_)
335 static const Scalar moleFracRefH2O = getParam<Scalar>(
"FreeFlow.RefMoleFracH2O");
336 static const Scalar boundaryLayerThickness = getParam<Scalar>(
"FreeFlow.BoundaryLayerThickness");
337 static const Scalar massTransferCoefficient = getParam<Scalar>(
"FreeFlow.MassTransferCoefficient");
340 const Scalar moleFracH2OInside = volVars.moleFraction(gasPhaseIdx, H2OIdx);
341 static const Scalar referencePermeability = getParam<Scalar>(
"SpatialParams.referencePermeability", 2.23e-14);
345 Scalar evaporationRateMole = 0;
346 if (moleFracH2OInside - moleFracRefH2O > 0)
348 evaporationRateMole = massTransferCoefficient
349 * volVars.diffusionCoefficient(gasPhaseIdx, H2OIdx)
350 * (moleFracH2OInside - moleFracRefH2O)
351 / boundaryLayerThickness
352 * volVars.molarDensity(gasPhaseIdx);
356 evaporationRateMole = massTransferCoefficient
357 * volVars.diffusionCoefficient(gasPhaseIdx, H2OIdx)
358 * (moleFracH2OInside - moleFracRefH2O)
359 / boundaryLayerThickness
364 values[conti0EqIdx] = evaporationRateMole;
368 if (volVars.pressure(gasPhaseIdx) - 1e5 > 0) {
369 values[conti1EqIdx] = (volVars.pressure(gasPhaseIdx) - 1e5)
370 /(globalPos - fvGeometry.scv(scvf.insideScvIdx()).center()).two_norm()
371 *volVars.mobility(gasPhaseIdx)
372 *referencePermeability
373 *volVars.molarDensity(gasPhaseIdx)
374 *volVars.moleFraction(gasPhaseIdx, AirIdx);
378 values[conti1EqIdx] = (volVars.pressure(gasPhaseIdx) - 1e5)
379 /(globalPos - fvGeometry.scv(scvf.insideScvIdx()).center()).two_norm()
380 *volVars.mobility(gasPhaseIdx)
381 *referencePermeability
382 *volVars.molarDensity(gasPhaseIdx) * (1-moleFracRefH2O);
386 values[energyEqIdx] = FluidSystem::componentEnthalpy(volVars.fluidState(), gasPhaseIdx, H2OIdx) * values[conti0EqIdx] * FluidSystem::molarMass(H2OIdx);
388 values[energyEqIdx] += FluidSystem::componentEnthalpy(volVars.fluidState(), gasPhaseIdx, AirIdx)* values[conti1EqIdx] * FluidSystem::molarMass(AirIdx);
390 values[energyEqIdx] += FluidSystem::thermalConductivity(elemVolVars[scvf.insideScvIdx()].fluidState(), gasPhaseIdx) * (volVars.temperature() - temperatureRef)/boundaryLayerThickness;
405 PrimaryVariables priVars(0.0);
406 priVars.setState(bothPhases);
409 priVars[pressureIdx] = initPressure_ -
density*9.81*globalPos[dimWorld-1];
410 priVars[switchIdx] = initGasSaturation_;
411 priVars[xwNaClIdx] = massToMoleFrac_(initSalinity_);
412 priVars[precipNaClIdx] = 0.0;
413 priVars[energyEqIdx] = temperature_;
439 NumEqVector
source(
const Element &element,
440 const FVElementGeometry& fvGeometry,
441 const ElementVolumeVariables& elemVolVars,
442 const SubControlVolume &scv)
const
446 const auto& volVars = elemVolVars[scv];
448 Scalar moleFracNaCl_wPhase = volVars.moleFraction(liquidPhaseIdx, NaClIdx);
449 Scalar massFracNaCl_Max_wPhase = this->
spatialParams().solubilityLimit();
450 Scalar moleFracNaCl_Max_wPhase = massToMoleFrac_(massFracNaCl_Max_wPhase);
451 Scalar saltPorosity = this->
spatialParams().minimalPorosity(element, scv);
455 Scalar precipSalt = volVars.porosity() * volVars.molarDensity(liquidPhaseIdx)
456 * volVars.saturation(liquidPhaseIdx)
457 * abs(moleFracNaCl_wPhase - moleFracNaCl_Max_wPhase);
458 if (moleFracNaCl_wPhase < moleFracNaCl_Max_wPhase)
462 if (precipSalt*timeStepSize_ + volVars.solidVolumeFraction(sPhaseIdx)* volVars.solidComponentMolarDensity(sPhaseIdx)< 0)
463 precipSalt = -volVars.solidVolumeFraction(sPhaseIdx)* volVars.solidComponentMolarDensity(sPhaseIdx)/timeStepSize_;
466 if (volVars.solidVolumeFraction(sPhaseIdx) >= this->spatialParams().referencePorosity(element, scv) - saltPorosity && precipSalt > 0)
469 source[conti0EqIdx + NaClIdx] += -precipSalt;
470 source[precipNaClEqIdx] += precipSalt;
482 return permeability_;
487 for (
const auto& element : elements(this->
gridGeometry().gridView()))
492 fvGeometry.bindElement(element);
494 for (
auto&& scv : scvs(fvGeometry))
496 VolumeVariables volVars;
497 volVars.update(elemSol, *
this, element, scv);
498 const auto dofIdxGlobal = scv.dofIndex();
499 permeability_[dofIdxGlobal] = volVars.permeability();
506 return 0.054977871437821;
516 static Scalar massToMoleFrac_(Scalar XwNaCl)
518 const Scalar Mw = 18.015e-3;
519 const Scalar Ms = 58.44e-3;
521 const Scalar X_NaCl = XwNaCl;
523 auto xwNaCl = -Mw * X_NaCl / ((Ms - Mw) * X_NaCl - Ms);
530 Scalar initPressure_;
531 Scalar initGasSaturation_;
532 Scalar initSalinity_;
536 Scalar pressureLow_, pressureHigh_;
537 Scalar temperatureLow_, temperatureHigh_;
542 Scalar timeStepSize_ = 0.0;
543 static constexpr Scalar eps_ = 1e-6;
545 std::vector<Scalar> permeability_;
549 std::vector<Scalar> x_;
550 std::vector<Scalar> y_;
551 std::vector<Scalar> y2_;
Element solution classes and factory functions.
Defines a type tag and some properties for models using the box scheme.
Properties for all models using cell-centered finite volume scheme with TPFA.
The available discretization methods in Dumux.
Properties of pure molecular oxygen .
Material properties of pure salt .
A compositional two-phase fluid system with a liquid and a gaseous phase and , and (dissolved miner...
A solid phase consisting of multiple inert solid components.
@ p0s1
first phase pressure and second phase saturation as primary variables
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:115
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
const GridGeometry & fvGridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:584
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
The component balance index that should be replaced by the total mass/mole balance.
Definition: common/properties.hh:104
The type of the spatial parameters object.
Definition: common/properties.hh:221
The type of the fluid system to use.
Definition: common/properties.hh:223
The type of the solid system to use.
Definition: common/properties.hh:227
The formulation of the model.
Definition: common/properties.hh:237
Interface for passing data sets to a file and plotting them, if gnuplot is installed.
Definition: gnuplotinterface.hh:57
Properties of granite.
Definition: granite.hh:45
A class for the NaCl properties.
Definition: nacl.hh:47
A compositional two-phase fluid system with a liquid and a gaseous phase and , and (dissolved miner...
Definition: brineair.hh:75
A solid phase consisting of multiple inert solid components.
Definition: compositionalsolidphase.hh:42
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
SpatialParams & spatialParams()
Returns the spatial parameters object.
Definition: dumux/porousmediumflow/problem.hh:146
Problem where brine is evaporating at the top boundary. The system is closed at the remaining boundar...
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:136
void setTimeStepSize(Scalar timeStepSize)
The time step size.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:245
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:280
Scalar extrusionFactorAtPos(const GlobalPosition &globalPos) const
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:504
void setTime(Scalar time)
The current time.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:235
void updateVtkOutput(const SolutionVector &curSol)
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:485
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a neumann boundary segment.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:318
SalinizationProblem(std::shared_ptr< const FVGridGeometry > fvGridGeometry)
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:200
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:293
const std::vector< Scalar > & getPermeability()
Adds additional VTK output data to the VTKWriter.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:480
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluates the source term for all phases within a given sub-controlvolume.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:439
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:259
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:403
Scalar temperature() const
Returns the temperature within the domain.
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:267
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:55
std::tuple< TwoPNCMinNI > InheritsFrom
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:55
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:56
std::tuple< Salinization, BoxModel > InheritsFrom
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:56
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:57
std::tuple< Salinization, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:57
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:64
Dune::YaspGrid< 2, Dune::TensorProductCoordinates< Scalar, 2 > > type
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:65
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:76
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:83
GetPropType< TypeTag, Properties::GridGeometry > FVGridGeometry
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:94
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/2pncmin/implicit/nonisothermal/problem.hh:95
Spatial parameters for the salinization problem, where evaporation from a porous medium saturated wit...
Definition: porousmediumflow/2pncmin/implicit/nonisothermal/spatialparams.hh:49
Declares all properties used in Dumux.
Adaption of the fully implicit scheme to the two-phase n-component fully implicit model with addition...
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.