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

Orchestrates phasor-domain dynamic simulation of an AC/DC network. More...

#include <DQsym.h>

Public Member Functions

 DQsym ()=default
 Default constructor.
 
void initialize (Network *net)
 Loads network topology and area metadata for simulation.
 
DQsymResult run (Config &cfg)
 Runs the full DQsym time-domain simulation.
 
void reset ()
 Resets internal DSSS state so a fresh run can be started.
 
void exportCSV (const std::string &filename) const
 Writes simulation results to a CSV file.
 
void plot () const
 Opens an interactive plot of the most recent simulation results.
 
const DQsymResultgetResult () const
 Returns the result of the last completed simulation.
 
bool hasRun () const
 Returns whether at least one simulation has completed.
 
MatrixXcd DSSS (DSSState &, const MatrixXcd &, const MatrixXcd &, const MatrixXcd &, const MatrixXcd &, const VectorXd &, const VectorXd &, const VectorXi &, const VectorXi &, const MatrixXcd &, const VectorXcd &, double dt=2e-5, double f0=50.0)
 Advances the discrete-time phasor-domain state-space system one step at a time.
 
void buildMatricesForState (const MatrixXcd &, const MatrixXcd &, const MatrixXcd &, const MatrixXcd &, const VectorXi &, const VectorXi &, const VectorXd &, const VectorXd &, MatrixXcd &, MatrixXcd &, MatrixXcd &, MatrixXcd &)
 Builds switch-modified discrete-time matrices for the current breaker state.
 

Detailed Description

Orchestrates phasor-domain dynamic simulation of an AC/DC network.

Initializes area/subnetwork metadata from a Network, builds discrete-time state-space matrices, and runs the DSSS integrator with optional breaker switching. Results can be exported to CSV or plotted interactively.

Constructor & Destructor Documentation

◆ DQsym()

DQsym::DQsym ( )
default

Default constructor.

Member Function Documentation

◆ buildMatricesForState()

void DQsym::buildMatricesForState ( const MatrixXcd &  A0,
const MatrixXcd &  B0,
const MatrixXcd &  C0,
const MatrixXcd &  D0,
const VectorXi &  swVec_in,
const VectorXi &  swType,
const VectorXd &  swOnRes,
const VectorXd &  swOffRes,
MatrixXcd &  Ao,
MatrixXcd &  Bo,
MatrixXcd &  Co,
MatrixXcd &  Do 
)

Builds switch-modified discrete-time matrices for the current breaker state.

Parameters
AdBase discrete-time state matrix (phasor domain).
BdBase discrete-time input matrix (phasor domain).
CdBase discrete-time output matrix (phasor domain).
DdBase discrete-time feed-through matrix (phasor domain).
swVecCurrent switch state vector.
swVecOldPrevious switch state vector.
swOnResON-resistances for switches.
swOffResOFF-resistances for switches.
AdsOutput: modified state matrix.
BdsOutput: modified input matrix.
CdsOutput: modified output matrix.
DdsOutput: modified feed-through matrix.

References s.

Referenced by DSSS().

◆ DSSS()

MatrixXcd DQsym::DSSS ( DSSState st,
const MatrixXcd &  Ad,
const MatrixXcd &  Bd,
const MatrixXcd &  Cd,
const MatrixXcd &  Dd,
const VectorXd &  swOnRes,
const VectorXd &  swOffRes,
const VectorXi &  swType,
const VectorXi &  brkVec,
const MatrixXcd &  u,
const VectorXcd &  xo,
double  dt = 2e-5,
double  f0 = 50.0 
)

Advances the discrete-time phasor-domain state-space system one step at a time.

Solves the discrete-time state-space system with switch-dependent matrices.

Rebuilds switch-modified matrices whenever the breaker configuration changes. Operates directly on the supplied st, updating it in place.

Parameters
stPersistent DSSS state (matrices, previous x, switch vectors).
AdDiscrete-time state matrix.
BdDiscrete-time input matrix.
CdDiscrete-time output matrix.
DdDiscrete-time feed-through matrix.
swOnResON-resistance for each switch.
swOffResOFF-resistance for each switch.
swTypeSwitch type identifier per element pin.
brkVecCurrent breaker (open/closed) state vector.
uInput matrix over the simulation horizon (n_inputs × T).
xoInitial state vector.
dtTime step (default 2e-5 s).
f0Fundamental frequency in Hz (default 50 Hz).
Returns
Output matrix (n_outputs × T).

This function computes the output of a discrete-time state-space system for a given sequence of inputs. It supports dynamic changes in the system matrices based on the state of switches (breakers). The state-space model is updated whenever the switch configuration changes.

The core calculation is performed in the phasor domain. The state vector is rotated at each time step to account for the system's fundamental frequency, and the final output is computed based on the updated state.

Note
This implementation does not include a half-step predictor/corrector.
Parameters
AdThe discrete-time state matrix.
BdThe discrete-time input matrix.
CdThe discrete-time output matrix.
DdThe discrete-time feed-through matrix.
swOnResA vector of ON-resistances for the switches.
swOffResA vector of OFF-resistances for the switches.
swTypeA vector indicating the type of each switch.
brkVecA vector representing the current state of the breakers (switches).
uThe input matrix over the simulation time.
xoThe initial state vector.
dtThe time step for the simulation.
f0The fundamental frequency of the system.
Returns
A matrix representing the system's output over the simulation time.

References DSSState::Ads, DSSState::Bds, buildMatricesForState(), DSSState::Cds, convertToPhasor(), DSSState::Dds, DSSState::initialized, DSSState::nInputs, DSSState::nOutputs, DSSState::nStates, DSSState::nSwitches, DSSState::swVec, DSSState::swVecOld, DSSState::x_old, and DSSState::yswitch.

Referenced by example_DQsym_DSSS2(), example_DQsym_math_operations(), example_DQsym_RLC(), and run().

◆ exportCSV()

void DQsym::exportCSV ( const std::string &  filename) const

Writes simulation results to a CSV file.

Parameters
filenameOutput file path.

References DQsymResult::DSSabcHist, DQsymResult::time, and write_file().

Referenced by example_DQsym_MMC_controlled(), and example_DQsym_Simple_MMC().

◆ getResult()

const DQsymResult & DQsym::getResult ( ) const

Returns the result of the last completed simulation.

Returns
Const reference to stored DQsymResult.

◆ hasRun()

bool DQsym::hasRun ( ) const
inline

Returns whether at least one simulation has completed.

Returns
True after run() succeeds at least once.

◆ initialize()

void DQsym::initialize ( Network net)

Loads network topology and area metadata for simulation.

Parameters
netPointer to the network to simulate.

References Network::add_areas(), Network::get_ac_grid_names(), Network::get_ac_grids(), Network::get_converters(), Network::get_dc_grid_names(), Network::get_dc_grids(), and Network::is_area_empty().

Referenced by example_DQsym_MMC_controlled(), and example_DQsym_Simple_MMC().

◆ plot()

void DQsym::plot ( ) const

Opens an interactive plot of the most recent simulation results.

References DQsymResult::DSSabcHist, plot_abc_groups_implot(), and DQsymResult::time.

Referenced by example_DQsym_MMC_controlled(), and example_DQsym_Simple_MMC().

◆ reset()

void DQsym::reset ( )
inline

Resets internal DSSS state so a fresh run can be started.

◆ run()


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