Skip to content

Commit 8fabaad

Browse files
committed
add appropriate ports
1 parent 4b61bee commit 8fabaad

22 files changed

Lines changed: 224 additions & 133 deletions

File tree

‎GridKit/Model/PhasorDynamics/Converter/REGCA/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ Name | Port | Init | Description
9393
`bus` | Bus | Known | Terminal bus voltage
9494
`ipcmd` | Input | Unknown | Active-current command input
9595
`iqcmd` | Input | Unknown | Reactive-current command input
96-
`ibranchr` | Output | Known | Branch-current real-component output
97-
`ibranchi` | Output | Known | Branch-current imaginary-component output
96+
`ir` | Output | Known | Terminal-current real-component output
97+
`ii` | Output | Known | Terminal-current imaginary-component output
9898
`pbranch` | Output | Known | Branch active-power output
9999
`qbranch` | Output | Known | Branch reactive-power output
100100

@@ -265,8 +265,8 @@ All internal derivatives initialize to zero.
265265

266266
Monitor | Units | Description | Note
267267
--------|--------|-----------------------------|------
268-
`ir` | [p.u.] | Real current injection | System base; exported through `ibranchr` when assigned
269-
`ii` | [p.u.] | Imaginary current injection | System base; exported through `ibranchi` when assigned
268+
`ir` | [p.u.] | Real current injection | System base; exported through `ir` when assigned
269+
`ii` | [p.u.] | Imaginary current injection | System base; exported through `ii` when assigned
270270
`p` | [p.u.] | Active-power output | System base; exported through `pbranch` when assigned
271271
`q` | [p.u.] | Reactive-power output | System base; exported through `qbranch` when assigned
272272

‎GridKit/Model/PhasorDynamics/Converter/REGCA/RegcaData.hpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ namespace GridKit
5555
/// Signal outputs for the REGCA converter model.
5656
enum class RegcaSignalOutputs : size_t
5757
{
58-
ibranchr, ///< Optional branch-current real-component output signal ID
59-
ibranchi, ///< Optional branch-current imaginary-component output signal ID
60-
pbranch, ///< Optional branch active-power output signal ID
61-
qbranch, ///< Optional branch reactive-power output signal ID
58+
ir, ///< Optional terminal-current real-component output signal ID
59+
ii, ///< Optional terminal-current imaginary-component output signal ID
60+
pbranch, ///< Optional branch active-power output signal ID
61+
qbranch, ///< Optional branch reactive-power output signal ID
6262
};
6363

6464
/// Variables available through the monitor interface.

‎GridKit/Model/PhasorDynamics/Converter/REGCA/RegcaImpl.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,13 @@ namespace GridKit
332332

333333
auto* y = y_.getData();
334334

335-
if (auto port = ports_.out.template port<RegcaSignalOutputs::ibranchr>())
335+
if (auto port = ports_.out.template port<RegcaSignalOutputs::ir>())
336336
{
337337
port.link(&y[static_cast<size_t>(RegcaInternalVariables::IR)],
338338
&(this->getVariableIndex(static_cast<IdxT>(RegcaInternalVariables::IR))));
339339
}
340340

