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

Root network model holding buses, elements, and AC/DC grid hierarchy. More...

#include <network.h>

Inheritance diagram for Network:
Collaboration diagram for Network:

Public Member Functions

 Network ()
 Construct an empty network with zero pins.
 
virtual ~Network ()
 Destroy the network and all owned buses, elements, and grid sub-networks.
 
void addBus (const std::string &busName, std::unique_ptr< Bus > bus)
 Register an owned bus (transfers ownership on root networks).
 
void addBus (Bus *bus)
 Register a bus using its own name as the map key.
 
void addBus (const std::string &busName, Bus *bus)
 Register a bus under an explicit name (transfers ownership on root networks).
 
void addBusView (const std::string &busName, Bus *bus)
 Register a non-owning bus pointer (used by SubNetwork views).
 
void addElement (const std::string &designator, std::unique_ptr< Element > elem)
 Register an owned element.
 
void addElement (Element *elem)
 Register an element using an auto-generated designator.
 
void addElement (const std::string &designator, Element *elem)
 Register an element under a specific designator string.
 
void addElementView (const std::string &designator, Element *elem)
 Register a non-owning element pointer (used by SubNetwork views).
 
void connectElementToBus (Element *elem, int terminal, Bus *bus)
 Connect an element terminal to a bus and record the association in both directions.
 
void deleteElement (const std::string &designator)
 Remove and destroy an element by designator.
 
void deleteBus (const std::string &busName)
 Remove and destroy a bus by name.
 
void printConnections ()
 Print bus-to-element connection listing to standard output.
 
void printBuses ()
 Print all registered buses to standard output.
 
void printElements ()
 Print all registered elements to standard output.
 
void print_summary () const
 Print a concise summary of network contents (counts and names).
 
const std::unordered_map< std::string, Bus * > & getBuses () const
 Const access to the bus name-to-pointer map.
 
const std::unordered_map< std::string, Element * > & getElements () const
 Const access to the element designator-to-pointer map.
 
std::unordered_map< std::string, Element * > & getElements ()
 Mutable access to the element designator-to-pointer map.
 
const std::unordered_map< Bus *, std::vector< Element * > > & getConnections () const
 Const access to the bus-to-connected-elements map.
 
std::unordered_map< Bus *, std::vector< Element * > > & getConnections ()
 Mutable access to the bus-to-connected-elements map.
 
void add_areas ()
 Populate AC and DC grid sub-networks from the current flat network topology.
 
void empty_areas ()
 Destroy all grid sub-networks and clear grid/converter registries.
 
bool is_area_empty ()
 Check whether both AC and DC grid maps are empty.
 
vector< string > get_ac_grid_names ()
 Return ordered names of registered AC grids.
 
vector< string > get_dc_grid_names ()
 Return ordered names of registered DC grids.
 
std::unordered_map< std::string, SubNetwork * > & get_ac_grids ()
 Mutable access to the AC grid sub-network map.
 
std::unordered_map< std::string, SubNetwork * > & get_dc_grids ()
 Mutable access to the DC grid sub-network map.
 
std::unordered_map< std::string, Element * > & get_converters ()
 Mutable access to the converter element map.
 

Protected Attributes

std::unordered_map< std::string, Bus * > buses
 
std::unordered_map< std::string, Element * > elements
 
std::unordered_map< Bus *, std::vector< Element * > > connections
 
int pins = 0
 
std::vector< std::string > ac_grid_names
 
std::vector< std::string > dc_grid_names
 
std::unordered_map< std::string, SubNetwork * > ac_grids
 
std::unordered_map< std::string, SubNetwork * > dc_grids
 
std::unordered_map< std::string, Element * > converters
 
bool ownsResources_ = true
 When true, buses/elements registered via addBus/addElement are owned.
 

Detailed Description

Root network model holding buses, elements, and AC/DC grid hierarchy.

Owns buses and elements registered via addBus/addElement and deletes them in the destructor. Sub-networks (AC/DC grids) are owned separately and released through empty_areas().

Constructor & Destructor Documentation

◆ Network()

Network::Network ( )
default

Construct an empty network with zero pins.

◆ ~Network()

Network::~Network ( )
virtual

