Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ template <symmetry_tag sym_type> struct SolverOutput {
using sym = sym_type;

std::vector<ComplexValue<sym>> u;
std::vector<ComplexValue<sym>> bus_injection; // TODO(mgovers): remove this for v2
std::vector<ComplexValue<sym>> bus_injection;
std::vector<BusSolverOutput> bus;
std::vector<BranchSolverOutput<sym>> branch;
std::vector<ApplianceSolverOutput<sym>> source;
Expand Down Expand Up @@ -405,28 +405,11 @@ struct OptimizerOutput {
TransformerTapPositionOutput transformer_tap_positions;
};

template <typename T> struct SupernodeOutput;

template <steady_state_solver_output_type SolverOutputType> struct SupernodeOutput<SolverOutputType> {
using sym = decode_symmetry_v<SolverOutputType>;

ComplexValueVector<sym> bus_injection; // user bus output
BranchSolverOutput<sym> branch; // user link
};
template <short_circuit_solver_output_type SolverOutputType> struct SupernodeOutput<SolverOutputType> {
using sym = decode_symmetry_v<SolverOutputType>;

BranchShortCircuitSolverOutput<sym> branch; // user link
};

template <typename T> struct MathOutput {
using SolverOutputType = T;
using UnderlyingSolverOutputType = underlying_value_t<SolverOutputType>;
using sym = decode_symmetry_v<SolverOutputType>;

SolverOutputType solver_output;
OptimizerOutput optimizer_output;
std::vector<SupernodeOutput<UnderlyingSolverOutputType>> supernode_output;
};

// component indices at physical model side
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ struct Idx2DHash {
}
};

namespace detail {
template <typename T> struct underlying_value {
using type = T;
};
template <std::ranges::range T> struct underlying_value<T> {
using type = underlying_value<std::ranges::range_value_t<T>>::type;
};
} // namespace detail

template <typename T> using underlying_value_t = detail::underlying_value<std::remove_cvref_t<T>>::type;

struct symmetric_t {};
struct asymmetric_t {};

Expand All @@ -66,10 +55,6 @@ template <symmetry_tag T> constexpr bool is_asymmetric_v = std::derived_from<T,

template <symmetry_tag T> using other_symmetry_t = std::conditional_t<is_symmetric_v<T>, asymmetric_t, symmetric_t>;

template <typename T>
requires symmetry_tag<typename underlying_value_t<T>::sym>
using decode_symmetry_v = underlying_value_t<T>::sym;

