diff --git a/Documentation/ProjectFile/properties/property/LinearProperty/c_LinearProperty.md b/Documentation/ProjectFile/properties/property/LinearProperty/c_LinearProperty.md index d8e69c344807b85d0f49902127e819c1086faf33..3084fb72be7c5374396fdc04a41dadeb1ea4ab6e 100644 --- a/Documentation/ProjectFile/properties/property/LinearProperty/c_LinearProperty.md +++ b/Documentation/ProjectFile/properties/property/LinearProperty/c_LinearProperty.md @@ -1,7 +1,8 @@ Definition of a linear property: -\f$y(x) = y_{\textrm{ref}} (1 + m (x - x_{\textrm{ref}})\f$ +\f$y(x_{i}) = y_{\textrm{ref}} (1 + \sum_{i=1}^{n} m_{i} (x_{i} - x_{i,\textrm{ref}})\f$ where + - \f$x_{i}\f$ can be a number of dependent variables, for instance temperature, pressure - \f$y_{\textrm{ref}}\f$ is a reference value, for instance reference density - - \f$m\f$ is a value influencing the slope of the linear relationship - - \f$x_{\textrm{ref}}\f$ is a reference condition, for instance reference - temperature + - \f$m_{i}\f$ is a value influencing the slope of the linear relationship with respect to dependent variable + - \f$x_{i, \textrm{ref}}\f$ is a reference condition with respect to dependent variable, for instance reference + temperature, reference pressure diff --git a/Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/i_independent_variables.md b/Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/i_independent_variables.md new file mode 100644 index 0000000000000000000000000000000000000000..ced4170f0c727c567047be5b4283f4c51b4fda14 --- /dev/null +++ b/Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/i_independent_variables.md @@ -0,0 +1 @@ +Specify multiple variable types that linear material property depends upon. diff --git a/Documentation/ProjectFile/properties/property/LinearProperty/independent_variable/i_independent_variable.md b/Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/independent_variable/i_independent_variable.md similarity index 100% rename from Documentation/ProjectFile/properties/property/LinearProperty/independent_variable/i_independent_variable.md rename to Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/independent_variable/i_independent_variable.md diff --git a/Documentation/ProjectFile/properties/property/LinearProperty/independent_variable/t_reference_condition.md b/Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/independent_variable/t_reference_condition.md similarity index 100% rename from Documentation/ProjectFile/properties/property/LinearProperty/independent_variable/t_reference_condition.md rename to Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/independent_variable/t_reference_condition.md diff --git a/Documentation/ProjectFile/properties/property/LinearProperty/independent_variable/t_slope.md b/Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/independent_variable/t_slope.md similarity index 100% rename from Documentation/ProjectFile/properties/property/LinearProperty/independent_variable/t_slope.md rename to Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/independent_variable/t_slope.md diff --git a/Documentation/ProjectFile/properties/property/LinearProperty/independent_variable/t_variable_name.md b/Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/independent_variable/t_variable_name.md similarity index 100% rename from Documentation/ProjectFile/properties/property/LinearProperty/independent_variable/t_variable_name.md rename to Documentation/ProjectFile/properties/property/LinearProperty/independent_variables/independent_variable/t_variable_name.md diff --git a/MaterialLib/MPL/CreateProperty.cpp b/MaterialLib/MPL/CreateProperty.cpp index 3def3fe929d919f00bb7d96cb815e6957508e768..b0fef33a1c806306c8ae970064ac2f64411060af 100644 --- a/MaterialLib/MPL/CreateProperty.cpp +++ b/MaterialLib/MPL/CreateProperty.cpp @@ -115,30 +115,37 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty( //! \ogs_file_param{properties__property__LinearProperty__reference_value} config.getConfigParameter<double>("reference_value"); - auto const& independent_variable_config = - //! \ogs_file_param{properties__property__LinearProperty__independent_variable} - config.getConfigSubtree("independent_variable"); - - auto const& variable_name = - //! \ogs_file_param{properties__property__LinearProperty__independent_variable__variable_name} - independent_variable_config.getConfigParameter<std::string>( - "variable_name"); - auto const reference_condition = - //! \ogs_file_param{properties__property__LinearProperty__independent_variable__reference_condition} - independent_variable_config.getConfigParameter<double>( - "reference_condition"); - auto const slope = - //! \ogs_file_param{properties__property__LinearProperty__independent_variable__slope} - independent_variable_config.getConfigParameter<double>("slope"); - - MaterialPropertyLib::Variable ivt = - MaterialPropertyLib::convertStringToVariable(variable_name); - - MaterialPropertyLib::IndependentVariable const iv{ - ivt, reference_condition, slope}; + std::vector<MaterialPropertyLib::IndependentVariable> ivs; + auto const& independent_variables_config = + //! \ogs_file_param{properties__property__LinearProperty__independent_variables} + config.getConfigSubtree("independent_variables"); + for (auto const& independent_variable_config : + independent_variables_config.getConfigSubtreeList( + "independent_variable")) + { + auto const& variable_name = + //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__variable_name} + independent_variable_config.getConfigParameter<std::string>( + "variable_name"); + auto const reference_condition = + //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__reference_condition} + independent_variable_config.getConfigParameter<double>( + "reference_condition"); + auto const slope = + //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__slope} + independent_variable_config.getConfigParameter<double>("slope"); + + MaterialPropertyLib::Variable ivt = + MaterialPropertyLib::convertStringToVariable(variable_name); + + MaterialPropertyLib::IndependentVariable iv{ + ivt, reference_condition, slope}; + + ivs.push_back(std::move(iv)); + } return std::make_unique<MaterialPropertyLib::LinearProperty>( - reference_value, iv); + reference_value, ivs); } if (property_type == "Exponential") diff --git a/MaterialLib/MPL/Properties/LinearProperty.cpp b/MaterialLib/MPL/Properties/LinearProperty.cpp index b288a1a0932b96fa47748c7ecb886e52bd8dd698..39e157a406aca35a493babc3e683ae2523ab85e7 100644 --- a/MaterialLib/MPL/Properties/LinearProperty.cpp +++ b/MaterialLib/MPL/Properties/LinearProperty.cpp @@ -9,13 +9,15 @@ * */ +#include <numeric> + #include "MaterialLib/MPL/Properties/LinearProperty.h" namespace MaterialPropertyLib { LinearProperty::LinearProperty(PropertyDataType const& property_reference_value, - IndependentVariable const& v) - : _independent_variable(v) + std::vector<IndependentVariable> const& vs) + : _independent_variables(vs) { _value = property_reference_value; } @@ -25,12 +27,23 @@ PropertyDataType LinearProperty::value( ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/) const { - return std::get<double>(_value) * - (1 + - std::get<double>(_independent_variable.slope) * - (std::get<double>(variable_array[static_cast<int>( - _independent_variable.type)]) - - std::get<double>(_independent_variable.reference_condition))); + auto calculate_linearized_ratio = + [&variable_array](double const initial_linearized_ratio, + auto const& iv) { + return initial_linearized_ratio + + std::get<double>(iv.slope) * + (std::get<double>( + variable_array[static_cast<int>(iv.type)]) - + std::get<double>(iv.reference_condition)); + }; + + double const linearized_ratio_to_reference_value = + std::accumulate(_independent_variables.begin(), + _independent_variables.end(), + 1.0, + calculate_linearized_ratio); + + return std::get<double>(_value) * linearized_ratio_to_reference_value; } PropertyDataType LinearProperty::dValue( @@ -39,9 +52,16 @@ PropertyDataType LinearProperty::dValue( ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/) const { - return _independent_variable.type == primary_variable + auto const independent_variable = + std::find_if(_independent_variables.begin(), + _independent_variables.end(), + [&primary_variable](auto const& iv) -> bool { + return iv.type == primary_variable; + }); + + return independent_variable != _independent_variables.end() ? std::get<double>(_value) * - std::get<double>(_independent_variable.slope) + std::get<double>(independent_variable->slope) : decltype(_value){}; } diff --git a/MaterialLib/MPL/Properties/LinearProperty.h b/MaterialLib/MPL/Properties/LinearProperty.h index 49674792a9bcd154cc0e523553ef59ab8c2a0ac1..b63263cb7f72b304cbfa2c841f9d84cdb7a1b1ad 100644 --- a/MaterialLib/MPL/Properties/LinearProperty.h +++ b/MaterialLib/MPL/Properties/LinearProperty.h @@ -32,7 +32,7 @@ public: /// the PropertyDataType definition and sets the protected attribute _value /// of the base class Property to that value. LinearProperty(PropertyDataType const& property_reference_value, - IndependentVariable const& v); + std::vector<IndependentVariable> const& vs); /// This method computes the value of a property depending linearly on /// the value of the given primary variable. @@ -56,6 +56,6 @@ public: double const /*t*/) const override; private: - IndependentVariable const _independent_variable; + std::vector<IndependentVariable> const _independent_variables; }; } // namespace MaterialPropertyLib diff --git a/Tests/Data/Parabolic/HT/FaultedCube/Ra_795_fault_bcgs_jacobi.prj b/Tests/Data/Parabolic/HT/FaultedCube/Ra_795_fault_bcgs_jacobi.prj index a110aa9c61f17662acd7bdbce80aadc1ed441692..5ff73f383d7d40d8afab8a666fb6fe98f5f28bb8 100644 --- a/Tests/Data/Parabolic/HT/FaultedCube/Ra_795_fault_bcgs_jacobi.prj +++ b/Tests/Data/Parabolic/HT/FaultedCube/Ra_795_fault_bcgs_jacobi.prj @@ -44,11 +44,13 @@ <name>density</name> <type>Linear</type> <reference_value>1.0e+3</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>20</reference_condition> - <slope>-4.3e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <slope>-4.3e-4</slope> + <reference_condition>20</reference_condition> + </independent_variable> + </independent_variables> </property> <property> <name>viscosity</name> @@ -130,11 +132,13 @@ <name>density</name> <type>Linear</type> <reference_value>1.0e+3</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>20</reference_condition> - <slope>-4.3e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <slope>-4.3e-4</slope> + <reference_condition>20</reference_condition> + </independent_variable> + </independent_variables> </property> <property> <name>viscosity</name> diff --git a/Tests/Data/Parabolic/HT/SimpleSynthetics/constraint_bc_1e3.prj b/Tests/Data/Parabolic/HT/SimpleSynthetics/constraint_bc_1e3.prj index 512c6418c85af6d1e6df36d6aa071302dfad2d63..37934ee2a603aa16c42f4a0881ae3b41cf549909 100644 --- a/Tests/Data/Parabolic/HT/SimpleSynthetics/constraint_bc_1e3.prj +++ b/Tests/Data/Parabolic/HT/SimpleSynthetics/constraint_bc_1e3.prj @@ -27,11 +27,13 @@ <name>density</name> <type>Linear</type> <reference_value>1000</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>20</reference_condition> - <slope>-4.3e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>20</reference_condition> + <slope>-4.3e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>viscosity</name> diff --git a/Tests/Data/Parabolic/HT/StaggeredCoupling/ADecovalexTHMCBasedHTExample/th_decovalex.prj b/Tests/Data/Parabolic/HT/StaggeredCoupling/ADecovalexTHMCBasedHTExample/th_decovalex.prj index 73cf55c63f151b801d6802392f3f9df0fa5cac33..d0ab97ea4621091471aa0e005d88f1ec978fe09a 100644 --- a/Tests/Data/Parabolic/HT/StaggeredCoupling/ADecovalexTHMCBasedHTExample/th_decovalex.prj +++ b/Tests/Data/Parabolic/HT/StaggeredCoupling/ADecovalexTHMCBasedHTExample/th_decovalex.prj @@ -28,11 +28,13 @@ <name>density</name> <type>Linear</type> <reference_value>1000.0</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>293.0</reference_condition> - <slope>-4.3e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>293.0</reference_condition> + <slope>-4.3e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>viscosity</name> @@ -110,11 +112,13 @@ <name>density</name> <type>Linear</type> <reference_value>1000.0</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>293.0</reference_condition> - <slope>-4.3e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>293.0</reference_condition> + <slope>-4.3e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>viscosity</name> diff --git a/Tests/Data/Parabolic/HT/StaggeredCoupling/ConstViscosity/square_5500x5500_staggered_scheme.prj b/Tests/Data/Parabolic/HT/StaggeredCoupling/ConstViscosity/square_5500x5500_staggered_scheme.prj index 0a86074b5d98b85ea37edf1869a889d35d03e8c8..c917a415e8298ab7e8467372735ab266f5863083 100644 --- a/Tests/Data/Parabolic/HT/StaggeredCoupling/ConstViscosity/square_5500x5500_staggered_scheme.prj +++ b/Tests/Data/Parabolic/HT/StaggeredCoupling/ConstViscosity/square_5500x5500_staggered_scheme.prj @@ -38,11 +38,13 @@ <name>density</name> <type>Linear</type> <reference_value>1000</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <slope>-4.3e-4</slope> - <reference_condition>20</reference_condition> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <slope>-4.3e-4</slope> + <reference_condition>20</reference_condition> + </independent_variable> + </independent_variables> </property> <property> <name>viscosity</name> diff --git a/Tests/Data/Parabolic/HT/StaggeredCoupling/ConstViscosity/square_5500x5500_staggered_scheme_adaptive_dt.prj b/Tests/Data/Parabolic/HT/StaggeredCoupling/ConstViscosity/square_5500x5500_staggered_scheme_adaptive_dt.prj index 0c95f675c79d061c6bef9e63dd54ab945fd56821..4bc76f8eac5c3d46b74874b70847eb0623de3e0c 100644 --- a/Tests/Data/Parabolic/HT/StaggeredCoupling/ConstViscosity/square_5500x5500_staggered_scheme_adaptive_dt.prj +++ b/Tests/Data/Parabolic/HT/StaggeredCoupling/ConstViscosity/square_5500x5500_staggered_scheme_adaptive_dt.prj @@ -38,11 +38,13 @@ <name>density</name> <type>Linear</type> <reference_value>1000</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <slope>-4.3e-4</slope> - <reference_condition>20</reference_condition> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <slope>-4.3e-4</slope> + <reference_condition>20</reference_condition> + </independent_variable> + </independent_variables> </property> <property> <name>viscosity</name> diff --git a/Tests/Data/ThermoHydroMechanics/Linear/Beam_sealed_bimaterial/square_1e2.prj b/Tests/Data/ThermoHydroMechanics/Linear/Beam_sealed_bimaterial/square_1e2.prj index ace71de594666a8f855939efddd65b2a903707f4..836015ac38065dd76ac5aa65901fe4b7f08f8f58 100644 --- a/Tests/Data/ThermoHydroMechanics/Linear/Beam_sealed_bimaterial/square_1e2.prj +++ b/Tests/Data/ThermoHydroMechanics/Linear/Beam_sealed_bimaterial/square_1e2.prj @@ -46,11 +46,13 @@ <name>density</name> <type>Linear</type> <reference_value>1e-6</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>283.15</reference_condition> - <slope>-2.07e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>283.15</reference_condition> + <slope>-2.07e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>thermal_expansivity</name> @@ -130,11 +132,13 @@ <name>density</name> <type>Linear</type> <reference_value>1e-6</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>283.15</reference_condition> - <slope>-2.07e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>283.15</reference_condition> + <slope>-2.07e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>thermal_expansivity</name> @@ -214,11 +218,13 @@ <name>density</name> <type>Linear</type> <reference_value>1e-6</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>283.15</reference_condition> - <slope>-2.07e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>283.15</reference_condition> + <slope>-2.07e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>thermal_expansivity</name> diff --git a/Tests/Data/ThermoHydroMechanics/Linear/Beam_unsealed_bimaterial/square_1e2.prj b/Tests/Data/ThermoHydroMechanics/Linear/Beam_unsealed_bimaterial/square_1e2.prj index 663649224712c0c1912d6df2dd0f610060d72033..6c05c0a549295d8da49daeffd344a709c2d567b4 100644 --- a/Tests/Data/ThermoHydroMechanics/Linear/Beam_unsealed_bimaterial/square_1e2.prj +++ b/Tests/Data/ThermoHydroMechanics/Linear/Beam_unsealed_bimaterial/square_1e2.prj @@ -47,11 +47,13 @@ <name>density</name> <type>Linear</type> <reference_value>1e-6</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>283.15</reference_condition> - <slope>-2.07e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>283.15</reference_condition> + <slope>-2.07e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>thermal_expansivity</name> @@ -131,11 +133,13 @@ <name>density</name> <type>Linear</type> <reference_value>1e-6</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>283.15</reference_condition> - <slope>-2.07e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>283.15</reference_condition> + <slope>-2.07e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>thermal_expansivity</name> @@ -215,11 +219,13 @@ <name>density</name> <type>Linear</type> <reference_value>1e-6</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>283.15</reference_condition> - <slope>-2.07e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>283.15</reference_condition> + <slope>-2.07e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>thermal_expansivity</name> diff --git a/Tests/Data/ThermoHydroMechanics/Linear/Square_sealed_homogeneous/square_1e0.prj b/Tests/Data/ThermoHydroMechanics/Linear/Square_sealed_homogeneous/square_1e0.prj index ef56bac35b7336c5059d53995536851667a4949e..d8fc949e157a82454e97f19853cd64625b9f772b 100644 --- a/Tests/Data/ThermoHydroMechanics/Linear/Square_sealed_homogeneous/square_1e0.prj +++ b/Tests/Data/ThermoHydroMechanics/Linear/Square_sealed_homogeneous/square_1e0.prj @@ -47,11 +47,13 @@ <name>density</name> <type>Linear</type> <reference_value>1e-6</reference_value> - <independent_variable> - <variable_name>temperature</variable_name> - <reference_condition>273.15</reference_condition> - <slope>-2.07e-4</slope> - </independent_variable> + <independent_variables> + <independent_variable> + <variable_name>temperature</variable_name> + <reference_condition>273.15</reference_condition> + <slope>-2.07e-4</slope> + </independent_variable> + </independent_variables> </property> <property> <name>thermal_expansivity</name> diff --git a/Tests/MaterialLib/TestMPLLinearProperty.cpp b/Tests/MaterialLib/TestMPLLinearProperty.cpp index b4d8ee9f773887ba7cce65db635f2a4781db493a..aebb470733616e7c97cea967c31ff6b955d9c99e 100644 --- a/Tests/MaterialLib/TestMPLLinearProperty.cpp +++ b/Tests/MaterialLib/TestMPLLinearProperty.cpp @@ -19,7 +19,9 @@ TEST(MaterialPropertyLib, LinearProperty) double const x_ref = 293.15; MaterialPropertyLib::IndependentVariable const iv{ MaterialPropertyLib::Variable::temperature, x_ref, m}; - MaterialPropertyLib::LinearProperty linear_property{y_ref, iv}; + + std::vector<MaterialPropertyLib::IndependentVariable> ivs{iv}; + MaterialPropertyLib::LinearProperty linear_property{y_ref, ivs}; MaterialPropertyLib::VariableArray variable_array; variable_array[static_cast<int>(