From cf9ec821cda200d2955cf244329b0542b8ee8d2a Mon Sep 17 00:00:00 2001 From: "AzureAD\\PanagiotisXenos" Date: Thu, 19 Dec 2024 12:54:05 +0200 Subject: [PATCH 1/2] update check for tap phase shifter for pandapower v3.0 Signed-off-by: AzureAD\PanagiotisXenos --- .../gridmodel/from_pandapower/_aux_add_trafo.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lightsim2grid/gridmodel/from_pandapower/_aux_add_trafo.py b/lightsim2grid/gridmodel/from_pandapower/_aux_add_trafo.py index 1ed2d46..56dd4ff 100644 --- a/lightsim2grid/gridmodel/from_pandapower/_aux_add_trafo.py +++ b/lightsim2grid/gridmodel/from_pandapower/_aux_add_trafo.py @@ -61,9 +61,15 @@ def _aux_add_trafo(converter, model, pp_net, pp_to_ls): warnings.warn("There were some Nan in the pp_net.trafo[\"tap_side\"], they have been replaced by \"hv\"") is_tap_hv_side[~np.isfinite(is_tap_hv_side)] = True - if np.any(pp_net.trafo["tap_phase_shifter"].values): - raise RuntimeError("ideal phase shifter are not modeled. Please remove all trafo with " - "pp_net.trafo[\"tap_phase_shifter\"] set to True.") + if int(pp.__version__.split(".")[0]) < 3: + if np.any(pp_net.trafo["tap_phase_shifter"].values): + raise RuntimeError("Ideal phase shifters are not modeled. Please remove all trafos with " + "pp_net.trafo[\"tap_phase_shifter\"] set to True.") + else: + if np.any(pp_net.trafo["tap_changer_type"].values == "Ideal") or \ + np.any(pp_net.trafo3w["tap_changer_type"].values == "Ideal"): + raise RuntimeError("Ideal phase shifters are not modeled. Please remove all 2-winding or 3-winding trafos " + "with \"tap_changer_type\" set to \"Ideal\".") tap_angles_ = 1.0 * pp_net.trafo["tap_step_degree"].values if np.any(~np.isfinite(tap_angles_)): From 94f5e1679cc067dd84a85ca86a0c756b946e7a1a Mon Sep 17 00:00:00 2001 From: "AzureAD\\PanagiotisXenos" Date: Thu, 19 Dec 2024 13:08:16 +0200 Subject: [PATCH 2/2] update check for tap phase shifter for pandapower v3.0 Signed-off-by: AzureAD\PanagiotisXenos --- .../gridmodel/from_pandapower/_aux_add_trafo.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lightsim2grid/gridmodel/from_pandapower/_aux_add_trafo.py b/lightsim2grid/gridmodel/from_pandapower/_aux_add_trafo.py index 56dd4ff..19da77b 100644 --- a/lightsim2grid/gridmodel/from_pandapower/_aux_add_trafo.py +++ b/lightsim2grid/gridmodel/from_pandapower/_aux_add_trafo.py @@ -61,14 +61,17 @@ def _aux_add_trafo(converter, model, pp_net, pp_to_ls): warnings.warn("There were some Nan in the pp_net.trafo[\"tap_side\"], they have been replaced by \"hv\"") is_tap_hv_side[~np.isfinite(is_tap_hv_side)] = True - if int(pp.__version__.split(".")[0]) < 3: + if "tap_phase_shifter" in pp_net.trafo: if np.any(pp_net.trafo["tap_phase_shifter"].values): raise RuntimeError("Ideal phase shifters are not modeled. Please remove all trafos with " "pp_net.trafo[\"tap_phase_shifter\"] set to True.") - else: - if np.any(pp_net.trafo["tap_changer_type"].values == "Ideal") or \ - np.any(pp_net.trafo3w["tap_changer_type"].values == "Ideal"): - raise RuntimeError("Ideal phase shifters are not modeled. Please remove all 2-winding or 3-winding trafos " + elif "tap_changer_type" in pp_net.trafo: + if np.any(pp_net.trafo["tap_changer_type"].values == "Ideal"): + raise RuntimeError("Ideal phase shifters are not modeled. Please remove all 2-winding trafos " + "with \"tap_changer_type\" set to \"Ideal\".") + elif "tap_changer_type" in pp_net.trafo3w: + if np.any(pp_net.trafo3w["tap_changer_type"].values == "Ideal"): + raise RuntimeError("Ideal phase shifters are not modeled. Please remove all 3-winding trafos " "with \"tap_changer_type\" set to \"Ideal\".") tap_angles_ = 1.0 * pp_net.trafo["tap_step_degree"].values