From ee74ddb153c07de399ccc50a2c8212e7c25c4333 Mon Sep 17 00:00:00 2001 From: DONNOT Benjamin Date: Thu, 5 Oct 2023 10:10:20 +0200 Subject: [PATCH] fixing a bug in DC pf --- lightsim2grid/tests/test_multi_slack.py | 7 +++++++ src/DCSolver.tpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lightsim2grid/tests/test_multi_slack.py b/lightsim2grid/tests/test_multi_slack.py index e061c53..a2edaac 100644 --- a/lightsim2grid/tests/test_multi_slack.py +++ b/lightsim2grid/tests/test_multi_slack.py @@ -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 diff --git a/src/DCSolver.tpp b/src/DCSolver.tpp index 132b6ad..ff38cc1 100644 --- a/src/DCSolver.tpp +++ b/src/DCSolver.tpp @@ -40,7 +40,7 @@ bool BaseDCSolver::compute_pf(const Eigen::SparseMatrix // 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 @@ -95,7 +95,7 @@ bool BaseDCSolver::compute_pf(const Eigen::SparseMatrix } // 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);