Revision 99df01fda8dd45d3f791d917001bc4d5ee605a7b authored by Dmitri Naumov on 05 July 2021, 13:15:45 UTC, committed by Dmitri Naumov on 05 July 2021, 21:55:13 UTC
1 parent 7d3a855
Raw File
TestMPLLinear.cpp
/**
 * \file
 *
 * \copyright
 * Copyright (c) 2012-2021, 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 <gtest/gtest.h>

#include "MaterialLib/MPL/Properties/Linear.h"

TEST(MaterialPropertyLib, Linear)
{
    double const y_ref = 1.0;
    double const m = 1.0;
    double const x_ref = 293.15;
    MaterialPropertyLib::IndependentVariable const iv{
        MaterialPropertyLib::Variable::temperature, x_ref, m};

    std::vector<MaterialPropertyLib::IndependentVariable> ivs{iv};
    MaterialPropertyLib::Linear linear_property{"linear", y_ref, ivs};

    MaterialPropertyLib::VariableArray variable_array;
    variable_array[static_cast<int>(
        MaterialPropertyLib::Variable::temperature)] = 303.15;
    ParameterLib::SpatialPosition const pos;
    double const time = std::numeric_limits<double>::quiet_NaN();
    double const dt = std::numeric_limits<double>::quiet_NaN();
    ASSERT_NEAR(
        std::get<double>(linear_property.value(variable_array, pos, time, dt)),
        y_ref * (1 + m * (std::get<double>(variable_array[static_cast<int>(
                              MaterialPropertyLib::Variable::temperature)]) -
                          x_ref)),
        1.e-10);
    ASSERT_EQ(std::get<double>(linear_property.dValue(
                  variable_array, MaterialPropertyLib::Variable::phase_pressure,
                  pos, time, dt)),
              0.0);
    ASSERT_NEAR(std::get<double>(linear_property.dValue(
                    variable_array, MaterialPropertyLib::Variable::temperature,
                    pos, time, dt)),
                y_ref * m, 1.e-16);
    ASSERT_EQ(std::get<double>(linear_property.d2Value(
                  variable_array, MaterialPropertyLib::Variable::temperature,
                  MaterialPropertyLib::Variable::temperature, pos, time, dt)),
              0.0);
}
back to top