https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: d3dc3ce00894cdbe4b2a87cd2b3319182637b11a authored by Tom Fischer on 16 October 2021, 08:42:50 UTC
Merge branch 'FixMemLeakInResetPropertiesInPolygonalRegion' into 'master'
Tip revision: d3dc3ce
TemperatureDependentViscosity.h
/**
 *  \brief A linear temperature dependent viscosity model.
 *
 *  \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
 *
 * \file
 *
 *  Created on August 10, 2016, 10:45 AM
 */

#pragma once

#include <string>
#include <cmath>

#include "MaterialLib/Fluid/FluidProperty.h"

namespace MaterialLib
{
namespace Fluid
{
/**
 *  Class of a temperature dependent viscosity model, which provides a good fit
 *  over temperature variations of 150 K.
 *
 *   \f[
 *        \mu = \mu_0\, \exp(-\frac{T-T_c}{T_v})
 *   \f]
 *   where
 *    \f{eqnarray*}{
 *       &\mu_0:&  \mbox{reference viscosity at the temperature of} T_c\\
 *       &T:&      \mbox{temperature,}\\
 *       &T_c:&    \mbox{reference temperature,}\\
 *       &T_v:&    \mbox{constant}\\
 *    \f}
 */
class TemperatureDependentViscosity final : public FluidProperty
{
public:
    /**
     *  @param mu0   \f$ \mu_0 \f$
     *  @param T_c   \f$ T_c \f$
     *  @param T_v   \f$ T_v \f$
     */
    explicit TemperatureDependentViscosity(const double mu0,
                                           const double T_c,
                                           const double T_v)
        : _mu0(mu0), _temperature_c(T_c), _temperature_v(T_v)
    {
    }

    /// Get model name.
    std::string getName() const override
    {
        return "Temperature dependent viscosity";
    }

    /** Get viscosity value.
     * \param var_vals Variable values in an array. The order of its elements
     *                 is given in enum class PropertyVariableType.
     */
    double getValue(const ArrayType& var_vals) const override
    {
        const double T = var_vals[static_cast<int>(PropertyVariableType::T)];
        return _mu0 * std::exp(-(T - _temperature_c) / _temperature_v);
    }

    /**
     * Get the partial differential of the viscosity with respect to
     * temperature.
     * \param var_vals  Variable values  in an array. The order of its elements
     *                  is given in enum class PropertyVariableType.
     * \param var       Variable type.
     */
    double getdValue(const ArrayType& var_vals,
                     const PropertyVariableType var) const override
    {
        (void)var;
        const double T = var_vals[static_cast<int>(PropertyVariableType::T)];
        return -_mu0 / _temperature_v *
               std::exp(-(T - _temperature_c) / _temperature_v);
    }

private:
    const double _mu0;            ///<  Initial viscosity.
    const double _temperature_c;  ///<  Reference temperature 1.
    const double _temperature_v;  ///<  Reference temperature 2.
};

}  // namespace Fluid
}  // namespace MaterialLib
back to top