From 98535e35f013171626208acd4c377ed1711e04f2 Mon Sep 17 00:00:00 2001 From: Nitish Bharambe Date: Wed, 21 Aug 2024 13:38:06 +0200 Subject: [PATCH] clip i0 Signed-off-by: Nitish Bharambe --- src/power_grid_model_io/converters/pandapower_converter.py | 7 ++++++- tests/unit/converters/test_pandapower_converter_input.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/power_grid_model_io/converters/pandapower_converter.py b/src/power_grid_model_io/converters/pandapower_converter.py index 145afb93..d1afe3d6 100644 --- a/src/power_grid_model_io/converters/pandapower_converter.py +++ b/src/power_grid_model_io/converters/pandapower_converter.py @@ -747,8 +747,13 @@ def _create_pgm_input_transformers(self): # pylint: disable=too-many-statements pgm_transformers["sn"] = sn_mva * parallel * 1e6 pgm_transformers["uk"] = vk_percent * 1e-2 pgm_transformers["pk"] = vkr_percent * sn_mva * parallel * (1e6 * 1e-2) - pgm_transformers["i0"] = i_no_load * 1e-2 pgm_transformers["p0"] = pfe * parallel * 1e3 + pgm_transformers["i0"] = i_no_load * 1e-2 + if any(np.less(pgm_transformers["i0"], pgm_transformers["p0"] / pgm_transformers["sn"])): + logger.warning("Minimum value of i0 is clipped to p0/sn") + pgm_transformers["i0"] = np.clip( + pgm_transformers["i0"], a_min=pgm_transformers["p0"] / pgm_transformers["sn"], a_max=None + ) pgm_transformers["clock"] = clocks pgm_transformers["winding_from"] = winding_types["winding_from"] pgm_transformers["winding_to"] = winding_types["winding_to"] diff --git a/tests/unit/converters/test_pandapower_converter_input.py b/tests/unit/converters/test_pandapower_converter_input.py index 877b4295..00a8864c 100644 --- a/tests/unit/converters/test_pandapower_converter_input.py +++ b/tests/unit/converters/test_pandapower_converter_input.py @@ -822,6 +822,7 @@ def test_create_pgm_input_shunts(mock_init_array: MagicMock, two_pp_objs, conver @patch("power_grid_model_io.converters.pandapower_converter.initialize_array") @patch("power_grid_model_io.converters.pandapower_converter.np.round", new=lambda x: x) +@patch("power_grid_model_io.converters.pandapower_converter.np.less", new=lambda x, _, **kwargs: x) @patch("power_grid_model_io.converters.pandapower_converter.np.divide", new=lambda x, _, **kwargs: x) @patch("power_grid_model_io.converters.pandapower_converter.np.bitwise_and", new=lambda x, _: x) @patch("power_grid_model_io.converters.pandapower_converter.np.logical_and", new=lambda x, _: x)