-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest_parse_bus_row.cpp
More file actions
71 lines (59 loc) · 1.71 KB
/
Copy pathtest_parse_bus_row.cpp
File metadata and controls
71 lines (59 loc) · 1.71 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
61
62
63
64
65
66
67
68
69
70
71
#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"(
%% bus data
mpc.bus = [
1 2 0 0 0 0 1 1 0 230 1 1.1 0.0;
2 1 300 98.61 0 0 1 1 0 230 1 1.1 0.0;
3 2 300 98.61 0 0 1 1 0 230 1 1.1 0.0;
4 3 400 131.47 0 0 1 1 0 230 1 1.1 0.0;
5 2 0 0 0 0 1 1 0 230 1 1.1 0.9;
];
)"};
} // namespace
int main(int /* argc */, char** /* argv */)
{
int fail = 0;
std::vector<BusData<RealT, IdxT>> bus_answer{
{1, 2, 0, 0, 1, 1, 0, 230, 1, 1.1, 0.0},
{2, 1, 0, 0, 1, 1, 0, 230, 1, 1.1, 0.0},
{3, 2, 0, 0, 1, 1, 0, 230, 1, 1.1, 0.0},
{4, 3, 0, 0, 1, 1, 0, 230, 1, 1.1, 0.0},
{5, 2, 0, 0, 1, 1, 0, 230, 1, 1.1, 0.9},
};
std::vector<LoadData<RealT, IdxT>> load_answer{
{1, 0, 0},
{2, 300, 98.61},
{3, 300, 98.61},
{4, 400, 131.47},
{5, 0, 0},
};
{
SystemModelData<RealT, IdxT> mp;
std::istringstream iss(matpower_data);
GridKit::readMatPower(mp, iss);
if (!isEqual(mp.bus, bus_answer))
fail++;
std::cout << "After reading the bus component, fail == " << fail << "\n";
}
{
SystemModelData<RealT, IdxT> mp;
std::istringstream iss(matpower_data);
GridKit::readMatPower(mp, iss);
if (!isEqual(mp.load, load_answer))
fail++;
std::cout << "After reading the bus component, fail == " << fail << "\n";
}
std::cout << "Tests " << (fail ? "FAILED" : "PASSED") << "\n";
return fail;
}