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 29 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

Definition at line 20 of file AverageMolarMass.cpp.

21{
22 name_ = std::move(name);
23}

References MaterialPropertyLib::name, and MaterialPropertyLib::Property::name_.

Member Function Documentation

◆ checkScale()

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

Reimplemented from MaterialPropertyLib::Property.

Definition at line 25 of file AverageMolarMass.cpp.

26{
27 if (!(std::holds_alternative<Phase*>(scale_)))
28 {
30 "The property 'AverageMolarMass' is implemented on the 'phase' "
31 "scale only.");
32 }
33}
#define OGS_FATAL(...)
Definition Error.h:26
std::variant< Medium *, Phase *, Component * > scale_
Definition Property.h:297

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 130 of file AverageMolarMass.cpp.

134{
135 OGS_FATAL("AverageMolarMass::d2Value is not yet implemented.");
136
137 return 0.;
138}

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 85 of file AverageMolarMass.cpp.

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

References MaterialPropertyLib::gas_phase_pressure, MaterialPropertyLib::molar_mass, MaterialPropertyLib::mole_fraction, OGS_FATAL, MaterialPropertyLib::Property::scale_, and MaterialPropertyLib::temperature.

◆ 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 35 of file AverageMolarMass.cpp.

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

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


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