changed: move the PTFlash parameters to Opm::Parameters

This commit is contained in:
Arne Morten Kvarving 2024-07-01 14:13:14 +02:00
parent 6beb557b2a
commit 3a261e15e3
3 changed files with 90 additions and 71 deletions

View File

@ -28,17 +28,20 @@
#ifndef OPM_FLASH_INTENSIVE_QUANTITIES_HH
#define OPM_FLASH_INTENSIVE_QUANTITIES_HH
#include "flashproperties.hh"
#include "flashindices.hh"
#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>
#include <opm/material/Constants.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/fluidstates/CompositionalFluidState.hpp>
#include <opm/models/common/energymodule.hh>
#include <opm/models/common/diffusionmodule.hh>
#include <opm/material/fluidstates/CompositionalFluidState.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/models/flash/flashproperties.hh>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <opm/models/ptflash/flashindices.hh>
#include <opm/models/ptflash/flashparameters.hh>
namespace Opm {
@ -107,9 +110,9 @@ public:
const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
const auto& problem = elemCtx.problem();
const Scalar flashTolerance = Parameters::get<TypeTag, Properties::FlashTolerance>();
const int flashVerbosity = Parameters::get<TypeTag, Properties::FlashVerbosity>();
const std::string flashTwoPhaseMethod = Parameters::get<TypeTag, Properties::FlashTwoPhaseMethod>();
const Scalar flashTolerance = Parameters::get<TypeTag, Parameters::FlashTolerance>();
const int flashVerbosity = Parameters::get<TypeTag, Parameters::FlashVerbosity>();
const std::string flashTwoPhaseMethod = Parameters::get<TypeTag, Parameters::FlashTwoPhaseMethod>();
// extract the total molar densities of the components
ComponentVector z(0.);

View File

@ -28,34 +28,41 @@
#ifndef OPM_PTFLASH_MODEL_HH
#define OPM_PTFLASH_MODEL_HH
#include <opm/material/constraintsolvers/PTFlash.hpp>
#include <opm/material/densead/Math.hpp>
#include "flashproperties.hh"
#include "flashprimaryvariables.hh"
#include "flashlocalresidual.hh"
#include <opm/models/flash/flashratevector.hh>
#include <opm/models/flash/flashboundaryratevector.hh>
#include "flashintensivequantities.hh"
#include <opm/models/flash/flashextensivequantities.hh>
#include "flashindices.hh"
#include "flashnewtonmethod.hh"
#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
#include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
#include <opm/models/common/multiphasebasemodel.hh>
#include <opm/models/common/energymodule.hh>
#include <opm/models/flash/flashratevector.hh>
#include <opm/models/flash/flashboundaryratevector.hh>
#include <opm/models/flash/flashextensivequantities.hh>
#include <opm/models/flash/flashproperties.hh>
#include <opm/models/io/vtkcompositionmodule.hh>
#include <opm/models/io/vtkenergymodule.hh>
#include <opm/models/io/vtkdiffusionmodule.hh>
#include <opm/models/io/vtkenergymodule.hh>
#include <opm/models/io/vtkptflashmodule.hh>
#include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
#include <opm/material/constraintsolvers/PTFlash.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 <sstream>
#include <string>
namespace Opm {
template <class TypeTag>
class FlashModel;
}
namespace Opm::Properties {
@ -71,69 +78,66 @@ struct FlashModel { using InheritsFrom = std::tuple<VtkDiffusion,
//! Use the FlashLocalResidual function for the flash model
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::FlashModel> { using type = Opm::FlashLocalResidual<TypeTag>; };
struct LocalResidual<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashLocalResidual<TypeTag>; };
//! Use the PT flash specific newton method for the flash model
template<class TypeTag>
struct NewtonMethod<TypeTag, TTag::FlashModel> { using type = Opm::FlashNewtonMethod<TypeTag>; };
struct NewtonMethod<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashNewtonMethod<TypeTag>; };
//! Use the Pt flash solver by default
template<class TypeTag>
struct FlashSolver<TypeTag, TTag::FlashModel>
{ using type = Opm::PTFlash<GetPropType<TypeTag, Properties::Scalar>,
GetPropType<TypeTag, Properties::FluidSystem>>; };
//! Let the flash solver choose its tolerance by default
template<class TypeTag>
struct FlashTolerance<TypeTag, TTag::FlashModel>
{
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 1.e-12;
using type = Opm::PTFlash<GetPropType<TypeTag, Properties::Scalar>,
GetPropType<TypeTag, Properties::FluidSystem>>;
};
// Flash solver verbosity
template<class TypeTag>
struct FlashVerbosity<TypeTag, TTag::FlashModel> { static constexpr int value = 0; };
// Flash two-phase method
template<class TypeTag>
struct FlashTwoPhaseMethod<TypeTag, TTag::FlashModel> { static constexpr auto value = "ssi"; };
//! the Model property
template<class TypeTag>
struct Model<TypeTag, TTag::FlashModel> { using type = Opm::FlashModel<TypeTag>; };
struct Model<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashModel<TypeTag>; };
//! the PrimaryVariables property
template<class TypeTag>
struct PrimaryVariables<TypeTag, TTag::FlashModel> { using type = Opm::FlashPrimaryVariables<TypeTag>; };
struct PrimaryVariables<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashPrimaryVariables<TypeTag>; };
//! the RateVector property
template<class TypeTag>
struct RateVector<TypeTag, TTag::FlashModel> { using type = Opm::FlashRateVector<TypeTag>; };
struct RateVector<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashRateVector<TypeTag>; };
//! the BoundaryRateVector property
template<class TypeTag>
struct BoundaryRateVector<TypeTag, TTag::FlashModel> { using type = Opm::FlashBoundaryRateVector<TypeTag>; };
struct BoundaryRateVector<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashBoundaryRateVector<TypeTag>; };
//! the IntensiveQuantities property
template<class TypeTag>
struct IntensiveQuantities<TypeTag, TTag::FlashModel> { using type = Opm::FlashIntensiveQuantities<TypeTag>; };
struct IntensiveQuantities<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashIntensiveQuantities<TypeTag>; };
//! the ExtensiveQuantities property
template<class TypeTag>
struct ExtensiveQuantities<TypeTag, TTag::FlashModel> { using type = Opm::FlashExtensiveQuantities<TypeTag>; };
struct ExtensiveQuantities<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashExtensiveQuantities<TypeTag>; };
//! The indices required by the flash-baseed isothermal compositional model
template<class TypeTag>
struct Indices<TypeTag, TTag::FlashModel> { using type = Opm::FlashIndices<TypeTag, /*PVIdx=*/0>; };
struct Indices<TypeTag, TTag::FlashModel>
{ using type = Opm::FlashIndices<TypeTag, /*PVIdx=*/0>; };
// disable molecular diffusion by default
template<class TypeTag>
struct EnableDiffusion<TypeTag, TTag::FlashModel> { static constexpr bool value = false; };
struct EnableDiffusion<TypeTag, TTag::FlashModel>
{ static constexpr bool value = false; };
//! Disable the energy equation by default
template<class TypeTag>
struct EnableEnergy<TypeTag, TTag::FlashModel> { static constexpr bool value = false; };
struct EnableEnergy<TypeTag, TTag::FlashModel>
{ static constexpr bool value = false; };
} // namespace Opm::Properties
@ -152,6 +156,24 @@ template<class TypeTag>
struct EnableThermodynamicHints<TypeTag, Properties::TTag::FlashModel>
{ static constexpr bool value = true; };
//! Let the flash solver choose its tolerance by default
template<class TypeTag>
struct FlashTolerance<TypeTag, Properties::TTag::FlashModel>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 1.e-12;
};
// Flash two-phase method
template<class TypeTag>
struct FlashTwoPhaseMethod<TypeTag, Properties::TTag::FlashModel>
{ static constexpr auto value = "ssi"; };
// Flash solver verbosity
template<class TypeTag>
struct FlashVerbosity<TypeTag, Properties::TTag::FlashModel>
{ static constexpr int value = 0; };
} // namespace Opm::Parameters
namespace Opm {
@ -239,12 +261,12 @@ public:
if (enableEnergy)
Opm::VtkEnergyModule<TypeTag>::registerParameters();
Parameters::registerParam<TypeTag, Properties::FlashTolerance>
Parameters::registerParam<TypeTag, Parameters::FlashTolerance>
("The maximum tolerance for the flash solver to "
"consider the solution converged");
Parameters::registerParam<TypeTag, Properties::FlashVerbosity>
Parameters::registerParam<TypeTag, Parameters::FlashVerbosity>
("Flash solver verbosity level");
Parameters::registerParam<TypeTag, Properties::FlashTwoPhaseMethod>
Parameters::registerParam<TypeTag, Parameters::FlashTwoPhaseMethod>
("Method for solving vapor-liquid composition. Available options include: "
"ssi, newton, ssi+newton");
}

