-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest_parse_branch_row.cpp
More file actions
60 lines (47 loc) · 1.68 KB
/
Copy pathtest_parse_branch_row.cpp
File metadata and controls
60 lines (47 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include "MatPowerTesting.hpp"
#include <Model/PowerFlow/MatpowerParser.hpp>
#include <Model/PowerFlow/PowerFlowData.hpp>
using namespace GridKit;
using namespace GridKit::Testing;
using namespace GridKit::PowerFlowData;
namespace
{
using IdxT = int;
using RealT = double;
static const std::string matpower_data{
R"(
%% branch data
% fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax
mpc.branch = [
1 2 0.00281 0.0281 0.00712 400 400 400 0 0 1 -360 360;
1 4 0.00304 0.0304 0.00658 0 0 0 0 0 1 -360 360;
1 5 0.00064 0.0064 0.03126 0 0 0 0 0 1 -360 360;
2 3 0.00108 0.0108 0.01852 0 0 0 0 0 1 -360 360;
3 4 0.00297 0.0297 0.00674 0 0 0 0 0 1 -360 360;
4 5 0.00297 0.0297 0.00674 240 240 240 0 0 1 -360 360;
];
)"};
} // namespace
int main(int /* argc */, char** /* argv */)
{
int fail = 0;
std::vector<BranchData<RealT, IdxT>> branch_answer{
{1, 2, 0.00281, 0.0281, 0.00712, 400, 400, 400, 0, 0, 1, -360, 360},
{1, 4, 0.00304, 0.0304, 0.00658, 0, 0, 0, 0, 0, 1, -360, 360},
{1, 5, 0.00064, 0.0064, 0.03126, 0, 0, 0, 0, 0, 1, -360, 360},
{2, 3, 0.00108, 0.0108, 0.01852, 0, 0, 0, 0, 0, 1, -360, 360},
{3, 4, 0.00297, 0.0297, 0.00674, 0, 0, 0, 0, 0, 1, -360, 360},
{4, 5, 0.00297, 0.0297, 0.00674, 240, 240, 240, 0, 0, 1, -360, 360},
};
SystemModelData<RealT, IdxT> mp;
{
std::istringstream iss(matpower_data);
GridKit::readMatPower(mp, iss);
if (!isEqual(mp.branch, branch_answer))
fail++;
std::cout << "After reading the branch component, fail == " << fail << "\n";
}
std::cout << "Tests " << (fail ? "FAILED" : "PASSED") << "\n";
return fail;
}