OGS 6.1.0-1699-ge946d4c5f
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 double reference_density =
83  config.getConfigParameter<double>("reference_density");
84  const double reference_concentration =
86  config.getConfigParameter<double>("reference_concentration");
87  const double 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 double reference_density =
104  config.getConfigParameter<double>("reference_density");
105  const double reference_concentration =
107  config.getConfigParameter<double>("reference_concentration");
108  const double fluid_density_concentration_difference_ratio =
110  config.getConfigParameter<double>(
111  "fluid_density_concentration_difference_ratio");
112  const double reference_pressure =
114  config.getConfigParameter<double>("reference_pressure");
115  const double 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  return createLiquidDensity(config);
143  if (type == "TemperatureDependent")
145  if (type == "ConcentrationDependent")
147  if (type == "ConcentrationAndPressureDependent")
149  if (type == "IdealGasLaw")
150  {
152  config.checkConfigParameter("type", "IdealGasLaw");
153  return std::make_unique<IdealGasLaw>(
155  config.getConfigParameter<double>("molar_mass"));
156  }
157  if (type == "WaterDensityIAPWSIF97Region1")
158  {
159  return std::make_unique<WaterDensityIAPWSIF97Region1>();
160  }
161 
162  OGS_FATAL(
163  "The density type %s is unavailable.\n"
164  "The available types are: \n\tConstant, \n\tLiquidDensity, "
165  "\n\tTemperatureDependent, \n\tIdealGasLaw."
166  "\n\tWaterDensityIAPWSIF97Region1\n",
167  type.data());
168 }
169 
170 } // end namespace
171 } // end namespace
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:71