Skip to content

Commit e4a863f

Browse files
authored
Merge branch 'main' into feature/refactor-measured-values-statistics
2 parents 7f788a2 + ed725de commit e4a863f

File tree

99 files changed

+1461
-1443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1461
-1443
lines changed

.github/conda_pgm_env.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ dependencies:
1515
- nlohmann_json
1616
- msgpack-cxx
1717
- numpy
18+
- cmake
19+
- ninja
1820
# test deps
1921
- pytest
2022
- pytest-cov

.github/workflows/clang-tidy.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ concurrency:
4444

4545
jobs:
4646
clang-tidy:
47-
runs-on: ubuntu-22.04
47+
runs-on: ubuntu-24.04
4848
strategy:
4949
matrix:
5050
build-option: [ debug, release ]
@@ -60,10 +60,10 @@ jobs:
6060
- name: Install packages
6161
run: |
6262
sudo apt-get update
63-
sudo apt-get install -y ninja-build clang-15 clang-tidy-15
64-
sudo ln -s /usr/bin/clang-15 /usr/local/bin/clang
65-
sudo ln -s /usr/bin/clang++-15 /usr/local/bin/clang++
66-
sudo ln -s /usr/bin/clang-tidy-15 /usr/local/bin/clang-tidy
63+
sudo apt-get install -y ninja-build clang-18 clang-tidy-18
64+
sudo ln -s /usr/bin/clang-18 /usr/local/bin/clang
65+
sudo ln -s /usr/bin/clang++-18 /usr/local/bin/clang++
66+
sudo ln -s /usr/bin/clang-tidy-18 /usr/local/bin/clang-tidy
6767
6868
- name: Enable brew
6969
run: |

.github/workflows/main.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
xcode-version: latest-stable
216216

217217
- name: Build wheels
218-
uses: pypa/cibuildwheel@v2.23.0
218+
uses: pypa/cibuildwheel@v2.23.1
219219
# GitHub Actions specific build parameters
220220
env:
221221
# pass GitHub runner info into Linux container
@@ -235,10 +235,18 @@ jobs:
235235
strategy:
236236
matrix:
237237
os: ["ubuntu", "windows"] # We do not test conda for MacOS
238-
238+
include:
239+
- os: ubuntu
240+
shell: bash -el {0}
241+
- os: windows
242+
shell: powershell
243+
244+
env:
245+
POWER_GRID_MODEL_NO_BINARY_BUILD: 1
246+
239247
defaults:
240248
run:
241-
shell: bash -el {0}
249+
shell: ${{ matrix.shell }}
242250
steps:
243251
- uses: actions/checkout@v4
244252

@@ -253,8 +261,26 @@ jobs:
253261
run: |
254262
conda info
255263
conda list
256-
257-
- name: Build
264+
265+
- name: Build and install cmake target for Windows
266+
if: matrix.os == 'windows'
267+
run: |
268+
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
269+
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
270+
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
271+
272+
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/ -S .
273+
cmake --build build/ --verbose -j1
274+
cmake --install build/ --prefix ${env:CONDA_PREFIX}/Library
275+
276+
- name: Build and install cmake target for Linux
277+
if: matrix.os == 'ubuntu'
278+
run: |
279+
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/ -S . -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
280+
cmake --build build/ --verbose -j1
281+
cmake --install build/
282+
283+
- name: Build python
258284
run: python -m pip install . -vv --no-build-isolation --no-deps
259285

260286
- name: Test

