Skip to content

Commit 3bb015e

Browse files
authored
Merge branch 'main' into feature/dependency-inversion-main-model-impl-info
Signed-off-by: Martijn Govers <[email protected]>
2 parents 93dff85 + 8ac0bc6 commit 3bb015e

File tree

12 files changed

+52
-39
lines changed

12 files changed

+52
-39
lines changed

.github/workflows/build-test-release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,15 @@ jobs:
260260
conda info
261261
conda list
262262
263-
- uses: ./.github/actions/enable-msvc
263+
- name: Enable MSVC
264+
uses: ./.github/actions/enable-msvc
264265
if: runner.os == 'Windows'
265266

267+
- name: Enable gcc/g++
268+
if: matrix.os == 'ubuntu'
269+
run: |
270+
conda install -y gcc_linux-64 gxx_linux-64
271+
266272
- name: Build and install cmake target for Windows
267273
if: matrix.os == 'windows'
268274
run: |

.github/workflows/check-code-quality.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ jobs:
4242
4343
- name: Install and run ruff
4444
run: |
45-
pip install ruff .
45+
pip install ruff
4646
ruff check .
4747
ruff format .
4848
git restore README.md
4949
5050
- name: Install and run clang-format
5151
run: |
52-
sudo apt-get update && sudo apt-get install -y clang-format-18
52+
sudo apt-get install -y clang-format-18
5353
find . -regex '.*\.\(h\|c\|cpp\|hpp\|cc\|cxx\)' -exec clang-format-18 -style=file -i {} \;
5454
5555
- name: Install and run markdownlint
@@ -60,7 +60,6 @@ jobs:
6060
6161
- name: If needed raise error
6262
run: |
63-
6463
if [[ `git status --porcelain --untracked-files=no` ]]; then
6564
echo "Formatting not correct! See below the files which need to be reformatted!"
6665
git status --porcelain --untracked-files=no

.readthedocs.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ sphinx:
1111
build:
1212
os: "ubuntu-24.04"
1313
tools:
14-
python: "3.11"
14+
python: "3.13"
1515
apt_packages:
1616
- graphviz
17+
- gcc-14
18+
- g++-14
1719
jobs:
1820
post_install:
1921
# Build package with doc requirements from pyproject.optional-dependencies
20-
- pip install --verbose --editable .[doc]
22+
- CC=gcc-14 CXX=g++-14 pip install --verbose --editable .[doc]
2123

2224
# remove API DLL define in header
2325
- find power_grid_model_c/power_grid_model_c/include -name *.h -exec sed -i -r "s/#define PGM.*//g" {} \;

power_grid_model_c/power_grid_model/include/power_grid_model/job_interface.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ template <typename Adapter> class JobInterface {
7676
}
7777

7878
private:
79-
friend Adapter; // CRTP compliance
79+
friend Adapter;
8080
JobInterface() = default;
8181
JobInterface(const JobInterface& /*other*/) = default;
8282
JobInterface& operator=(const JobInterface& /*other*/) = default;

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#include "../all_components.hpp"
1111

