Template Class Component
Defined in File Component.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public GridKit::Model::Evaluator< scalar_type, index_type >(Template Class Evaluator)
Derived Types
public GridKit::EMT::Bus< scalar_type, index_type >(Template Class Bus)public GridKit::EMT::LineLumped< scalar_type, index_type >(Template Class LineLumped)public GridKit::EMT::LoadZ< scalar_type, index_type >(Template Class LoadZ)public GridKit::EMT::Pll< scalar_type, index_type >(Template Class Pll)public GridKit::EMT::Pmu< scalar_type, index_type >(Template Class Pmu)public GridKit::EMT::Signal< scalar_type, index_type >(Template Class Signal)public GridKit::EMT::SystemModel< scalar_type, index_type >(Template Class SystemModel)public GridKit::EMT::VectorFit< scalar_type, index_type >(Template Class VectorFit)public GridKit::EMT::VoltageSource< scalar_type, index_type >(Template Class VoltageSource)
Class Documentation
-
template<typename scalar_type, typename index_type>
class Component : public GridKit::Model::Evaluator<scalar_type, index_type> EMT component, which views its blocks of the system vectors.
A terminal reads the variables it is connected to and adds to their residuals. An input reads the variables it is connected to. An output is a value that the model computes, added to the residuals of the variables it is connected to. Each output is evaluated with the residual only when it is connected, and otherwise only for a monitor.
Subclassed by GridKit::EMT::Bus< scalar_type, index_type >, GridKit::EMT::LineLumped< scalar_type, index_type >, GridKit::EMT::LoadZ< scalar_type, index_type >, GridKit::EMT::Pll< scalar_type, index_type >, GridKit::EMT::Pmu< scalar_type, index_type >, GridKit::EMT::Signal< scalar_type, index_type >, GridKit::EMT::SystemModel< scalar_type, index_type >, GridKit::EMT::VectorFit< scalar_type, index_type >, GridKit::EMT::VoltageSource< scalar_type, index_type >
Public Functions
-
template<Utilities::SizedEnum InputT>
int connectInput(InputT input, Component &component, std::vector<IdxT> indices) Connect
inputto the local values ofcomponentatindices.- Template Parameters:
InputT – Input enumeration of the model.
- Parameters:
input – [in] Input to connect.
component – [in] Component whose values the input reads.
indices – [in] Local index in
componentof each of those values.
- Returns:
0 on success, 1 if
indiceshas the wrong size or an index is out of range.- Pre:
setLayouthas sized both components.
-
template<Utilities::SizedEnum OutputT>
int connectOutput(OutputT output, Component &component, std::vector<IdxT> indices) Connect
outputto the local residuals ofcomponentatindices.- Template Parameters:
OutputT – Output enumeration of the model.
- Parameters:
output – [in] Output to connect.
component – [in] Component whose residuals the output is added to.
indices – [in] Local index in
componentof each of those residuals.
- Returns:
0 on success, 1 if
indiceshas the wrong size or an index is out of range.- Pre:
setLayouthas sized both components.
-
template<Utilities::SizedEnum VariableT>
inline IdxT size(VariableT variable) const Size of internal variable
variable.
-
template<Utilities::SizedEnum VariableT>
inline std::span<ScalarT> y(VariableT variable) Values of internal variable
variable, once the system is allocated.
-
template<Utilities::SizedEnum VariableT>
inline std::span<ScalarT> getResidual(VariableT variable) Residuals of internal variable
variable, once the system is allocated.
-
template<Utilities::SizedEnum VariableT>
inline std::span<ScalarT> absoluteTolerance(VariableT variable) Absolute tolerances of internal variable
variable, once the system is allocated.
-
template<Utilities::SizedEnum OutputT>
inline IdxT outputSize(OutputT output) const Number of entries of output
output.
-
template<Utilities::SizedEnum OutputT>
inline bool outputConnected(OutputT output) const True if
outputis added to a residual.
-
template<Utilities::SizedEnum OutputT>
inline std::span<const ScalarT> getOutput(OutputT output) const Entries of output
outputthatevaluateOutputsevaluated last, zero before the first evaluation.
-
inline virtual int evaluateOutputs()
Evaluate every output at the current values, whether or not it is connected.
-
inline const std::string &id() const
Case id, or
id.symbolfor a submodel.
-
inline virtual int allocate() override
The system binds each component to its blocks.
-
inline virtual int tagDifferentiable() override
Fill the tag() vector with proper indicators.
Note
For some models, this may be a no-op, and the vector returned by tag() will still be empty.
- Pre:
allocate() must have been called.
-
inline virtual int setAbsoluteTolerance(RealT rel_tol) override
The relative tolerance, unless a model scales its own.
-
virtual int evaluateResidual() override
Add the residual of a linear model to the system residual.
The residual of a linear model is its constant partials dF/dy and dF/dy’ applied to the values and the derivatives, so no kernel is evaluated. A model with any other term forwards
evaluateResidualto its kernels.- Returns:
0.
- Pre:
tagDifferentiablehas stored the partials.
-
virtual int evaluateJacobian() override
Set the Jacobian entries to dF/dy + alpha dF/dy’.
- Returns:
0.
- Pre:
tagDifferentiablehas stored the partials of the entries.
-
inline virtual IdxT size() override
How many variables exist in the model.
-
inline virtual IdxT nnz() override
How many non-zero elements are in this model’s Jacobian.
This knowledge may be needed to allocate the buffers for the model’s Jacobian, so it it should not depend on allocate() having been called.
See also
-
inline virtual bool hasJacobian() override
Is the Jacobian defined. Used in IDA to determine whether DQ is used or not.
- Returns:
true
- Returns:
false
-
inline virtual VectorT &absoluteTolerance() override
Get the absolute tolerance for each variable in the model.
- Returns:
a reference to the absolute tolerance vector.
- Pre:
setAbsoluteTolerancemust have been called first.
-
inline virtual const VectorT &absoluteTolerance() const override
Get the absolute tolerance for each variable in the model.
- Returns:
a const reference to the absolute tolerance vector.
- Pre:
setAbsoluteTolerancemust have been called first.
-
inline virtual std::vector<bool> &tag() override
An indicator for which variables in the model are differential (true) or algebraic (false).
This information may be required for certain integrator features (such as the AnalysisManager::NativeDynamicSolver::Rosenbrock integrator), but is not required to be set. A reference to an empty vector may be returned.
- Pre:
tagDifferentiable() must have been called.
-
struct Connection
Local variables of
component, atindices, that a terminal, an input or an output is connected to.
-
struct CooBuffer
Derivative entries in global indices.
-
template<Utilities::SizedEnum InputT>