TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 > Class Template Reference

CPP API: mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 > Class Template Reference
mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 > Class Template Reference

A temporal-hybrid simulation. More...

#include <temporal_hybrid_model.h>

Public Types

using result1_function = std::function< ResultType1(const Model1 &, ScalarType t)>
 
using result2_function = std::function< ResultType2(const Model2 &, ScalarType t)>
 
using switching_condition = std::function< bool(const ResultType1 &state_model1, const ResultType2 &state_model2, bool model1_used)>
 

Public Member Functions

void advance (ScalarType tmax, const switching_condition &switch_model)
 Advance simulation to tmax. More...
 
auto & get_model1 ()
 
const auto & get_model1 () const
 Returns first model used for the simulation. More...
 
auto & get_model2 ()
 
const auto & get_model2 () const
 Returns second model used for the simulation. More...
 
ResultType1 get_result_model1 () const
 Get the result of model 1. More...
 
ResultType2 get_result_model2 () const
 Get the result of model 2. More...
 
 TemporalHybridSimulation (Model1 &&model1, Model2 &&model2, const result1_function &result1, const result2_function &result2, bool initially_use_model1, ScalarType t0=0, ScalarType dt=0.1)
 Create a temporal-hybrid simulation. More...
 
auto & using_model1 ()
 
const auto & using_model1 () const
 Returns whether the first model is currently used for simulation. More...
 

Private Attributes

ScalarType m_dt
 Step size with which the switching condition is checked. More...
 
Model1 m_model1
 First model used for the simulation. More...
 
Model2 m_model2
 Second model used for the simulation. More...
 
result1_function m_result1
 Result function of first model. More...
 
result2_function m_result2
 Result function of second model. More...
 
ScalarType m_t
 Current time step. More...
 
bool m_using_model1
 Boolean specifying whether model 1 is currently used for simulation. More...
 

Detailed Description

template<class Model1, class Model2, class ResultType1, class ResultType2>
class mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >

A temporal-hybrid simulation.

The temporal-hybrid simulation switches between two models during the course of time according to a given condition. This requires a specilization of the convert_model function for the two models used.

Template Parameters
Model1(Simulation) Type of the first model used.
Model2(Simulation) Type of the second model used.
ResultType1Result type of the first model. The results of both models are needed to evalute the switching condition.
ResultType2Result type of the second model. The results of both models are needed to evalute the switching condition.

Member Typedef Documentation

◆ result1_function

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
using mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::result1_function = std::function<ResultType1(const Model1&, ScalarType t)>

◆ result2_function

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
using mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::result2_function = std::function<ResultType2(const Model2&, ScalarType t)>

◆ switching_condition

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
using mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::switching_condition = std::function<bool(const ResultType1& state_model1, const ResultType2& state_model2, bool model1_used)>

Constructor & Destructor Documentation

◆ TemporalHybridSimulation()

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::TemporalHybridSimulation ( Model1 &&  model1,
Model2 &&  model2,
const result1_function result1,
const result2_function result2,
bool  initially_use_model1,
ScalarType  t0 = 0,
ScalarType  dt = 0.1 
)
inline

Create a temporal-hybrid simulation.

Parameters
[in]model1First model/simulation used for the hybrid simulation.
[in]model2Second model/simulation used for the hybrid simulation.
[in]result1Function returning the result/current state of first model.
[in]result2Function returning the result/current state of second model.
[in]initially_use_model1Boolean specifying which model to use at simulation start.
[in]t0Start time of the simulation.
[in]dtTimestep with which the switching is checked.

Member Function Documentation

◆ advance()

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
void mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::advance ( ScalarType  tmax,
const switching_condition switch_model 
)
inline

Advance simulation to tmax.

Parameters
[in]tmaxEnd time point of the simulation
[in]switch_modelSwitching condition that is checked every m_dt step.

◆ get_model1() [1/2]

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
auto& mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::get_model1 ( )
inline

◆ get_model1() [2/2]

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
const auto& mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::get_model1 ( ) const
inline

Returns first model used for the simulation.

◆ get_model2() [1/2]

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
auto& mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::get_model2 ( )
inline

◆ get_model2() [2/2]

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
const auto& mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::get_model2 ( ) const
inline

Returns second model used for the simulation.

◆ get_result_model1()

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
ResultType1 mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::get_result_model1 ( ) const
inline

Get the result of model 1.

Returns
Result of model 1 using the function m_result1.

◆ get_result_model2()

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
ResultType2 mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::get_result_model2 ( ) const
inline

Get the result of model 2.

Returns
Result of model 2 using the function m_result1.

◆ using_model1() [1/2]

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
auto& mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::using_model1 ( )
inline

◆ using_model1() [2/2]

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
const auto& mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::using_model1 ( ) const
inline

Returns whether the first model is currently used for simulation.

Member Data Documentation

◆ m_dt

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
ScalarType mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::m_dt
private

Step size with which the switching condition is checked.

◆ m_model1

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
Model1 mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::m_model1
private

First model used for the simulation.

◆ m_model2

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
Model2 mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::m_model2
private

Second model used for the simulation.

◆ m_result1

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
result1_function mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::m_result1
private

Result function of first model.

◆ m_result2

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
result2_function mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::m_result2
private

Result function of second model.

◆ m_t

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
ScalarType mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::m_t
private

Current time step.

◆ m_using_model1

template<class Model1 , class Model2 , class ResultType1 , class ResultType2 >
bool mio::hybrid::TemporalHybridSimulation< Model1, Model2, ResultType1, ResultType2 >::m_using_model1
private

Boolean specifying whether model 1 is currently used for simulation.