341-
if (auto port = ports_.out.template port<RegcaSignalOutputs::ibranchi>())
341+
if (auto port = ports_.out.template port<RegcaSignalOutputs::ii>())
342342
{
343343
port.link(&y[static_cast<size_t>(RegcaInternalVariables::II)],
344344
&(this->getVariableIndex(static_cast<IdxT>(RegcaInternalVariables::II))));

‎GridKit/Model/PhasorDynamics/Load/LoadZ/CMakeLists.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ gridkit_add_library(
3333
SOURCES LoadZDependencyTracking.cpp
3434
LINK_LIBRARIES PUBLIC GridKit::phasor_dynamics_core)
3535

36+
target_link_libraries(
37+
phasor_dynamics_loadz
38+
PUBLIC GridKit::phasor_dynamics_signal)
39+
target_link_libraries(
40+
phasor_dynamics_loadz_dependency_tracking
41+
PUBLIC GridKit::phasor_dynamics_signal_dependency_tracking)
42+
3643
# Link to interface target for all components
3744
target_link_libraries(
3845
phasor_dynamics_components

‎GridKit/Model/PhasorDynamics/Load/LoadZ/LoadZ.hpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <GridKit/Model/PhasorDynamics/BusBase.hpp>
44
#include <GridKit/Model/PhasorDynamics/Component.hpp>
55
#include <GridKit/Model/PhasorDynamics/Load/LoadZ/LoadZData.hpp>
6+
#include <GridKit/Model/PhasorDynamics/SignalPorts.hpp>
67
#include <GridKit/Model/VariableMonitor.hpp>
78

89
namespace GridKit
@@ -43,6 +44,8 @@ namespace GridKit
4344
using ModelDataT = LoadZData<RealT, IdxT>;
4445
using MonitorT = Model::VariableMonitor<LoadZ, LoadZData>;
4546

47+
using SignalPortsT = SignalPorts<ScalarT, ModelDataT>;
48+
4649
LoadZ(BusT* bus);
4750
LoadZ(BusT* bus, RealT R, RealT X);
4851
LoadZ(BusT* bus, const ModelDataT& data);
@@ -62,6 +65,11 @@ namespace GridKit
6265
}
6366

6467
public:
68+
SignalPortsT& getPorts()
69+
{
70+
return ports_;
71+
}
72+
6573
void setR(RealT R)
6674
{
6775
R_ = R;
@@ -107,6 +115,8 @@ namespace GridKit
107115
const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);
108116

109117
private:
118+
SignalPortsT ports_;
119+
110120
BusT* bus_{nullptr};
111121
RealT R_{0.1};
112122
RealT X_{0.01};

‎GridKit/Model/PhasorDynamics/Load/LoadZ/LoadZData.hpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ namespace GridKit
3333
/// Signal outputs supported for a load
3434
enum class LoadZSignalOutputs : size_t
3535
{
36+
ir, ///< Real terminal current
37+
ii, ///< Imaginary terminal current
3638
};
3739

3840
/// Variables able to be monitored for a load

‎GridKit/Model/PhasorDynamics/Load/LoadZ/LoadZImpl.hpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ namespace GridKit
105105
wb_.resize(2);
106106
h_.resize(2);
107107

108+
if (auto port = ports_.out.template port<LoadZSignalOutputs::ir>())
109+
{
110+
port.link(&y_.getData()[0], &(this->getVariableIndex(0)));
111+
}
112+
if (auto port = ports_.out.template port<LoadZSignalOutputs::ii>())
113+
{
114+
port.link(&y_.getData()[1], &(this->getVariableIndex(1)));
115+
}
116+
108117
allocated_ = true;
109118
return 0;
110119
}

‎GridKit/Model/PhasorDynamics/Load/LoadZIP/CMakeLists.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ gridkit_add_library(
2828
SOURCES LoadZIPDependencyTracking.cpp
2929
LINK_LIBRARIES PUBLIC GridKit::phasor_dynamics_core)
3030

31+
target_link_libraries(
32+
phasor_dynamics_loadzip
33+
PUBLIC GridKit::phasor_dynamics_signal)
34+
target_link_libraries(
35+
phasor_dynamics_loadzip_dependency_tracking
36+
PUBLIC GridKit::phasor_dynamics_signal_dependency_tracking)
37+
3138
# Link to interface target for all components
3239
target_link_libraries(
3340
phasor_dynamics_components

‎GridKit/Model/PhasorDynamics/Load/LoadZIP/LoadZIP.hpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <GridKit/Model/PhasorDynamics/BusBase.hpp>
44
#include <GridKit/Model/PhasorDynamics/Component.hpp>
55
#include <GridKit/Model/PhasorDynamics/Load/LoadZIP/LoadZIPData.hpp>
6+
#include <GridKit/Model/PhasorDynamics/SignalPorts.hpp>
67
#include <GridKit/Model/VariableMonitor.hpp>
78

89
namespace GridKit
@@ -43,6 +44,8 @@ namespace GridKit
4344
using ModelDataT = LoadZIPData<RealT, IdxT>;
4445
using MonitorT = Model::VariableMonitor<LoadZIP, LoadZIPData>;
4546

47+
using SignalPortsT = SignalPorts<ScalarT, ModelDataT>;
48+
4649
LoadZIP(BusT* bus);
4750
LoadZIP(BusT* bus, RealT Pnom, RealT Qnom, RealT alphaI, RealT alphaP);
4851
LoadZIP(BusT* bus, const ModelDataT& data);
@@ -62,6 +65,11 @@ namespace GridKit
6265
}
6366

6467
public:
68+
SignalPortsT& getPorts()
69+
{
70+
return ports_;
71+
}
72+
6573
void setPnom(RealT Pnom)
6674
{
6775
Pnom_ = Pnom;
@@ -120,6 +128,8 @@ namespace GridKit
120128
const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);
121129

122130
private:
131+
SignalPortsT ports_;
132+
123133
BusT* bus_{nullptr};
124134
RealT Pnom_{0};
125135
RealT Qnom_{0};

‎GridKit/Model/PhasorDynamics/Load/LoadZIP/LoadZIPData.hpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ namespace GridKit
3030
/// Signal outputs supported for a loadZIP
3131
enum class LoadZIPSignalOutputs : size_t
3232
{
33+
ir, ///< Real terminal current
34+
ii, ///< Imaginary terminal current
3335
};
3436

3537
/// Variables able to be monitored for a loadZIP

0 commit comments

Comments
 (0)