Skip to content
Snippets Groups Projects
Commit 1afdb903 authored by wenqing's avatar wenqing
Browse files

[FL] Changed the structure of fluid property classes

parent 76ab964c
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ append_source_files(SOURCES Fluid)
append_source_files(SOURCES Fluid/Density)
append_source_files(SOURCES Fluid/Viscosity)
append_source_files(SOURCES Fluid/GibbsFreeEnergy)
append_source_files(SOURCES Fluid/FluidProperties)
append_source_files(SOURCES PorousMedium/Porosity)
append_source_files(SOURCES PorousMedium/Storage)
......
/**
* \copyright
* Copyright (c) 2012-2016, 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 CompositeDensityViscosityModel.cpp
*
* Created on November 29, 2016, 3:19 PM
*/
#include "CompositeDensityViscosityModel.h"
#include "MaterialLib/Fluid/FluidProperty.h"
namespace MaterialLib
{
namespace Fluid
{
CompositeDensityViscosityModel::CompositeDensityViscosityModel(
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& density,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& viscosity)
: _density(std::move(density)), _viscosity(std::move(viscosity))
{
}
inline double CompositeDensityViscosityModel::getValue(
const PropertyType property_type, const ArrayType& variable_values) const
{
switch (property_type)
{
case PropertyType::Density:
return _density->getValue(variable_values);
case PropertyType::Vicosity:
return _viscosity->getValue(variable_values);
default:
return 0.;
}
}
inline double CompositeDensityViscosityModel::getdValue(
const PropertyType property_type,
const ArrayType& variable_values,
const PropertyVariableType variable_type) const
{
switch (property_type)
{
case PropertyType::Density:
return _density->getdValue(variable_values, variable_type);
case PropertyType::Vicosity:
return _viscosity->getdValue(variable_values, variable_type);
default:
return 0.;
}
}
} // end namespace
} // end namespace
......@@ -5,60 +5,92 @@
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* \file CompositeFluidProperty.h
* \file FluidProperties.h
*
* Created on November 29, 2016, 2:23 PM
*/
#ifndef OGS_COMPOSITE_FLUID_PROPERTY_H
#define OGS_COMPOSITE_FLUID_PROPERTY_H
#ifndef OGS_FLUID_PROPERTIES_H
#define OGS_FLUID_PROPERTIES_H
#include <array>
#include <memory>
#include "PropertyVariableType.h"
#include "MaterialLib/Fluid/FluidProperty.h"
#include "MaterialLib/Fluid/PropertyVariableType.h"
namespace MaterialLib
{
namespace Fluid
{
/// Property type.
enum class PropertyType
/// Fluid property type.
enum class FluidPropertyType
{
Density,
Vicosity,
HeatCapacity,
ThermalConductivity
Density = 0,
Vicosity = 1,
HeatCapacity = 2,
ThermalConductivity = 3,
number_of_property_types = 4 ///< Number of property types.
};
class CompositeFluidProperty
const unsigned FluidPropertyTypeNumber =
static_cast<unsigned>(FluidPropertyType::number_of_property_types);
/// Base class of fluid properties.
class FluidProperties
{
public:
typedef std::array<double, PropertyVariableNumber> ArrayType;
virtual ~CompositeFluidProperty(){};
FluidProperties(
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)
: _property_models{{std::move(density), std::move(viscosity),
std::move(heat_capacity),
std::move(thermal_conductivity)}}
{
}
virtual ~FluidProperties(){};
/**
* Get the value of a Property.
* \param property_type Property type.
* \param variable_values An array of variables. The order of its elements
* is given in enum class PropertyVariableType.
* is temperature, pressure, concentration, which is
* defined in enum class PropertyVariableType.
*/
virtual double getValue(const PropertyType property_type,
virtual double getValue(const FluidPropertyType property_type,
const ArrayType& variable_values) const = 0;
/**
* Get the partial differential of a property.
* \param property_type Property type.
* \param variable_values An array of variables. The order of its elements
* is given in enum class PropertyVariableType.
* is temperature, pressure, concentration, which is
* defined in enum class PropertyVariableType.
* \param variable_type Variable type
*/
virtual double getdValue(
const PropertyType property_type,
const FluidPropertyType property_type,
const ArrayType& variable_values,
const PropertyVariableType variable_type) const = 0;
protected:
/** Fluid property models.
* 0: density;
* 1: viscosity;
* 2: specific heat capacity;
* 3: thermal conductivity
*
* The index is specified via enum class PropertyType.
*/
std::array<std::unique_ptr<FluidProperty>, FluidPropertyTypeNumber>
_property_models;
};
} // end namespace
} // end namespace
#endif /* OGS_COMPOSITE_FLUID_PROPERTY_H */
#endif /* OGS_FLUID_PROPERTIES_H */
......@@ -5,17 +5,16 @@
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* \file CompositeDensityViscosityModel.h
* \file TemperaturePressureConcentrationDependentFluidProperties.h
*
* Created on November 29, 2016, 3:19 PM
*/
#ifndef OGS_COMPOSITE_DENSITY_VISCOSITY_MODEL_H
#define OGS_COMPOSITE_DENSITY_VISCOSITY_MODEL_H
#ifndef OGS_TEMPERATURE_PRESSURE_CONCENTRATION_DEPENDENT_FLUID_PROPERTIES_H
#define OGS_TEMPERATURE_PRESSURE_CONCENTRATION_DEPENDENT_FLUID_PROPERTIES_H
#include <memory>
#include "MaterialLib/Fluid/CompositeFluidProperty.h"
#include "FluidProperties.h"
#include "MaterialLib/Fluid/FluidProperty.h"
namespace MaterialLib
{
......@@ -23,39 +22,56 @@ namespace Fluid
{
class FluidProperty;
/// A class contains density and viscosity model.
class CompositeDensityViscosityModel final : public CompositeFluidProperty
/// A class contains density, viscosity, heat_capacity and thermal_conductivity
/// models, which are all functions of temperature, pressure and concentration.
class TemperaturePressureConcentrationDependentFluidProperties final
: public FluidProperties
{
public:
CompositeDensityViscosityModel(
TemperaturePressureConcentrationDependentFluidProperties(
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& density,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& viscosity);
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& viscosity,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& heat_capacity,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&&
thermal_conductivity)
: FluidProperties(std::move(density), std::move(viscosity),
std::move(heat_capacity),
std::move(thermal_conductivity))
{
}
/**
* Get the value of a Property.
* \param property_type Property type.
* \param variable_values An array of variables. The order of its elements
* is given in enum class PropertyVariableType.
* is temperature, pressure, concentration, which is
* defined in enum class PropertyVariableType.
*/
double getValue(const PropertyType property_type,
const ArrayType& variable_values) const override;
double getValue(const FluidPropertyType property_type,
const ArrayType& variable_values) const override
{
return _property_models[static_cast<unsigned>(property_type)]->getValue(
variable_values);
}
/**
* Get the partial differential of a property.
* \param property_type Property type.
* \param variable_values An array of variables. The order of its elements
* is given in enum class PropertyVariableType.
* is temperature, pressure, concentration, which is
* defined in enum class PropertyVariableType.
* \param variable_type Variable type
*/
double getdValue(const PropertyType property_type,
double getdValue(const FluidPropertyType property_type,
const ArrayType& variable_values,
const PropertyVariableType variable_type) const override;
private:
std::unique_ptr<MaterialLib::Fluid::FluidProperty> _density;
std::unique_ptr<MaterialLib::Fluid::FluidProperty> _viscosity;
const PropertyVariableType variable_type) const override
{
return _property_models[static_cast<unsigned>(property_type)]
->getdValue(variable_values, variable_type);
}
};
} // end namespace
} // end namespace
#endif /* OGS_COMPOSITE_DENSITY_VISCOSITY_MODEL_H */
#endif /* OGS_TEMPERATURE_PRESSURE_CONCENTRATION_DEPENDENT_FLUID_PROPERTIES_H \
*/
......@@ -7,7 +7,7 @@
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* \file TestCompositeDensityViscosityModel.cpp
* \file TestFluidProperties.cpp
*
*/
......@@ -16,12 +16,12 @@
#include <memory>
#include <cmath>
#include "TestTools.h"
#include "Tests/TestTools.h"
#include "MaterialLib/Fluid/Density/createFluidDensityModel.h"
#include "MaterialLib/Fluid/Viscosity/createViscosityModel.h"
#include "MaterialLib/Fluid/CompositeFluidProperty.h"
#include "MaterialLib/Fluid/CompositeFluidProperty/CompositeDensityViscosityModel.h"
#include "MaterialLib/Fluid/FluidProperties/FluidProperties.h"
#include "MaterialLib/Fluid/FluidProperties/TemperaturePressureConcentrationDependentFluidProperties.h"
using namespace MaterialLib;
using namespace MaterialLib::Fluid;
......@@ -59,28 +59,29 @@ TEST(MaterialFluidModel, checkCompositeDensityViscosityModel)
"</viscosity>";
auto mu = createTestModel(xml_v, createViscosityModel, "viscosity");
std::unique_ptr<CompositeFluidProperty> composite_fluid_model =
std::unique_ptr<CompositeFluidProperty>(
new CompositeDensityViscosityModel(std::move(rho), std::move(mu)));
std::unique_ptr<FluidProperties> fluid_model =
std::unique_ptr<FluidProperties>(
new TemperaturePressureConcentrationDependentFluidProperties(
std::move(rho), std::move(mu), nullptr, nullptr));
ArrayType vars;
vars[0] = 350.0;
const double mu_expected = 1.e-3 * std::exp(-(vars[0] - 293) / 368);
ASSERT_NEAR(mu_expected,
composite_fluid_model->getValue(PropertyType::Vicosity, vars),
1.e-10);
ASSERT_NEAR(-mu_expected,
composite_fluid_model->getdValue(
PropertyType::Vicosity, vars,
MaterialLib::Fluid::PropertyVariableType::T),
fluid_model->getValue(FluidPropertyType::Vicosity, vars),
1.e-10);
ASSERT_NEAR(
-mu_expected,
fluid_model->getdValue(FluidPropertyType::Vicosity, vars,
MaterialLib::Fluid::PropertyVariableType::T),
1.e-10);
vars[0] = 273.1;
ASSERT_NEAR(1000.0 * (1 + 4.3e-4 * (vars[0] - 293.0)),
composite_fluid_model->getValue(PropertyType::Density, vars),
fluid_model->getValue(FluidPropertyType::Density, vars),
1.e-10);
ASSERT_NEAR(1000.0 * 4.3e-4, composite_fluid_model->getdValue(
PropertyType::Density, vars,
Fluid::PropertyVariableType::T),
ASSERT_NEAR(1000.0 * 4.3e-4,
fluid_model->getdValue(FluidPropertyType::Density, vars,
Fluid::PropertyVariableType::T),
1.e-10);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment