OGS
MaterialPropertyLib::AverageMolarMass Class Referencefinal

Detailed Description

Molar mass of a mixture by mole fraction weighted average \( M=\Sigma_\zeta x_{n,\alpha}^{\zeta}M^{\zeta}\).

This property must be a phase property.

Definition at line 20 of file AverageMolarMass.h.

#include <AverageMolarMass.h>

Inheritance diagram for MaterialPropertyLib::AverageMolarMass:
[legend]
Collaboration diagram for MaterialPropertyLib::AverageMolarMass:
[legend]

Public Member Functions

 AverageMolarMass (std::string name)
void checkScale () const override
PropertyDataType value (VariableArray const &variable_array, ParameterLib::SpatialPosition const &, double const, double const) const override
PropertyDataType dValue (VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
PropertyDataType d2Value (VariableArray const &variable_array, Variable const variable1, Variable const variable2, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
 Default implementation: 2nd derivative of any constant property is zero.
Public Member Functions inherited from MaterialPropertyLib::Property
virtual ~Property ()
virtual PropertyDataType initialValue (ParameterLib::SpatialPosition const &pos, double const t) const
virtual PropertyDataType value () const
virtual PropertyDataType value (VariableArray const &variable_array, VariableArray const &variable_array_prev, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
virtual PropertyDataType dValue (VariableArray const &variable_array, VariableArray const &variable_array_prev, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
virtual void setProperties (std::vector< std::unique_ptr< Phase > > const &phases)
 Default implementation:
void setScale (std::variant< Medium *, Phase *, Component * > scale)
template<typename T>
initialValue (ParameterLib::SpatialPosition const &pos, double const t) const
template<typename T>
value () const
template<typename T>
value (VariableArray const &variable_array, VariableArray const &variable_array_prev, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
template<typename T>
value (VariableArray const &variable_array, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
template<typename T>
dValue (VariableArray const &variable_array, VariableArray const &variable_array_prev, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
template<typename T>
dValue (VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
template<typename T>
d2Value (VariableArray const &variable_array, Variable const &variable1, Variable const &variable2, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const

Additional Inherited Members

Protected Attributes inherited from MaterialPropertyLib::Property
std::string name_
PropertyDataType value_
 The single value of a property.
PropertyDataType dvalue_
std::variant< Medium *, Phase *, Component * > scale_

Constructor & Destructor Documentation

◆ AverageMolarMass()

MaterialPropertyLib::AverageMolarMass::AverageMolarMass ( std::string name)
explicit

Member Function Documentation

◆ checkScale()

void MaterialPropertyLib::AverageMolarMass::checkScale ( ) const
overridevirtual

Reimplemented from MaterialPropertyLib::Property.

Definition at line 16 of file AverageMolarMass.cpp.

17{
18 if (!(std::holds_alternative<Phase*>(scale_)))
19 {
21 "The property 'AverageMolarMass' is implemented on the 'phase' "
22 "scale only.");
23 }
24}
#define OGS_FATAL(...)
Definition Error.h:19
std::variant< Medium *, Phase *, Component * > scale_

References OGS_FATAL, and MaterialPropertyLib::Property::scale_.

◆ d2Value()

PropertyDataType MaterialPropertyLib::AverageMolarMass::d2Value ( VariableArray const & variable_array,
Variable const variable1,
Variable const variable2,
ParameterLib::SpatialPosition const & pos,
double const t,
double const dt ) const
overridevirtual

Default implementation: 2nd derivative of any constant property is zero.

This virtual method will compute the second derivative of a property with respect to the given variables pv1 and pv2.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 121 of file AverageMolarMass.cpp.

125{
126 OGS_FATAL("AverageMolarMass::d2Value is not yet implemented.");
127
128 return 0.;
129}

References OGS_FATAL.

◆ dValue()

PropertyDataType MaterialPropertyLib::AverageMolarMass::dValue ( VariableArray const & variable_array,
Variable const variable,
ParameterLib::SpatialPosition const & pos,
double const t,
double const dt ) const
overridevirtual

This virtual method will compute the property derivative value based on the variables that are passed as arguments with the default implementation using empty variables array for the previous time step.

The default implementation of this method only returns the property value derivative without altering it.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 76 of file AverageMolarMass.cpp.

80{
81 if ((variable != Variable::gas_phase_pressure) &&
82 (variable != Variable::temperature))
83 {
85 "AverageMolarMass::dValue is implemented for derivatives with "
86 "respect to phase_pressure or temperature only.");
87 }
88
89 auto phase = std::get<Phase*>(scale_);
90
91 auto const numberOfComponents = phase->numberOfComponents();
92 if (numberOfComponents <= 1)
93 {
94 return 0.;
95 }
96 else if (numberOfComponents > 2)
97 {
99 "AverageMolarMass::dValue is currently implemented two or less "
100 "phase components only.");
101 }
102
103 // TODO (grunwald) : This should return a vector of length
104 // phase->numberOfComponents(). Currently, this feature is implemented
105 // for binary phases only.
106 auto const dxnC = phase->property(PropertyType::mole_fraction)
107 .template dValue<Eigen::Vector2d>(
108 variable_array, variable, pos, t, dt)[0];
109
110 auto const M_0 = phase->component(0)
111 .property(PropertyType::molar_mass)
112 .template value<double>(variable_array, pos, t, dt);
113 auto const M_1 = phase->component(1)
114 .property(PropertyType::molar_mass)
115 .template value<double>(variable_array, pos, t, dt);
116
117 return dxnC * (M_0 - M_1);
118
119} // namespace MaterialPropertyLib
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
virtual PropertyDataType value() const
int numberOfComponents(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media, std::string const &phase_name)

References dValue(), MaterialPropertyLib::gas_phase_pressure, MaterialPropertyLib::molar_mass, MaterialPropertyLib::mole_fraction, OGS_FATAL, MaterialPropertyLib::Property::scale_, MaterialPropertyLib::temperature, and MaterialPropertyLib::Property::value().

Referenced by dValue().

◆ value()

PropertyDataType MaterialPropertyLib::AverageMolarMass::value ( VariableArray const & variable_array,
ParameterLib::SpatialPosition const & pos,
double const t,
double const dt ) const
overridevirtual

This virtual method will compute the property value based on the variables that are passed as arguments with the default implementation using empty variables array for the previous time step.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 26 of file AverageMolarMass.cpp.

30{
31 auto phase = std::get<Phase*>(scale_);
32 auto const numberOfComponents = phase->numberOfComponents();
33 if (numberOfComponents < 1)
34 {
35 // if phase contains no components, jst return phase molar mass
36 return phase->property(PropertyType::molar_mass)
37 .template value<double>(variable_array, pos, t, dt);
38 }
39 else if (numberOfComponents > 2)
40 {
42 "AverageMolarMass::value only allows for phases consisting of up "
43 "to two components.");
44 }
45
46 // TODO (grunwald) : Task here is to retrieve the individual molar fractions
47 // of each compontne in the phase. Those are not static properties (as in
48 // case of molar mass), but they depend on some state-dependent rule. Option
49 // 1 is to call that rule here, option 2 would be to wrap this composition
50 // info into some container and to put it into the variable_array. This
51 // would have to be a vector of variable size, depending on the number of
52 // components. Unfortunately, the data types of MPL::VariableArray do not
53 // include such a type.
54 //
55 // Therefore, I go with option 1 here, which unfortunately only allows the
56 // use of binary mixtures at the moment.
57 auto const molar_fraction =
58 phase->property(PropertyType::mole_fraction)
59 .template value<Eigen::Vector2d>(variable_array, pos, t, dt);
60
61 double M = 0.;
62 for (size_t c = 0; c < numberOfComponents; c++)
63 {
64 auto const M_zeta =
65 phase->component(c)
67 .template value<double>(variable_array, pos, t, dt);
68 auto const xn_zeta = molar_fraction[c];
69
70 M += xn_zeta * M_zeta;
71 }
72
73 return M;
74}

References MaterialPropertyLib::c, MaterialPropertyLib::molar_fraction, MaterialPropertyLib::molar_mass, MaterialPropertyLib::mole_fraction, OGS_FATAL, MaterialPropertyLib::Property::scale_, and MaterialPropertyLib::Property::value().


The documentation for this class was generated from the following files: