Harmony
HARMONic stabilitY assessment of PE-penetrated power systems
Loading...
Searching...
No Matches
StateSpaceModel Class Reference

Assembles and stores the linear state-space representation of a network. More...

#include <State_Space_Model.h>

Classes

class  Tree
 Spanning-tree node used during loop/cutset detection. More...
 

Public Member Functions

 StateSpaceModel ()=default
 Default constructor; matrices are populated by formState().
 
void formState (Network *net, const std::vector< Bus * > &out, SSMMode mode=SSMMode::Standard)
 Assembles state-space matrices from a network.
 
const Eigen::MatrixXd & getA () const
 
const Eigen::MatrixXd & getB () const
 
const Eigen::MatrixXd & getC () const
 
const Eigen::MatrixXd & getD () const
 
const Eigen::MatrixXd & getBRaw () const
 
SSMMode getMode () const
 
const std::vector< InputMapping > & getInputMap () const
 
const std::vector< StateMapping > & getStateMap () const
 
const std::vector< OutputMapping > & getOutputMap () const
 
const std::vector< InputGroup > & getInputGroups () const
 
int getInputIndex (const std::string &elementName, int pin=0) const
 Looks up the B-matrix column index for an element input pin.
 
int getStateIndex (const std::string &elementName, int stateIdx=0) const
 Looks up the A-matrix row index for an element state.
 
MatrixXcd buildInputVector (int nKeep, const std::map< std::string, std::vector< MatrixXcd > > &elementStates) const
 Builds the input vector u from per-element state contributions.
 
void printMapping () const
 Prints input, state, and output index mappings to stdout.
 

Static Public Member Functions

static std::vector< std::vector< Bus * > > form_cutset_nodes (const std::vector< Bus * > &, const std::vector< std::pair< Bus *, Bus * > > &)
 Partitions buses into cutset node groups.
 
static std::vector< std::vector< Element * > > form_cutsets (const std::vector< std::vector< Bus * > > &, const std::map< Bus *, std::vector< Element * > > &)
 Maps cutset node groups to the elements that form each cutset.
 
static std::map< Bus *, std::vector< Element * > > generateBusToElementsMap (const std::vector< Element * > &)
 Builds a bus-to-elements adjacency map.
 
static std::vector< std::vector< Element * > > findLoops (const std::vector< Bus * > &, const std::map< Bus *, std::vector< Element * > > &)
 Finds fundamental loops in the network graph.
 

Detailed Description

Assembles and stores the linear state-space representation of a network.

Starting from the modified nodal admittance formulation, this class identifies state variables (inductor currents, capacitor voltages, converter plant states), independent sources, switches, and output buses, then constructs the A, B, C, and D matrices together with human-readable index mappings.

Constructor & Destructor Documentation

◆ StateSpaceModel()

StateSpaceModel::StateSpaceModel ( )
default

Default constructor; matrices are populated by formState().

Member Function Documentation

◆ buildInputVector()

MatrixXcd StateSpaceModel::buildInputVector ( int  nKeep,
const std::map< std::string, std::vector< MatrixXcd > > &  elementStates 
) const

Builds the input vector u from per-element state contributions.

In DQsym mode, rows are grouped in triplets and DC values are broadcast to all three phase rows.

Parameters
nKeepNumber of harmonic columns to retain per input group.
elementStatesMap from element name to its input coefficient matrices.
Returns
Complex input matrix (nu × nKeep).

References DQsym.

Referenced by DQsym::run().

◆ findLoops()

std::vector< std::vector< Element * > > StateSpaceModel::findLoops ( const std::vector< Bus * > &  nodes,
const std::map< Bus *, std::vector< Element * > > &  node_collection 
)
static

Finds fundamental loops in the network graph.

Parameters
busesAll network buses.
busToElementsAdjacency map from bus to incident elements.
Returns
Element lists, one per loop.

◆ form_cutset_nodes()

std::vector< std::vector< Bus * > > StateSpaceModel::form_cutset_nodes ( const std::vector< Bus * > &  buses,
const std::vector< std::pair< Bus *, Bus * > > &  connections 
)
static

Partitions buses into cutset node groups.

