Skip to content

Commit

Permalink
fix code smells
Browse files Browse the repository at this point in the history
Signed-off-by: Martijn Govers <[email protected]>
  • Loading branch information
mgovers committed Feb 8, 2024
1 parent 284e6d4 commit a6ac10d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@ template <bool sym> class NewtonRaphsonSESolver {
/// Q_ij = 0
/// R_ii = -1.0, only diagonal
/// assign -1.0 to diagonal of 3x3 tensor, for asym
void virtually_remove_constraints(NRSEGainBlock<sym>& block) {
void virtually_remove_constraints(NRSEGainBlock<sym>& block) const {
block.r_P_theta() = RealTensor<sym>{-1.0};
block.r_Q_v() = RealTensor<sym>{-1.0};
}

/// R_ii = -variance, only diagonal
/// assign variance to diagonal of 3x3 tensor, for asym
void process_injection_diagonal(NRSEGainBlock<sym>& block, NRSERhs<sym>& rhs_block, auto const& injection) {
void process_injection_diagonal(NRSEGainBlock<sym>& block, NRSERhs<sym>& rhs_block, auto const& injection) const {
rhs_block.tau_p() += injection.value.real();
rhs_block.tau_q() += injection.value.imag();
block.r_P_theta() = RealTensor<sym>{RealValue<sym>{-injection.p_variance}};
Expand All @@ -357,7 +357,7 @@ template <bool sym> class NewtonRaphsonSESolver {
/// @param yij admittance of (row with injection, c)
/// @param u_state Voltage state of iteration
void process_injection_row(NRSEGainBlock<sym>& block, NRSEGainBlock<sym>& diag_block, NRSERhs<sym>& rhs_block,
auto const& yij, auto const& u_state) {
auto const& yij, auto const& u_state) const {
auto const hm_ui_uj_yij = hm_complex_form(yij, u_state.ui_uj_conj);
auto const nl_ui_uj_yij = dot(hm_ui_uj_yij, u_state.abs_uj_inv);
auto const injection_jac = calculate_jacobian(hm_ui_uj_yij, nl_ui_uj_yij);
Expand Down Expand Up @@ -461,7 +461,7 @@ template <bool sym> class NewtonRaphsonSESolver {
/// @param y_bus
void fill_qt(YBus<sym> const& y_bus) {
iterate_matrix_skip_fills(
[this](Idx /* row */, Idx /* col */, Idx data_idx, Idx data_idx_transpose) {
[this](Idx /* row */, Idx /* col */, Idx data_idx, Idx data_idx_transpose) const {
auto& block = data_gain_[data_idx];

block.qt_P_theta() = data_gain_[data_idx_transpose].q_P_theta();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ template <column_vector_or_tensor DerivedA> inline auto cabs(Eigen::ArrayBase<De

// phase_shift(x) = e^{i arg(x)} = x / |x|
inline DoubleComplex phase_shift(DoubleComplex const x) {
auto const abs_x = cabs(x);
if (abs_x > 0.0) {
if (auto const abs_x = cabs(x); abs_x > 0.0) {
return x / abs_x;
}
return DoubleComplex{1.0};
Expand Down

0 comments on commit a6ac10d

Please sign in to comment.