-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcreate_chronics.hpp
More file actions
77 lines (64 loc) · 1.92 KB
/
create_chronics.hpp
File metadata and controls
77 lines (64 loc) · 1.92 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
72
73
74
75
76
77
/* Create Chronics hook.
*
* Author: Ritesh Karki <ritesh.karki@rwth-aachen.de>
* SPDX-FileCopyrightText: 2014-2025 Institute for Automation of Complex Power Systems, RWTH Aachen University
* SPDX-License-Identifier: Apache-2.0
*/
#include <filesystem>
#include <unordered_map>
#include <vector>
#include <nlohmann/json.hpp>
#include <villas/hook.hpp>
#include <villas/sample.hpp>
namespace villas {
namespace node {
struct GridMapping {
std::unordered_map<int, int> load_bus;
std::unordered_map<int, int> sgen_bus;
};
struct ChronicsOptions {
std::filesystem::path loads_dir;
std::filesystem::path sgens_dir;
std::filesystem::path grid_path;
std::filesystem::path output_dir;
int round_decimals = 3;
bool compress = true;
bool negate_sgens = true;
float voltage = 20.0;
static ChronicsOptions from_json(const json_t &cfg);
};
class ChronicsHook : public Hook {
public:
using Hook::Hook;
void run();
void flush();
GridMapping load_grid();
void discover_files();
void process_load_files();
void process_sgen_files();
void process_samples_from_file(const std::string &filename,
const std::vector<Sample *> &samples);
void round_values();
void write_outputs();
void discover_files_from_node(struct file *f);
void prepare() override;
void start() override;
void stop() override;
private:
ChronicsOptions options;
GridMapping mapping;
std::vector<std::filesystem::path> load_files;
std::vector<std::filesystem::path> sgen_files;
std::vector<std::vector<double>> load_p_columns;
std::vector<std::vector<double>> load_q_columns;
std::vector<std::vector<double>> prod_p_columns;
std::vector<std::vector<double>> prod_q_columns;
std::vector<std::vector<double>> prod_v_columns;
std::vector<std::string> column_names;
std::string load_col_names;
std::string sgen_col_names;
bool done;
unsigned sgen_idx;
};
} // namespace node
} // namespace villas