diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ea5c7c..5721da7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,6 +5,9 @@ orbs: executors: + gcc_13: + docker: + - image: gcc:13 gcc_12: docker: - image: gcc:12 @@ -20,6 +23,18 @@ executors: gcc_8: docker: - image: gcc:8 + clang18: + docker: + - image: silkeh/clang:18 + clang17: + docker: + - image: silkeh/clang:17 + clang16: + docker: + - image: silkeh/clang:16 + clang15: + docker: + - image: silkeh/clang:15 clang14: docker: - image: silkeh/clang:14 @@ -40,13 +55,30 @@ executors: - image: silkeh/clang:9 # no c++ 11, does not work jobs: + compile_gcc12: + executor: gcc_12 + resource_class: small + steps: + - checkout + - run: apt-get update && apt-get install python3-pip python3-full -y + - run: python3 -m pip install virtualenv + - run: python3 -m virtualenv venv_test + - run: + command: | + source venv_test/bin/activate + pip install -U grid2op + pip install -U pybind11 + git submodule init + git submodule update + make + CC=gcc python setup.py build + python -m pip install -U . compile_gcc11: executor: gcc_11 resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -64,8 +96,7 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -83,8 +114,7 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -102,8 +132,7 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -116,13 +145,12 @@ jobs: make CC=gcc python setup.py build python -m pip install -U . - compile_gcc12: - executor: gcc_12 + compile_gcc13: + executor: gcc_13 resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip python3-virtualenv -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full -y # - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -152,8 +180,7 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full git -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -170,8 +197,7 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip git -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full git -y - run: command: | git submodule init @@ -190,8 +216,7 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip git -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full git -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -209,8 +234,7 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip git -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full git -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -228,8 +252,7 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip git -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full git -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -247,8 +270,79 @@ jobs: resource_class: small steps: - checkout - - run: apt-get update && apt-get install python3-pip git -y - - run: python3 -m pip install --upgrade pip setuptools + - run: apt-get update && apt-get install python3-pip python3-full git -y + - run: python3 -m pip install virtualenv + - run: python3 -m virtualenv venv_test + - run: + command: | + source venv_test/bin/activate + pip install -U grid2op + pip install -U pybind11 + git submodule init + git submodule update + make + CC=clang python setup.py build + CC=clang python -m pip install -U . + compile_clang15: + executor: clang15 + resource_class: small + steps: + - checkout + - run: apt-get update && apt-get install python3-pip python3-full git -y + - run: python3 -m pip install virtualenv + - run: python3 -m virtualenv venv_test + - run: + command: | + source venv_test/bin/activate + pip install -U grid2op + pip install -U pybind11 + git submodule init + git submodule update + make + CC=clang python setup.py build + CC=clang python -m pip install -U . + compile_clang16: + executor: clang16 + resource_class: small + steps: + - checkout + - run: apt-get update && apt-get install python3-pip python3-full git -y + - run: python3 -m pip install virtualenv + - run: python3 -m virtualenv venv_test + - run: + command: | + source venv_test/bin/activate + pip install -U grid2op + pip install -U pybind11 + git submodule init + git submodule update + make + CC=clang python setup.py build + CC=clang python -m pip install -U . + compile_clang17: + executor: clang17 + resource_class: small + steps: + - checkout + - run: apt-get update && apt-get install python3-pip python3-full git -y + - run: python3 -m pip install virtualenv + - run: python3 -m virtualenv venv_test + - run: + command: | + source venv_test/bin/activate + pip install -U grid2op + pip install -U pybind11 + git submodule init + git submodule update + make + CC=clang python setup.py build + CC=clang python -m pip install -U . + compile_clang18: + executor: clang18 + resource_class: small + steps: + - checkout + - run: apt-get update && apt-get install python3-pip python3-full git -y - run: python3 -m pip install virtualenv - run: python3 -m virtualenv venv_test - run: @@ -279,7 +373,7 @@ jobs: size: medium # ("medium" "large" "xlarge" "2xlarge") steps: - checkout - - run: python3 -m pip install --upgrade pip setuptools + - run: py -m pip install --upgrade pip setuptools - run: py -m pip install virtualenv - run: py -m virtualenv venv_test - run: @@ -309,11 +403,16 @@ workflows: compile: jobs: - compile_gcc8 - - compile_gcc10 - - compile_gcc11 + # - compile_gcc10 + # - compile_gcc11 - compile_gcc12 + - compile_gcc13 # - compile_clang10 # does not work I don't know why, too lazy to check - compile_clang11 - - compile_clang13 - - compile_clang14 + # - compile_clang13 + # - compile_clang14 + # - compile_clang15 + # - compile_clang16 + - compile_clang17 + - compile_clang18 - compile_windows diff --git a/.gitignore b/.gitignore index e4e3737..5272312 100644 --- a/.gitignore +++ b/.gitignore @@ -278,3 +278,5 @@ lightsim2grid/tests/_grid2op_for_test/ bug_sparselu bug_sparselu_eigen.cpp test_segfault.sh +nohup.out +test_rte/ \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2fa05e1..a02c84e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -39,6 +39,8 @@ Change Log - [FIXED] a bug where copying a lightsim2grid `GridModel` did not fully copy it - [FIXED] a bug in the "topo_vect" comprehension cpp side (sometimes some buses might not be activated / deactivated correctly) +- [FIXED] a bug when reading a grid initialize from pypowsybl (trafo names where put in place + of shunt names) - [FIXED] read the docs was broken - [ADDED] sets of methods to extract the main component of a grid and perform powerflow only on this one. @@ -49,11 +51,17 @@ Change Log - [ADDED] a timer to get the time spent in the gridmodel for the powerflow (env.backend.timer_gridmodel_xx_pf) which also include the time - [ADDED] support for more than 2 busbars per substation (requires grid2op >= 1.10.0) +- [ADDED] possibility to retrieve the bus id of the original iidm when initializing from pypowsybl + (`return_sub_id` kwargs). This is a "beta" feature and will be adressed in a better way + in a near future. +- [ADDED] possibility to continue the grid2op 'step' when the solver converges but a load or a + generator is disconnected from the grid. - [IMPROVED] now performing the new grid2op `create_test_suite` - [IMPROVED] now lightsim2grid properly throw `BackendError` - [IMPROVED] clean ce cpp side by refactoring: making clearer the difference (linear) solver vs powerflow algorithm and move same type of files in the same directory. This change does not really affect python side at the moment (but will in future versions) +- [IMPROVED] CI to test on gcc 13 and clang 18 (latest versions to date) [0.7.5] 2023-10-05 -------------------- diff --git a/README.md b/README.md index 303ef73..cf1c078 100644 --- a/README.md +++ b/README.md @@ -268,9 +268,10 @@ cd .. Some tests are performed automatically on standard platform each time modifications are made in the lightsim2grid code. -These tests include, for now, compilation on gcc (version 8, 10, 11 and 12) and clang (version 11, 13 and 14). +These tests include, for now, compilation on gcc (version 8, 12 and 13) and clang (version 11, 16 and 17). -**NB** Intermediate versions of clang and gcc (*eg* gcc 9 or clang 12) are not tested regularly, but lightsim2grid used to work on these. We suppose that if it works on *eg* clang 10 and clang 14 then it compiles also on all intermediate versions. +**NB** Intermediate versions of clang and gcc (*eg* gcc 9 or clang 12) are not tested regularly, but lightsim2grid used to work on these. +We suppose that if it works on *eg* clang 10 and clang 14 then it compiles also on all intermediate versions. **NB** Package might work (we never tested it) on earlier version of these compilers. The only "real" requirement for lightsim2grid is to have a compiler supporting c++11 diff --git a/lightsim2grid/gridmodel/from_pypowsybl.py b/lightsim2grid/gridmodel/from_pypowsybl.py index ef7a856..6501ead 100644 --- a/lightsim2grid/gridmodel/from_pypowsybl.py +++ b/lightsim2grid/gridmodel/from_pypowsybl.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, RTE (https://www.rte-france.com) +# Copyright (c) 2023-2024, 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, @@ -6,7 +6,9 @@ # SPDX-License-Identifier: MPL-2.0 # This file is part of LightSim2grid, LightSim2grid implements a c++ backend targeting the Grid2Op platform. +import warnings import numpy as np +import pandas as pd import pypowsybl as pypo from lightsim2grid_cpp import GridModel @@ -39,7 +41,8 @@ def init(net : pypo.network, sn_mva = 100., sort_index=True, f_hz = 50., # unused - only_main_component=True): + only_main_component=True, + return_sub_id=False): model = GridModel() # model.set_f_hz(f_hz) @@ -66,7 +69,7 @@ def init(net : pypo.network, 0, 0 # unused ) model._orig_to_ls = 1 * bus_df_orig["bus_id"].values - + # do the generators if sort_index: df_gen = net.get_generators().sort_index() @@ -148,7 +151,7 @@ def init(net : pypo.network, for line_id, (is_or_disc, is_ex_disc) in enumerate(zip(lor_disco, lex_disco)): if is_or_disc or is_ex_disc: model.deactivate_powerline(line_id) - model.set_line_names(df_line.index) + model.set_line_names(df_line.index) # for trafo if sort_index: @@ -201,19 +204,23 @@ def init(net : pypo.network, for shunt_id, disco in enumerate(sh_disco): if disco: model.deactivate_shunt(shunt_id) - model.set_shunt_names(df_trafo.index) + model.set_shunt_names(df_shunt.index) # for hvdc (TODO not tested yet) - df_dc = net.get_hvdc_lines().sort_index() - df_sations = net.get_vsc_converter_stations().sort_index() + if sort_index: + df_dc = net.get_hvdc_lines().sort_index() + df_sations = net.get_vsc_converter_stations().sort_index() + else: + df_dc = net.get_hvdc_lines() + df_sations = net.get_vsc_converter_stations() # bus_from_id = df_sations.loc[df_dc["converter_station1_id"].values]["bus_id"].values # bus_to_id = df_sations.loc[df_dc["converter_station2_id"].values]["bus_id"].values - bus_from_id, hvdc_from_disco = _aux_get_bus(bus_df, df_sations.loc[df_dc["converter_station1_id"].values]) - bus_to_id, hvdc_to_disco = _aux_get_bus(bus_df, df_sations.loc[df_dc["converter_station2_id"].values]) + hvdc_bus_from_id, hvdc_from_disco = _aux_get_bus(bus_df, df_sations.loc[df_dc["converter_station1_id"].values]) + hvdc_bus_to_id, hvdc_to_disco = _aux_get_bus(bus_df, df_sations.loc[df_dc["converter_station2_id"].values]) loss_percent = np.zeros(df_dc.shape[0]) # TODO loss_mw = np.zeros(df_dc.shape[0]) # TODO - model.init_dclines(bus_from_id, - bus_to_id, + model.init_dclines(hvdc_bus_from_id, + hvdc_bus_to_id, df_dc["target_p"].values, loss_percent, loss_mw, @@ -270,10 +277,34 @@ def init(net : pypo.network, # TODO checks # no 3windings trafo and other exotic stuff if net.get_phase_tap_changers().shape[0] > 0: - pass - # raise RuntimeError("Impossible currently to init a grid with tap changers at the moment.") + warnings.warn("There are tap changers in the iidm grid which are not taken " + "into account in the lightsim2grid at the moment. " + "NB: lightsim2grid gridmodel can handle tap changer, it is just not " + "handled by the 'from_pypowsybl` function at the moment.") # and now deactivate all elements and nodes not in the main component if only_main_component: model.consider_only_main_component() - return model + if not return_sub_id: + # for backward compatibility + return model + else: + # voltage_level_id is kind of what I call "substation" in grid2op + vl_unique = bus_df["voltage_level_id"].unique() + sub_df = pd.DataFrame(index=np.sort(vl_unique), data={"sub_id": np.arange(vl_unique.size)}) + buses_sub_id = pd.merge(left=bus_df, right=sub_df, how="left", left_on="voltage_level_id", right_index=True)[["bus_id", "sub_id"]] + gen_sub = pd.merge(left=df_gen, right=sub_df, how="left", left_on="voltage_level_id", right_index=True)[["sub_id"]] + load_sub = pd.merge(left=df_load, right=sub_df, how="left", left_on="voltage_level_id", right_index=True)[["sub_id"]] + lor_sub = pd.merge(left=df_line, right=sub_df, how="left", left_on="voltage_level1_id", right_index=True)[["sub_id"]] + lex_sub = pd.merge(left=df_line, right=sub_df, how="left", left_on="voltage_level2_id", right_index=True)[["sub_id"]] + tor_sub = pd.merge(left=df_trafo, right=sub_df, how="left", left_on="voltage_level1_id", right_index=True)[["sub_id"]] + tex_sub = pd.merge(left=df_trafo, right=sub_df, how="left", left_on="voltage_level2_id", right_index=True)[["sub_id"]] + batt_sub = pd.merge(left=df_batt, right=sub_df, how="left", left_on="voltage_level_id", right_index=True)[["sub_id"]] + sh_sub = pd.merge(left=df_shunt, right=sub_df, how="left", left_on="voltage_level_id", right_index=True)[["sub_id"]] + hvdc_vl_info = pd.DataFrame(index=df_dc.index, + data={"voltage_level1_id": df_sations.loc[df_dc["converter_station1_id"].values]["voltage_level_id"].values, + "voltage_level2_id": df_sations.loc[df_dc["converter_station2_id"].values]["voltage_level_id"].values + }) + hvdc_sub_from_id = pd.merge(left=hvdc_vl_info, right=sub_df, how="left", left_on="voltage_level1_id", right_index=True)[["sub_id"]] + hvdc_sub_to_id = pd.merge(left=hvdc_vl_info, right=sub_df, how="left", left_on="voltage_level2_id", right_index=True)[["sub_id"]] + return model, (buses_sub_id, gen_sub, load_sub, (lor_sub, tor_sub), (lex_sub, tex_sub), batt_sub, sh_sub, hvdc_sub_from_id, hvdc_sub_to_id) diff --git a/lightsim2grid/lightSimBackend.py b/lightsim2grid/lightSimBackend.py index 410d2da..f91d869 100644 --- a/lightsim2grid/lightSimBackend.py +++ b/lightsim2grid/lightSimBackend.py @@ -10,6 +10,7 @@ from typing import Optional, Union import warnings import numpy as np +import pandas as pd import time from grid2op.Action import CompleteAction @@ -49,6 +50,8 @@ def __init__(self, use_static_gen: bool=False, # add the static generators as generator gri2dop side loader_method: Literal["pandapower", "pypowsybl"] = "pandapower", loader_kwargs : Optional[dict] = None, + stop_if_load_disco : Optional[bool] = True, + stop_if_gen_disco : Optional[bool] = True, ): try: # for grid2Op >= 1.7.1 @@ -62,7 +65,10 @@ def __init__(self, dist_slack_non_renew=dist_slack_non_renew, use_static_gen=use_static_gen, loader_method=loader_method, - loader_kwargs=loader_kwargs) + loader_kwargs=loader_kwargs, + stop_if_load_disco=stop_if_load_disco, + stop_if_gen_disco=stop_if_gen_disco, + ) except TypeError as exc_: warnings.warn("Please use grid2op >= 1.7.1: with older grid2op versions, " "you cannot set max_iter, tol nor solver_type arguments.") @@ -79,6 +85,16 @@ def __init__(self, self._loader_method = loader_method self._loader_kwargs = loader_kwargs + #: .. versionadded:: 0.7.6 + #: if set to `True` (default) then the backend will raise a + #: BackendError in case of disconnected load + self._stop_if_load_disco = stop_if_load_disco + + #: .. versionadded:: 0.7.6 + #: if set to `True` (default) then the backend will raise a + #: BackendError in case of disconnected generator + self._stop_if_gen_disco = stop_if_gen_disco + if loader_method == "pandapower": self.supported_grid_format = ("json", ) # new in 1.9.6 elif loader_method == "pypowsybl": @@ -452,7 +468,14 @@ def _aux_pypowsybl_init_substations(self, loader_kwargs): for i in range(self.n_busbar_per_sub)] ) self._grid._orig_to_ls = new_orig_to_ls - + + def _get_subid_from_buses_legacy(self, buses_sub_id, el_sub_df): + # buses_sub_id is the first element as returned by from_pypowsybl / init function + # el_sub_df is an element dataframe returned by the same function + tmp = pd.merge(el_sub_df.reset_index(), buses_sub_id, how="left", right_on="sub_id", left_on="sub_id") + res = tmp.drop_duplicates(subset='id').set_index("id").sort_index()["bus_id"].values + return res + def _load_grid_pypowsybl(self, path=None, filename=None): from lightsim2grid.gridmodel.from_pypowsybl import init as init_pypow import pypowsybl.network as pypow_net @@ -470,7 +493,8 @@ def _load_grid_pypowsybl(self, path=None, filename=None): gen_slack_id = None if "gen_slack_id" in loader_kwargs: gen_slack_id = int(loader_kwargs["gen_slack_id"]) - self._grid = init_pypow(grid_tmp, gen_slack_id=gen_slack_id, sort_index=True) + self._grid, subs_id = init_pypow(grid_tmp, gen_slack_id=gen_slack_id, sort_index=True, return_sub_id=True) + (buses_sub_id, gen_sub, load_sub, (lor_sub, tor_sub), (lex_sub, tex_sub), batt_sub, sh_sub, hvdc_sub_from_id, hvdc_sub_to_id) = subs_id self.__nb_bus_before = len(self._grid.get_bus_vn_kv()) self._aux_pypowsybl_init_substations(loader_kwargs) self._aux_setup_right_after_grid_init() @@ -492,18 +516,28 @@ def _load_grid_pypowsybl(self, path=None, filename=None): self.name_sub = ["sub_{}".format(i) for i, _ in enumerate(df.iterrows())] if not from_sub: - self.load_to_subid = np.array([el.bus_id for el in self._grid.get_loads()], dtype=dt_int) - self.gen_to_subid = np.array([el.bus_id for el in self._grid.get_generators()], dtype=dt_int) - self.line_or_to_subid = np.array([el.bus_or_id for el in self._grid.get_lines()] + - [el.bus_hv_id for el in self._grid.get_trafos()], - dtype=dt_int) - self.line_ex_to_subid = np.array([el.bus_ex_id for el in self._grid.get_lines()] + - [el.bus_lv_id for el in self._grid.get_trafos()], - dtype=dt_int) - self.storage_to_subid = np.array([el.bus_id for el in self._grid.get_storages()], dtype=dt_int) - self.shunt_to_subid = np.array([el.bus_id for el in self._grid.get_shunts()], dtype=dt_int) + # consider that each "bus" in the powsybl grid is a substation + # this is the "standard" behaviour for IEEE grid in grid2op + # but can be considered "legacy" behaviour for more realistic grid + this_load_sub = self._get_subid_from_buses_legacy(buses_sub_id, load_sub) + this_gen_sub = self._get_subid_from_buses_legacy(buses_sub_id, gen_sub) + this_lor_sub = self._get_subid_from_buses_legacy(buses_sub_id, lor_sub) + this_tor_sub = self._get_subid_from_buses_legacy(buses_sub_id, tor_sub) + this_lex_sub = self._get_subid_from_buses_legacy(buses_sub_id, lex_sub) + this_tex_sub = self._get_subid_from_buses_legacy(buses_sub_id, tex_sub) + this_batt_sub = self._get_subid_from_buses_legacy(buses_sub_id, batt_sub) + this_sh_sub = self._get_subid_from_buses_legacy(buses_sub_id, sh_sub) + + self.load_to_subid = np.array(this_load_sub, dtype=dt_int) + self.gen_to_subid = np.array(this_gen_sub, dtype=dt_int) + self.line_or_to_subid = np.concatenate((this_lor_sub, this_tor_sub)).astype(dt_int) + self.line_ex_to_subid = np.concatenate((this_lex_sub, this_tex_sub)).astype(dt_int) + self.storage_to_subid = np.array(this_batt_sub, dtype=dt_int) + self.shunt_to_subid = np.array(this_sh_sub, dtype=dt_int) else: # TODO get back the sub id from the grid_tmp.get_substations() + # need to work on that grid2op side: different make sure the labelling of the buses are correct ! + (buses_sub_id, gen_sub, load_sub, (lor_sub, tor_sub), (lex_sub, tex_sub), batt_sub, sh_sub, hvdc_sub_from_id, hvdc_sub_to_id) = subs_id raise NotImplementedError("Today the only supported behaviour is to consider the 'buses' of the powsybl grid " "are the 'substation' of this backend. " "This will change in the future, but in the meantime please add " @@ -511,12 +545,23 @@ def _load_grid_pypowsybl(self, path=None, filename=None): "a lightsim2grid grid.") # the names - self.name_load = np.array([f"load_{el.bus_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_loads())]) - self.name_gen = np.array([f"gen_{el.bus_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_generators())]) - self.name_line = np.array([f"{el.bus_or_id}_{el.bus_ex_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_lines())] + - [f"{el.bus_hv_id}_{el.bus_lv_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_trafos())]) - self.name_storage = np.array([f"storage_{el.bus_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_storages())]) - self.name_shunt = np.array([f"shunt_{el.bus_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_shunts())]) + use_grid2op_default_names = True + if "use_grid2op_default_names" in loader_kwargs and not loader_kwargs["use_grid2op_default_names"]: + use_grid2op_default_names = False + + if use_grid2op_default_names: + self.name_load = np.array([f"load_{el.bus_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_loads())]) + self.name_gen = np.array([f"gen_{el.bus_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_generators())]) + self.name_line = np.array([f"{el.bus_or_id}_{el.bus_ex_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_lines())] + + [f"{el.bus_hv_id}_{el.bus_lv_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_trafos())]) + self.name_storage = np.array([f"storage_{el.bus_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_storages())]) + self.name_shunt = np.array([f"shunt_{el.bus_id}_{id_obj}" for id_obj, el in enumerate(self._grid.get_shunts())]) + else: + self.name_load = np.array(load_sub.index) + self.name_gen = np.array(gen_sub.index) + self.name_line = np.concatenate((lor_sub.index, tor_sub.index)) + self.name_storage = np.array(batt_sub.index) + self.name_shunt = np.array(sh_sub.index) # complete the other vectors self._compute_pos_big_topo() @@ -537,8 +582,8 @@ def _load_grid_pypowsybl(self, path=None, filename=None): max_not_too_max = (np.finfo(dt_float).max * 0.5 - 1.) self.thermal_limit_a = max_not_too_max * np.ones(self.n_line, dtype=dt_float) bus_vn_kv = np.array(self._grid.get_bus_vn_kv()) - shunt_bus_id = np.array([el.bus_id for el in self._grid.get_shunts()]) - self._sh_vnkv = bus_vn_kv[shunt_bus_id] + # shunt_bus_id = np.array([el.bus_id for el in self._grid.get_shunts()]) + self._sh_vnkv = bus_vn_kv[self.shunt_to_subid] self._aux_finish_setup_after_reading() def _aux_setup_right_after_grid_init(self): @@ -567,6 +612,8 @@ def _aux_setup_right_after_grid_init(self): # grid2op version >= 1.10.0 then we use this self._grid._max_nb_bus_per_sub = self.n_busbar_per_sub + self._grid.tell_solver_need_reset() + def _load_grid_pandapower(self, path=None, filename=None): if hasattr(type(self), "can_handle_more_than_2_busbar"): type(self.init_pp_backend).n_busbar_per_sub = self.n_busbar_per_sub @@ -979,12 +1026,12 @@ def runpf(self, is_dc=False): self.next_prod_p[:] = self.prod_p - if np.any(~np.isfinite(self.load_v)) or np.any(self.load_v <= 0.): + if self._stop_if_load_disco and ((~np.isfinite(self.load_v)).any() or (self.load_v <= 0.).any()): disco = (~np.isfinite(self.load_v)) | (self.load_v <= 0.) load_disco = np.where(disco)[0] self._timer_postproc += time.perf_counter() - beg_postroc raise BackendError(f"At least one load is disconnected (check loads {load_disco})") - if np.any(~np.isfinite(self.prod_v)) or np.any(self.prod_v <= 0.): + if self._stop_if_gen_disco and ((~np.isfinite(self.prod_v)).any() or (self.prod_v <= 0.).any()): disco = (~np.isfinite(self.prod_v)) | (self.prod_v <= 0.) gen_disco = np.where(disco)[0] self._timer_postproc += time.perf_counter() - beg_postroc @@ -1093,7 +1140,8 @@ def copy(self): "_my_kwargs", "supported_grid_format", "_turned_off_pv", "_dist_slack_non_renew", "_loader_method", "_loader_kwargs", - "_missing_two_busbars_support_info", "n_busbar_per_sub" + "_missing_two_busbars_support_info", "n_busbar_per_sub", + "_use_static_gen", "_stop_if_load_disco", "_stop_if_gen_disco" ] for attr_nm in li_regular_attr: if hasattr(self, attr_nm): diff --git a/src/GridModel.h b/src/GridModel.h index 4fefb2f..7a4b69c 100644 --- a/src/GridModel.h +++ b/src/GridModel.h @@ -352,27 +352,35 @@ class GridModel : public GenericContainer const std::vector & get_bus_status() const {return bus_status_;} void set_line_names(const std::vector & names){ + GenericContainer::check_size(names, powerlines_.nb(), "set_line_names"); powerlines_.set_names(names); } void set_dcline_names(const std::vector & names){ + GenericContainer::check_size(names, dc_lines_.nb(), "set_dcline_names"); dc_lines_.set_names(names); } void set_trafo_names(const std::vector & names){ + GenericContainer::check_size(names, trafos_.nb(), "set_trafo_names"); trafos_.set_names(names); } void set_gen_names(const std::vector & names){ + GenericContainer::check_size(names, generators_.nb(), "set_gen_names"); generators_.set_names(names); } void set_load_names(const std::vector & names){ + GenericContainer::check_size(names, loads_.nb(), "set_load_names"); loads_.set_names(names); } void set_storage_names(const std::vector & names){ + GenericContainer::check_size(names, storages_.nb(), "set_storage_names"); storages_.set_names(names); } void set_sgen_names(const std::vector & names){ + GenericContainer::check_size(names, sgens_.nb(), "set_sgen_names"); sgens_.set_names(names); } void set_shunt_names(const std::vector & names){ + GenericContainer::check_size(names, shunts_.nb(), "set_shunt_names"); shunts_.set_names(names); } diff --git a/src/element_container/DCLineContainer.cpp b/src/element_container/DCLineContainer.cpp index 716229b..01a683b 100644 --- a/src/element_container/DCLineContainer.cpp +++ b/src/element_container/DCLineContainer.cpp @@ -15,13 +15,13 @@ DCLineContainer::StateRes DCLineContainer::get_state() const { std::vector loss_percent(loss_percent_.begin(), loss_percent_.end()); std::vector loss_mw(loss_mw_.begin(), loss_mw_.end()); - std::vector status = status_; + std::vector status = status_; DCLineContainer::StateRes res(names_, - from_gen_.get_state(), - to_gen_.get_state(), - loss_percent, - loss_mw, - status); + from_gen_.get_state(), + to_gen_.get_state(), + loss_percent, + loss_mw, + status); return res; } @@ -39,16 +39,16 @@ void DCLineContainer::set_state(DCLineContainer::StateRes & my_state){ } void DCLineContainer::init(const Eigen::VectorXi & branch_from_id, - const Eigen::VectorXi & branch_to_id, - const RealVect & p_mw, - const RealVect & loss_percent, - const RealVect & loss_mw, - const RealVect & vm_or_pu, - const RealVect & vm_ex_pu, - const RealVect & min_q_or, - const RealVect & max_q_or, - const RealVect & min_q_ex, - const RealVect & max_q_ex){ + const Eigen::VectorXi & branch_to_id, + const RealVect & p_mw, + const RealVect & loss_percent, + const RealVect & loss_mw, + const RealVect & vm_or_pu, + const RealVect & vm_ex_pu, + const RealVect & min_q_or, + const RealVect & max_q_or, + const RealVect & min_q_ex, + const RealVect & max_q_ex){ loss_percent_ = loss_percent; loss_mw_ = loss_mw; status_ = std::vector(branch_from_id.size(), true); diff --git a/src/element_container/DCLineContainer.h b/src/element_container/DCLineContainer.h index 5ee14dc..a64fb1f 100644 --- a/src/element_container/DCLineContainer.h +++ b/src/element_container/DCLineContainer.h @@ -186,7 +186,7 @@ class DCLineContainer : public GenericContainer } // for buses only connected through dc line, i don't add them // they are not in the same "connected component" - virtual void get_graph(std::vector > & res) const {}; + virtual void get_graph(std::vector > & res) const {}; virtual void disconnect_if_not_in_main_component(std::vector & busbar_in_main_component); virtual void nb_line_end(std::vector & res) const; virtual void update_bus_status(std::vector & bus_status) const { diff --git a/src/element_container/GeneratorContainer.cpp b/src/element_container/GeneratorContainer.cpp index b580c40..2515997 100644 --- a/src/element_container/GeneratorContainer.cpp +++ b/src/element_container/GeneratorContainer.cpp @@ -11,11 +11,18 @@ #include void GeneratorContainer::init(const RealVect & generators_p, - const RealVect & generators_v, - const RealVect & generators_min_q, - const RealVect & generators_max_q, - const Eigen::VectorXi & generators_bus_id) + const RealVect & generators_v, + const RealVect & generators_min_q, + const RealVect & generators_max_q, + const Eigen::VectorXi & generators_bus_id) { + int size = static_cast(generators_p.size()); + GenericContainer::check_size(generators_p, size, "generators_p"); + GenericContainer::check_size(generators_v, size, "generators_v"); + GenericContainer::check_size(generators_min_q, size, "generators_min_q"); + GenericContainer::check_size(generators_max_q, size, "generators_max_q"); + GenericContainer::check_size(generators_bus_id, size, "generators_bus_id"); + p_mw_ = generators_p; vm_pu_ = generators_v; bus_id_ = generators_bus_id; @@ -50,15 +57,18 @@ void GeneratorContainer::init(const RealVect & generators_p, } void GeneratorContainer::init_full(const RealVect & generators_p, - const RealVect & generators_v, - const RealVect & generators_q, - const std::vector & voltage_regulator_on, - const RealVect & generators_min_q, - const RealVect & generators_max_q, - const Eigen::VectorXi & generators_bus_id - ) + const RealVect & generators_v, + const RealVect & generators_q, + const std::vector & voltage_regulator_on, + const RealVect & generators_min_q, + const RealVect & generators_max_q, + const Eigen::VectorXi & generators_bus_id + ) { init(generators_p, generators_v, generators_min_q, generators_max_q, generators_bus_id); + int size = static_cast(generators_p.size()); + GenericContainer::check_size(generators_q, size, "generators_q"); + GenericContainer::check_size(voltage_regulator_on, size, "voltage_regulator_on"); voltage_regulator_on_ = voltage_regulator_on; q_mvar_ = generators_q; } @@ -353,7 +363,7 @@ Eigen::VectorXi GeneratorContainer::get_slack_bus_id() const{ } void GeneratorContainer::set_p_slack(const RealVect& node_mismatch, - const std::vector & id_grid_to_solver) + const std::vector & id_grid_to_solver) { if(bus_slack_weight_.size() == 0){ // TODO DEBUG MODE: perform this check only in debug mode @@ -377,9 +387,9 @@ void GeneratorContainer::set_p_slack(const RealVect& node_mismatch, } void GeneratorContainer::init_q_vector(int nb_bus, - Eigen::VectorXi & total_gen_per_bus, - RealVect & total_q_min_per_bus, - RealVect & total_q_max_per_bus) const // delta_q_per_gen_) // total number of bus on the grid + Eigen::VectorXi & total_gen_per_bus, + RealVect & total_q_min_per_bus, + RealVect & total_q_max_per_bus) const { const int nb_gen = nb(); for(int gen_id = 0; gen_id < nb_gen; ++gen_id) @@ -397,11 +407,11 @@ void GeneratorContainer::init_q_vector(int nb_bus, } void GeneratorContainer::set_q(const RealVect & reactive_mismatch, - const std::vector & id_grid_to_solver, - bool ac, - const Eigen::VectorXi & total_gen_per_bus, - const RealVect & total_q_min_per_bus, - const RealVect & total_q_max_per_bus) + const std::vector & id_grid_to_solver, + bool ac, + const Eigen::VectorXi & total_gen_per_bus, + const RealVect & total_q_min_per_bus, + const RealVect & total_q_max_per_bus) { const int nb_gen = nb(); res_q_ = RealVect::Constant(nb_gen, 0.); diff --git a/src/element_container/GenericContainer.cpp b/src/element_container/GenericContainer.cpp index 6daa4fe..cf6dc51 100644 --- a/src/element_container/GenericContainer.cpp +++ b/src/element_container/GenericContainer.cpp @@ -27,14 +27,17 @@ void GenericContainer::_get_amps(RealVect & a, const RealVect & p, const RealVec } a = p2q2.array() * _1_sqrt_3 / v_tmp.array(); } + void GenericContainer::_reactivate(int el_id, std::vector & status){ bool val = status.at(el_id); status.at(el_id) = true; //TODO why it's needed to do that again } + void GenericContainer::_deactivate(int el_id, std::vector & status){ bool val = status.at(el_id); status.at(el_id) = false; //TODO why it's needed to do that again } + void GenericContainer::_change_bus(int el_id, int new_bus_me_id, Eigen::VectorXi & el_bus_ids, SolverControl & solver_control, int nb_bus){ // bus id here "me_id" and NOT "solver_id" // throw error: object id does not exist @@ -105,13 +108,14 @@ int GenericContainer::_get_bus(int el_id, const std::vector & status_, con } void GenericContainer::v_kv_from_vpu(const Eigen::Ref & Va, - const Eigen::Ref & Vm, - const std::vector & status, - int nb_element, - const Eigen::VectorXi & bus_me_id, - const std::vector & id_grid_to_solver, - const RealVect & bus_vn_kv, - RealVect & v){ + const Eigen::Ref & Vm, + const std::vector & status, + int nb_element, + const Eigen::VectorXi & bus_me_id, + const std::vector & id_grid_to_solver, + const RealVect & bus_vn_kv, + RealVect & v) +{ v = RealVect::Constant(nb_element, -1.0); for(int el_id = 0; el_id < nb_element; ++el_id){ // if the element is disconnected, i leave it like that @@ -133,13 +137,13 @@ void GenericContainer::v_kv_from_vpu(const Eigen::Ref & Va, void GenericContainer::v_deg_from_va(const Eigen::Ref & Va, - const Eigen::Ref & Vm, - const std::vector & status, - int nb_element, - const Eigen::VectorXi & bus_me_id, - const std::vector & id_grid_to_solver, - const RealVect & bus_vn_kv, - RealVect & theta){ + const Eigen::Ref & Vm, + const std::vector & status, + int nb_element, + const Eigen::VectorXi & bus_me_id, + const std::vector & id_grid_to_solver, + const RealVect & bus_vn_kv, + RealVect & theta){ theta = RealVect::Constant(nb_element, 0.0); for(int el_id = 0; el_id < nb_element; ++el_id){ // if the element is disconnected, i leave it like that diff --git a/src/element_container/LineContainer.cpp b/src/element_container/LineContainer.cpp index 610aa45..efeac7d 100644 --- a/src/element_container/LineContainer.cpp +++ b/src/element_container/LineContainer.cpp @@ -11,11 +11,11 @@ #include void LineContainer::init(const RealVect & branch_r, - const RealVect & branch_x, - const CplxVect & branch_h, - const Eigen::VectorXi & branch_from_id, - const Eigen::VectorXi & branch_to_id - ) + const RealVect & branch_x, + const CplxVect & branch_h, + const Eigen::VectorXi & branch_from_id, + const Eigen::VectorXi & branch_to_id + ) { /** This method initialize the Ybus matrix from the branch matrix. @@ -29,6 +29,13 @@ void LineContainer::init(const RealVect & branch_r, //TODO consistency with trafo: have a converter methods to convert this value into pu, and store the pu // in this method + int size = static_cast(branch_r.size()); + GenericContainer::check_size(branch_r, size, "branch_r"); + GenericContainer::check_size(branch_x, size, "branch_x"); + GenericContainer::check_size(branch_h, size, "branch_h"); + GenericContainer::check_size(branch_from_id, size, "branch_from_id"); + GenericContainer::check_size(branch_to_id, size, "branch_to_id"); + bus_or_id_ = branch_from_id; bus_ex_id_ = branch_to_id; powerlines_h_or_ = 0.5 * branch_h; @@ -40,12 +47,12 @@ void LineContainer::init(const RealVect & branch_r, } void LineContainer::init(const RealVect & branch_r, - const RealVect & branch_x, - const CplxVect & branch_h_or, - const CplxVect & branch_h_ex, - const Eigen::VectorXi & branch_from_id, - const Eigen::VectorXi & branch_to_id - ) + const RealVect & branch_x, + const CplxVect & branch_h_or, + const CplxVect & branch_h_ex, + const Eigen::VectorXi & branch_from_id, + const Eigen::VectorXi & branch_to_id + ) { /** This method initialize the Ybus matrix from the branch matrix. @@ -59,6 +66,14 @@ void LineContainer::init(const RealVect & branch_r, //TODO consistency with trafo: have a converter methods to convert this value into pu, and store the pu // in this method + int size = static_cast(branch_r.size()); + GenericContainer::check_size(branch_r, size, "branch_r"); + GenericContainer::check_size(branch_x, size, "branch_x"); + GenericContainer::check_size(branch_h_or, size, "branch_h_or"); + GenericContainer::check_size(branch_h_ex, size, "branch_h_ex"); + GenericContainer::check_size(branch_from_id, size, "branch_from_id"); + GenericContainer::check_size(branch_to_id, size, "branch_to_id"); + bus_or_id_ = branch_from_id; bus_ex_id_ = branch_to_id; powerlines_h_or_ = branch_h_or; @@ -150,9 +165,9 @@ void LineContainer::fillYbus_spmat(Eigen::SparseMatrix & res, bool ac } void LineContainer::fillYbus(std::vector > & res, - bool ac, - const std::vector & id_grid_to_solver, - real_type sn_mva) const + bool ac, + const std::vector & id_grid_to_solver, + real_type sn_mva) const { // fill the matrix //TODO template here instead of "if" for ac / dc @@ -206,10 +221,10 @@ void LineContainer::fillYbus(std::vector > & res, } void LineContainer::fillBp_Bpp(std::vector > & Bp, - std::vector > & Bpp, - const std::vector & id_grid_to_solver, - real_type sn_mva, - FDPFMethod xb_or_bx) const + std::vector > & Bpp, + const std::vector & id_grid_to_solver, + real_type sn_mva, + FDPFMethod xb_or_bx) const { // For Bp @@ -291,10 +306,10 @@ void LineContainer::fillBp_Bpp(std::vector > & Bp, void LineContainer::fillBf_for_PTDF(std::vector > & Bf, - const std::vector & id_grid_to_solver, - real_type sn_mva, - int nb_powerline, - bool transpose) const + const std::vector & id_grid_to_solver, + real_type sn_mva, + int nb_powerline, + bool transpose) const { const Eigen::Index nb_line = powerlines_r_.size(); @@ -351,12 +366,12 @@ void LineContainer::reset_results() } void LineContainer::compute_results(const Eigen::Ref & Va, - const Eigen::Ref & Vm, - const Eigen::Ref & V, - const std::vector & id_grid_to_solver, - const RealVect & bus_vn_kv, - real_type sn_mva, - bool ac) + const Eigen::Ref & Vm, + const Eigen::Ref & V, + const std::vector & id_grid_to_solver, + const RealVect & bus_vn_kv, + real_type sn_mva, + bool ac) { // it needs to be initialized at 0. Eigen::Index nb_element = nb(); diff --git a/src/element_container/LoadContainer.cpp b/src/element_container/LoadContainer.cpp index d7eb561..d9d0a1b 100644 --- a/src/element_container/LoadContainer.cpp +++ b/src/element_container/LoadContainer.cpp @@ -10,9 +10,14 @@ #include void LoadContainer::init(const RealVect & loads_p, - const RealVect & loads_q, - const Eigen::VectorXi & loads_bus_id) + const RealVect & loads_q, + const Eigen::VectorXi & loads_bus_id) { + int size = static_cast(loads_p.size()); + GenericContainer::check_size(loads_p, size, "loads_p"); + GenericContainer::check_size(loads_q, size, "loads_q"); + GenericContainer::check_size(loads_bus_id, size, "loads_bus_id"); + p_mw_ = loads_p; q_mvar_ = loads_q; bus_id_ = loads_bus_id; @@ -29,6 +34,7 @@ LoadContainer::StateRes LoadContainer::get_state() const LoadContainer::StateRes res(names_, p_mw, q_mvar, bus_id, status); return res; } + void LoadContainer::set_state(LoadContainer::StateRes & my_state ) { reset_results(); @@ -47,7 +53,10 @@ void LoadContainer::set_state(LoadContainer::StateRes & my_state ) } -void LoadContainer::fillSbus(CplxVect & Sbus, const std::vector & id_grid_to_solver, bool ac) const { +void LoadContainer::fillSbus(CplxVect & Sbus, + const std::vector & id_grid_to_solver, + bool ac) const +{ int nb_load = nb(); int bus_id_me, bus_id_solver; cplx_type tmp; diff --git a/src/element_container/ShuntContainer.cpp b/src/element_container/ShuntContainer.cpp index 76a6129..4b5687b 100644 --- a/src/element_container/ShuntContainer.cpp +++ b/src/element_container/ShuntContainer.cpp @@ -11,9 +11,14 @@ #include void ShuntContainer::init(const RealVect & shunt_p_mw, - const RealVect & shunt_q_mvar, - const Eigen::VectorXi & shunt_bus_id) + const RealVect & shunt_q_mvar, + const Eigen::VectorXi & shunt_bus_id) { + int size = static_cast(shunt_p_mw.size()); + GenericContainer::check_size(shunt_p_mw, size, "shunt_p_mw"); + GenericContainer::check_size(shunt_q_mvar, size, "shunt_q_mvar"); + GenericContainer::check_size(shunt_bus_id, size, "shunt_bus_id"); + p_mw_ = shunt_p_mw; q_mvar_ = shunt_q_mvar; bus_id_ = shunt_bus_id; @@ -132,12 +137,12 @@ void ShuntContainer::fillYbus_spmat(Eigen::SparseMatrix & res, bool a } void ShuntContainer::compute_results(const Eigen::Ref & Va, - const Eigen::Ref & Vm, - const Eigen::Ref & V, - const std::vector & id_grid_to_solver, - const RealVect & bus_vn_kv, - real_type sn_mva, - bool ac) + const Eigen::Ref & Vm, + const Eigen::Ref & V, + const std::vector & id_grid_to_solver, + const RealVect & bus_vn_kv, + real_type sn_mva, + bool ac) { const int nb_shunt = static_cast(p_mw_.size()); v_kv_from_vpu(Va, Vm, status_, nb_shunt, bus_id_, id_grid_to_solver, bus_vn_kv, res_v_); diff --git a/src/element_container/TrafoContainer.cpp b/src/element_container/TrafoContainer.cpp index ac4c346..f33e1cd 100644 --- a/src/element_container/TrafoContainer.cpp +++ b/src/element_container/TrafoContainer.cpp @@ -12,16 +12,16 @@ #include void TrafoContainer::init(const RealVect & trafo_r, - const RealVect & trafo_x, - const CplxVect & trafo_b, - const RealVect & trafo_tap_step_pct, - // const RealVect & trafo_tap_step_degree, - const RealVect & trafo_tap_pos, - const RealVect & trafo_shift_degree, - const std::vector & trafo_tap_hv, // is tap on high voltage (true) or low voltate - const Eigen::VectorXi & trafo_hv_id, - const Eigen::VectorXi & trafo_lv_id - ) + const RealVect & trafo_x, + const CplxVect & trafo_b, + const RealVect & trafo_tap_step_pct, + // const RealVect & trafo_tap_step_degree, + const RealVect & trafo_tap_pos, + const RealVect & trafo_shift_degree, + const std::vector & trafo_tap_hv, // is tap on high voltage (true) or low voltate + const Eigen::VectorXi & trafo_hv_id, + const Eigen::VectorXi & trafo_lv_id + ) { /** INPUT DATA ARE ALREADY PAIR UNIT !! @@ -164,15 +164,17 @@ void TrafoContainer::_update_model_coeffs() } } -void TrafoContainer::fillYbus_spmat(Eigen::SparseMatrix & res, bool ac, const std::vector & id_grid_to_solver) +void TrafoContainer::fillYbus_spmat(Eigen::SparseMatrix & res, + bool ac, + const std::vector & id_grid_to_solver) { throw std::runtime_error("You should not use that!"); } void TrafoContainer::fillYbus(std::vector > & res, - bool ac, - const std::vector & id_grid_to_solver, - real_type sn_mva) const + bool ac, + const std::vector & id_grid_to_solver, + real_type sn_mva) const { //TODO merge that with fillYbusBranch! //TODO template here instead of "if" for ac / dc @@ -222,7 +224,10 @@ void TrafoContainer::fillYbus(std::vector > & res, } } -void TrafoContainer::hack_Sbus_for_dc_phase_shifter(CplxVect & Sbus, bool ac, const std::vector & id_grid_to_solver){ +void TrafoContainer::hack_Sbus_for_dc_phase_shifter(CplxVect & Sbus, + bool ac, + const std::vector & id_grid_to_solver) +{ if(ac) return; // return; const int nb_trafo = nb(); @@ -256,13 +261,13 @@ void TrafoContainer::hack_Sbus_for_dc_phase_shifter(CplxVect & Sbus, bool ac, co } void TrafoContainer::compute_results(const Eigen::Ref & Va, - const Eigen::Ref & Vm, - const Eigen::Ref & V, - const std::vector & id_grid_to_solver, - const RealVect & bus_vn_kv, - real_type sn_mva, - bool ac - ) + const Eigen::Ref & Vm, + const Eigen::Ref & V, + const std::vector & id_grid_to_solver, + const RealVect & bus_vn_kv, + real_type sn_mva, + bool ac + ) { // it needs to be initialized at 0. const int nb_element = nb(); @@ -360,10 +365,10 @@ void TrafoContainer::reset_results(){ void TrafoContainer::fillBp_Bpp(std::vector > & Bp, - std::vector > & Bpp, - const std::vector & id_grid_to_solver, - real_type sn_mva, - FDPFMethod xb_or_bx) const + std::vector > & Bpp, + const std::vector & id_grid_to_solver, + real_type sn_mva, + FDPFMethod xb_or_bx) const { // For Bp @@ -461,10 +466,10 @@ void TrafoContainer::fillBp_Bpp(std::vector > & Bp, void TrafoContainer::fillBf_for_PTDF(std::vector > & Bf, - const std::vector & id_grid_to_solver, - real_type sn_mva, - int nb_powerline, - bool transpose) const + const std::vector & id_grid_to_solver, + real_type sn_mva, + int nb_powerline, + bool transpose) const { const Eigen::Index nb_trafo = r_.size();