View File

@ -24,32 +24,26 @@
* \file
* \ingroup FlashModel
*
* \brief Declares the properties required by the compositional
* \brief Declares the parameters for the compositional
* multi-phase model based on flash calculations.
*/
#ifndef OPM_PTFLASH_PROPERTIES_HH
#define OPM_PTFLASH_PROPERTIES_HH
#ifndef EWOMS_PTFLASH_PARAMETERS_HH
#define EWOMS_PTFLASH_PARAMETERS_HH
#include <opm/models/common/multiphasebaseproperties.hh>
#include <opm/models/io/vtkcompositionmodule.hh>
#include <opm/models/io/vtkenergymodule.hh>
#include <opm/models/io/vtkdiffusionmodule.hh>
#include <opm/models/flash/flashparameters.hh>
namespace Opm::Properties {
#include <opm/models/utils/propertysystem.hh>
namespace Opm::Parameters {
//! The type of the flash constraint solver
template<class TypeTag, class MyTypeTag>
struct FlashSolver { using type = UndefinedProperty; };
//! The maximum accepted error of the flash solver
template<class TypeTag, class MyTypeTag>
struct FlashTolerance { using type = UndefinedProperty; };
//! The verbosity level of the flash solver
template<class TypeTag, class MyTypeTag>
struct FlashVerbosity { using type = UndefinedProperty; };
//! Two-phase flash method
template<class TypeTag, class MyTypeTag>
struct FlashTwoPhaseMethod { using type = UndefinedProperty; };
struct FlashTwoPhaseMethod { using type = Properties::UndefinedProperty; };
} // namespace Opm::Properties
//! The verbosity level of the flash solver
template<class TypeTag, class MyTypeTag>
struct FlashVerbosity { using type = Properties::UndefinedProperty; };
} // namespace Opm::Parameters
#endif