From f366cd59168aaf48502dd7355d9d56ea9ef4a498 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Wed, 27 Mar 2019 06:01:55 +0100 Subject: [PATCH] [T/MPL] Test the ExponentialProperty. --- .../TestMPLExponentialProperty.cpp | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Tests/MaterialLib/TestMPLExponentialProperty.cpp diff --git a/Tests/MaterialLib/TestMPLExponentialProperty.cpp b/Tests/MaterialLib/TestMPLExponentialProperty.cpp new file mode 100644 index 00000000000..99477ac5155 --- /dev/null +++ b/Tests/MaterialLib/TestMPLExponentialProperty.cpp @@ -0,0 +1,61 @@ +/** + * \file + * + * \copyright + * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ +#include <cmath> + +#include <gtest/gtest.h> + +#include "MaterialLib/MPL/Properties/ExponentialProperty.h" + +TEST(MaterialPropertyLib, ExponentialProperty) +{ + double const y_ref = 1e-3; + double const reference_condition = 20.0; + double const factor = 1 / 75.0; + MaterialPropertyLib::ExponentData const exp_data{ + MaterialPropertyLib::Variable::temperature, reference_condition, factor}; + MaterialPropertyLib::ExponentialProperty exp_property{y_ref, exp_data}; + + MaterialPropertyLib::VariableArray variable_array; + variable_array[static_cast<int>( + MaterialPropertyLib::Variable::temperature)] = 20; + ASSERT_NEAR( + boost::get<double>(exp_property.value(variable_array)), + y_ref * (std::exp(-factor * + (boost::get<double>(variable_array[static_cast<int>( + MaterialPropertyLib::Variable::temperature)]) - + reference_condition))), + 1.e-10); + ASSERT_EQ( + boost::get<double>(exp_property.dValue( + variable_array, MaterialPropertyLib::Variable::phase_pressure)), + 0.0); + ASSERT_NEAR( + boost::get<double>(exp_property.dValue( + variable_array, MaterialPropertyLib::Variable::temperature)), + -y_ref * factor * + std::exp(-factor * + (boost::get<double>(variable_array[static_cast<int>( + MaterialPropertyLib::Variable::temperature)]) - + reference_condition)), + 1.e-16); + ASSERT_NEAR( + boost::get<double>( + exp_property.d2Value(variable_array, + MaterialPropertyLib::Variable::temperature, + MaterialPropertyLib::Variable::temperature)), + y_ref * std::pow(factor, 2) * + std::exp(-factor * + (boost::get<double>(variable_array[static_cast<int>( + MaterialPropertyLib::Variable::temperature)]) - + reference_condition)), + 1.e-16); +} + -- GitLab