Skip to content

Commit

Permalink
adding possibility to load a grid where everything is not 'fully conn…
Browse files Browse the repository at this point in the history
…ected'
  • Loading branch information
BDonnot committed Oct 3, 2024
1 parent d3989ea commit 0be568f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ TODO: in `main.cpp` check the returned policy of pybind11 and also the `py::call
TODO: a cpp class that is able to compute (DC powerflow) ContingencyAnalysis and TimeSeries using PTDF and LODF
TODO: integration test with pandapower (see `pandapower/contingency/contingency.py` and import `lightsim2grid_installed` and check it's True)

[0.9.1] 2024-xx-yy
[0.9.2] 2024-xx-yy
--------------------------
- [ADDED] support loading a grid when everything is NOT on the same bus
(`topo_vect` used to be wrong in this case). This is especially usefull
for grid loaded with `pypowsybl`

[0.9.1] 2024-09-30
--------------------------
- [FIXED] a bug due to wrong type (in a numpy array) for the element name which lead in turn
to a fail assertion (equality between two numpy arrays returning a bool and not an array)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Benjamin DONNOT'

# The full version, including alpha/beta/rc tags
release = "0.9.1"
release = "0.9.2.dev0"
version = '0.9'

# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lightsim2grid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: MPL-2.0
# This file is part of LightSim2grid, LightSim2grid implements a c++ backend targeting the Grid2Op platform.

__version__ = "0.9.1"
__version__ = "0.9.2.dev0"

__all__ = ["newtonpf", "SolverType", "ErrorType", "solver", "compilation_options"]

Expand Down
19 changes: 17 additions & 2 deletions lightsim2grid/lightSimBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,6 @@ def _aux_finish_setup_after_reading(self):
self.nb_obj_per_bus = np.zeros(2 * self.__nb_bus_before, dtype=dt_int).reshape(-1)

self.topo_vect = np.ones(cls.dim_topo, dtype=dt_int).reshape(-1)

if cls.shunts_data_available:
self.shunt_topo_vect = np.ones(cls.n_shunt, dtype=dt_int)
# shunts
Expand Down Expand Up @@ -1031,12 +1030,28 @@ def _aux_finish_setup_after_reading(self):
self.storage_theta = np.full(cls.n_storage, dtype=dt_float, fill_value=np.NaN).reshape(-1)

self._count_object_per_bus()
self.topo_vect[cls.load_pos_topo_vect] = cls.global_bus_to_local(np.array([el.bus_id for el in self._grid.get_loads()]),
cls.load_to_subid)
self.topo_vect[cls.gen_pos_topo_vect] = cls.global_bus_to_local(np.array([el.bus_id for el in self._grid.get_generators()]),
cls.gen_to_subid)
self.topo_vect[cls.storage_pos_topo_vect] = cls.global_bus_to_local(np.array([el.bus_id for el in self._grid.get_storages()]),
cls.storage_to_subid)
lor_glob_bus = np.concatenate((np.array([el.bus_or_id for el in self._grid.get_lines()]),
np.array([el.bus_hv_id for el in self._grid.get_trafos()])))
self.topo_vect[cls.line_or_pos_topo_vect] = cls.global_bus_to_local(lor_glob_bus,
cls.line_or_to_subid)
lex_glob_bus = np.concatenate((np.array([el.bus_ex_id for el in self._grid.get_lines()]),
np.array([el.bus_lv_id for el in self._grid.get_trafos()])))
self.topo_vect[cls.line_ex_pos_topo_vect] = cls.global_bus_to_local(lex_glob_bus,
cls.line_ex_to_subid)

self._grid.tell_solver_need_reset()
self.__me_at_init = self._grid.copy()
self.__init_topo_vect = np.ones(cls.dim_topo, dtype=dt_int)
self.__init_topo_vect[:] = self.topo_vect
if cls.shunts_data_available:
self.sh_bus[:] = 1
self.sh_bus[:] = cls.global_bus_to_local(np.array([el.bus_id for el in self._grid.get_shunts()]),
cls.shunt_to_subid)

def assert_grid_correct_after_powerflow(self) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pybind11.setup_helpers import Pybind11Extension, build_ext


__version__ = "0.9.1"
__version__ = "0.9.2.dev0"
KLU_SOLVER_AVAILABLE = False

# Try to link against SuiteSparse (if available)
Expand Down

0 comments on commit 0be568f

Please sign in to comment.