docs/advanced_documentation/build-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export CXX=clang++-18 # or g++-13
210210
export CC=clang-18 # gcc-13
211211
export CMAKE_PREFIX_PATH=/home/linuxbrew/.linuxbrew
212212
export LLVM_COV=llvm-cov-18
213-
export CLANG_TIDY=clang-tidy-15 # only if you want to use one of the clang-tidy presets
213+
export CLANG_TIDY=clang-tidy-18 # only if you want to use one of the clang-tidy presets
214214
```
215215
216216
### Ubuntu Software Packages

docs/user_manual/calculations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ Power flow calculations that take the behavior of these regulators into account
628628

629629
The following control logic is used:
630630

631-
- Regulated transformers are ranked according to how close they are to {hoverxreftooltip}`sources <user_manual/components:source>` in terms of the amount of transformers inbetween.
631+
- Regulated transformers are ranked according to how close they are to {hoverxreftooltip}`sources <user_manual/components:source>` in terms of the amount of regulated transformers inbetween.
632632
- Transformers are regulated in order according to their ranks.
633633
- Initialize all transformers to their starting tap position (see {hoverxreftooltip}`user_manual/calculations:Initialization and exploitation of regulated transformers`)
634634
- Find the optimal state using the following procedure

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ using nlohmann::json;
4444
// visitor for json conversion
4545
struct JsonMapArrayData {
4646
size_t size{};
47-
msgpack::sbuffer buffer{};
47+
msgpack::sbuffer buffer;
4848
};
4949

5050
struct JsonSAXVisitor {
@@ -130,8 +130,8 @@ struct JsonSAXVisitor {
130130
throw SerializationError{ss.str()};
131131
}
132132

133-
std::stack<JsonMapArrayData> data_buffers{};
134-
msgpack::sbuffer root_buffer{};
133+
std::stack<JsonMapArrayData> data_buffers;
134+
msgpack::sbuffer root_buffer;
135135
};
136136

137137
// visitors for parsing
@@ -192,8 +192,15 @@ struct MapArrayVisitor : DefaultErrorVisitor<MapArrayVisitor<map_array>> {
192192
std::same_as<map_array, visit_map_t> || std::same_as<map_array, visit_map_array_t>;
193193
static constexpr bool enable_array =
194194
std::same_as<map_array, visit_array_t> || std::same_as<map_array, visit_map_array_t>;
195-
static constexpr std::string_view static_err_msg =
196-
enable_map ? (enable_array ? "Map or an array expected." : "Map expected.") : "Array expected.";
195+
static constexpr std::string_view static_err_msg = [] {
196+
if constexpr (enable_map && enable_array) {
197+
return "Map or an array expected.";
198+
} else if constexpr (enable_map) {
199+
return "Map expected.";
200+
} else {
201+
return "Array expected.";
202+
}
203+
}();
197204

198205
Idx size{};
199206
bool is_map{};
@@ -228,7 +235,7 @@ struct MapArrayVisitor : DefaultErrorVisitor<MapArrayVisitor<map_array>> {
228235
struct StringVisitor : DefaultErrorVisitor<StringVisitor> {
229236
static constexpr std::string_view static_err_msg = "String expected.";
230237

231-
std::string_view str{};
238+
std::string_view str;
232239
bool visit_str(const char* v, uint32_t size) {
233240
str = {v, size};
234241
return true;

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ struct MapArray {
7676
struct JsonConverter : msgpack::null_visitor {
7777
static constexpr char sep_char = ' ';
7878

79-
Idx indent;
80-
Idx max_indent_level;
81-
std::stringstream ss{};
82-
std::stack<MapArray> map_array{};
79+
Idx indent{};
80+
Idx max_indent_level{};
81+
std::stringstream ss{}; // NOLINT(readability-redundant-member-init)
82+
std::stack<MapArray> map_array{}; // NOLINT(readability-redundant-member-init)
8383

8484
void print_indent() {
8585
if (indent < 0) {
@@ -293,7 +293,7 @@ class Serializer {
293293
std::vector<ComponentBuffer> component_buffers_; // list of components, then all scenario flatten
294294

295295
// msgpack pakcer
296-
msgpack::sbuffer msgpack_buffer_{};
296+
msgpack::sbuffer msgpack_buffer_;
297297
msgpack::packer<msgpack::sbuffer> packer_;
298298
bool use_compact_list_{};
299299
std::map<MetaComponent const*, std::vector<MetaAttribute const*>> attributes_;
@@ -506,12 +506,10 @@ class Serializer {
506506
}
507507

508508
void pack_element_in_list(columnar_t /*tag*/, BufferView const& element_buffer, MetaComponent const& /*component*/,
509-
std::span<MetaAttribute const* const> attributes) {
509+
[[maybe_unused]] std::span<MetaAttribute const* const> attributes) {
510510
assert(is_columnar(element_buffer));
511511
assert(element_buffer.reordered_attribute_buffers.size() == attributes.size());
512512

513-
(void)attributes; // suppress unused variable in release mode
514-
515513
pack_array(element_buffer.reordered_attribute_buffers.size());
516514
for (auto const& attribute_buffer : element_buffer.reordered_attribute_buffers) {
517515
if (check_nan(attribute_buffer, element_buffer.idx)) {
@@ -606,7 +604,7 @@ class Serializer {
606604
});
607605
}
608606
void pack_attribute(AttributeBuffer<void const> const& attribute_buffer, Idx idx) {
609-
return ctype_func_selector(attribute_buffer.meta_attribute->ctype, [&]<class T> {
607+
ctype_func_selector(attribute_buffer.meta_attribute->ctype, [this, &attribute_buffer, idx]<class T> {
610608
packer_.pack(*(reinterpret_cast<T const*>(attribute_buffer.data) + idx));
611609
});
612610
}

power_grid_model_c/power_grid_model/include/power_grid_model/calculation_parameters.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ template <symmetry_tag sym_type> struct BranchShortCircuitSolverOutput {
5454

5555
// fault math calculation parameters and math output
5656
struct FaultCalcParam {
57-
DoubleComplex y_fault{};
57+
DoubleComplex y_fault;
5858
FaultType fault_type{};
5959
FaultPhase fault_phase{};
6060
};
@@ -116,7 +116,7 @@ static_assert(sensor_calc_param_type<PowerSensorCalcParam<asymmetric_t>>);
116116
struct TransformerTapRegulatorCalcParam {
117117
double u_set{};
118118
double u_band{};
119-
DoubleComplex z_compensation{};
119+
DoubleComplex z_compensation;
120120
IntS status{};
121121
};
122122

@@ -183,7 +183,7 @@ struct SourceCalcParam {
183183
DoubleComplex y1;
184184
DoubleComplex y0;
185185

186-
template <symmetry_tag sym> inline ComplexTensor<sym> y_ref() const {
186+
template <symmetry_tag sym> ComplexTensor<sym> y_ref() const {
187187
if constexpr (is_symmetric_v<sym>) {
188188
return y1;
189189
} else {

power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,20 @@ using IntSVector = std::vector<IntS>;
9191
template <class T, class... Ts>
9292
concept is_in_list_c = (std::same_as<std::remove_const_t<T>, Ts> || ...);
9393

94+
namespace capturing {
95+
// perfect forward into void
96+
template <class... T>
97+
constexpr void into_the_void(T&&... /*ignored*/) { // NOLINT(cppcoreguidelines-missing-std-forward)
98+
// do nothing; the constexpr allows all compilers to optimize this away
99+
}
100+
} // namespace capturing
101+
94102
// functor to include all
95103
struct IncludeAll {
96-
template <class... T> constexpr bool operator()(T&&... /*ignored*/) const { return true; }
104+
template <class... T> consteval bool operator()(T&&... args) const {
105+
capturing::into_the_void(std::forward<T>(args)...);
106+
return true;
107+
}
97108
};
98109
constexpr IncludeAll include_all{};
99110

power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ class AutomaticTapCalculationError : public PowerGridError {
196196
}
197197
};
198198

199+
class AutomaticTapInputError : public PowerGridError {
200+
public:
201+
AutomaticTapInputError(std::string const& msg) {
202+
append_msg("Automatic tap changer has invalid configuration. " + msg); // NOSONAR
203+
}
204+
};
205+
199206
class IDWrongType : public PowerGridError {
200207
public:
201208
explicit IDWrongType(ID id) { append_msg("Wrong type for object with id " + detail::to_string(id) + '\n'); }

0 commit comments

Comments
 (0)