TransFlow
0.1.0
A transient pipeline flow simulation library
|
The TimeSeries class is used to store the boundary conditions for several time steps. More...
#include <timeseries.hpp>
Classes | |
class | Series |
Public Member Functions | |
TimeSeries (const arma::uword nSteps, const arma::uword dt=60) | |
Construct time series with a given number of steps, and a fixed time step. More... | |
TimeSeries (const arma::uvec ×tamps) | |
Construct from timestamps. More... | |
TimeSeries (const Pipeline &pipeline, const arma::uword nSteps, const arma::uword dt=60, const std::vector< std::string > &boundarySettings={"inlet", "outlet", "inlet"}) | |
Construct time series from Pipeline, copying flow, pressure, temperature and composition from Pipeline. More... | |
TimeSeries (const std::string &filename, const std::vector< std::string > &boundarySettings={"inlet", "outlet", "inlet"}) | |
Wrapper for TimeSeries(const std::string&, arma::uword, arma::uword, const std::vector<std::string>&) which loads the whole file. More... | |
TimeSeries (const std::string &filename, arma::uword lastRow, const std::vector< std::string > &boundarySettings={"inlet", "outlet", "inlet"}) | |
Wrapper for TimeSeries(const std::string&, arma::uword, arma::uword, const std::vector<std::string>&), with the option to skip the end of the csv-file. More... | |
TimeSeries (const std::string &filename, arma::uword firstRow, arma::uword lastRow, const std::vector< std::string > &boundarySettings={"inlet", "outlet", "inlet"}) | |
Load boundary conditions from a CSV. More... | |
TimeSeries (const arma::mat &data, const std::vector< std::string > &boundarySettings={"inlet", "outlet", "inlet"}) | |
Construct from matrix. More... | |
TimeSeries (const arma::uvec ×tamps, const std::vector< BoundaryConditions > &boundaryConditions) | |
Construct from timestamps and boundary conditions. More... | |
TimeSeries (const arma::uword dt, const std::vector< BoundaryConditions > &boundaryConditions) | |
Construct with constant time step and vector of boundary conditions. More... | |
void | setBoundarySettings (const std::vector< std::string > settings) |
Set boundary settings via vector of string, or brace-init-list like {"inlet", "outlet", "inlet"} More... | |
void | save (const std::string &filename) |
const auto & | timestamps () const |
Get (const ref) timestamps. | |
const std::vector< Composition > & | inletComposition () const |
Get (const ref) inlet composition. | |
const std::vector< Composition > & | outletComposition () const |
Get (const ref) outlet composition. | |
const auto & | inletFlow () const |
Get (const ref) inlet flow. | |
const auto & | inletPressure () const |
Get (const ref) inlet pressure. | |
const auto & | inletTemperature () const |
Get (const ref) inlet temperature. | |
const auto & | outletFlow () const |
Get (const ref) outlet flow. | |
const auto & | outletPressure () const |
Get (const ref) outlet pressure. | |
const auto & | outletTemperature () const |
Get (const ref) outlet temperature. | |
auto & | timestamps () |
Get (ref) timestamps. | |
std::vector< Composition > & | inletComposition () |
Get (ref) inlet composition. | |
std::vector< Composition > & | outletComposition () |
Get (ref) outlet composition. | |
auto & | inletFlow () |
Get (ref) inlet flow. | |
auto & | inletPressure () |
Get (ref) inlet pressure. | |
auto & | inletTemperature () |
Get (ref) inlet temperature. | |
auto & | outletFlow () |
Get (ref) outlet flow. | |
auto & | outletPressure () |
Get (ref) outlet pressure. | |
auto & | outletTemperature () |
Get (ref) outlet temperature. | |
operator std::vector< TimeStep > () const | |
TimeStep | at (std::size_t pos) const |
std::vector-like at(i) getter | |
arma::uword | size () const |
Get size (number of grid points). | |
Private Member Functions | |
void | loadFromMatrix (const arma::mat &bc) |
Load boundary conditions from matrix (private) More... | |
Private Attributes | |
arma::uvec | m_timestamps |
Timestamps [s]. | |
Series | m_inletFlow |
Inlet flow [kg/s]. | |
Series | m_inletPressure |
Inlet pressure [Pa]. | |
Series | m_inletTemperature |
Inlet temperature [K]. | |
Series | m_outletFlow |
Outlet flow [kg/s]. | |
Series | m_outletPressure |
Outlet pressure [Pa]. | |
Series | m_outletTemperature |
Outlet temperature [K]. | |
std::vector< Composition > | m_inletComposition |
Inlet composition [fraction]. | |
std::vector< Composition > | m_outletComposition |
Outlet composition [fraction]. | |
The TimeSeries class is used to store the boundary conditions for several time steps.
The boundary conditions are stored in a arma::mat for convenience, so we can set the individual components like inlet flow via
TimeSeries ts(100); ts.inletFlow() = arma::linspace<arma::vec>(0, 250, 100); ts.outletPressure().fill(1e6); ts.inletTemperature() = arma::zeros<vec>(100) + 273.15;
There is a user-defined conversion to vector<BoundaryConditions> which is used when simulating each time step.
TimeSeries::TimeSeries | ( | const arma::uword | nSteps, |
const arma::uword | dt = 60 |
||
) |
Construct time series with a given number of steps, and a fixed time step.
nSteps | Number of steps |
dt | Time step |
TimeSeries::TimeSeries | ( | const arma::uvec & | timestamps | ) |
Construct from timestamps.
timestamps | Timestamps |
TimeSeries::TimeSeries | ( | const Pipeline & | pipeline, |
const arma::uword | nSteps, | ||
const arma::uword | dt = 60 , |
||
const std::vector< std::string > & | boundarySettings = {"inlet", "outlet", "inlet"} |
||
) |
TimeSeries::TimeSeries | ( | const std::string & | filename, |
const std::vector< std::string > & | boundarySettings = {"inlet", "outlet", "inlet"} |
||
) |
Wrapper for TimeSeries(const std::string&, arma::uword, arma::uword, const std::vector<std::string>&) which loads the whole file.
filename | Path to CSV-file |
boundarySettings | Boundary settings to use |
TimeSeries::TimeSeries | ( | const std::string & | filename, |
arma::uword | lastRow, | ||
const std::vector< std::string > & | boundarySettings = {"inlet", "outlet", "inlet"} |
||
) |
Wrapper for TimeSeries(const std::string&, arma::uword, arma::uword, const std::vector<std::string>&), with the option to skip the end of the csv-file.
filename | Path to CSV-file |
lastRow | Last row of CSV-file to load (zero-indexed) |
boundarySettings | Boundary settings to use |
TimeSeries::TimeSeries | ( | const std::string & | filename, |
arma::uword | firstRow, | ||
arma::uword | lastRow, | ||
const std::vector< std::string > & | boundarySettings = {"inlet", "outlet", "inlet"} |
||
) |
Load boundary conditions from a CSV.
The CSV has to be in one of two formats; either 7 columns
or 27 columns
where inlet and outlet composition have the columns
filename | Path to CSV-file |
firstRow | First row of CSV-file to load (zero-indexed) |
lastRow | Last row of CSV-file to load (zero-indexed) |
boundarySettings | Boundary settings to use |
TimeSeries::TimeSeries | ( | const arma::mat & | data, |
const std::vector< std::string > & | boundarySettings = {"inlet", "outlet", "inlet"} |
||
) |
Construct from matrix.
The matrix has to be in one of two formats; either 7 columns
or 27 columns
where inlet and outlet composition have the columns
data | Matrix with boundary conditions |
boundarySettings | Boundary settings to use |
TimeSeries::TimeSeries | ( | const arma::uvec & | timestamps, |
const std::vector< BoundaryConditions > & | boundaryConditions | ||
) |
Construct from timestamps and boundary conditions.
timestamps | Vector of timestamps [s] |
boundaryConditions | Vector of boundary conditions |
TimeSeries::TimeSeries | ( | const arma::uword | dt, |
const std::vector< BoundaryConditions > & | boundaryConditions | ||
) |
Construct with constant time step and vector of boundary conditions.
dt | Time step [s] |
boundaryConditions | BoundaryConditions instance |
|
private |
Load boundary conditions from matrix (private)
bc | Arma matrix with boundary conditions |
TimeSeries::operator std::vector< TimeStep > | ( | ) | const |
User-defined conversion to vector of TimeStep. Convenient when we want to loop over all time steps, e.g. in Simulator::simulate().
void TimeSeries::setBoundarySettings | ( | const std::vector< std::string > | settings | ) |
Set boundary settings via vector of string, or brace-init-list like {"inlet", "outlet", "inlet"}
settings | Vector of strings or brace-init-list, like {"inlet", "outlet", "inlet"} . |
Valid options are "inlet"
, "outlet"
, "both"
and "none"
.