Parameters
busesAll network buses.
treeEdgesSpanning-tree edges as (parent, child) bus pairs.
Returns
Groups of buses forming cutsets.

References j.

◆ form_cutsets()

std::vector< std::vector< Element * > > StateSpaceModel::form_cutsets ( const std::vector< std::vector< Bus * > > &  cutset_nodes,
const std::map< Bus *, std::vector< Element * > > &  busToElementsMap 
)
static

Maps cutset node groups to the elements that form each cutset.

Parameters
cutsetNodesBus groups produced by form_cutset_nodes().
busToElementsAdjacency map from bus to incident elements.
Returns
Element lists, one per cutset.

◆ formState()

void StateSpaceModel::formState ( Network net,
const std::vector< Bus * > &  out,
SSMMode  mode = SSMMode::Standard 
)

Assembles state-space matrices from a network.

Parameters
netNetwork to linearize.
outOutput buses whose voltages form the C/D outputs.
modeColumn layout mode (Standard or DQsym).

References createZeroMatrix(), DQsym, extractCoefficient(), Network::getElements(), Bus::getPinNumber(), getStateCount(), Bus::isGround(), and j.

Referenced by example_state_space(), and DQsym::run().

◆ generateBusToElementsMap()

std::map< Bus *, std::vector< Element * > > StateSpaceModel::generateBusToElementsMap ( const std::vector< Element * > &  elements)
static

Builds a bus-to-elements adjacency map.

Parameters
elementsAll network elements.
Returns
Map from each bus to the elements connected to it.

◆ getA()

const Eigen::MatrixXd & StateSpaceModel::getA ( ) const
inline
Returns
State matrix A (n_states × n_states).

Referenced by example_state_space(), and DQsym::run().

◆ getB()

const Eigen::MatrixXd & StateSpaceModel::getB ( ) const
inline
Returns
Input matrix B or B_dqsym depending on current mode.

References DQsym.

Referenced by example_state_space(), and DQsym::run().

◆ getBRaw()

const Eigen::MatrixXd & StateSpaceModel::getBRaw ( ) const
inline
Returns
Raw input matrix B before DQsym column expansion.

◆ getC()

const Eigen::MatrixXd & StateSpaceModel::getC ( ) const
inline
Returns
Output matrix C (n_outputs × n_states).

Referenced by example_state_space().

◆ getD()

const Eigen::MatrixXd & StateSpaceModel::getD ( ) const
inline
Returns
Feed-through matrix D or D_dqsym depending on current mode.

References DQsym.

Referenced by example_state_space().

◆ getInputGroups()

const std::vector< InputGroup > & StateSpaceModel::getInputGroups ( ) const
inline
Returns
Per-source column group metadata.

Referenced by DQsym::run().

◆ getInputIndex()

int StateSpaceModel::getInputIndex ( const std::string &  elementName,
int  pin = 0 
) const
inline

Looks up the B-matrix column index for an element input pin.

Parameters
elementNameElement symbol/name.
pinPin index within the element (default 0).
Returns
Column index in B, or -1 if not found.

◆ getInputMap()

const std::vector< InputMapping > & StateSpaceModel::getInputMap ( ) const
inline
Returns
Input pin to B-column mappings.

◆ getMode()

SSMMode StateSpaceModel::getMode ( ) const
inline
Returns
Active matrix layout mode.

◆ getOutputMap()

const std::vector< OutputMapping > & StateSpaceModel::getOutputMap ( ) const
inline
Returns
Output pin to C-row mappings.

◆ getStateIndex()

int StateSpaceModel::getStateIndex ( const std::string &  elementName,
int  stateIdx = 0 
) const
inline

Looks up the A-matrix row index for an element state.

Parameters
elementNameElement symbol/name.
stateIdxState index within the element (default 0).
Returns
Row index in A, or -1 if not found.

Referenced by DQsym::run().

◆ getStateMap()

const std::vector< StateMapping > & StateSpaceModel::getStateMap ( ) const
inline
Returns
State variable to A-row mappings.

◆ printMapping()

void StateSpaceModel::printMapping ( ) const

Prints input, state, and output index mappings to stdout.

References DQsym.


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