OGS
CreateViscosityModel.cpp
Go to the documentation of this file.
1 
13 #include "CreateViscosityModel.h"
14 
15 #include "BaseLib/Error.h"
20 #include "WaterViscosityIAPWS.h"
21 
22 namespace MaterialLib
23 {
24 namespace Fluid
25 {
31 static std::unique_ptr<FluidProperty> createLinearPressureDependentViscosity(
32  BaseLib::ConfigTree const& config)
33 {
35  config.checkConfigParameter("type", "LinearPressure");
36 
38  const auto mu0 = config.getConfigParameter<double>("mu0");
39 
41  const auto p0 = config.getConfigParameter<double>("p0");
42 
44  const auto gamma = config.getConfigParameter<double>("gamma");
45 
46  return std::make_unique<LinearPressureDependentViscosity>(mu0, p0, gamma);
47 }
48 
54 static std::unique_ptr<FluidProperty> createTemperatureDependentViscosity(
55  BaseLib::ConfigTree const& config)
56 {
58  config.checkConfigParameter("type", "TemperatureDependent");
59 
61  const auto mu0 = config.getConfigParameter<double>("mu0");
62 
64  const auto Tc = config.getConfigParameter<double>("tc");
65 
67  const auto Tv = config.getConfigParameter<double>("tv");
68 
69  return std::make_unique<TemperatureDependentViscosity>(mu0, Tc, Tv);
70 }
71 
72 std::unique_ptr<FluidProperty> createViscosityModel(
73  BaseLib::ConfigTree const& config)
74 {
76  auto const type = config.peekConfigParameter<std::string>("type");
77 
78  if (type == "Constant")
79  {
81  config.checkConfigParameter("type", "Constant");
82  return std::make_unique<ConstantFluidProperty>(
84  config.getConfigParameter<double>("value"));
85  }
86  if (type == "LinearPressure")
87  {
89  }
90  if (type == "TemperatureDependent")
91  {
93  }
94  if (type == "Vogels")
95  {
97  config.checkConfigParameter("type", "Vogels");
98 
99  INFO("Using Vogels model, which gives viscosity in SI unit, Pa s");
100  auto const fluid_type =
102  config.peekConfigParameter<std::string>("liquid_type");
103  if (fluid_type == "Water")
104  {
106  config.checkConfigParameter("liquid_type", "Water");
107 
108  const VogelsViscosityConstantsWater constants;
109  return std::make_unique<
111  constants);
112  }
113  if (fluid_type == "CO2")
114  {
116  config.checkConfigParameter("liquid_type", "CO2");
117  const VogelsViscosityConstantsCO2 constants;
118  return std::make_unique<
120  constants);
121  }
122  if (fluid_type == "CH4")
123  {
125  config.checkConfigParameter("liquid_type", "CH4");
126  const VogelsViscosityConstantsCH4 constants;
127  return std::make_unique<
129  constants);
130  }
131 
132  OGS_FATAL(
133  "The fluid type {:s} for Vogels model is unavailable.\n"
134  "The available fluid types are Water, CO2 and CH4\n",
135  fluid_type.data());
136  }
137  if (type == "WaterViscosityIAPWS")
138  {
140  config.checkConfigParameter("type", "WaterViscosityIAPWS");
141  return std::make_unique<WaterViscosityIAPWS>();
142  }
143 
144  OGS_FATAL(
145  "The viscosity type {:s} is unavailable.\n"
146  "The available types are \n\tConstant, \n\tLinearPressure "
147  "\n\tTemperatureDependent, \n\tVogels\n",
148  type.data());
149 }
150 
151 } // namespace Fluid
152 } // namespace MaterialLib
A function for creating viscosity model.
#define OGS_FATAL(...)
Definition: Error.h:26
Declaration of class for the pressure dependent viscosity model.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:34
A linear temperature dependent viscosity model.
Declaration of class for the pressure dependent viscosity model.
Viscosity model according to Release on the IAPWS Formulation 2008 for the Viscosity of Ordinary Wate...
T peekConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, T const &value) const
T getConfigParameter(std::string const &param) const
static std::unique_ptr< FluidProperty > createTemperatureDependentViscosity(BaseLib::ConfigTree const &config)
std::unique_ptr< FluidProperty > createViscosityModel(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createLinearPressureDependentViscosity(BaseLib::ConfigTree const &config)