ptflash/flashmodel.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 OPM_PTFLASH_MODEL_HH
29#define OPM_PTFLASH_MODEL_HH
30
31#include <opm/material/constraintsolvers/PTFlash.hpp>
32#include <opm/material/constraintsolvers/PTFlashMethod.hpp>
33
34#include <opm/material/densead/Math.hpp>
35
36#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
37#include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
38
41
46
51
58
59#include <cassert>
60#include <memory>
61#include <sstream>
62#include <string>
63#include <tuple>
64
65namespace Opm {
66
67template <class TypeTag>
68class FlashModel;
69
70}
71
72namespace Opm::Properties {
73
74namespace TTag {
76struct FlashModel { using InheritsFrom = std::tuple<MultiPhaseBaseModel>; };
77} // namespace TTag
78
80template<class TypeTag>
81struct LocalResidual<TypeTag, TTag::FlashModel>
83
85template<class TypeTag>
86struct NewtonMethod<TypeTag, TTag::FlashModel>
88
90template<class TypeTag>
91struct FlashSolver<TypeTag, TTag::FlashModel>
92{
93 using type = PTFlash<GetPropType<TypeTag, Properties::Scalar>,
95};
96
98template<class TypeTag>
99struct Model<TypeTag, TTag::FlashModel>
101
103template<class TypeTag>
104struct PrimaryVariables<TypeTag, TTag::FlashModel>
106
108template<class TypeTag>
109struct RateVector<TypeTag, TTag::FlashModel>
111
113template<class TypeTag>
114struct BoundaryRateVector<TypeTag, TTag::FlashModel>
116
118template<class TypeTag>
119struct IntensiveQuantities<TypeTag, TTag::FlashModel>
121
123template<class TypeTag>
124struct ExtensiveQuantities<TypeTag, TTag::FlashModel>
126
128template<class TypeTag>
129struct Indices<TypeTag, TTag::FlashModel>
130{ using type = FlashIndices<TypeTag, /*PVIdx=*/0>; };
131
132// disable molecular diffusion by default
133template<class TypeTag>
134struct EnableDiffusion<TypeTag, TTag::FlashModel>
135{ static constexpr bool value = false; };
136
138template<class TypeTag>
139struct EnableEnergy<TypeTag, TTag::FlashModel>
140{ static constexpr bool value = false; };
141
142template<class TypeTag>
143struct EnableWater<TypeTag, TTag::MultiPhaseBaseModel>
145
146} // namespace Opm::Properties
147
148namespace Opm {
149
192template <class TypeTag>
194 : public MultiPhaseBaseModel<TypeTag>
195{
196 using ParentType = MultiPhaseBaseModel<TypeTag>;
197
201
203
204 enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
205 static constexpr bool enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>();
206 static constexpr bool enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>();
207
209
210public:
211 explicit FlashModel(Simulator& simulator)
212 : ParentType(simulator)
213 {
214 // Reject an unknown method here rather than from inside the flash: the
215 // intensive quantities are updated in parallel, where the throw would
216 // escape an OpenMP region and terminate instead of being reported.
217 ptFlashMethodFromString(Parameters::Get<Parameters::FlashTwoPhaseMethod>());
218 }
219
223 static void registerParameters()
224 {
226
227 // register runtime parameters of the VTK output modules
230
231 if constexpr (enableDiffusion) {
233 }
234
235 if constexpr (enableEnergy) {
237 }
238
239 Parameters::Register<Parameters::FlashTolerance<Scalar>>
240 ("The maximum tolerance for the flash solver to "
241 "consider the solution converged");
242 Parameters::Register<Parameters::FlashVerbosity>(
243 "Flash solver verbosity level. Messages are written to the debug log and require "
244 "--debug-verbosity-level to be at least 1");
245 Parameters::Register<Parameters::FlashTwoPhaseMethod>
246 ("Method for solving vapor-liquid composition. Available options include: "
247 "ssi, newton, ssi+newton");
248
249 Parameters::SetDefault<Parameters::FlashTolerance<Scalar>>(1.e-8);
250 Parameters::SetDefault<Parameters::EnableIntensiveQuantityCache>(true);
251
252 // since thermodynamic hints are basically free if the cache for intensive quantities is
253 // enabled, and this model usually shows quite a performance improvment if they are
254 // enabled, let's enable them by default.
255 Parameters::SetDefault<Parameters::EnableThermodynamicHints>(true);
256 }
257
261 std::string primaryVarName(unsigned pvIdx) const
262 {
263 const std::string& tmp = EnergyModule::primaryVarName(pvIdx);
264 if (!tmp.empty()) {
265 return tmp;
266 }
267
268 std::ostringstream oss;
269 if (Indices::z0Idx <= pvIdx && pvIdx < Indices::z0Idx + numComponents - 1) {
270 oss << "z_," << FluidSystem::componentName(/*compIdx=*/pvIdx - Indices::z0Idx);
271 }
272 else if (pvIdx == Indices::pressure0Idx) {
273 oss << "pressure_" << FluidSystem::phaseName(0);
274 }
275 else {
276 assert(false);
277 }
278
279 return oss.str();
280 }
281
285 std::string eqName(unsigned eqIdx) const
286 {
287 const std::string& tmp = EnergyModule::eqName(eqIdx);
288 if (!tmp.empty()) {
289 return tmp;
290 }
291
292 std::ostringstream oss;
293 if (Indices::conti0EqIdx <= eqIdx &&
294 eqIdx < Indices::conti0EqIdx + numComponents)
295 {
296 const unsigned compIdx = eqIdx - Indices::conti0EqIdx;
297 oss << "continuity^" << FluidSystem::componentName(compIdx);
298 }
299 else {
300 assert(false);
301 }
302
303 return oss.str();
304 }
305
307 {
309
310 // add the VTK output modules which are meaningful for the model
311 this->addOutputModule(std::make_unique<VtkCompositionModule<TypeTag>>(this->simulator_));
312 this->addOutputModule(std::make_unique<VtkPTFlashModule<TypeTag>>(this->simulator_));
313 if constexpr (enableDiffusion) {
314 this->addOutputModule(std::make_unique<VtkDiffusionModule<TypeTag>>(this->simulator_));
315 }
316 if constexpr (enableEnergy) {
317 this->addOutputModule(std::make_unique<VtkEnergyModule<TypeTag>>(this->simulator_));
318 }
319 }
320};
321
322} // namespace Opm
323
324#endif
Provides the auxiliary methods required for consideration of the energy equation.
Definition: energymodule.hh:55
Implements a boundary vector for the fully implicit compositional multi-phase model which is based on...
Definition: flashboundaryratevector.hh:49
This template class contains the data which is required to calculate all fluxes of components over a ...
Definition: flashextensivequantities.hh:54
Defines the primary variable and equation indices for the compositional multi-phase model based on fl...
Definition: flash/flashindices.hh:47
Contains the intensive quantities of the flash-based compositional multi-phase model.
Definition: flash/flashintensivequantities.hh:60
Calculates the local residual of the compositional multi-phase model based on flash calculations.
Definition: flash/flashlocalresidual.hh:47
A compositional multi-phase model based on flash-calculations.
Definition: ptflash/flashmodel.hh:195
FlashModel(Simulator &simulator)
Definition: ptflash/flashmodel.hh:211
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: ptflash/flashmodel.hh:223
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: ptflash/flashmodel.hh:261
void registerOutputModules_()
Definition: ptflash/flashmodel.hh:306
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition: ptflash/flashmodel.hh:285
A Newton solver specific to the PTFlash model.
Definition: flashnewtonmethod.hh:56
Represents the primary variables used by the compositional flow model based on flash calculations.
Definition: flash/flashprimaryvariables.hh:52
Definition: flashratevector.hh:48
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:161
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:183
void registerOutputModules_()
Definition: multiphasebasemodel.hh:259
VTK output module for the fluid composition.
Definition: vtkcompositionmodule.hpp:57
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkcompositionmodule.hpp:87
VTK output module for quantities which make sense for models which incorperate molecular diffusion.
Definition: vtkdiffusionmodule.hpp:58
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkdiffusionmodule.hpp:88
VTK output module for quantities which make sense for models which assume thermal equilibrium.
Definition: vtkenergymodule.hpp:58
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkenergymodule.hpp:87
VTK output module for the PT Flash calculation This module deals with the following quantities: K,...
Definition: vtkptflashmodule.hpp:53
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkptflashmodule.hpp:83
Contains the classes required to consider energy as a conservation quantity in a multi-phase module.
Declares the properties required by the compositional multi-phase model based on flash calculations.
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
Declares the parameters for the compositional multi-phase model based on flash calculations.
Type of object for specifying boundary conditions.
Definition: fvbaseproperties.hh:124
Enable diffusive fluxes?
Definition: multiphasebaseproperties.hh:91
Enable water?
Definition: multiphasebaseproperties.hh:103
Data required to calculate a flux over a face.
Definition: fvbaseproperties.hh:163
NcpFlash< GetPropType< TypeTag, Properties::Scalar >, GetPropType< TypeTag, Properties::FluidSystem > > type
Definition: flash/flashmodel.hh:88
The type of the flash constraint solver.
Definition: flashproperties.hh:39
Enumerations used by the model.
Definition: multiphasebaseproperties.hh:51
The secondary variables within a sub-control volume.
Definition: fvbaseproperties.hh:138
The type of the local residual function.
Definition: fvbaseproperties.hh:99
The type of the model.
Definition: basicproperties.hh:92
Specifies the type of the actual Newton method.
Definition: newtonmethodproperties.hh:32
A vector of primary variables within a sub-control volume.
Definition: fvbaseproperties.hh:135
Vector containing volumetric or areal rates of quantities.
Definition: fvbaseproperties.hh:121
The type tag for the isothermal single phase problems.
Definition: flash/flashmodel.hh:74
std::tuple< MultiPhaseBaseModel > InheritsFrom
Definition: flash/flashmodel.hh:74