TransFlow  0.1.0
A transient pipeline flow simulation library
TimeSeries Class Reference

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 &timestamps)
 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 &timestamps, 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< Compositionm_inletComposition
 Inlet composition [fraction].
 
std::vector< Compositionm_outletComposition
 Outlet composition [fraction].
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ TimeSeries() [1/9]

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.

Parameters
nStepsNumber of steps
dtTime step

◆ TimeSeries() [2/9]

TimeSeries::TimeSeries ( const arma::uvec &  timestamps)

Construct from timestamps.

Parameters
timestampsTimestamps

◆ TimeSeries() [3/9]

TimeSeries::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.

Parameters
pipelinePipeline to copy boundary conditions from
nStepsNumber of steps
dtTime step
boundarySettingsBoundary settings to use

◆ TimeSeries() [4/9]

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.

See also
TimeSeries(const std::string&, arma::uword, arma::uword, const std::vector<std::string>>&)
Parameters
filenamePath to CSV-file
boundarySettingsBoundary settings to use

◆ TimeSeries() [5/9]

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.

See also
TimeSeries(const std::string&, arma::uword, arma::uword, const std::vector<std::string>>&)
Parameters
filenamePath to CSV-file
lastRowLast row of CSV-file to load (zero-indexed)
boundarySettingsBoundary settings to use

◆ TimeSeries() [6/9]

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

  • timestamp [s]
  • inlet flow [kg/s]
  • inlet pressure [Pa]
  • inlet temperature [K]
  • outlet flow [kg/s]
  • outlet pressure[Pa]
  • outlet temperature [K]

or 27 columns

  • timestamp [s]
  • inlet flow [kg/s]
  • inlet pressure [Pa]
  • inlet temperature [K]
  • inlet composition (10 cols) [fraction]
  • outlet flow [kg/s]
  • outlet pressure [Pa]
  • outlet temperature [K]
  • outlet composition (10 cols) [fraction]

where inlet and outlet composition have the columns

  • C1, C2, C3, iC4, nC4, iC5, nC5, C6, N2, CO2
Parameters
filenamePath to CSV-file
firstRowFirst row of CSV-file to load (zero-indexed)
lastRowLast row of CSV-file to load (zero-indexed)
boundarySettingsBoundary settings to use

◆ TimeSeries() [7/9]

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

  • timestamp [s]
  • inlet flow [kg/s]
  • inlet pressure [Pa]
  • inlet temperature [K]
  • outlet flow [kg/s]
  • outlet pressure[Pa]
  • outlet temperature [K]

or 27 columns

  • timestamp [s]
  • inlet flow [kg/s]
  • inlet pressure [Pa]
  • inlet temperature [K]
  • inlet composition (10 cols) [fraction]
  • outlet flow [kg/s]
  • outlet pressure [Pa]
  • outlet temperature [K]
  • outlet composition (10 cols) [fraction]

where inlet and outlet composition have the columns

  • C1, C2, C3, iC4, nC4, iC5, nC5, C6, N2, CO2
Parameters
dataMatrix with boundary conditions
boundarySettingsBoundary settings to use

◆ TimeSeries() [8/9]

TimeSeries::TimeSeries ( const arma::uvec &  timestamps,
const std::vector< BoundaryConditions > &  boundaryConditions 
)

Construct from timestamps and boundary conditions.

Parameters
timestampsVector of timestamps [s]
boundaryConditionsVector of boundary conditions

◆ TimeSeries() [9/9]

TimeSeries::TimeSeries ( const arma::uword  dt,
const std::vector< BoundaryConditions > &  boundaryConditions 
)

Construct with constant time step and vector of boundary conditions.

Parameters
dtTime step [s]
boundaryConditionsBoundaryConditions instance

Member Function Documentation

◆ loadFromMatrix()

void TimeSeries::loadFromMatrix ( const arma::mat &  bc)
private

Load boundary conditions from matrix (private)

Parameters
bcArma matrix with boundary conditions

◆ operator std::vector< TimeStep >()

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().

◆ setBoundarySettings()

void TimeSeries::setBoundarySettings ( const std::vector< std::string >  settings)

Set boundary settings via vector of string, or brace-init-list like {"inlet", "outlet", "inlet"}

Parameters
settingsVector of strings or brace-init-list, like {"inlet", "outlet", "inlet"}.

Valid options are "inlet", "outlet", "both" and "none".


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