TransFlow
0.1.0
A transient pipeline flow simulation library
|
The Composition class is a simple container class for the composition of natural gas. We use arma::vec::fixed<10> to fix the number of components at 10. More...
#include <composition.hpp>
Public Member Functions | |
Composition () | |
Empty constructor. Returns composition with all fractions set to zero. | |
Composition (const arma::vec &composition) | |
Construct for arma::vec. Explicit to disallow implicit conversion from arma::vec. More... | |
double | operator() (const arma::uword i) const |
Get fraction of component i. | |
double & | operator() (const arma::uword i) |
Get/set fraction of component i. | |
operator arma::vec () const | |
User-defined implicit conversion from Composition to arma::vec. More... | |
const arma::vec & | vec () const |
Get (const ref) member arma::vec. | |
arma::vec | vec () |
Get (copy of) member arma::vec. | |
bool | isNormalized () const |
Returns true if composition is normalized. | |
Composition & | normalize () |
Normalizes the composition and returns refeference. | |
Composition | normalized () const |
Returns normalized copy (self is const.). | |
double | C1 () const |
Get C1 fraction. | |
double | C2 () const |
Get C2 fraction. | |
double | C3 () const |
Get C3 fraction. | |
double | iC4 () const |
Get iC4 fraction. | |
double | nC4 () const |
Get nC4 fraction. | |
double | iC5 () const |
Get iC5 fraction. | |
double | nC5 () const |
Get nC5 fraction. | |
double | C6 () const |
Get C6+ fraction. | |
double | N2 () const |
Get N2 fraction. | |
double | CO2 () const |
Get CO2 fraction. | |
double & | C1 () |
Get/set C1 fraction. | |
double & | C2 () |
Get/set C2 fraction. | |
double & | C3 () |
Get/set C3 fraction. | |
double & | iC4 () |
Get/set iC4 fraction. | |
double & | nC4 () |
Get/set nC4 fraction. | |
double & | iC5 () |
Get/set iC5 fraction. | |
double & | nC5 () |
Get/set nC5 fraction. | |
double & | C6 () |
Get/set C6+ fraction. | |
double & | N2 () |
Get/set N2 fraction. | |
double & | CO2 () |
Get/set CO2 fraction. | |
Static Public Attributes | |
const static arma::uword | n_elem = 10 |
Number of elements (fixed) | |
static const Composition | defaultComposition |
Default composition. | |
Private Attributes | |
arma::vec::fixed< 10 > | m_composition |
Store composition as fixed size vector, so the size can never be changed. Will throw error if we try to construct Composition with incorrect number of elements. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Composition &c) |
For pretty printing. More... | |
bool | operator== (const Composition &lhs, const Composition &rhs) |
Overloaded comparison operator. | |
The Composition class is a simple container class for the composition of natural gas. We use arma::vec::fixed<10> to fix the number of components at 10.
The composition is stored in order C1, C2, C3, iC4, nC4, iC5, nC5, C6, N2, CO2.
The only member variable is the composition of the gas. All other functions are for convenience, getters, normalization etc.
|
explicit |
Construct for arma::vec. Explicit to disallow implicit conversion from arma::vec.
composition |
|
inline |
User-defined implicit conversion from Composition to arma::vec.
This allows Composition to be a drop-in replacement for the arma::vec in most cases.
|
friend |
For pretty printing.
So we can do
std::cout << composition;
and get nice printing.
|
private |
Store composition as fixed size vector, so the size can never be changed. Will throw error if we try to construct Composition with incorrect number of elements.
Fractions are stored in order C1, C2, C3, iC4, nC4, iC5, nC5, C6, N2, CO2.