|
Harmony
HARMONic stabilitY assessment of PE-penetrated power systems
|
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 DQsymResult & | getResult () 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. | |
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.
|
default |
Default constructor.
| 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.
| Ad | Base discrete-time state matrix (phasor domain). |
| Bd | Base discrete-time input matrix (phasor domain). |
| Cd | Base discrete-time output matrix (phasor domain). |
| Dd | Base discrete-time feed-through matrix (phasor domain). |
| swVec | Current switch state vector. |
| swVecOld | Previous switch state vector. |
| swOnRes | ON-resistances for switches. |
| swOffRes | OFF-resistances for switches. |
| Ads | Output: modified state matrix. |
| Bds | Output: modified input matrix. |
| Cds | Output: modified output matrix. |
| Dds | Output: modified feed-through matrix. |
References s.
Referenced by 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.
| st | Persistent DSSS state (matrices, previous x, switch vectors). |
| Ad | Discrete-time state matrix. |
| Bd | Discrete-time input matrix. |
| Cd | Discrete-time output matrix. |
| Dd | Discrete-time feed-through matrix. |
| swOnRes | ON-resistance for each switch. |
| swOffRes | OFF-resistance for each switch. |
| swType | Switch type identifier per element pin. |
| brkVec | Current breaker (open/closed) state vector. |
| u | Input matrix over the simulation horizon (n_inputs × T). |
| xo | Initial state vector. |
| dt | Time step (default 2e-5 s). |
| f0 | Fundamental frequency in Hz (default 50 Hz). |
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.
| Ad | The discrete-time state matrix. |
| Bd | The discrete-time input matrix. |
| Cd | The discrete-time output matrix. |
| Dd | The discrete-time feed-through matrix. |
| swOnRes | A vector of ON-resistances for the switches. |
| swOffRes | A vector of OFF-resistances for the switches. |
| swType | A vector indicating the type of each switch. |
| brkVec | A vector representing the current state of the breakers (switches). |
| u | The input matrix over the simulation time. |
| xo | The initial state vector. |
| dt | The time step for the simulation. |
| f0 | The fundamental frequency of the system. |
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().
| void DQsym::exportCSV | ( | const std::string & | filename | ) | const |
Writes simulation results to a CSV file.
| filename | Output file path. |
References DQsymResult::DSSabcHist, DQsymResult::time, and write_file().
Referenced by example_DQsym_MMC_controlled(), and example_DQsym_Simple_MMC().
| const DQsymResult & DQsym::getResult | ( | ) | const |
Returns the result of the last completed simulation.
|
inline |
Returns whether at least one simulation has completed.
| void DQsym::initialize | ( | Network * | net | ) |
Loads network topology and area metadata for simulation.
| net | Pointer 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().
| 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().
|
inline |
Resets internal DSSS state so a fresh run can be started.
| DQsymResult DQsym::run | ( | Config & | cfg | ) |
Runs the full DQsym time-domain simulation.
| cfg | Simulation parameters (time range, step size, breakers, outputs). |
References Config::breakerFunction, DQsymResult::brkHistory, StateSpaceModel::buildInputVector(), discretizeABCD(), dqn2abc_groups_at_time(), DQsym, DQsymResult::DSSabcHist, DSSS(), Config::dt, Config::f, StateSpaceModel::formState(), StateSpaceModel::getA(), StateSpaceModel::getB(), Element::getConnections(), StateSpaceModel::getInputGroups(), StateSpaceModel::getStateIndex(), Config::nKeep, Config::outputBuses, MMC::stepControllers(), Config::swOffRes, Config::swOnRes, Config::swType, Config::t_end, Config::t_start, and DQsymResult::time.
Referenced by example_DQsym_MMC_controlled(), and example_DQsym_Simple_MMC().