Destroy the network and all owned buses, elements, and grid sub-networks.

References buses, connections, elements, and empty_areas().

Member Function Documentation

◆ add_areas()

◆ addBus() [1/3]

void Network::addBus ( Bus bus)

Register a bus using its own name as the map key.

References addBus(), and Bus::getBusName().

◆ addBus() [2/3]

void Network::addBus ( const std::string &  busName,
Bus bus 
)

Register a bus under an explicit name (transfers ownership on root networks).

References addBus().

◆ addBus() [3/3]

void Network::addBus ( const std::string &  busName,
std::unique_ptr< Bus bus 
)

Register an owned bus (transfers ownership on root networks).

References addBusView(), and ownsResources_.

Referenced by addBus(), addBus(), example_DQsym_MMC_controlled(), example_DQsym_Simple_MMC(), and example_state_space().

◆ addBusView()

void Network::addBusView ( const std::string &  busName,
Bus bus 
)

Register a non-owning bus pointer (used by SubNetwork views).

References buses, Bus::getPinNumber(), Bus::isGround(), and pins.

Referenced by add_areas(), and addBus().

◆ addElement() [1/3]

void Network::addElement ( const std::string &  designator,
Element elem 
)

Register an element under a specific designator string.

References addElement().

◆ addElement() [2/3]

void Network::addElement ( const std::string &  designator,
std::unique_ptr< Element elem 
)

◆ addElement() [3/3]

void Network::addElement ( Element elem)

Register an element using an auto-generated designator.

References addElement(), and Element::getElementSymbol().

◆ addElementView()

void Network::addElementView ( const std::string &  designator,
Element elem 
)

Register a non-owning element pointer (used by SubNetwork views).

References elements.

Referenced by add_areas(), and addElement().

◆ connectElementToBus()

void Network::connectElementToBus ( Element elem,
int  terminal,
Bus bus 
)

Connect an element terminal to a bus and record the association in both directions.

Parameters
elemElement whose terminal is being wired.
terminalTerminal index on the element (0-based).
busTarget bus.

References Element::attachBus(), Bus::attachElement(), buses, connections, elements, Bus::getBusName(), Element::getElementSymbol(), Element::getInputPins(), Element::getOutputPins(), and Bus::getPinNumber().

Referenced by example_DQsym_MMC_controlled(), example_DQsym_Simple_MMC(), example_OPF_double_area(), example_OPF_PV(), example_OPF_single_area(), example_OPF_WT(), example_point2point_case(), example_stability_check(), and example_state_space().

◆ deleteBus()

void Network::deleteBus ( const std::string &  busName)

Remove and destroy a bus by name.

Parameters
busNameName of the bus to delete.

References buses, connections, Bus::getPinNumber(), Bus::isGround(), and pins.

◆ deleteElement()

void Network::deleteElement ( const std::string &  designator)

Remove and destroy an element by designator.

Parameters
designatorDesignator of the element to delete.

References buses, connections, converters, and elements.

◆ empty_areas()

void Network::empty_areas ( )

Destroy all grid sub-networks and clear grid/converter registries.

Populates AC and DC grid subnetworks from the main network.

Deletes owned SubNetwork shells in ac_grids and dc_grids; does not delete buses or elements referenced by those views.

This function iterates through all buses in the provided network, categorizes them into AC or DC areas based on their location string, and groups them into SubNetwork objects. It also identifies and separates MMC converters.

Parameters
netPointer to the main Network object.

References ac_grid_names, ac_grids, converters, dc_grid_names, and dc_grids.

Referenced by ~Network().

◆ get_ac_grid_names()

vector< string > Network::get_ac_grid_names ( )
inline

Return ordered names of registered AC grids.

Returns
Vector of AC grid name strings.

References ac_grid_names.

Referenced by StabilityEstimate::add_areas(), and DQsym::initialize().

◆ get_ac_grids()

std::unordered_map< std::string, SubNetwork * > & Network::get_ac_grids ( )
inline

Mutable access to the AC grid sub-network map.

Returns
Reference to name-to-SubNetwork map for AC areas.

References ac_grids.

Referenced by StabilityEstimate::add_areas(), and DQsym::initialize().

◆ get_converters()

