power-grid-model 1.10.17__py3-none-win_amd64.whl → 1.12.119__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of power-grid-model might be problematic. Click here for more details.
- power_grid_model/__init__.py +54 -29
- power_grid_model/_core/__init__.py +3 -3
- power_grid_model/_core/buffer_handling.py +507 -478
- power_grid_model/_core/data_handling.py +195 -141
- power_grid_model/_core/data_types.py +142 -0
- power_grid_model/_core/dataset_definitions.py +109 -109
- power_grid_model/_core/enum.py +226 -0
- power_grid_model/_core/error_handling.py +215 -198
- power_grid_model/_core/errors.py +134 -0
- power_grid_model/_core/index_integer.py +17 -17
- power_grid_model/_core/options.py +71 -69
- power_grid_model/_core/power_grid_core.py +577 -562
- power_grid_model/_core/power_grid_dataset.py +545 -490
- power_grid_model/_core/power_grid_meta.py +262 -244
- power_grid_model/_core/power_grid_model.py +1025 -687
- power_grid_model/_core/power_grid_model_c/__init__.py +3 -0
- power_grid_model/_core/power_grid_model_c/bin/power_grid_model_c.dll +0 -0
- power_grid_model/_core/power_grid_model_c/get_pgm_dll_path.py +63 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/basics.h +251 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/buffer.h +108 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset.h +332 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +1060 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/handle.h +111 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/meta_data.h +189 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/model.h +130 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/options.h +142 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/serialization.h +118 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c.h +36 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/basics.hpp +65 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/buffer.hpp +61 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/dataset.hpp +224 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/handle.hpp +108 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/meta_data.hpp +84 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/model.hpp +63 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/options.hpp +52 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/serialization.hpp +124 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/utils.hpp +81 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp.hpp +19 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfig.cmake +37 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfigVersion.cmake +65 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets-release.cmake +19 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets.cmake +144 -0
- power_grid_model/_core/power_grid_model_c/lib/power_grid_model_c.lib +0 -0
- power_grid_model/_core/power_grid_model_c/share/LICENSE +292 -0
- power_grid_model/_core/power_grid_model_c/share/README.md +15 -0
- power_grid_model/_core/serialization.py +319 -317
- power_grid_model/_core/typing.py +20 -0
- power_grid_model/{_utils.py → _core/utils.py} +798 -783
- power_grid_model/data_types.py +321 -319
- power_grid_model/enum.py +27 -214
- power_grid_model/errors.py +37 -119
- power_grid_model/typing.py +43 -48
- power_grid_model/utils.py +529 -400
- power_grid_model/validation/__init__.py +25 -10
- power_grid_model/validation/{rules.py → _rules.py} +1167 -962
- power_grid_model/validation/{validation.py → _validation.py} +1172 -1015
- power_grid_model/validation/assertions.py +93 -92
- power_grid_model/validation/errors.py +602 -524
- power_grid_model/validation/utils.py +313 -318
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info}/METADATA +162 -165
- power_grid_model-1.12.119.dist-info/RECORD +65 -0
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info}/WHEEL +1 -1
- power_grid_model-1.12.119.dist-info/entry_points.txt +3 -0
- power_grid_model/_core/_power_grid_core.dll +0 -0
- power_grid_model-1.10.17.dist-info/RECORD +0 -32
- power_grid_model-1.10.17.dist-info/top_level.txt +0 -1
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @brief header file which includes handle functions
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
#ifndef POWER_GRID_MODEL_C_HANDLE_H
|
|
12
|
+
#define POWER_GRID_MODEL_C_HANDLE_H
|
|
13
|
+
|
|
14
|
+
#include "basics.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief Create a new handle.
|
|
22
|
+
*
|
|
23
|
+
* A handle object is needed to store error information.
|
|
24
|
+
* If you run it in multi-threading at user side, each thread should have unique handle.
|
|
25
|
+
* The handle should be destroyed by PGM_destroy_handle().
|
|
26
|
+
*
|
|
27
|
+
* @return A pointer to the created handle.
|
|
28
|
+
*/
|
|
29
|
+
PGM_API PGM_Handle* PGM_create_handle(void);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @brief Destroy the handle.
|
|
33
|
+
*
|
|
34
|
+
* @param handle The pointer to the handle created by PGM_create_handle().
|
|
35
|
+
*/
|
|
36
|
+
PGM_API void PGM_destroy_handle(PGM_Handle* handle);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @brief Get error code of last operation.
|
|
40
|
+
*
|
|
41
|
+
* The behavior is implementation-defined if the handle is NULL.
|
|
42
|
+
*
|
|
43
|
+
* @param handle The pointer to the handle you just used for an operation.
|
|
44
|
+
* @return The error code, see #PGM_ErrorCode .
|
|
45
|
+
*/
|
|
46
|
+
PGM_API PGM_Idx PGM_error_code(PGM_Handle const* handle);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @brief Get error message of last operation.
|
|
50
|
+
*
|
|
51
|
+
* If the error code is PGM_batch_error.
|
|
52
|
+
* Use PGM_n_failed_scenarios(), PGM_failed_scenarios(), and PGM_batch_errors() to retrieve the detail.
|
|
53
|
+
*
|
|
54
|
+
* The behavior is implementation-defined if the handle is NULL.
|
|
55
|
+
*
|
|
56
|
+
* @param handle The pointer to the handle you just used for an operation.
|
|
57
|
+
* @return A char const* poiner to a zero terminated string.
|
|
58
|
+
* The pointer is not valid if you execute another operation.
|
|
59
|
+
* You need to copy the string in your own data.
|
|
60
|
+
*/
|
|
61
|
+
PGM_API char const* PGM_error_message(PGM_Handle const* handle);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @brief Get the number of failed scenarios. Only applicable when you just executed a batch calculation.
|
|
65
|
+
*
|
|
66
|
+
* The behavior is implementation-defined if the handle is NULL.
|
|
67
|
+
*
|
|
68
|
+
* @param handle The pointer to the handle you just used for a batch calculation.
|
|
69
|
+
* @return The number of failed scenarios.
|
|
70
|
+
*/
|
|
71
|
+
PGM_API PGM_Idx PGM_n_failed_scenarios(PGM_Handle const* handle);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @brief Get the list of failed scenarios, Only applicable when you just execute a batch calculation.
|
|
75
|
+
*
|
|
76
|
+
* The behavior is implementation-defined if the handle is NULL.
|
|
77
|
+
*
|
|
78
|
+
* @param handle The pointer to the handle you just used for a batch calculation.
|
|
79
|
+
* @return A pointer to a PGM_Idx array with length returned by PGM_n_failed_scenarios().
|
|
80
|
+
* The pointer is not valid if you execute another operation.
|
|
81
|
+
* You need to copy the array in your own data.
|
|
82
|
+
*/
|
|
83
|
+
PGM_API PGM_Idx const* PGM_failed_scenarios(PGM_Handle const* handle);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @brief Get the list of batch errors. Only applicable when you just execute a batch calculation.
|
|
87
|
+
*
|
|
88
|
+
* The behavior is implementation-defined if the handle is NULL.
|
|
89
|
+
*
|
|
90
|
+
* @param handle The pointer to the handle you just used for a batch calculation.
|
|
91
|
+
* @return A pointer to a char const* array with length returned by PGM_n_failed_scenarios().
|
|
92
|
+
* Each entry is a zero terminated string.
|
|
93
|
+
* The pointer is not valid if you execute another operation.
|
|
94
|
+
* You need to copy the array (and the string) in your own data.
|
|
95
|
+
*/
|
|
96
|
+
PGM_API char const** PGM_batch_errors(PGM_Handle const* handle);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @brief Clear and reset the handle.
|
|
100
|
+
*
|
|
101
|
+
* The behavior is implementation-defined if the handle is NULL.
|
|
102
|
+
*
|
|
103
|
+
* @param handle The pointer to the handle.
|
|
104
|
+
*/
|
|
105
|
+
PGM_API void PGM_clear_error(PGM_Handle* handle);
|
|
106
|
+
|
|
107
|
+
#ifdef __cplusplus
|
|
108
|
+
}
|
|
109
|
+
#endif
|
|
110
|
+
|
|
111
|
+
#endif
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @brief header file which includes meta data functions
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
#ifndef POWER_GRID_MODEL_C_META_DATA_H
|
|
12
|
+
#define POWER_GRID_MODEL_C_META_DATA_H
|
|
13
|
+
|
|
14
|
+
#include "basics.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief Get number of datasets.
|
|
22
|
+
*
|
|
23
|
+
* @param handle
|
|
24
|
+
* @return The number of datasets.
|
|
25
|
+
*/
|
|
26
|
+
PGM_API PGM_Idx PGM_meta_n_datasets(PGM_Handle* handle);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @brief Get pointer of idx-th dataset.
|
|
30
|
+
*
|
|
31
|
+
* @param handle
|
|
32
|
+
* @param idx The sequence number, should be between [0, PGM_meta_n_datasets()).
|
|
33
|
+
* @return The pointer to the idx-th dataset. The pointer is permanantly valid.
|
|
34
|
+
* Or a NULL if your input is out of bound.
|
|
35
|
+
*/
|
|
36
|
+
PGM_API PGM_MetaDataset const* PGM_meta_get_dataset_by_idx(PGM_Handle* handle, PGM_Idx idx);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @brief Get pointer of dataset by name.
|
|
40
|
+
*
|
|
41
|
+
* @param handle
|
|
42
|
+
* @param dataset The name of the dataset.
|
|
43
|
+
* @return The pointer to the dataset with that name. The pointer is permanantly valid.
|
|
44
|
+
* Or a NULL if your input is out of bound.
|
|
45
|
+
*/
|
|
46
|
+
PGM_API PGM_MetaDataset const* PGM_meta_get_dataset_by_name(PGM_Handle* handle, char const* dataset);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @brief Get name of the dataset.
|
|
50
|
+
*
|
|
51
|
+
* @param handle
|
|
52
|
+
* @param dataset The pointer to a dataset object.
|
|
53
|
+
* @return The name of the dataset in a char const*. The pointer is permanantly valid.
|
|
54
|
+
*/
|
|
55
|
+
PGM_API char const* PGM_meta_dataset_name(PGM_Handle* handle, PGM_MetaDataset const* dataset);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @brief Get the number of components for a dataset.
|
|
59
|
+
*
|
|
60
|
+
* @param handle
|
|
61
|
+
* @param dataset The pointer to the dataset.
|
|
62
|
+
* @return Number of components.
|
|
63
|
+
*/
|
|
64
|
+
PGM_API PGM_Idx PGM_meta_n_components(PGM_Handle* handle, PGM_MetaDataset const* dataset);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @brief Get pointer of idx-th component of a dataset.
|
|
68
|
+
*
|
|
69
|
+
* @param handle
|
|
70
|
+
* @param dataset The pointer to the dataset.
|
|
71
|
+
* @param idx The sequence number, should be between [0, PGM_meta_n_components()).
|
|
72
|
+
* @return The pointer to the idx-th component. The pointer is permanantly valid.
|
|
73
|
+
* Or a NULL if your input is out of bound.
|
|
74
|
+
*/
|
|
75
|
+
PGM_API PGM_MetaComponent const* PGM_meta_get_component_by_idx(PGM_Handle* handle, PGM_MetaDataset const* dataset,
|
|
76
|
+
PGM_Idx idx);
|
|
77
|
+
/**
|
|
78
|
+
* @brief Get pointer of a component by name.
|
|
79
|
+
*
|
|
80
|
+
* @param handle
|
|
81
|
+
* @param dataset The name of the dataset.
|
|
82
|
+
* @param component The name of the component.
|
|
83
|
+
* @return The pointer to the component with that name. The pointer is permanantly valid.
|
|
84
|
+
* Or a NULL if your input is out of bound.
|
|
85
|
+
*/
|
|
86
|
+
PGM_API PGM_MetaComponent const* PGM_meta_get_component_by_name(PGM_Handle* handle, char const* dataset,
|
|
87
|
+
char const* component);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @brief Get name of component.
|
|
91
|
+
*
|
|
92
|
+
* @param handle
|
|
93
|
+
* @param component The pointer to the component.
|
|
94
|
+
* @return The name of the component in a char const*. The pointer is permanantly valid.
|
|
95
|
+
*/
|
|
96
|
+
PGM_API char const* PGM_meta_component_name(PGM_Handle* handle, PGM_MetaComponent const* component);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @brief Get size of the component.
|
|
100
|
+
*
|
|
101
|
+
* @param handle
|
|
102
|
+
* @param component The pointer to the component.
|
|
103
|
+
* @return Size of the component.
|
|
104
|
+
*/
|
|
105
|
+
PGM_API size_t PGM_meta_component_size(PGM_Handle* handle, PGM_MetaComponent const* component);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @brief Get alignment of the component.
|
|
109
|
+
*
|
|
110
|
+
* @param handle
|
|
111
|
+
* @param component The pointer to the component.
|
|
112
|
+
* @return Alignment of the component.
|
|
113
|
+
*/
|
|
114
|
+
PGM_API size_t PGM_meta_component_alignment(PGM_Handle* handle, PGM_MetaComponent const* component);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @brief Get number of attributes of the component.
|
|
118
|
+
*
|
|
119
|
+
* @param handle
|
|
120
|
+
* @param component The pointer to the component.
|
|
121
|
+
* @return Number of attributes.
|
|
122
|
+
*/
|
|
123
|
+
PGM_API PGM_Idx PGM_meta_n_attributes(PGM_Handle* handle, PGM_MetaComponent const* component);
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @brief Get pointer of idx-th attribute of a component.
|
|
127
|
+
*
|
|
128
|
+
* @param handle
|
|
129
|
+
* @param component The pointer to the component.
|
|
130
|
+
* @param idx The sequence number, should be between [0, PGM_meta_n_attributes())
|
|
131
|
+
* @return The pointer to the idx-th attribute. The pointer is permanantly valid.
|
|
132
|
+
* Or a NULL if your input is out of bound.
|
|
133
|
+
*/
|
|
134
|
+
PGM_API PGM_MetaAttribute const* PGM_meta_get_attribute_by_idx(PGM_Handle* handle, PGM_MetaComponent const* component,
|
|
135
|
+
PGM_Idx idx);
|
|
136
|
+
/**
|
|
137
|
+
* @brief Get pointer of a attribute by name.
|
|
138
|
+
*
|
|
139
|
+
* @param handle
|
|
140
|
+
* @param dataset The name of the dataset.
|
|
141
|
+
* @param component The name of the component.
|
|
142
|
+
* @param attribute The name of the attribute.
|
|
143
|
+
* @return The pointer to the component with that name. The pointer is permanantly valid.
|
|
144
|
+
* Or a NULL if your input is out of bound.
|
|
145
|
+
*/
|
|
146
|
+
PGM_API PGM_MetaAttribute const* PGM_meta_get_attribute_by_name(PGM_Handle* handle, char const* dataset,
|
|
147
|
+
char const* component, char const* attribute);
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @brief Get attribute name.
|
|
151
|
+
*
|
|
152
|
+
* @param handle
|
|
153
|
+
* @param attribute The pointer to attribute.
|
|
154
|
+
* @return The name of the attribute in char const*. The pointer is permanantly valid.
|
|
155
|
+
*/
|
|
156
|
+
PGM_API char const* PGM_meta_attribute_name(PGM_Handle* handle, PGM_MetaAttribute const* attribute);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @brief Get the type of an attribute.
|
|
160
|
+
*
|
|
161
|
+
* @param handle
|
|
162
|
+
* @param attribute The pointer to attribute.
|
|
163
|
+
* @return The type of the attribute as in enum PGM_CType.
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
PGM_API PGM_Idx PGM_meta_attribute_ctype(PGM_Handle* handle, PGM_MetaAttribute const* attribute);
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @brief Get the offset of an attribute in a component.
|
|
170
|
+
*
|
|
171
|
+
* @param handle
|
|
172
|
+
* @param attribute The pointer to attribute.
|
|
173
|
+
* @return The offset of this attribute.
|
|
174
|
+
*/
|
|
175
|
+
PGM_API size_t PGM_meta_attribute_offset(PGM_Handle* handle, PGM_MetaAttribute const* attribute);
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @brief Get whether the system is little endian.
|
|
179
|
+
*
|
|
180
|
+
* @param handle
|
|
181
|
+
* @return 1 if the system is litten endian; 0 if the system is big endian.
|
|
182
|
+
*/
|
|
183
|
+
PGM_API int PGM_is_little_endian(PGM_Handle* handle);
|
|
184
|
+
|
|
185
|
+
#ifdef __cplusplus
|
|
186
|
+
}
|
|
187
|
+
#endif
|
|
188
|
+
|
|
189
|
+
#endif
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @brief header file which includes model functions
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
#ifndef POWER_GRID_MODEL_C_MODEL_H
|
|
12
|
+
#define POWER_GRID_MODEL_C_MODEL_H
|
|
13
|
+
|
|
14
|
+
#include "basics.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief Create a new instance of Power Grid Model.
|
|
22
|
+
*
|
|
23
|
+
* This is the main function to create a new model.
|
|
24
|
+
* You need to prepare the buffer data for input.
|
|
25
|
+
* The returned model need to be freed by PGM_destroy_model()
|
|
26
|
+
*
|
|
27
|
+
* @param handle
|
|
28
|
+
* @param system_frequency The frequency of the system, usually 50 or 60 Hz
|
|
29
|
+
* @param input_dataset Pointer to an instance of PGM_ConstDataset. It should have data type "input".
|
|
30
|
+
* @return The opaque pointer to the created model.
|
|
31
|
+
* If there are errors during the creation, a NULL is returned.
|
|
32
|
+
* Use PGM_error_code() and PGM_error_message() to check the error.
|
|
33
|
+
*/
|
|
34
|
+
PGM_API PGM_PowerGridModel* PGM_create_model(PGM_Handle* handle, double system_frequency,
|
|
35
|
+
PGM_ConstDataset const* input_dataset);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @brief Update the model by changing mutable attributes of some elements.
|
|
39
|
+
*
|
|
40
|
+
* Use PGM_error_code() and PGM_error_message() to check if there are errors in the update.
|
|
41
|
+
* NOTE: The model will be in an undefined state after errors occured during the update and should be destroyed.
|
|
42
|
+
*
|
|
43
|
+
* @param handle
|
|
44
|
+
* @param model A pointer to an existing model.
|
|
45
|
+
* @param update_dataset Pointer to an instance of PGM_ConstDataset. It should have data type "update".
|
|
46
|
+
* @return
|
|
47
|
+
*/
|
|
48
|
+
PGM_API void PGM_update_model(PGM_Handle* handle, PGM_PowerGridModel* model, PGM_ConstDataset const* update_dataset);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @brief Make a copy of an existing model.
|
|
52
|
+
*
|
|
53
|
+
* The returned model need to be freed by PGM_destroy_model()
|
|
54
|
+
*
|
|
55
|
+
* @param handle
|
|
56
|
+
* @param model A pointer to an existing model
|
|
57
|
+
* @return A opaque pointer to the new copy.
|
|
58
|
+
* If there are errors during the creation, a NULL is returned.
|
|
59
|
+
* Use PGM_error_code() and PGM_error_message() to check the error.
|
|
60
|
+
*/
|
|
61
|
+
PGM_API PGM_PowerGridModel* PGM_copy_model(PGM_Handle* handle, PGM_PowerGridModel const* model);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @brief Get the sequence numbers based on list of ids in a given component.
|
|
65
|
+
*
|
|
66
|
+
* For example, if there are 5 nodes in the model with id [10, 2, 5, 15, 30].
|
|
67
|
+
* We have a node ID list of [2, 5, 15, 5, 10, 10, 30].
|
|
68
|
+
* We would like to know the sequence number of each element in the model.
|
|
69
|
+
* Calling this function should result in a sequence array of [1, 2, 3, 2, 0, 0, 4].
|
|
70
|
+
*
|
|
71
|
+
* If you supply a non-existing ID in the ID array, an error will be raised.
|
|
72
|
+
* Use PGM_error_code() and PGM_error_message() to check the error.
|
|
73
|
+
*
|
|
74
|
+
* @param handle
|
|
75
|
+
* @param model A pointer to an existing model.
|
|
76
|
+
* @param component A char const* string as component name.
|
|
77
|
+
* @param size The size of the ID array.
|
|
78
|
+
* @param ids A pointer to a #PGM_ID array buffer, this should be at least length of size.
|
|
79
|
+
* @param indexer A pointer to a #PGM_Idx array buffer. The results will be written to this array.
|
|
80
|
+
* The array should be pre-allocated with at least length of size.
|
|
81
|
+
*/
|
|
82
|
+
PGM_API void PGM_get_indexer(PGM_Handle* handle, PGM_PowerGridModel const* model, char const* component, PGM_Idx size,
|
|
83
|
+
PGM_ID const* ids, PGM_Idx* indexer);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @brief Execute a one-time or batch calculation.
|
|
87
|
+
*
|
|
88
|
+
* This is the main function to execute calculation.
|
|
89
|
+
* You can choose to execute one-time calculation or batch calculation,
|
|
90
|
+
* by controlling the batch_dataset argument.
|
|
91
|
+
* If batch_dataset == NULL, it is a one-time calculation.
|
|
92
|
+
* If batch_dataset != NULL, it is a batch calculation with batch update in the batch_dataset.
|
|
93
|
+
*
|
|
94
|
+
* The user can use the function set_next_cartesian_product_dimension() to combine multiple batch datasets
|
|
95
|
+
* to create a multi-dimension batch calculation using a linked list pattern. The calculation core will
|
|
96
|
+
* interpret the combined dataset as a cartesian product on a linked list of all the scenarios.
|
|
97
|
+
* Each batch dataset in the linked list represents one dimension of the cartesian product.
|
|
98
|
+
*
|
|
99
|
+
* You need to pre-allocate all output buffer.
|
|
100
|
+
*
|
|
101
|
+
* Use PGM_error_code() and PGM_error_message() to check the error.
|
|
102
|
+
*
|
|
103
|
+
* @param handle
|
|
104
|
+
* @param model A pointer to an existing model.
|
|
105
|
+
* @param opt A pointer to options, you need to pre-set all the calculation options you want.
|
|
106
|
+
* @param output_dataset A pointer to an instance of PGM_MutableDataset.
|
|
107
|
+
* The dataset should have type "*_output", depending on the type of dataset.
|
|
108
|
+
* You need to pre-allocate all output memory buffers.
|
|
109
|
+
* You do not need to output all the component types as in the input.
|
|
110
|
+
* For example, you can choose only create output buffers for node, not for line.
|
|
111
|
+
* @param batch_dataset A pointer to an instance of PGM_ConstDataset for batch calculation.
|
|
112
|
+
* Or NULL for single calculation.
|
|
113
|
+
* The dataset should have is_batch == true. The type of the dataset should be "update".
|
|
114
|
+
* @return
|
|
115
|
+
*/
|
|
116
|
+
PGM_API void PGM_calculate(PGM_Handle* handle, PGM_PowerGridModel* model, PGM_Options const* opt,
|
|
117
|
+
PGM_MutableDataset const* output_dataset, PGM_ConstDataset const* batch_dataset);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @brief Destroy the model returned by PGM_create_model() or PGM_copy_model().
|
|
121
|
+
*
|
|
122
|
+
* @param model The pointer to the model.
|
|
123
|
+
*/
|
|
124
|
+
PGM_API void PGM_destroy_model(PGM_PowerGridModel* model);
|
|
125
|
+
|
|
126
|
+
#ifdef __cplusplus
|
|
127
|
+
}
|
|
128
|
+
#endif
|
|
129
|
+
|
|
130
|
+
#endif
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @brief header file which includes options functions
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
#ifndef POWER_GRID_MODEL_C_OPTIONS_H
|
|
12
|
+
#define POWER_GRID_MODEL_C_OPTIONS_H
|
|
13
|
+
|
|
14
|
+
#include "basics.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief Create an option instance.
|
|
22
|
+
*
|
|
23
|
+
* The option is needed to run calculations.
|
|
24
|
+
* This function create a new option instance with the following default values:
|
|
25
|
+
* - calculation_type: PGM_power_flow
|
|
26
|
+
* - calculation_method: PGM_default_method
|
|
27
|
+
* - symmetric: 1
|
|
28
|
+
* - err_tol: 1e-8
|
|
29
|
+
* - max_iter: 20
|
|
30
|
+
* - threading: -1
|
|
31
|
+
* - short_circuit_voltage_scaling: PGM_short_circuit_voltage_scaling_maximum
|
|
32
|
+
* - experimental_features: PGM_experimental_features_disabled
|
|
33
|
+
*
|
|
34
|
+
* @param handle
|
|
35
|
+
* @return The pointer to the option instance. Should be freed by PGM_destroy_options().
|
|
36
|
+
*/
|
|
37
|
+
PGM_API PGM_Options* PGM_create_options(PGM_Handle* handle);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @brief Free an option instance.
|
|
41
|
+
*
|
|
42
|
+
* @param opt The pointer to the option instance created by PGM_create_options().
|
|
43
|
+
*/
|
|
44
|
+
PGM_API void PGM_destroy_options(PGM_Options* opt);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @brief Specify type of calculation.
|
|
48
|
+
*
|
|
49
|
+
* @param handle
|
|
50
|
+
* @param opt The pointer to the option instance.
|
|
51
|
+
* @param type See #PGM_CalculationType .
|
|
52
|
+
*/
|
|
53
|
+
PGM_API void PGM_set_calculation_type(PGM_Handle* handle, PGM_Options* opt, PGM_Idx type);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @brief Specify method of calculation.
|
|
57
|
+
*
|
|
58
|
+
* @param handle
|
|
59
|
+
* @param opt The pointer to the option instance.
|
|
60
|
+
* @param method See #PGM_CalculationMethod .
|
|
61
|
+
*/
|
|
62
|
+
PGM_API void PGM_set_calculation_method(PGM_Handle* handle, PGM_Options* opt, PGM_Idx method);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @brief Specify if we are calculating symmetrically or asymmetrically.
|
|
66
|
+
*
|
|
67
|
+
* @param handle
|
|
68
|
+
* @param opt The pointer to the option instance.
|
|
69
|
+
* @param sym See #PGM_CalculationSymmetry . 1 for symmetric calculation; 0 for asymmetric calculation.
|
|
70
|
+
*/
|
|
71
|
+
PGM_API void PGM_set_symmetric(PGM_Handle* handle, PGM_Options* opt, PGM_Idx sym);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @brief Specify the error tolerance to stop iterations. Only applicable if using iterative method.
|
|
75
|
+
*
|
|
76
|
+
* It is in terms of voltage deviation per iteration in p.u.
|
|
77
|
+
*
|
|
78
|
+
* @param handle
|
|
79
|
+
* @param opt The pointer to the option instance.
|
|
80
|
+
* @param err_tol The relative votlage deviation tolerance.
|
|
81
|
+
*/
|
|
82
|
+
PGM_API void PGM_set_err_tol(PGM_Handle* handle, PGM_Options* opt, double err_tol);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @brief Specify maximum number of iterations. Only applicable if using iterative method.
|
|
86
|
+
*
|
|
87
|
+
* @param handle
|
|
88
|
+
* @param opt The pointer to the option instance.
|
|
89
|
+
* @param max_iter The maximum number of iterations.
|
|
90
|
+
*/
|
|
91
|
+
PGM_API void PGM_set_max_iter(PGM_Handle* handle, PGM_Options* opt, PGM_Idx max_iter);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @brief Specify the multi-threading strategy. Only applicable for batch calculation.
|
|
95
|
+
*
|
|
96
|
+
* @param handle
|
|
97
|
+
* @param opt The pointer to the option instance.
|
|
98
|
+
* @param threading The value of the threading setting. See below:
|
|
99
|
+
* - -1: No multi-threading, calculate sequentially.
|
|
100
|
+
* - 0: use number of machine available threads.
|
|
101
|
+
* - >0: specify number of threads you want to calculate in parallel.
|
|
102
|
+
*/
|
|
103
|
+
PGM_API void PGM_set_threading(PGM_Handle* handle, PGM_Options* opt, PGM_Idx threading);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @brief Specify the voltage scaling min/max for short circuit calculations
|
|
107
|
+
*
|
|
108
|
+
* @param handle
|
|
109
|
+
* @param opt pointer to option instance
|
|
110
|
+
* @param short_circuit_voltage_scaling See #PGM_ShortCircuitVoltageScaling
|
|
111
|
+
*/
|
|
112
|
+
PGM_API void PGM_set_short_circuit_voltage_scaling(PGM_Handle* handle, PGM_Options* opt,
|
|
113
|
+
PGM_Idx short_circuit_voltage_scaling);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @brief Specify the tap changing strategy for power flow calculations
|
|
117
|
+
*
|
|
118
|
+
* @param handle
|
|
119
|
+
* @param opt pointer to option instance
|
|
120
|
+
* @param tap_changing_strategy See #PGM_TapChangingStrategy
|
|
121
|
+
*/
|
|
122
|
+
PGM_API void PGM_set_tap_changing_strategy(PGM_Handle* handle, PGM_Options* opt, PGM_Idx tap_changing_strategy);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @brief Enable/disable experimental features.
|
|
126
|
+
*
|
|
127
|
+
* [Danger mode]
|
|
128
|
+
*
|
|
129
|
+
* The behavior of experimental features may not be final and no stability guarantees are made to the users.
|
|
130
|
+
* Features marked as 'experimental' as well as the behavior of experimental functionality itself may change over time.
|
|
131
|
+
*
|
|
132
|
+
* @param handle
|
|
133
|
+
* @param opt pointer to option instance
|
|
134
|
+
* @param experimental_features See #PGM_ExperimentalFeatures
|
|
135
|
+
*/
|
|
136
|
+
PGM_API void PGM_set_experimental_features(PGM_Handle* handle, PGM_Options* opt, PGM_Idx experimental_features);
|
|
137
|
+
|
|
138
|
+
#ifdef __cplusplus
|
|
139
|
+
}
|
|
140
|
+
#endif
|
|
141
|
+
|
|
142
|
+
#endif
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @brief header file which includes serialization functions
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
#ifndef POWER_GRID_MODEL_C_SERIALIZATION_H
|
|
12
|
+
#define POWER_GRID_MODEL_C_SERIALIZATION_H
|
|
13
|
+
|
|
14
|
+
#include "basics.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief Create a deserializer from binary buffer/byte stream.
|
|
22
|
+
* @param handle
|
|
23
|
+
* @param data The pointer to the byte stream.
|
|
24
|
+
* @param size The size of the byte stream.
|
|
25
|
+
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
26
|
+
* @return A pointer to the deserializer instance. Should be freed by PGM_destroy_deserializer().
|
|
27
|
+
* Returns NULL if errors occured (check the handle for error information).
|
|
28
|
+
*/
|
|
29
|
+
PGM_API PGM_Deserializer* PGM_create_deserializer_from_binary_buffer(PGM_Handle* handle, char const* data, PGM_Idx size,
|
|
30
|
+
PGM_Idx serialization_format);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @brief Create a deserializer from a null terminated C string.
|
|
34
|
+
* @param handle
|
|
35
|
+
* @param data_string The pointer to the null-terminated C string.
|
|
36
|
+
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
37
|
+
* @return A pointer to the deserializer instance. Should be freed by PGM_destroy_deserializer().
|
|
38
|
+
* Returns NULL if errors occured (check the handle for error information).
|
|
39
|
+
*/
|
|
40
|
+
PGM_API PGM_Deserializer* PGM_create_deserializer_from_null_terminated_string(PGM_Handle* handle,
|
|
41
|
+
char const* data_string,
|
|
42
|
+
PGM_Idx serialization_format);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @brief Get the PGM_WritableDataset object from the deserializer.
|
|
46
|
+
* @param handle
|
|
47
|
+
* @param deserializer The pointer to the deserializer.
|
|
48
|
+
* @return A pointer the instance of PGM_WritableDataset.
|
|
49
|
+
* The pointer has the same lifetime as the deserializer.
|
|
50
|
+
* Use PGM_writable_dataset_get_info() to get the information of the dataset.
|
|
51
|
+
* Use PGM_writable_dataset_set_buffer() to set buffer.
|
|
52
|
+
*/
|
|
53
|
+
PGM_API PGM_WritableDataset* PGM_deserializer_get_dataset(PGM_Handle* handle, PGM_Deserializer* deserializer);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @brief Parse the dataset and write to the user-provided buffers.
|
|
57
|
+
* The buffers must be set through PGM_writable_dataset_set_buffer().
|
|
58
|
+
* @param handle
|
|
59
|
+
* @param deserializer The pointer to the deserializer
|
|
60
|
+
* @return No return value; check handle for error.
|
|
61
|
+
*/
|
|
62
|
+
PGM_API void PGM_deserializer_parse_to_buffer(PGM_Handle* handle, PGM_Deserializer* deserializer);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @brief Destory deserializer
|
|
66
|
+
* @param deserializer pointer to deserializer
|
|
67
|
+
* @return
|
|
68
|
+
*/
|
|
69
|
+
PGM_API void PGM_destroy_deserializer(PGM_Deserializer* deserializer);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @brief Create a serializer object based on input dataset, the buffers must be set in advance.
|
|
73
|
+
* @param handle
|
|
74
|
+
* @param dataset A pointer to an instance of PGM_ConstDataset
|
|
75
|
+
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
76
|
+
* @return A pointer to the new serializer object. Should be freed by PGM_destroy_serializer()
|
|
77
|
+
* Returns NULL if errors occured (check the handle for error information).
|
|
78
|
+
*/
|
|
79
|
+
PGM_API PGM_Serializer* PGM_create_serializer(PGM_Handle* handle, PGM_ConstDataset const* dataset,
|
|
80
|
+
PGM_Idx serialization_format);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @brief Serialize the dataset into a binary buffer format.
|
|
84
|
+
* @param handle
|
|
85
|
+
* @param serializer A pointer to an existing serializer.
|
|
86
|
+
* @param use_compact_list 1 for use compact list per element of serialization; 0 for use dictionary per element.
|
|
87
|
+
* @param data Output argument: the data pointer of the packed buffer will be written to *data.
|
|
88
|
+
* @param size Output argument: the length of the packed buffer will be written to *size.
|
|
89
|
+
* @return No return value; check handle for error.
|
|
90
|
+
*/
|
|
91
|
+
PGM_API void PGM_serializer_get_to_binary_buffer(PGM_Handle* handle, PGM_Serializer* serializer,
|
|
92
|
+
PGM_Idx use_compact_list, char const** data, PGM_Idx* size);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @brief Serialize the dataset into a zero terminated C string.
|
|
96
|
+
* Only supported for uncompressed data formats.
|
|
97
|
+
* @param handle
|
|
98
|
+
* @param serializer A pointer to an existing serializer.
|
|
99
|
+
* @param use_compact_list 1 for use compact list per element of serialization; 0 for use dictionary per element.
|
|
100
|
+
* @param indent The indentation of the JSON, use -1 for no indent and no new line (compact format).
|
|
101
|
+
* @return A NULL-terminated json string.
|
|
102
|
+
* Returns NULL if errors occured (check the handle for error information).
|
|
103
|
+
*/
|
|
104
|
+
PGM_API char const* PGM_serializer_get_to_zero_terminated_string(PGM_Handle* handle, PGM_Serializer* serializer,
|
|
105
|
+
PGM_Idx use_compact_list, PGM_Idx indent);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @brief Destroy serializer.
|
|
109
|
+
* @param serializer The pointer to the serializer.
|
|
110
|
+
* @return
|
|
111
|
+
*/
|
|
112
|
+
PGM_API void PGM_destroy_serializer(PGM_Serializer* serializer);
|
|
113
|
+
|
|
114
|
+
#ifdef __cplusplus
|
|
115
|
+
}
|
|
116
|
+
#endif
|
|
117
|
+
|
|
118
|
+
#endif
|