OGS 6.2.0-97-g4a610c866
CreateFluidDensityModel.cpp
Go to the documentation of this file.
1 
12 #include <array>
13 
15 
16 #include "BaseLib/Error.h"
17 
18 #include "IdealGasLaw.h"
22 #include "LiquidDensity.h"
24 
26 
27 namespace MaterialLib
28 {
29 namespace Fluid
30 {
36 static std::unique_ptr<FluidProperty> createLiquidDensity(
37  BaseLib::ConfigTree const& config)
38 {
40  config.checkConfigParameter("type", "LiquidDensity");
41 
43  const auto beta = config.getConfigParameter<double>("beta");
45  const auto rho0 = config.getConfigParameter<double>("rho0");
47  const auto T0 = config.getConfigParameter<double>("temperature0");
49  const auto p0 = config.getConfigParameter<double>("p0");
51  const auto E = config.getConfigParameter<double>("bulk_modulus");
52  return std::make_unique<LiquidDensity>(beta, rho0, T0, p0, E);
53 }
54 
60 static std::unique_ptr<FluidProperty> createLinearTemperatureDependentDensity(
61  BaseLib::ConfigTree const& config)
62 {
64  config.checkConfigParameter("type", "TemperatureDependent");
65 
67  const auto rho0 = config.getConfigParameter<double>("rho0");
69  const auto T0 = config.getConfigParameter<double>("temperature0");
71  const auto beta = config.getConfigParameter<double>("beta");
72  return std::make_unique<LinearTemperatureDependentDensity>(rho0, T0, beta);
73 }
74 
75 static std::unique_ptr<FluidProperty> createLinearConcentrationDependentDensity(
76  BaseLib::ConfigTree const& config)
77 {
79  config.checkConfigParameter("type", "ConcentrationDependent");
80 
81  const auto reference_density =
83  config.getConfigParameter<double>("reference_density");
84  const auto reference_concentration =
86  config.getConfigParameter<double>("reference_concentration");
87  const auto fluid_density_difference_ratio =
89  config.getConfigParameter<double>("fluid_density_difference_ratio");
90  return std::make_unique<LinearConcentrationDependentDensity>(
92  reference_concentration,
93  fluid_density_difference_ratio);
94 }
95 static std::unique_ptr<FluidProperty>
97  BaseLib::ConfigTree const& config)
98 {
100  config.checkConfigParameter("type", "ConcentrationAndPressureDependent");
101 
102  const auto reference_density =
104  config.getConfigParameter<double>("reference_density");
105  const auto reference_concentration =
107  config.getConfigParameter<double>("reference_concentration");
108  const auto fluid_density_concentration_difference_ratio =
110  config.getConfigParameter<double>(
111  "fluid_density_concentration_difference_ratio");
112  const auto reference_pressure =
114  config.getConfigParameter<double>("reference_pressure");
115  const auto fluid_density_pressure_difference_ratio =
117  config.getConfigParameter<double>(
118  "fluid_density_pressure_difference_ratio");
119  return std::make_unique<LinearConcentrationAndPressureDependentDensity>(
121  reference_concentration,
122  fluid_density_concentration_difference_ratio,
124  fluid_density_pressure_difference_ratio);
125 }
126 
127 std::unique_ptr<FluidProperty> createFluidDensityModel(
128  BaseLib::ConfigTree const& config)
129 {
131  auto const type = config.peekConfigParameter<std::string>("type");
132 
133  if (type == "Constant")
134  {
136  config.checkConfigParameter("type", "Constant");
137  return std::make_unique<ConstantFluidProperty>(
139  config.getConfigParameter<double>("value"));
140  }
141  if (type == "LiquidDensity")
142  {
143  return createLiquidDensity(config);
144  }
145  if (type == "TemperatureDependent")
146  {
148  }
149  if (type == "ConcentrationDependent")
150  {
152  }
153  if (type == "ConcentrationAndPressureDependent")
154  {
156  }
157  if (type == "IdealGasLaw")
158  {
160  config.checkConfigParameter("type", "IdealGasLaw");
161  return std::make_unique<IdealGasLaw>(
163  config.getConfigParameter<double>("molar_mass"));
164  }
165  if (type == "WaterDensityIAPWSIF97Region1")
166  {
167  return std::make_unique<WaterDensityIAPWSIF97Region1>();
168  }
169 
170  OGS_FATAL(
171  "The density type %s is unavailable.\n"
172  "The available types are: \n\tConstant, \n\tLiquidDensity, "
173  "\n\tTemperatureDependent, \n\tIdealGasLaw."
174  "\n\tWaterDensityIAPWSIF97Region1\n",
175  type.data());
176 }
177 
178 } // namespace Fluid
179 } // namespace MaterialLib
Declaration of class IdealGasLow for fluid density by the ideal gas law depending on one variable lin...
static std::unique_ptr< FluidProperty > createLinearConcentrationAndPressureDependentDensity(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createLinearConcentrationDependentDensity(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createLiquidDensity(BaseLib::ConfigTree const &config)
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, T const &value) const
T peekConfigParameter(std::string const &param) const
std::unique_ptr< FluidProperty > createFluidDensityModel(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createLinearTemperatureDependentDensity(BaseLib::ConfigTree const &config)
create an instance of a fluid density class.
#define OGS_FATAL(fmt,...)
Definition: Error.h:63