std::unordered_map< std::string, Element * > & Network::get_converters ( )
inline

Mutable access to the converter element map.

Returns
Reference to designator-to-Element map for converters.

References converters.

Referenced by StabilityEstimate::add_areas(), and DQsym::initialize().

◆ get_dc_grid_names()

vector< string > Network::get_dc_grid_names ( )
inline

Return ordered names of registered DC grids.

Returns
Vector of DC grid name strings.

References dc_grid_names.

Referenced by StabilityEstimate::add_areas(), and DQsym::initialize().

◆ get_dc_grids()

std::unordered_map< std::string, SubNetwork * > & Network::get_dc_grids ( )
inline

Mutable access to the DC grid sub-network map.

Returns
Reference to name-to-SubNetwork map for DC areas.

References dc_grids.

Referenced by StabilityEstimate::add_areas(), and DQsym::initialize().

◆ getBuses()

const std::unordered_map< std::string, Bus * > & Network::getBuses ( ) const
inline

Const access to the bus name-to-pointer map.

Returns
Reference to the internal bus map.

References buses.

Referenced by StabilityEstimate::compute_equivalent_admittance_parameters_num(), PowerFlow::make_OPF(), and SubNetwork::printInfo().

◆ getConnections() [1/2]

std::unordered_map< Bus *, std::vector< Element * > > & Network::getConnections ( )
inline

Mutable access to the bus-to-connected-elements map.

Returns
Reference to the internal connections map.

References connections.

◆ getConnections() [2/2]

const std::unordered_map< Bus *, std::vector< Element * > > & Network::getConnections ( ) const
inline

Const access to the bus-to-connected-elements map.

Returns
Reference to the internal connections map.

References connections.

◆ getElements() [1/2]

std::unordered_map< std::string, Element * > & Network::getElements ( )
inline

Mutable access to the element designator-to-pointer map.

Returns
Reference to the internal element map.

References elements.

◆ getElements() [2/2]

const std::unordered_map< std::string, Element * > & Network::getElements ( ) const
inline

Const access to the element designator-to-pointer map.

Returns
Reference to the internal element map.

References elements.

Referenced by extendBusAC(), StateSpaceModel::formState(), PowerFlow::make_OPF(), and SubNetwork::printInfo().

◆ is_area_empty()

bool Network::is_area_empty ( )
inline

Check whether both AC and DC grid maps are empty.

Returns
True if no AC or DC grid sub-networks are registered.

References ac_grids, and dc_grids.

Referenced by StabilityEstimate::add_areas(), and DQsym::initialize().

◆ print_summary()

void Network::print_summary ( ) const

Print a concise summary of network contents (counts and names).

Prints a summary of the detected AC/DC grids and converters.

References ac_grids, converters, and dc_grids.

◆ printBuses()

void Network::printBuses ( )

Print all registered buses to standard output.

References buses.

◆ printConnections()

void Network::printConnections ( )

Print bus-to-element connection listing to standard output.

References connections, and Bus::getBusName().

Referenced by runJsonSimulation().

◆ printElements()

void Network::printElements ( )

Print all registered elements to standard output.

References elements.

Referenced by runJsonSimulation().

Member Data Documentation

◆ ac_grid_names

std::vector<std::string> Network::ac_grid_names
protected

◆ ac_grids

std::unordered_map<std::string, SubNetwork*> Network::ac_grids
protected

◆ buses

std::unordered_map<std::string, Bus*> Network::buses
protected

◆ connections

std::unordered_map<Bus*, std::vector<Element*> > Network::connections
protected

◆ converters

std::unordered_map<std::string, Element*> Network::converters
protected

◆ dc_grid_names

std::vector<std::string> Network::dc_grid_names
protected

◆ dc_grids

std::unordered_map<std::string, SubNetwork*> Network::dc_grids
protected

◆ elements

std::unordered_map<std::string, Element*> Network::elements
protected

◆ ownsResources_

bool Network::ownsResources_ = true
protected

When true, buses/elements registered via addBus/addElement are owned.

Referenced by SubNetwork::SubNetwork(), SubNetwork::SubNetwork(), addBus(), and addElement().

◆ pins

int Network::pins = 0
protected

Referenced by addBusView(), and deleteBus().


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