OGS 6.2.0-97-g4a610c866
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")
89  {
91  }
92  if (type == "TemperatureDependent")
93  {
95  }
96  if (type == "Vogels")
97  {
99  config.checkConfigParameter("type", "Vogels");
100 
101  INFO("Using Vogels model, which gives viscosity in SI unit, Pa s");
102  auto const fluid_type =
104  config.peekConfigParameter<std::string>("liquid_type");
105  if (fluid_type == "Water")
106  {
108  config.checkConfigParameter("liquid_type", "Water");
109 
110  const VogelsViscosityConstantsWater constants;
111  return std::make_unique<
113  constants);
114  }
115  if (fluid_type == "CO2")
116  {
118  config.checkConfigParameter("liquid_type", "CO2");
119  const VogelsViscosityConstantsCO2 constants;
120  return std::make_unique<
122  constants);
123  }
124  if (fluid_type == "CH4")
125  {
127  config.checkConfigParameter("liquid_type", "CH4");
128  const VogelsViscosityConstantsCH4 constants;
129  return std::make_unique<
131  constants);
132  }
133 
134  OGS_FATAL(
135  "The fluid type %s for Vogels model is unavailable.\n"
136  "The available fluid types are Water, CO2 and CH4\n",
137  fluid_type.data());
138  }
139  if (type == "WaterViscosityIAPWS")
140  {
142  config.checkConfigParameter("type", "WaterViscosityIAPWS");
143  return std::make_unique<WaterViscosityIAPWS>();
144  }
145 
146  OGS_FATAL(
147  "The viscosity type %s is unavailable.\n"
148  "The available types are \n\tConstant, \n\tLinearPressure "
149  "\n\tTemperatureDependent, \n\tVogels\n",
150  type.data());
151 }
152 
153 } // namespace Fluid
154 } // namespace MaterialLib
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:63
Declaration of class for the pressure dependent viscosity model.