3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
26#ifndef DUMUX_THERMOCHEM_PROBLEM_HH
27#define DUMUX_THERMOCHEM_PROBLEM_HH
28
29#include <dune/grid/yaspgrid.hh>
30
42
43#include "spatialparams.hh"
44#include "reaction.hh"
45#include "modifiedcao.hh"
46
47namespace Dumux {
48
49template <class TypeTag>
50class ThermoChemProblem;
51
52namespace Properties {
53// Create new type tags
54namespace TTag {
55struct ThermoChem { using InheritsFrom = std::tuple<OnePNCMinNI>; };
56struct ThermoChemBox { using InheritsFrom = std::tuple<ThermoChem, BoxModel>; };
57} // end namespace TTag
58
59// Set the grid type
60template<class TypeTag>
61struct Grid<TypeTag, TTag::ThermoChem> { using type = Dune::YaspGrid<2>; };
62// Set the problem property
63template<class TypeTag>
64struct Problem<TypeTag, TTag::ThermoChem> { using type = ThermoChemProblem<TypeTag>; };
65
66// The fluid system
67template<class TypeTag>
68struct FluidSystem<TypeTag, TTag::ThermoChem>
69{
72 static constexpr auto phaseIdx = H2ON2::gasPhaseIdx; // simulate the air phase
74};
75
76template<class TypeTag>
77struct SolidSystem<TypeTag, TTag::ThermoChem>
78{
83};
84
85// // Enable velocity output
86// template<class TypeTag>
87// struct VtkAddVelocity<TypeTag, TTag::ThermoChem> { static constexpr bool value = false; };
88
89// Set the spatial parameters
90template<class TypeTag>
91struct SpatialParams<TypeTag, TTag::ThermoChem>
92{
96};
97
98// Define whether mole(true) or mass (false) fractions are used
99template<class TypeTag>
100struct UseMoles<TypeTag, TTag::ThermoChem> { static constexpr bool value = true; };
101}
102
116template <class TypeTag>
118{
124
126 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
127 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
128 using VolumeVariables = typename GridVariables::GridVolumeVariables::VolumeVariables;
129
133 using Element = typename GridView::template Codim<0>::Entity;
134 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
135 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
136 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
141
142 enum { dim = GridView::dimension };
143 enum { dimWorld = GridView::dimensionworld };
144
145 enum
146 {
147 // Indices of the primary variables
148 pressureIdx = Indices::pressureIdx, //gas-phase pressure
149 H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx), // mole fraction water
150
151 CaOIdx = FluidSystem::numComponents,
152 CaO2H2Idx = FluidSystem::numComponents+1,
153
154 // Equation Indices
155 conti0EqIdx = Indices::conti0EqIdx,
156
157 // Phase Indices
158 cPhaseIdx = SolidSystem::comp0Idx,
159
160 temperatureIdx = Indices::temperatureIdx,
161 energyEqIdx = Indices::energyEqIdx
162 };
163
164 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
165
166public:
167 ThermoChemProblem(std::shared_ptr<const GridGeometry> gridGeometry)
169 {
170 name_ = getParam<std::string>("Problem.Name");
171 FluidSystem::init(/*tempMin=*/473.15,
172 /*tempMax=*/623.0,
173 /*numTemptempSteps=*/25,
174 /*startPressure=*/0,
175 /*endPressure=*/9e6,
176 /*pressureSteps=*/200);
177
178 // obtain BCs
179 boundaryPressure_ = getParam<Scalar>("Problem.BoundaryPressure");
180 boundaryVaporMoleFrac_ = getParam<Scalar>("Problem.BoundaryMoleFraction");
181 boundaryTemperature_ = getParam<Scalar>("Problem.BoundaryTemperature");
182
184 permeability_.resize(gridGeometry->gridView().size(codim));
185 porosity_.resize(gridGeometry->gridView().size(codim));
186 reactionRate_.resize(gridGeometry->gridView().size(codim));
187 }
188
194 const std::string name() const
195 { return name_; }
196
202 void setTimeStepSize( Scalar timeStepSize )
203 {
204 timeStepSize_ = timeStepSize;
205 }
206
215 BoundaryTypes boundaryTypesAtPos( const GlobalPosition &globalPos) const
216 {
217 BoundaryTypes values;
218
219 // we don't set any BCs for the solid phases
220 values.setDirichlet(pressureIdx);
221 values.setDirichlet(H2OIdx);
222 values.setDirichlet(temperatureIdx);
223
224 return values;
225 }
226
232 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
233 {
234 PrimaryVariables priVars(0.0);
235
236 priVars[pressureIdx] = boundaryPressure_;
237 priVars[H2OIdx] = boundaryVaporMoleFrac_;
238 priVars[temperatureIdx] = boundaryTemperature_;
239 priVars[CaO2H2Idx] = 0.0;
240 priVars[CaOIdx] = 0.2;
241
242 return priVars;
243 }
244
259 NumEqVector neumann(const Element& element,
260 const FVElementGeometry& fvGeometry,
261 const ElementVolumeVariables& elemVolVars,
262 const ElementFluxVariablesCache& elemFluxVarsCache,
263 const SubControlVolumeFace& scvf) const
264 {
265 NumEqVector flux(0.0);
266 return flux;
267 }
268
275 PrimaryVariables initialAtPos(const GlobalPosition& globalPos) const
276 {
277 PrimaryVariables priVars(0.0);
278
279 Scalar pInit;
280 Scalar tInit;
281 Scalar h2oInit;
282 Scalar CaOInit;
283 Scalar CaO2H2Init;
284
285 pInit = getParam<Scalar>("Problem.PressureInitial");
286 tInit = getParam<Scalar>("Problem.TemperatureInitial");
287 h2oInit = getParam<Scalar>("Problem.VaporInitial");
288 CaOInit = getParam<Scalar>("Problem.CaOInitial");
289 CaO2H2Init = getParam<Scalar>("Problem.CaO2H2Initial");
290
291 priVars[pressureIdx] = pInit;
292 priVars[H2OIdx] = h2oInit;
293 priVars[temperatureIdx] = tInit;
294
295 // these values are not used, as we didn't set BCs
296 // for the solid phases. For cell-centered models it is
297 // important to set the values to fully define Dirichlet BCs
298 priVars[CaOIdx] = CaOInit;
299 priVars[CaO2H2Idx] = CaO2H2Init;
300
301 return priVars;
302 }
303
322 NumEqVector source(const Element &element,
323 const FVElementGeometry& fvGeometry,
324 const ElementVolumeVariables& elemVolVars,
325 const SubControlVolume &scv) const
326 {
327
328 NumEqVector source(0.0);
329 const auto& volVars = elemVolVars[scv];
330
331 Scalar qMass = rrate_.thermoChemReaction(volVars);
332 const auto elemSol = elementSolution(element, elemVolVars, fvGeometry);
333 Scalar qMole = qMass/FluidSystem::molarMass(H2OIdx)*(1-volVars.porosity());
334
335 // make sure not more solid reacts than present
336 // In this test, we only consider discharge. Therefore, we use the cPhaseIdx for CaO.
337 if (-qMole*timeStepSize_ + volVars.solidVolumeFraction(cPhaseIdx)* volVars.solidComponentMolarDensity(cPhaseIdx) < 0 + eps_)
338 {
339 qMole = -volVars.solidVolumeFraction(cPhaseIdx)* volVars.solidComponentMolarDensity(cPhaseIdx)/timeStepSize_;
340 }
341 source[conti0EqIdx+CaO2H2Idx] = qMole;
342 source[conti0EqIdx+CaOIdx] = - qMole;
343 source[conti0EqIdx+H2OIdx] = - qMole;
344
345 Scalar deltaH = 108e3; // J/mol
346 source[energyEqIdx] = qMole * deltaH;
347
348 return source;
349 }
350
351
355 const std::vector<Scalar>& getPerm()
356 {
357 return permeability_;
358 }
359
363 const std::vector<Scalar>& getPoro()
364 {
365 return porosity_;
366 }
367
371 const std::vector<Scalar>& getRRate()
372 {
373 return reactionRate_;
374 }
375
381 void updateVtkOutput(const SolutionVector& curSol)
382 {
383 for (const auto& element : elements(this->gridGeometry().gridView()))
384 {
385 const auto elemSol = elementSolution(element, curSol, this->gridGeometry());
386
387 auto fvGeometry = localView(this->gridGeometry());
388 fvGeometry.bindElement(element);
389
390 for (auto&& scv : scvs(fvGeometry))
391 {
392 VolumeVariables volVars;
393 volVars.update(elemSol, *this, element, scv);
394 const auto dofIdxGlobal = scv.dofIndex();
395 permeability_[dofIdxGlobal] = this->spatialParams().permeability(element, scv, elemSol);
396 porosity_[dofIdxGlobal] = volVars.porosity();
397 reactionRate_[dofIdxGlobal] = rrate_.thermoChemReaction(volVars);
398 }
399 }
400 }
401
402private:
403 std::string name_;
404
405 static constexpr Scalar eps_ = 1e-6;
406
407 // boundary conditions
408 Scalar boundaryPressure_;
409 Scalar boundaryVaporMoleFrac_;
410 Scalar boundaryTemperature_;
411
412 std::vector<double> permeability_;
413 std::vector<double> porosity_;
414 std::vector<double> reactionRate_;
415
416 ReactionRate rrate_;
417 Scalar timeStepSize_;
418};
419
420} // end namespace Dumux
421
422#endif
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 mpfa.
Properties for all models using cell-centered finite volume scheme with TPFA.
Material properties of pure Calciumhydroxide .
Reation for a simple effective thermal conductivity.
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
A solid phase consisting of multiple inert solid components.
Corrected material properties of pure Calcium-Oxide without considering a porosity change in the rea...
Class for the evaluation of the reaction rate of Calciumoxide to Halciumhydroxide.
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
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
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
Property whether to use moles or kg as amount unit for balance equations.
Definition: common/properties.hh:102
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
A class for the CaO2H2 properties.
Definition: cao2h2.hh:46
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
Definition: 1padapter.hh:46
A two-phase fluid system with two components water Nitrogen for non-equilibrium models.
Definition: h2on2.hh:69
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
A class for the ModifiedCaO properties.
Definition: modifiedcao.hh:44
Test for the 1pncmin model in combination with the NI model for a quasi batch reaction of Calciumoxyd...
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:118
void updateVtkOutput(const SolutionVector &curSol)
Adds additional VTK output data to the VTKWriter.
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:381
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:215
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-control volume in units of .
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:322
ThermoChemProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:167
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial values for a control volume in .
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:275
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann boundary segment in dependency on the current solutio...
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:259
const std::vector< Scalar > & getPerm()
Returns the permeability.
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:355
const std::vector< Scalar > & getRRate()
Returns the reaction rate.
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:371
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:232
const std::string name() const
The problem name.
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:194
void setTimeStepSize(Scalar timeStepSize)
Sets the currently used time step size.
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:202
const std::vector< Scalar > & getPoro()
Returns the porosity.
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:363
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:55
std::tuple< OnePNCMinNI > InheritsFrom
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:55
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:56
std::tuple< ThermoChem, BoxModel > InheritsFrom
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:56
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:61
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:70
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:79
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:93
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pncmin/implicit/nonisothermal/problem.hh:94
Class for the evaluation of the reaction rate of Calciumoxide to Halciumhydroxide.
Definition: reaction.hh:38
VolumeVariables::PrimaryVariables::value_type thermoChemReaction(const VolumeVariables &volVars) const
Evaluates the reaction kinetics (see Nagel et al. 2014 ).
Definition: reaction.hh:46
Definition of the spatial parameters for the thermochemistry problem which uses the non-insothermal 1...
Definition: porousmediumflow/1pncmin/implicit/nonisothermal/spatialparams.hh:42
A single-phase, multi-component model considering mineralization processes.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.