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