OGS 6.1.0-1699-ge946d4c5f
CreateViscosityModel.cpp
Go to the documentation of this file.
1 
14 #include "CreateViscosityModel.h"
15 
16 #include "BaseLib/Error.h"
17 
22 #include "WaterViscosityIAPWS.h"
23 
24 namespace MaterialLib
25 {
26 namespace Fluid
27 {
33 static std::unique_ptr<FluidProperty> createLinearPressureDependentViscosity(
34  BaseLib::ConfigTree const& config)
35 {
37  config.checkConfigParameter("type", "LinearPressure");
38 
40  const auto mu0 = config.getConfigParameter<double>("mu0");
41 
43  const auto p0 = config.getConfigParameter<double>("p0");
44 
46  const auto gamma = config.getConfigParameter<double>("gamma");
47 
48  return std::make_unique<LinearPressureDependentViscosity>(mu0, p0, gamma);
49 }
50 
56 static std::unique_ptr<FluidProperty> createTemperatureDependentViscosity(
57  BaseLib::ConfigTree const& config)
58 {
60  config.checkConfigParameter("type", "TemperatureDependent");
61 
63  const auto mu0 = config.getConfigParameter<double>("mu0");
64 
66  const auto Tc = config.getConfigParameter<double>("tc");
67 
69  const auto Tv = config.getConfigParameter<double>("tv");
70 
71  return std::make_unique<TemperatureDependentViscosity>(mu0, Tc, Tv);
72 }
73 
74 std::unique_ptr<FluidProperty> createViscosityModel(
75  BaseLib::ConfigTree const& config)
76 {
78  auto const type = config.peekConfigParameter<std::string>("type");
79 
80  if (type == "Constant")
81  {
83  config.checkConfigParameter("type", "Constant");
84  return std::make_unique<ConstantFluidProperty>(
86  config.getConfigParameter<double>("value"));
87  }
88  if (type == "LinearPressure")
90  if (type == "TemperatureDependent")
92  if (type == "Vogels")
93  {
95  config.checkConfigParameter("type", "Vogels");
96 
97  INFO("Using Vogels model, which gives viscosity in SI unit, Pa s");
98  auto const fluid_type =
100  config.peekConfigParameter<std::string>("liquid_type");
101  if (fluid_type == "Water")
102  {
104  config.checkConfigParameter("liquid_type", "Water");
105 
106  const VogelsViscosityConstantsWater constants;
107  return std::make_unique<
109  constants);
110  }
111  if (fluid_type == "CO2")
112  {
114  config.checkConfigParameter("liquid_type", "CO2");
115  const VogelsViscosityConstantsCO2 constants;
116  return std::make_unique<
118  constants);
119  }
120  if (fluid_type == "CH4")
121  {
123  config.checkConfigParameter("liquid_type", "CH4");
124  const VogelsViscosityConstantsCH4 constants;
125  return std::make_unique<
127  constants);
128  }
129 
130  OGS_FATAL(
131  "The fluid type %s for Vogels model is unavailable.\n"
132  "The available fluid types are Water, CO2 and CH4\n",
133  fluid_type.data());
134  }
135  if (type == "WaterViscosityIAPWS")
136  {
138  config.checkConfigParameter("type", "WaterViscosityIAPWS");
139  return std::make_unique<WaterViscosityIAPWS>();
140  }
141 
142  OGS_FATAL(
143  "The viscosity type %s is unavailable.\n"
144  "The available types are \n\tConstant, \n\tLinearPressure "
145  "\n\tTemperatureDependent, \n\tVogels\n",
146  type.data());
147 }
148 
149 } // end namespace
150 } // end namespace
Declaration of class for the pressure dependent viscosity model.
static std::unique_ptr< FluidProperty > createTemperatureDependentViscosity(BaseLib::ConfigTree const &config)
std::unique_ptr< FluidProperty > createViscosityModel(BaseLib::ConfigTree const &config)
T getConfigParameter(std::string const &param) const
A function for creating viscosity model.
Viscosity model according to Release on the IAPWS Formulation 2008 for the Viscosity of Ordinary Wate...
static std::unique_ptr< FluidProperty > createLinearPressureDependentViscosity(BaseLib::ConfigTree const &config)
void checkConfigParameter(std::string const &param, T const &value) const
T peekConfigParameter(std::string const &param) const
A linear temperature dependent viscosity model.
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
Declaration of class for the pressure dependent viscosity model.