12+
#include <concepts>
13+
1214
namespace power_grid_model::main_core {
1315

1416
namespace detail {
@@ -103,7 +105,7 @@ template <typename Component, typename IndexType, class ComponentContainer, std:
103105
constexpr void produce_output(MainModelState<ComponentContainer> const& state, ComponentOutput&& output,
104106
ResFunc&& func) {
105107
std::ranges::transform(get_component_citer<Component>(state), comp_base_sequence<Component>(state),
106-
std::ranges::begin(output), std::forward<ResFunc>(func));
108+
std::ranges::begin(std::forward<ComponentOutput>(output)), std::forward<ResFunc>(func));
107109
}
108110

109111
} // namespace detail

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ constexpr void register_topology_components(ComponentContainer const& components
180180

181181
template <std::same_as<Branch> Component, class ComponentContainer>
182182
requires common::component_container_c<ComponentContainer, Component>
183-
constexpr void register_connections_components(ComponentContainer components, ComponentConnections& comp_conn) {
183+
constexpr void register_connections_components(ComponentContainer const& components, ComponentConnections& comp_conn) {
184184
apply_registration<Component>(components, comp_conn.branch_connected, [](Branch const& branch) {
185185
return BranchConnected{static_cast<IntS>(branch.from_status()), static_cast<IntS>(branch.to_status())};
186186
});
@@ -189,7 +189,7 @@ constexpr void register_connections_components(ComponentContainer components, Co
189189
}
190190
template <std::same_as<Branch3> Component, class ComponentContainer>
191191
requires common::component_container_c<ComponentContainer, Component>
192-
constexpr void register_connections_components(ComponentContainer components, ComponentConnections& comp_conn) {
192+
constexpr void register_connections_components(ComponentContainer const& components, ComponentConnections& comp_conn) {
193193
apply_registration<Component>(components, comp_conn.branch3_connected, [](Branch3 const& branch3) {
194194
return Branch3Connected{static_cast<IntS>(branch3.status_1()), static_cast<IntS>(branch3.status_2()),
195195
static_cast<IntS>(branch3.status_3())};
@@ -200,7 +200,7 @@ constexpr void register_connections_components(ComponentContainer components, Co
200200

201201
template <std::same_as<Source> Component, class ComponentContainer>
202202
requires common::component_container_c<ComponentContainer, Component>
203-
constexpr void register_connections_components(ComponentContainer components, ComponentConnections& comp_conn) {
203+
constexpr void register_connections_components(ComponentContainer const& components, ComponentConnections& comp_conn) {
204204
apply_registration<Component>(components, comp_conn.source_connected,
205205
[](Source const& source) { return source.status(); });
206206
}

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/y_bus.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include "../common/common.hpp"
8+
79
namespace power_grid_model::main_core {
810

911
template <symmetry_tag sym, typename ComponentContainer, typename... ComponentType>
@@ -47,7 +49,7 @@ void prepare_y_bus(MainModelState<ComponentContainer> const& state_, Idx n_math_
4749

4850
template <symmetry_tag sym, typename ComponentContainer, typename... ComponentType>
4951
static std::vector<MathModelParamIncrement> get_math_param_increment(
50-
MainModelState<ComponentContainer> received_state, Idx n_math_solvers_,
52+
MainModelState<ComponentContainer>& received_state, Idx n_math_solvers_,
5153
std::array<std::vector<Idx2D>, main_core::utils::n_types<ComponentType...>> const& parameter_changed_components_) {
5254
using AddToIncrement =
5355
void (*)(std::vector<MathModelParamIncrement>&, MainModelState<ComponentContainer> const&, Idx2D const&);

power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/y_bus.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ struct YBusStructure {
264264
// construct transpose entry
265265
lu_transpose_entry.resize(nnz_counter_lu);
266266
// default transpose_entry[i] = i
267-
std::iota(lu_transpose_entry.begin(), lu_transpose_entry.end(), 0);
267+
std::iota( // NOLINT(modernize-use-ranges) // not yet supported by some compilers
268+
lu_transpose_entry.begin(), lu_transpose_entry.end(), 0);
268269
// fill off-diagonal, loop all the branches
269270
for (auto const [entry_1, entry_2] : off_diag_map) {
270271
// for each branch entry tf and ft, they are transpose to each other

tests/benchmark_cpp/benchmark.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,26 @@ std::string make_key(LogEvent code) {
104104
}
105105

106106
auto get_benchmark_run_title(Option const& option, MainModelOptions const& model_options) {
107-
auto const mv_ring_type = option.has_mv_ring ? "meshed grid" : "radial grid";
107+
using namespace std::string_literals;
108+
auto const mv_ring_type = option.has_mv_ring ? "meshed grid"s : "radial grid"s;
108109
auto const sym_type =
109-
model_options.calculation_symmetry == CalculationSymmetry::symmetric ? "symmetric" : "asymmetric";
110+
model_options.calculation_symmetry == CalculationSymmetry::symmetric ? "symmetric"s : "asymmetric"s;
110111
auto const method = [calculation_method = model_options.calculation_method] {
111112
using enum CalculationMethod;
112113

113114
switch (calculation_method) {
114115
case newton_raphson:
115-
return "Newton-Raphson method";
116+
return "Newton-Raphson method"s;
116117
case linear:
117-
return "Linear method";
118+
return "Linear method"s;
118119
case linear_current:
119-
return "Linear current method";
120+
return "Linear current method"s;
120121
case iterative_current:
121-
return "Iterative current method";
122+
return "Iterative current method"s;
122123
case iterative_linear:
123-
return "Iterative linear method";
124+
return "Iterative linear method"s;
124125
case iec60909:
125-
return "IEC 60909 method";
126+
return "IEC 60909 method"s;
126127
default:
127128
throw MissingCaseForEnumError{"get_benchmark_run_title", calculation_method};
128129
}
@@ -171,15 +172,18 @@ struct PowerGridBenchmark {
171172
auto const run = [this, &model_options, &info](Idx batch_size_) {
172173
switch (model_options.calculation_type) {
173174
case short_circuit:
174-
return run_calculation<ShortCircuitOutputData>(model_options, batch_size_, info);
175+
run_calculation<ShortCircuitOutputData>(model_options, batch_size_, info);
176+
break;
175177
case power_flow:
176178
[[fallthrough]];
177179
case state_estimation: {
178180
switch (model_options.calculation_symmetry) {
179181
case CalculationSymmetry::symmetric:
180-
return run_calculation<OutputData<symmetric_t>>(model_options, batch_size_, info);
182+
run_calculation<OutputData<symmetric_t>>(model_options, batch_size_, info);
183+
break;
181184
case CalculationSymmetry::asymmetric:
182-
return run_calculation<OutputData<asymmetric_t>>(model_options, batch_size_, info);
185+
run_calculation<OutputData<asymmetric_t>>(model_options, batch_size_, info);
186+
break;
183187
default:
184188
throw MissingCaseForEnumError{"run_benchmark<calculation_symmetry>",
185189
model_options.calculation_symmetry};
@@ -231,11 +235,6 @@ struct PowerGridBenchmark {
231235
} // namespace
232236
} // namespace power_grid_model::benchmark
233237

234-
namespace {
235-
using power_grid_model::asymmetric_t;
236-
using power_grid_model::symmetric_t;
237-
} // namespace
238-
239238
int main(int /* argc */, char** /* argv */) {
240239
using enum power_grid_model::CalculationType;
241240
using enum power_grid_model::CalculationMethod;

tests/benchmark_cpp/fictional_grid_generator.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ class FictionalGridGenerator {
646646
std::uniform_real_distribution<double> load_scaling_gen{0.0, 1.0};
647647
load_series.resize(input.size() * batch_size);
648648
auto const n_object = std::ssize(input);
649-
for (Idx batch : IdxRange{batch_size}) {
650-
for (Idx object : IdxRange{n_object}) {
649+
for (Idx const batch : IdxRange{batch_size}) {
650+
for (Idx const object : IdxRange{n_object}) {
651651
T const& input_obj = input[object];
652652
U& update_obj = load_series[batch * n_object + object];
653653
update_obj.id = input_obj.id;
@@ -698,10 +698,10 @@ class FictionalGridGenerator {
698698

699699
sensor_series.resize(input.size() * batch_size);
700700
auto const n_object = std::ssize(input);
701-
for (Idx object : IdxRange{n_object}) {
701+
for (Idx const object : IdxRange{n_object}) {
702702
T const& input_obj = input[object];
703703

704-
for (Idx batch : IdxRange{batch_size}) {
704+
for (Idx const batch : IdxRange{batch_size}) {
705705
U& update_obj = sensor_series[batch * n_object + object];
706706
update_obj.id = input_obj.id;
707707
if constexpr (is_symmetric_v<typename T::sym>) {

0 commit comments

Comments
 (0)