Harmony
HARMONic stabilitY assessment of PE-penetrated power systems
Loading...
Searching...
No Matches
Switch.h
Go to the documentation of this file.
1#ifndef SWITCH_H
2#define SWITCH_H
3
9#include "../Element.h"
10
16class Switch : public Element {
17public:
18
26 Switch(const std::string& symbol, const std::string& location, int pins, const std::vector<bool>& state);
27
28 // override generic stamper
29 void writeMNAmatrix(SymEngine::DenseMatrix&, std::unordered_map<Bus*, int>&, int, std::map<Element*, std::vector<RCP<const Basic>>>&) override;
30
31 // change the state of the switch
32 void setOpen() {
33 phaseState.assign(phaseState.size(), false); // Set all phases to open
34 }
35 void setClosed() {
36 phaseState.assign(phaseState.size(), true); // Set all phases to closed
37 }
38 void setState(int phase, bool state) {
39 if (phase >= 0 && phase < phaseState.size()) {
40 phaseState[phase] = state; // Set specific phase state
41 }
42 }
43 void setState(bool state) {
44 for (int phase; phase < phaseState.size(); phase++) {
45 phaseState[phase] = state; // Set specific phase state
46 }
47 }
48
49 // getters
50 bool getState(int phase = 0) const { return phaseState[phase]; }
51
52 void printElementValues() override;
53
54private:
55 std::vector<bool> phaseState; // true = closed, false = open
56};
57
58#endif // SWITCH_H
59
Base class for multi-phase network elements with Y-parameters and MNA stamping hooks.
Definition Element.h:29
Single- or multi-phase switch with per-phase open/closed state.
Definition Switch.h:16
bool getState(int phase=0) const
Definition Switch.h:50
void writeMNAmatrix(SymEngine::DenseMatrix &, std::unordered_map< Bus *, int > &, int, std::map< Element *, std::vector< RCP< const Basic > > > &) override
Stamp this element into the symbolic MNA matrix (override in derived classes).
Definition Switch.cpp:18
void printElementValues() override
Print extended element-specific values (override in derived classes).
Definition Switch.cpp:46
void setOpen()
Definition Switch.h:32
void setClosed()
Definition Switch.h:35
void setState(int phase, bool state)
Definition Switch.h:38
void setState(bool state)
Definition Switch.h:43