Skip to content

Commit 7086fe7

Browse files
authored
Create phasor dynamics model data structures (#116)
* Create phasor dynamics bus and branch data structures. * Add load data structure. * Use BusData with BusInfinite. * Renamed PowerSystemData -> PowerFlowData --------- Co-authored-by: pelesh <pelesh@users.noreply.github.com>
1 parent 1303aa1 commit 7086fe7

35 files changed

Lines changed: 206 additions & 202 deletions

examples/PowerFlow/Grid3Bus/Grid3BusSys.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <Model/PowerFlow/Load/Load.hpp>
2323
#include <Model/PowerFlow/MatpowerParser.hpp>
2424
#include <Model/PowerFlow/MiniGrid/MiniGrid.hpp>
25-
#include <Model/PowerFlow/PowerSystemData.hpp>
25+
#include <Model/PowerFlow/PowerFlowData.hpp>
2626
#include <Model/PowerFlow/SystemModelPowerFlow.hpp>
2727
#include <Solver/SteadyState/Kinsol.hpp>
2828
#include <Utilities/Testing.hpp>
@@ -79,7 +79,7 @@ using namespace GridKit;
7979
using namespace AnalysisManager::Sundials;
8080
using namespace AnalysisManager;
8181
using namespace GridKit::Testing;
82-
using namespace GridKit::PowerSystemData;
82+
using namespace GridKit::PowerFlowData;
8383

8484
constexpr double theta2_ref = -4.87979; // [deg]
8585
constexpr double V2_ref = 1.08281; // [p.u.]
@@ -149,7 +149,7 @@ int parserCase()
149149
std::cout << "Solving same problem, but assembled from components via a parser ...\n\n";
150150

151151
// Data File Reading
152-
GridKit::PowerSystemData::SystemModelData<double, size_t> mp;
152+
GridKit::PowerFlowData::SystemModelData<double, size_t> mp;
153153

154154
std::istringstream iss(BUS3_DATA_STRING);
155155
GridKit::readMatPower(mp, iss);

examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <limits>
1313
#include <vector>
1414

15-
#include <Model/PowerFlow/PowerSystemData.hpp>
15+
#include <Model/PowerFlow/PowerFlowData.hpp>
1616
#include <Utilities/Testing.hpp>
1717

1818
namespace
@@ -34,9 +34,9 @@ namespace GridKit
3434
{
3535

3636
template <typename RealT = double, typename IdxT = int>
37-
inline bool isEqual(PowerSystemData::GenCostData<RealT, IdxT> a,
38-
PowerSystemData::GenCostData<RealT, IdxT> b,
39-
RealT tol = tol_)
37+
inline bool isEqual(PowerFlowData::GenCostData<RealT, IdxT> a,
38+
PowerFlowData::GenCostData<RealT, IdxT> b,
39+
RealT tol = tol_)
4040
{
4141
(void) tol; // suppress warning
4242
int fail = 0;
@@ -52,9 +52,9 @@ namespace GridKit
5252
}
5353

5454
template <typename RealT = double, typename IdxT = int>
55-
inline bool isEqual(PowerSystemData::GenData<RealT, IdxT> a,
56-
PowerSystemData::GenData<RealT, IdxT> b,
57-
RealT tol = tol_)
55+
inline bool isEqual(PowerFlowData::GenData<RealT, IdxT> a,
56+
PowerFlowData::GenData<RealT, IdxT> b,
57+
RealT tol = tol_)
5858
{
5959
int fail = 0;
6060

@@ -88,9 +88,9 @@ namespace GridKit
8888
}
8989

9090
template <typename RealT = double, typename IdxT = int>
91-
inline bool isEqual(PowerSystemData::BusData<RealT, IdxT> a,
92-
PowerSystemData::BusData<RealT, IdxT> b,
93-
RealT tol = tol_)
91+
inline bool isEqual(PowerFlowData::BusData<RealT, IdxT> a,
92+
PowerFlowData::BusData<RealT, IdxT> b,
93+
RealT tol = tol_)
9494
{
9595
int fail = 0;
9696

@@ -124,9 +124,9 @@ namespace GridKit
124124
}
125125

126126
template <typename RealT = double, typename IdxT = int>
127-
inline bool isEqual(PowerSystemData::LoadData<RealT, IdxT> a,
128-
PowerSystemData::LoadData<RealT, IdxT> b,
129-
RealT tol = tol_)
127+
inline bool isEqual(PowerFlowData::LoadData<RealT, IdxT> a,
128+
PowerFlowData::LoadData<RealT, IdxT> b,
129+
RealT tol = tol_)
130130
{
131131
int fail = 0;
132132

@@ -144,9 +144,9 @@ namespace GridKit
144144
}
145145

146146
template <typename RealT = double, typename IdxT = int>
147-
inline bool isEqual(PowerSystemData::BranchData<RealT, IdxT> a,
148-
PowerSystemData::BranchData<RealT, IdxT> b,
149-
RealT tol = tol_)
147+
inline bool isEqual(PowerFlowData::BranchData<RealT, IdxT> a,
148+
PowerFlowData::BranchData<RealT, IdxT> b,
149+
RealT tol = tol_)
150150
{
151151
int fail = 0;
152152

@@ -197,8 +197,8 @@ namespace GridKit
197197
}
198198

199199
template <typename RealT = double, typename IdxT = int>
200-
inline bool isEqual(PowerSystemData::SystemModelData<RealT, IdxT> a,
201-
PowerSystemData::SystemModelData<RealT, IdxT> b)
200+
inline bool isEqual(PowerFlowData::SystemModelData<RealT, IdxT> a,
201+
PowerFlowData::SystemModelData<RealT, IdxT> b)
202202
{
203203
int fail = 0;
204204

examples/PowerFlow/MatPowerTesting/test_parse_branch_row.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include "MatPowerTesting.hpp"
44
#include <Model/PowerFlow/MatpowerParser.hpp>
5-
#include <Model/PowerFlow/PowerSystemData.hpp>
5+
#include <Model/PowerFlow/PowerFlowData.hpp>
66

77
using namespace GridKit;
88
using namespace GridKit::Testing;
9-
using namespace GridKit::PowerSystemData;
9+
using namespace GridKit::PowerFlowData;
1010

1111
namespace
1212
{

examples/PowerFlow/MatPowerTesting/test_parse_bus_row.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include "MatPowerTesting.hpp"
44
#include <Model/PowerFlow/MatpowerParser.hpp>
5-
#include <Model/PowerFlow/PowerSystemData.hpp>
5+
#include <Model/PowerFlow/PowerFlowData.hpp>
66

77
using namespace GridKit;
88
using namespace GridKit::Testing;
9-
using namespace GridKit::PowerSystemData;
9+
using namespace GridKit::PowerFlowData;
1010

1111
namespace
1212
{

examples/PowerFlow/MatPowerTesting/test_parse_gen_row.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include "MatPowerTesting.hpp"
44
#include <Model/PowerFlow/MatpowerParser.hpp>
5-
#include <Model/PowerFlow/PowerSystemData.hpp>
5+
#include <Model/PowerFlow/PowerFlowData.hpp>
66

77
using namespace GridKit;
88
using namespace GridKit::Testing;
9-
using namespace GridKit::PowerSystemData;
9+
using namespace GridKit::PowerFlowData;
1010

1111
namespace
1212
{

examples/PowerFlow/MatPowerTesting/test_parse_gencost_row.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include "MatPowerTesting.hpp"
44
#include <Model/PowerFlow/MatpowerParser.hpp>
5-
#include <Model/PowerFlow/PowerSystemData.hpp>
5+
#include <Model/PowerFlow/PowerFlowData.hpp>
66

77
using namespace GridKit;
88
using namespace GridKit::Testing;
9-
using namespace GridKit::PowerSystemData;
9+
using namespace GridKit::PowerFlowData;
1010

1111
namespace
1212
{

examples/PowerFlow/MatPowerTesting/test_parse_matpower.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include "MatPowerTesting.hpp"
44
#include <Model/PowerFlow/MatpowerParser.hpp>
5-
#include <Model/PowerFlow/PowerSystemData.hpp>
5+
#include <Model/PowerFlow/PowerFlowData.hpp>
66

77
using namespace GridKit;
88
using namespace GridKit::Testing;
9-
using namespace GridKit::PowerSystemData;
9+
using namespace GridKit::PowerFlowData;
1010

1111
namespace
1212
{

src/Model/PhasorDynamics/Branch/Branch.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <cmath>
1313
#include <iostream>
1414

15+
#include <Model/PhasorDynamics/Branch/BranchData.hpp>
1516
#include <Model/PhasorDynamics/Bus/Bus.hpp>
16-
#include <Model/PowerFlow/PowerSystemData.hpp>
1717

1818
namespace GridKit
1919
{
@@ -36,8 +36,8 @@ namespace GridKit
3636
X_(0.01),
3737
G_(0.0),
3838
B_(0.0),
39-
bus1ID_(0),
40-
bus2ID_(0)
39+
bus1_id_(0),
40+
bus2_id_(0)
4141
{
4242
size_ = 0;
4343
}
@@ -67,21 +67,21 @@ namespace GridKit
6767
X_(X),
6868
G_(G),
6969
B_(B),
70-
bus1ID_(0),
71-
bus2ID_(0)
70+
bus1_id_(0),
71+
bus2_id_(0)
7272
{
7373
}
7474

7575
template <class ScalarT, typename IdxT>
76-
Branch<ScalarT, IdxT>::Branch(bus_type* bus1, bus_type* bus2, BranchData& data)
76+
Branch<ScalarT, IdxT>::Branch(bus_type* bus1, bus_type* bus2, model_data_type& data)
7777
: bus1_(bus1),
7878
bus2_(bus2),
79-
R_(data.r),
80-
X_(data.x),
81-
G_(0.0),
82-
B_(data.b),
83-
bus1ID_(data.fbus),
84-
bus2ID_(data.tbus)
79+
R_(data.R),
80+
X_(data.X),
81+
G_(data.G),
82+
B_(data.B),
83+
bus1_id_(data.bus1_id),
84+
bus2_id_(data.bus2_id)
8585
{
8686
size_ = 0;
8787
}

src/Model/PhasorDynamics/Branch/Branch.hpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,16 @@
1111
#include <Model/PhasorDynamics/Component.hpp>
1212

1313
// Forward declarations.
14-
namespace GridKit
15-
{
16-
namespace PowerSystemData
17-
{
18-
template <typename RealT, typename IdxT>
19-
struct BranchData;
20-
}
21-
} // namespace GridKit
22-
2314
namespace GridKit
2415
{
2516
namespace PhasorDynamics
2617
{
2718
template <class ScalarT, typename IdxT>
2819
class BusBase;
29-
}
20+
21+
template <typename RealT, typename IdxT>
22+
struct BranchData;
23+
} // namespace PhasorDynamics
3024
} // namespace GridKit
3125

3226
namespace GridKit
@@ -51,21 +45,15 @@ namespace GridKit
5145
using Component<ScalarT, IdxT>::yp_;
5246
using Component<ScalarT, IdxT>::tag_;
5347
using Component<ScalarT, IdxT>::f_;
54-
using Component<ScalarT, IdxT>::g_;
55-
using Component<ScalarT, IdxT>::yB_;
56-
using Component<ScalarT, IdxT>::ypB_;
57-
using Component<ScalarT, IdxT>::fB_;
58-
using Component<ScalarT, IdxT>::gB_;
59-
using Component<ScalarT, IdxT>::param_;
6048

61-
using bus_type = BusBase<ScalarT, IdxT>;
62-
using real_type = typename Component<ScalarT, IdxT>::real_type;
63-
using BranchData = GridKit::PowerSystemData::BranchData<real_type, IdxT>;
49+
using real_type = typename Component<ScalarT, IdxT>::real_type;
50+
using bus_type = BusBase<ScalarT, IdxT>;
51+
using model_data_type = BranchData<real_type, IdxT>;
6452

6553
public:
6654
Branch(bus_type* bus1, bus_type* bus2);
6755
Branch(bus_type* bus1, bus_type* bus2, real_type R, real_type X, real_type G, real_type B);
68-
Branch(bus_type* bus1, bus_type* bus2, BranchData& data);
56+
Branch(bus_type* bus1, bus_type* bus2, model_data_type& data);
6957
virtual ~Branch();
7058

7159
virtual int allocate() override;
@@ -154,8 +142,8 @@ namespace GridKit
154142
real_type X_;
155143
real_type G_;
156144
real_type B_;
157-
const IdxT bus1ID_;
158-
const IdxT bus2ID_;
145+
const IdxT bus1_id_;
146+
const IdxT bus2_id_;
159147
};
160148

161149
} // namespace PhasorDynamics
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @file BranchData.hpp
3+
* @author Slaven Peles (peless@ornl.gov)
4+
* @brief Modeling data for branches (transmission lines)
5+
*
6+
*/
7+
#pragma once
8+
9+
namespace GridKit
10+
{
11+
namespace PhasorDynamics
12+
{
13+
/**
14+
* @brief Contains modeling data for a Branch
15+
*
16+
* @tparam RealT Real parameter data type
17+
* @tparam IdxT Integer parameter data type
18+
*
19+
* Integer parameters are of the same type as matrix and vector indices.
20+
*
21+
* @todo Decide on naming scheme for model parameters.
22+
*/
23+
template <typename RealT, typename IdxT>
24+
struct BranchData
25+
{
26+
RealT R{0.0}; ///< line series resistance
27+
RealT X{0.0}; ///< line series reactance
28+
RealT G{0.0}; ///< line shunt conductance
29+
RealT B{0.0}; ///< line shunt charging
30+
31+
IdxT bus1_id{0}; ///< Unique ID of bus 1
32+
IdxT bus2_id{0}; ///< Unique ID of bus 2
33+
};
34+
} // namespace PhasorDynamics
35+
} // namespace GridKit

0 commit comments

Comments
 (0)