powerinjectionproblem.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 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 2 of the License, or
9 (at your option) any later version.
10
11 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
28#ifndef EWOMS_POWER_INJECTION_PROBLEM_HH
29#define EWOMS_POWER_INJECTION_PROBLEM_HH
30
31#include <opm/material/fluidmatrixinteractions/RegularizedVanGenuchten.hpp>
32#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
33#include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
34#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
35#include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
36#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
37#include <opm/material/components/SimpleH2O.hpp>
38#include <opm/material/components/Air.hpp>
39
44
45#include <dune/grid/yaspgrid.hh>
46
47#include <dune/common/version.hh>
48#include <dune/common/fvector.hh>
49#include <dune/common/fmatrix.hh>
50
51#include <sstream>
52#include <string>
53#include <type_traits>
54#include <iostream>
55
56namespace Opm {
57template <class TypeTag>
58class PowerInjectionProblem;
59}
60
61namespace Opm::Properties {
62
63namespace TTag {
65}
66
67// Set the grid implementation to be used
68template<class TypeTag>
69struct Grid<TypeTag, TTag::PowerInjectionBaseProblem>
70{ using type = Dune::YaspGrid</*dim=*/1>; };
71
72// set the Vanguard property
73template<class TypeTag>
74struct Vanguard<TypeTag, TTag::PowerInjectionBaseProblem>
76
77// Set the problem property
78template<class TypeTag>
79struct Problem<TypeTag, TTag::PowerInjectionBaseProblem>
81
82// Set the wetting phase
83template<class TypeTag>
84struct WettingPhase<TypeTag, TTag::PowerInjectionBaseProblem>
85{
86private:
88
89public:
90 using type = Opm::LiquidPhase<Scalar, Opm::SimpleH2O<Scalar> >;
91};
92
93// Set the non-wetting phase
94template<class TypeTag>
95struct NonwettingPhase<TypeTag, TTag::PowerInjectionBaseProblem>
96{
97private:
99
100public:
101 using type = Opm::GasPhase<Scalar, Opm::Air<Scalar> >;
102};
103
104// Set the material Law
105template<class TypeTag>
106struct MaterialLaw<TypeTag, TTag::PowerInjectionBaseProblem>
107{
108private:
110 enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
111 enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
112
114 using Traits = Opm::TwoPhaseMaterialTraits<Scalar,
115 /*wettingPhaseIdx=*/FluidSystem::wettingPhaseIdx,
116 /*nonWettingPhaseIdx=*/FluidSystem::nonWettingPhaseIdx>;
117
118 // define the material law which is parameterized by effective
119 // saturations
120 using EffectiveLaw = Opm::RegularizedVanGenuchten<Traits>;
121
122public:
123 // define the material law parameterized by absolute saturations
124 using type = Opm::EffToAbsLaw<EffectiveLaw>;
125};
126
127} // namespace Opm::Properties
128
129namespace Opm {
142template <class TypeTag>
143class PowerInjectionProblem : public GetPropType<TypeTag, Properties::BaseProblem>
144{
146
158
159 enum {
160 // number of phases
161 numPhases = FluidSystem::numPhases,
162
163 // phase indices
164 wettingPhaseIdx = FluidSystem::wettingPhaseIdx,
165 nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx,
166
167 // equation indices
168 contiNEqIdx = Indices::conti0EqIdx + nonWettingPhaseIdx,
169
170 // Grid and world dimension
171 dim = GridView::dimension,
172 dimWorld = GridView::dimensionworld
173 };
174
177
178 using CoordScalar = typename GridView::ctype;
179 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
180
181 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
182
183public:
187 explicit PowerInjectionProblem(Simulator& simulator)
188 : ParentType(simulator)
189 { }
190
195 {
196 ParentType::finishInit();
197
198 eps_ = 3e-6;
199 FluidSystem::init();
200
201 temperature_ = 273.15 + 26.6;
202
203 // parameters for the Van Genuchten law
204 // alpha and n
205 materialParams_.setVgAlpha(0.00045);
206 materialParams_.setVgN(7.3);
207 materialParams_.finalize();
208
209 K_ = this->toDimMatrix_(5.73e-08); // [m^2]
210
211 setupInitialFluidState_();
212 }
213
217 static void registerParameters()
218 {
219 ParentType::registerParameters();
220
221 Parameters::SetDefault<Parameters::CellsX>(250);
222 Parameters::SetDefault<Parameters::DomainSizeX<Scalar>>(100.0);
223
224 if constexpr (dim > 1) {
225 Parameters::SetDefault<Parameters::CellsY>(1);
226 Parameters::SetDefault<Parameters::DomainSizeY<Scalar>>(1.0);
227 }
228 if constexpr (dim == 3) {
229 Parameters::SetDefault<Parameters::CellsZ>(1);
230 Parameters::SetDefault<Parameters::DomainSizeZ<Scalar>>(1.0);
231 }
232
233 Parameters::SetDefault<Parameters::EndTime<Scalar>>(100.0);
234 Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(1e-3);
235 Parameters::SetDefault<Parameters::VtkWriteFilterVelocities>(true);
236 }
237
242
246 std::string name() const
247 {
248 std::ostringstream oss;
249 oss << "powerinjection_";
252 oss << "darcy";
253 else
254 oss << "forchheimer";
255
258 oss << "_" << "ad";
259 else
260 oss << "_" << "fd";
261
262 return oss.str();
263 }
264
269 {
270#ifndef NDEBUG
271 this->model().checkConservativeness();
272
273 // Calculate storage terms
274 EqVector storage;
275 this->model().globalStorage(storage);
276
277 // Write mass balance information for rank 0
278 if (this->gridView().comm().rank() == 0) {
279 std::cout << "Storage: " << storage << std::endl << std::flush;
280 }
281#endif // NDEBUG
282 }
284
289
293 template <class Context>
294 const DimMatrix& intrinsicPermeability(const Context& /*context*/,
295 unsigned /*spaceIdx*/,
296 unsigned /*timeIdx*/) const
297 { return K_; }
298
302 template <class Context>
303 Scalar ergunCoefficient(const Context& /*context*/,
304 unsigned /*spaceIdx*/,
305 unsigned /*timeIdx*/) const
306 { return 0.3866; }
307
311 template <class Context>
312 Scalar porosity(const Context& /*context*/,
313 unsigned /*spaceIdx*/,
314 unsigned /*timeIdx*/) const
315 { return 0.558; }
316
320 template <class Context>
321 const MaterialLawParams&
322 materialLawParams(const Context& /*context*/,
323 unsigned /*spaceIdx*/,
324 unsigned /*timeIdx*/) const
325 { return materialParams_; }
326
330 template <class Context>
331 Scalar temperature(const Context& /*context*/,
332 unsigned /*spaceIdx*/,
333 unsigned /*timeIdx*/) const
334 { return temperature_; }
335
337
342
349 template <class Context>
350 void boundary(BoundaryRateVector& values,
351 const Context& context,
352 unsigned spaceIdx,
353 unsigned timeIdx) const
354 {
355 const GlobalPosition& pos = context.pos(spaceIdx, timeIdx);
356
357 if (onLeftBoundary_(pos)) {
358 RateVector massRate(0.0);
359 massRate = 0.0;
360 massRate[contiNEqIdx] = -1.00; // kg / (m^2 * s)
361
362 // impose a forced flow boundary
363 values.setMassRate(massRate);
364 }
365 else if (onRightBoundary_(pos))
366 // free flow boundary with initial condition on the right
367 values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidState_);
368 else
369 values.setNoFlow();
370 }
371
373
378
382 template <class Context>
383 void initial(PrimaryVariables& values,
384 const Context& /*context*/,
385 unsigned /*spaceIdx*/,
386 unsigned /*timeIdx*/) const
387 {
388 // assign the primary variables
389 values.assignNaive(initialFluidState_);
390 }
391
398 template <class Context>
399 void source(RateVector& rate,
400 const Context& /*context*/,
401 unsigned /*spaceIdx*/,
402 unsigned /*timeIdx*/) const
403 { rate = Scalar(0.0); }
404
406
407private:
408 bool onLeftBoundary_(const GlobalPosition& pos) const
409 { return pos[0] < this->boundingBoxMin()[0] + eps_; }
410
411 bool onRightBoundary_(const GlobalPosition& pos) const
412 { return pos[0] > this->boundingBoxMax()[0] - eps_; }
413
414 void setupInitialFluidState_()
415 {
416 initialFluidState_.setTemperature(temperature_);
417
418 Scalar Sw = 1.0;
419 initialFluidState_.setSaturation(wettingPhaseIdx, Sw);
420 initialFluidState_.setSaturation(nonWettingPhaseIdx, 1 - Sw);
421
422 Scalar p = 1e5;
423 initialFluidState_.setPressure(wettingPhaseIdx, p);
424 initialFluidState_.setPressure(nonWettingPhaseIdx, p);
425
426 typename FluidSystem::template ParameterCache<Scalar> paramCache;
427 paramCache.updateAll(initialFluidState_);
428 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
429 initialFluidState_.setDensity(phaseIdx,
430 FluidSystem::density(initialFluidState_, paramCache, phaseIdx));
431 initialFluidState_.setViscosity(phaseIdx,
432 FluidSystem::viscosity(initialFluidState_, paramCache, phaseIdx));
433 }
434 }
435
436 DimMatrix K_;
437 MaterialLawParams materialParams_;
438
439 Opm::ImmiscibleFluidState<Scalar, FluidSystem> initialFluidState_;
440 Scalar temperature_;
441 Scalar eps_;
442};
443
444} // namespace Opm
445
446#endif
Provides a simulator vanguad which creates a regular grid made of quadrilaterals.
Definition: cubegridvanguard.hh:53
1D Problem with very fast injection of gas on the left.
Definition: powerinjectionproblem.hh:144
void finishInit()
Called by the Opm::Simulator in order to initialize the problem.
Definition: powerinjectionproblem.hh:194
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: powerinjectionproblem.hh:312
static void registerParameters()
Definition: powerinjectionproblem.hh:217
Scalar temperature(const Context &, unsigned, unsigned) const
Definition: powerinjectionproblem.hh:331
void endTimeStep()
Called by the simulator after each time integration.
Definition: powerinjectionproblem.hh:268
void initial(PrimaryVariables &values, const Context &, unsigned, unsigned) const
Evaluate the initial value for a control volume.
Definition: powerinjectionproblem.hh:383
Scalar ergunCoefficient(const Context &, unsigned, unsigned) const
Returns the Ergun coefficient.
Definition: powerinjectionproblem.hh:303
const MaterialLawParams & materialLawParams(const Context &, unsigned, unsigned) const
Definition: powerinjectionproblem.hh:322
std::string name() const
The problem name.
Definition: powerinjectionproblem.hh:246
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: powerinjectionproblem.hh:399
PowerInjectionProblem(Simulator &simulator)
Definition: powerinjectionproblem.hh:187
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the boundary conditions for a boundary segment.
Definition: powerinjectionproblem.hh:350
const DimMatrix & intrinsicPermeability(const Context &, unsigned, unsigned) const
Definition: powerinjectionproblem.hh:294
This file contains the necessary classes to calculate the volumetric fluxes out of a pressure potenti...
Definition: blackoilmodel.hh:74
Definition: blackoilbioeffectsmodules.hh:45
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:233
Specifies a flux module which uses the Darcy relation.
Definition: darcyfluxmodule.hh:67
Dune::YaspGrid< 1 > type
Definition: powerinjectionproblem.hh:70
The type of the DUNE grid.
Definition: basicproperties.hh:104
Opm::EffToAbsLaw< EffectiveLaw > type
Definition: powerinjectionproblem.hh:124
The material law which ought to be used (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:55
Opm::GasPhase< Scalar, Opm::Air< Scalar > > type
Definition: powerinjectionproblem.hh:101
The non-wetting phase for two-phase models.
Definition: immiscibleproperties.hh:44
The type of the problem.
Definition: fvbaseproperties.hh:86
Definition: fvbaseadlocallinearizer.hh:58
Definition: powerinjectionproblem.hh:64
Property which provides a Vanguard (manages grids)
Definition: basicproperties.hh:100
Opm::LiquidPhase< Scalar, Opm::SimpleH2O< Scalar > > type
Definition: powerinjectionproblem.hh:90
The wetting phase for two-phase models.
Definition: immiscibleproperties.hh:41