// math constant
using namespace std::complex_literals;
using DoubleComplex = std::complex<double>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ template <non_owning_view_c RandVarsView>
requires std::same_as<std::ranges::range_value_t<RandVarsView>,
DecomposedComplexRandVar<typename std::ranges::range_value_t<RandVarsView>::sym>>
constexpr auto combine(RandVarsView rand_vars) {
using sym = decode_symmetry_v<RandVarsView>;
static_assert(symmetry_tag<sym>);
using sym = std::ranges::range_value_t<RandVarsView>::sym;

DecomposedComplexRandVar<sym> result{
.real_component =
Expand Down Expand Up @@ -378,7 +377,7 @@ template <non_owning_view_c RandVarsView>
requires std::same_as<std::ranges::range_value_t<RandVarsView>,
UniformComplexRandVar<typename std::ranges::range_value_t<RandVarsView>::sym>>
constexpr auto combine_magnitude(RandVarsView rand_vars) {
using sym = decode_symmetry_v<RandVarsView>;
using sym = std::ranges::range_value_t<RandVarsView>::sym;

auto const weighted_average_magnitude_measurement =
statistics::combine(rand_vars | std::views::transform([](auto const& measurement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "common/counting_iterator.hpp"
#include "common/typing.hpp"

#include <algorithm>
#include <array>
#include <cstdint>
#include <optional>
Expand Down Expand Up @@ -212,14 +211,12 @@ inline void backward_substitution(ReducedEchelonForm& elimination_result) {
// only iterate over free columns to the right of the pivot column
// as these are the only ones that can be affected by the backward substitution
for (auto const backward_col_idx : backward_substitution_free_right_cols(free_col_indices, pivot_col_idx)) {
std::ignore =
elimination_result.matrix.get_value(pivot_row_idx, backward_col_idx)
.transform([&elimination_result, multiplier_value, row_idx,
backward_col_idx](IntS pivot_value) {
elimination_result.matrix.add_to_value(static_cast<IntS>(-multiplier_value * pivot_value),
row_idx, backward_col_idx);
return pivot_value;
});
elimination_result.matrix.get_value(pivot_row_idx, backward_col_idx)
.transform([&elimination_result, multiplier_value, row_idx, backward_col_idx](IntS pivot_value) {
elimination_result.matrix.add_to_value(static_cast<IntS>(-multiplier_value * pivot_value),
row_idx, backward_col_idx);
return pivot_value;
});
}
elimination_result.rhs[row_idx] -=
static_cast<DoubleComplex>(multiplier_value) * elimination_result.rhs[pivot_row_idx];
Expand Down Expand Up @@ -271,11 +268,11 @@ inline SolutionSet set_solution_system(ReducedEchelonForm& result) {
auto const pivot_edge_idx = result.pivot_edge_indices[matrix_row];
for (auto dfs_matrix_col : std::views::iota(Idx{}, free_indices_size)) {
Idx const free_edge_idx = result.free_edge_indices[dfs_matrix_col];
std::ignore = result.matrix.get_value(matrix_row, free_edge_idx)
.transform([&dfs_matrix, pivot_edge_idx, dfs_matrix_col](IntS matrix_element) {
dfs_matrix.set_value(matrix_element, pivot_edge_idx, dfs_matrix_col);
return matrix_element;
});
result.matrix.get_value(matrix_row, free_edge_idx)
.transform([&dfs_matrix, pivot_edge_idx, dfs_matrix_col](IntS matrix_element) {
dfs_matrix.set_value(matrix_element, pivot_edge_idx, dfs_matrix_col);
return matrix_element;
});
}
extended_rhs[pivot_edge_idx] = result.rhs[matrix_row];
}
Expand All @@ -297,13 +294,12 @@ inline std::vector<std::vector<DoubleComplex>> set_projection_system(Idx free_in
for (Idx dfs_matrix_col = 0; dfs_matrix_col < free_indices_number; dfs_matrix_col++) {
auto dot_product_rhs = DoubleComplex{};
for (Idx dfs_matrix_row = 0; dfs_matrix_row < total_indices_number; dfs_matrix_row++) {
std::ignore = solution_set.dfs_matrix.get_value(dfs_matrix_row, dfs_matrix_col)
.transform([&dot_product_rhs, &extended_rhs_ = solution_set.extended_rhs,
&dfs_matrix_row](IntS first_value) {
dot_product_rhs +=
static_cast<DoubleComplex>(first_value) * extended_rhs_[dfs_matrix_row];
return first_value;
});
solution_set.dfs_matrix.get_value(dfs_matrix_row, dfs_matrix_col)
.transform(
[&dot_product_rhs, &extended_rhs_ = solution_set.extended_rhs, &dfs_matrix_row](IntS first_value) {
dot_product_rhs += static_cast<DoubleComplex>(first_value) * extended_rhs_[dfs_matrix_row];
return first_value;
});
}
auto& projection_system_row = projection_system[dfs_matrix_col];
projection_system_row[free_indices_number] = dot_product_rhs;
Expand Down Expand Up @@ -369,11 +365,10 @@ inline std::vector<DoubleComplex> compute_internal_loads(SolutionSet const& solu
internal_loads[row] = solution_set.extended_rhs[row];
auto sum_value = DoubleComplex{};
for (auto const column : IdxRange{number_of_columns}) {
std::ignore =
solution_set.dfs_matrix.get_value(row, column).transform([&sum_value, &system, column](IntS value) {
sum_value += static_cast<DoubleComplex>(value) * system[column].back();
return value;
});
solution_set.dfs_matrix.get_value(row, column).transform([&sum_value, &system, column](IntS value) {
sum_value += static_cast<DoubleComplex>(value) * system[column].back();
return value;
});
}
internal_loads[row] -= sum_value;
}
Expand Down

This file was deleted.

Loading
Loading