Skip to content

Commit

Permalink
fixing a bug in DC pf
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Oct 5, 2023
1 parent 679bb65 commit ee74ddb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lightsim2grid/tests/test_multi_slack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Copyright (c) 2023, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# This file is part of LightSim2grid, LightSim2grid implements a c++ backend targeting the Grid2Op platform.

import numpy as np
import warnings
Expand Down
4 changes: 2 additions & 2 deletions src/DCSolver.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool BaseDCSolver<LinearSolver>::compute_pf(const Eigen::SparseMatrix<cplx_type>
// TODO SLACK (for now i put all slacks as PV, except the first one)
// this should be handled in Sbus, because we know the amount of power absorbed by the slack
// so we can compute it correctly !
Eigen::VectorXi my_pv = retrieve_pv_with_slack(slack_ids, pv);
const Eigen::VectorXi my_pv = retrieve_pv_with_slack(slack_ids, pv);
// const Eigen::VectorXi & my_pv = pv;

// find the slack buses
Expand Down Expand Up @@ -95,7 +95,7 @@ bool BaseDCSolver<LinearSolver>::compute_pf(const Eigen::SparseMatrix<cplx_type>
}

// remove the slack bus from Sbus
RealVect dcSbus = RealVect::Constant(nb_bus_solver - my_pv.size(), my_zero_);
RealVect dcSbus = RealVect::Constant(nb_bus_solver - slack_bus_ids_solver.size(), my_zero_);
for (int k=0; k < nb_bus_solver; ++k){
if(ybus_to_me(k) == -1) continue; // I don't add anything to the slack bus
const int col_res = ybus_to_me(k);
Expand Down

0 comments on commit ee74ddb

Please sign in to comment.