Template Class KModel#

Inheritance Relationships#

Base Type#

Class Documentation#

template<class T, class P = NoParams, class Sc = NoScratch, class S = NoDiscreteStates, class C = NoContinuousStates>
class KModel : public Karana::Models::BaseKModel#

KModel<T,P,Sc,S,C> uses the curiously recurring template pattern (CRTP) to determine what methods the derived class has, and make the appropriate calls. All C++ models should derive from this. Python models will have a different class to derive from. See the KModel component models section for more discussion about the KModel class.

Public Functions

inline virtual bool isFinalized() const override#

Checks whether the model is finalized.

Returns:

bool - Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.

inline virtual std::optional<km::Ktime> getNextModelStepTime(const km::Ktime &t) final#

Get the model’s next time step after t.

Parameters:

t – The t to use when calculating the next time step.

Returns:

The model’s next time step.

inline virtual km::Ktime getPeriod() final#

Get the model’s period.

Returns:

The model’s period.

inline virtual void setPeriod(const km::Ktime &t) override#

Set the model’s period.

Parameters:

t – - The value to set the model’s period to.

BaseKModel(std::string_view name, const kc::ks_ptr<kd::StatePropagator> &sp)#

Constructor

Public Members

kc::ks_ptr<P> params = nullptr#

The parameters for the model.

kc::ks_ptr<Sc> scratch = nullptr#

The scratch for the model.

kc::ks_ptr<S> discrete_states = nullptr#

The discrete states for the model.

kc::ks_ptr<C> continuous_states = nullptr#

The continuous states for the model.

Protected Functions

inline virtual void _registerModel() override#

Register this model instance with the state propagator. See the.

Registering and unregistering models for details.

inline virtual void _unregisterModel() override#

Unregister this model instance from the state propagator. See the.

Registering and unregistering models for details.

inline virtual const Eigen::Ref<const km::Vec> _getContinuousStates() const override#
inline virtual const Eigen::Ref<const km::Vec> _getContinuousStatesDeriv() override#

Get the derivative of the continuous states. Overriden by KModel if appropriate.

Returns:

The model’s continuous states’ derivatives.

inline virtual void _setContinuousStates(const Eigen::Ref<const km::Vec> x) override#

Set the continous model states.

Parameters:

x – The new continuous model states.