Loading...
Searching...
No Matches
flashmodel.hh
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_PTFLASH_MODEL_HH
#define OPM_PTFLASH_MODEL_HH
#include <opm/material/constraintsolvers/PTFlash.hpp>
#include <opm/material/densead/Math.hpp>
#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
#include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
#include <opm/models/common/energymodule.hh>
#include <opm/models/common/multiphasebasemodel.hh>
#include <opm/models/flash/flashboundaryratevector.hh>
#include <opm/models/flash/flashextensivequantities.hh>
#include <opm/models/flash/flashproperties.hh>
#include <opm/models/flash/flashratevector.hh>
#include <opm/models/io/vtkcompositionmodule.hpp>
#include <opm/models/io/vtkdiffusionmodule.hpp>
#include <opm/models/io/vtkenergymodule.hpp>
#include <opm/models/io/vtkptflashmodule.hpp>
#include <opm/models/ptflash/flashindices.hh>
#include <opm/models/ptflash/flashintensivequantities.hh>
#include <opm/models/ptflash/flashlocalresidual.hh>
#include <opm/models/ptflash/flashnewtonmethod.hh>
#include <opm/models/ptflash/flashparameters.hh>
#include <opm/models/ptflash/flashprimaryvariables.hh>
#include <cassert>
#include <memory>
#include <sstream>
#include <string>
#include <tuple>
namespace Opm {
template <class TypeTag>
class FlashModel;
}
namespace Opm::Properties {
namespace TTag {
struct FlashModel { using InheritsFrom = std::tuple<MultiPhaseBaseModel>; };
} // namespace TTag
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::FlashModel>
{ using type = FlashLocalResidual<TypeTag>; };
template<class TypeTag>
struct NewtonMethod<TypeTag, TTag::FlashModel>
{ using type = FlashNewtonMethod<TypeTag>; };
template<class TypeTag>
struct FlashSolver<TypeTag, TTag::FlashModel>
{
using type = PTFlash<GetPropType<TypeTag, Properties::Scalar>,
GetPropType<TypeTag, Properties::FluidSystem>>;
};
template<class TypeTag>
struct Model<TypeTag, TTag::FlashModel>
{ using type = FlashModel<TypeTag>; };
template<class TypeTag>
struct PrimaryVariables<TypeTag, TTag::FlashModel>
{ using type = FlashPrimaryVariables<TypeTag>; };
template<class TypeTag>
struct RateVector<TypeTag, TTag::FlashModel>
{ using type = FlashRateVector<TypeTag>; };
template<class TypeTag>
struct BoundaryRateVector<TypeTag, TTag::FlashModel>
{ using type = FlashBoundaryRateVector<TypeTag>; };
template<class TypeTag>
struct IntensiveQuantities<TypeTag, TTag::FlashModel>
{ using type = FlashIntensiveQuantities<TypeTag>; };
template<class TypeTag>
struct ExtensiveQuantities<TypeTag, TTag::FlashModel>
{ using type = FlashExtensiveQuantities<TypeTag>; };
template<class TypeTag>
struct Indices<TypeTag, TTag::FlashModel>
{ using type = FlashIndices<TypeTag, /*PVIdx=*/0>; };
// disable molecular diffusion by default
template<class TypeTag>
struct EnableDiffusion<TypeTag, TTag::FlashModel>
{ static constexpr bool value = false; };
template<class TypeTag>
struct EnableEnergy<TypeTag, TTag::FlashModel>
{ static constexpr bool value = false; };
template<class TypeTag>
struct EnableWater<TypeTag, TTag::MultiPhaseBaseModel>
{ static constexpr int value = GetPropType<TypeTag, Properties::FluidSystem>::waterEnabled; };
} // namespace Opm::Properties
namespace Opm {
template <class TypeTag>
class FlashModel
: public MultiPhaseBaseModel<TypeTag>
{
using ParentType = MultiPhaseBaseModel<TypeTag>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using Indices = GetPropType<TypeTag, Properties::Indices>;
enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() };
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
using EnergyModule = ::Opm::EnergyModule<TypeTag, enableEnergy>;
public:
explicit FlashModel(Simulator& simulator)
: ParentType(simulator)
{}
static void registerParameters()
{
ParentType::registerParameters();
// register runtime parameters of the VTK output modules
VtkCompositionModule<TypeTag>::registerParameters();
VtkPTFlashModule<TypeTag>::registerParameters();
if constexpr (enableDiffusion) {
VtkDiffusionModule<TypeTag>::registerParameters();
}
if constexpr (enableEnergy) {
VtkEnergyModule<TypeTag>::registerParameters();
}
Parameters::Register<Parameters::FlashTolerance<Scalar>>
("The maximum tolerance for the flash solver to "
"consider the solution converged");
Parameters::Register<Parameters::FlashVerbosity>
("Flash solver verbosity level");
Parameters::Register<Parameters::FlashTwoPhaseMethod>
("Method for solving vapor-liquid composition. Available options include: "
"ssi, newton, ssi+newton");
Parameters::SetDefault<Parameters::FlashTolerance<Scalar>>(1.e-8);
Parameters::SetDefault<Parameters::EnableIntensiveQuantityCache>(true);
// since thermodynamic hints are basically free if the cache for intensive quantities is
// enabled, and this model usually shows quite a performance improvment if they are
// enabled, let's enable them by default.
Parameters::SetDefault<Parameters::EnableThermodynamicHints>(true);
}
std::string primaryVarName(unsigned pvIdx) const
{
const std::string& tmp = EnergyModule::primaryVarName(pvIdx);
if (!tmp.empty()) {
return tmp;
}
std::ostringstream oss;
if (Indices::z0Idx <= pvIdx && pvIdx < Indices::z0Idx + numComponents - 1) {
oss << "z_," << FluidSystem::componentName(/*compIdx=*/pvIdx - Indices::z0Idx);
}
else if (pvIdx == Indices::pressure0Idx) {
oss << "pressure_" << FluidSystem::phaseName(0);
}
else {
assert(false);
}
return oss.str();
}
std::string eqName(unsigned eqIdx) const
{
const std::string& tmp = EnergyModule::eqName(eqIdx);
if (!tmp.empty()) {
return tmp;
}
std::ostringstream oss;
if (Indices::conti0EqIdx <= eqIdx &&
eqIdx < Indices::conti0EqIdx + numComponents)
{
const unsigned compIdx = eqIdx - Indices::conti0EqIdx;
oss << "continuity^" << FluidSystem::componentName(compIdx);
}
else {
assert(false);
}
return oss.str();
}
void registerOutputModules_()
{
ParentType::registerOutputModules_();
// add the VTK output modules which are meaningful for the model
this->addOutputModule(std::make_unique<VtkCompositionModule<TypeTag>>(this->simulator_));
this->addOutputModule(std::make_unique<VtkPTFlashModule<TypeTag>>(this->simulator_));
if constexpr (enableDiffusion) {
this->addOutputModule(std::make_unique<VtkDiffusionModule<TypeTag>>(this->simulator_));
}
if constexpr (enableEnergy) {
this->addOutputModule(std::make_unique<VtkEnergyModule<TypeTag>>(this->simulator_));
}
}
};
} // namespace Opm
#endif
Opm::EnergyModule
Provides the auxiliary methods required for consideration of the energy equation.
Definition energymodule.hh:54
Opm::FlashModel
A compositional multi-phase model based on flash-calculations.
Definition flashmodel.hh:194
Opm::FlashModel::registerParameters
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition flashmodel.hh:218
Opm::FlashModel::primaryVarName
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition flashmodel.hh:255
Opm::FlashModel::eqName
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition flashmodel.hh:279
Opm::FlashNewtonMethod
A Newton solver specific to the PTFlash model.
Definition flashnewtonmethod.hh:55
Opm::MultiPhaseBaseModel
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition multiphasebasemodel.hh:168
Opm::MultiPhaseBaseModel::registerParameters
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition multiphasebasemodel.hh:190
Opm::VtkCompositionModule
VTK output module for the fluid composition.
Definition vtkcompositionmodule.hpp:57
Opm::VtkCompositionModule::registerParameters
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtkcompositionmodule.hpp:87
Opm::VtkDiffusionModule
VTK output module for quantities which make sense for models which incorperate molecular diffusion.
Definition vtkdiffusionmodule.hpp:58
Opm::VtkDiffusionModule::registerParameters
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtkdiffusionmodule.hpp:88
Opm::VtkEnergyModule::registerParameters
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtkenergymodule.hpp:87
Opm::VtkPTFlashModule
VTK output module for the PT Flash calculation This module deals with the following quantities: K,...
Definition vtkptflashmodule.hpp:53
Opm::VtkPTFlashModule::registerParameters
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtkptflashmodule.hpp:83
energymodule.hh
Contains the classes required to consider energy as a conservation quantity in a multi-phase module.
flashboundaryratevector.hh
Implements a boundary vector for the fully implicit compositional multi-phase model which is based on...
flashextensivequantities.hh
This template class contains the data which is required to calculate all fluxes of components over a ...
flashnewtonmethod.hh
A Newton solver specific to the PTFlash model.
flashproperties.hh
Declares the properties required by the compositional multi-phase model based on flash calculations.
flashratevector.hh
Implements a vector representing rates of conserved quantities.
multiphasebasemodel.hh
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Opm::Properties::TTag
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:81
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Opm::GetPropType
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
Opm::getPropValue
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
Opm::Parameters::SetDefault
void SetDefault(decltype(Param::value) new_value)
Set a runtime parameter.
Definition parametersystem.hpp:212
Opm::Parameters::Register
void Register(const char *usageString)
Register a run-time parameter.
Definition parametersystem.hpp:292
flashindices.hh
Defines the primary variable and equation indices for the compositional multi-phase model based on fl...
flashintensivequantities.hh
Contains the intensive quantities of the flash-based compositional multi-phase model.
flashlocalresidual.hh
Calculates the local residual of the compositional multi-phase model based on flash calculations.
flashparameters.hh
Declares the parameters for the compositional multi-phase model based on flash calculations.
flashprimaryvariables.hh
Represents the primary variables used by the compositional flow model based on flash calculations.
Opm::Properties::BoundaryRateVector
Type of object for specifying boundary conditions.
Definition fvbaseproperties.hh:119
Opm::Properties::EnableDiffusion
Enable diffusive fluxes?
Definition multiphasebaseproperties.hh:91
Opm::Properties::EnableEnergy
Specify whether energy should be considered as a conservation quantity or not.
Definition multiphasebaseproperties.hh:87
Opm::Properties::EnableWater
Enable water?
Definition multiphasebaseproperties.hh:103
Opm::Properties::ExtensiveQuantities
Data required to calculate a flux over a face.
Definition fvbaseproperties.hh:149
Opm::Properties::FlashSolver
The type of the flash constraint solver.
Definition flashproperties.hh:39
Opm::Properties::Indices
Enumerations used by the model.
Definition multiphasebaseproperties.hh:51
Opm::Properties::IntensiveQuantities
The secondary variables within a sub-control volume.
Definition fvbaseproperties.hh:133
Opm::Properties::LocalResidual
The type of the local residual function.
Definition fvbaseproperties.hh:94
Opm::Properties::NewtonMethod
Specifies the type of the actual Newton method.
Definition newtonmethodproperties.hh:32
Opm::Properties::RateVector
Vector containing volumetric or areal rates of quantities.
Definition fvbaseproperties.hh:116
Opm::Properties::TTag::FlashModel
The type tag for the isothermal single phase problems.
Definition flashmodel.hh:74
vtkcompositionmodule.hpp
VTK output module for the fluid composition.
vtkdiffusionmodule.hpp
VTK output module for quantities which make sense for models which incorperate molecular diffusion.
vtkenergymodule.hpp
VTK output module for quantities which make sense for models which assume thermal equilibrium.
vtkptflashmodule.hpp
VTK output module for the PT Flash calculation This module deals with the following quantities: K,...