OGS
FluidPropertiesWithDensityDependentModels.cpp
Go to the documentation of this file.
1
14
15#include <string>
16
17#include "FluidProperties.h"
19
20namespace MaterialLib
21{
22namespace Fluid
23{
26 std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& density,
27 std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& viscosity,
28 std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& heat_capacity,
29 std::unique_ptr<MaterialLib::Fluid::FluidProperty>&&
30 thermal_conductivity,
31 const bool is_viscosity_density_dependent,
32 const bool is_heat_capacity_dependent,
33 const bool is_thermal_conductivity)
34 : FluidProperties(std::move(density), std::move(viscosity),
35 std::move(heat_capacity),
36 std::move(thermal_conductivity)),
37 _is_density_dependent{{false, is_viscosity_density_dependent,
38 is_heat_capacity_dependent,
39 is_thermal_conductivity}}
40{
41}
42
43double FluidPropertiesWithDensityDependentModels::getValue(
44 const FluidPropertyType property_type,
45 const ArrayType& variable_values) const
46{
47 ArrayType var_vals = variable_values;
48 if (_is_density_dependent[static_cast<unsigned>(property_type)])
49 {
50 var_vals[static_cast<unsigned>(PropertyVariableType::rho)] =
51 _property_models[static_cast<unsigned>(FluidPropertyType::Density)]
52 ->getValue(variable_values);
53 }
54 return _property_models[static_cast<unsigned>(property_type)]->getValue(
55 var_vals);
56}
57
58double FluidPropertiesWithDensityDependentModels::getdValue(
59 const FluidPropertyType property_type,
60 const ArrayType& variable_values,
61 const PropertyVariableType variable_type) const
62{
63 if (_is_density_dependent[static_cast<unsigned>(property_type)])
64 {
65 if (variable_type == PropertyVariableType::T)
66 {
67 return compute_df_drho_drho_dT(property_type, variable_values);
68 }
69 if (variable_type == PropertyVariableType::p)
70 {
71 return compute_df_drho_drho_dp(property_type, variable_values);
72 }
73 }
74 else
75 {
76 return _property_models[static_cast<unsigned>(property_type)]
77 ->getdValue(variable_values, variable_type);
78 }
79
80 return 0.0;
81}
82
83double FluidPropertiesWithDensityDependentModels::compute_df_drho_drho_dT(
84 const FluidPropertyType property_type,
85 const ArrayType& variable_values) const
86{
87 const auto& fluid_density_model =
88 _property_models[static_cast<unsigned>(FluidPropertyType::Density)];
89 const double drho_dT = fluid_density_model->getdValue(
90 variable_values, PropertyVariableType::T);
91
92 const double density_value = fluid_density_model->getValue(variable_values);
93
94 ArrayType var_vals = variable_values;
95 var_vals[static_cast<unsigned>(PropertyVariableType::rho)] = density_value;
96 const auto& fluid_property_model =
97 _property_models[static_cast<unsigned>(property_type)];
98
99 // return d()/dT + d ()/drho * drho/dT
100 return fluid_property_model->getdValue(var_vals, PropertyVariableType::T) +
101 fluid_property_model->getdValue(var_vals,
102 PropertyVariableType::rho) *
103 drho_dT;
104}
105
106double FluidPropertiesWithDensityDependentModels::compute_df_drho_drho_dp(
107 const FluidPropertyType property_type,
108 const ArrayType& variable_values) const
109{
110 const auto& fluid_density_model =
111 _property_models[static_cast<unsigned>(FluidPropertyType::Density)];
112
113 const double drho_dp = fluid_density_model->getdValue(
114 variable_values, PropertyVariableType::p);
115
116 const double density_value = fluid_density_model->getValue(variable_values);
117 ArrayType var_vals = variable_values;
118 var_vals[static_cast<unsigned>(PropertyVariableType::rho)] = density_value;
119
120 // return d ()/drho * drho/dp
121 return _property_models[static_cast<unsigned>(property_type)]->getdValue(
122 var_vals, PropertyVariableType::rho) *
123 drho_dp;
124}
125
126} // namespace Fluid
127} // namespace MaterialLib
std::string getValue(std::string const &line, std::string const &val_name, bool is_string)
FluidPropertiesWithDensityDependentModels(std::unique_ptr< MaterialLib::Fluid::FluidProperty > &&density, std::unique_ptr< MaterialLib::Fluid::FluidProperty > &&viscosity, std::unique_ptr< MaterialLib::Fluid::FluidProperty > &&heat_capacity, std::unique_ptr< MaterialLib::Fluid::FluidProperty > &&thermal_conductivity, const bool is_viscosity_density_dependent, const bool is_heat_capacity_dependent, const bool is_thermal_conductivity)
Base class of fluid properties.
virtual double getValue(const FluidPropertyType property_type, const ArrayType &variable_values) const =0
std::array< double, PropertyVariableNumber > ArrayType
PropertyVariableType
Variable that determine the property.
FluidPropertyType
Fluid property type.