Skip to content

Commit

Permalink
Merge pull request #2185 from dlohmeier/tap_controllers_oos_connectivity
Browse files Browse the repository at this point in the history
fix NaN in tap controllers
  • Loading branch information
dlohmeier authored Dec 19, 2023
2 parents 2da47f3 + 8c8e94c commit 875a3cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pandapower/control/controller/trafo/ContinuousTapControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# and Energy System Technology (IEE), Kassel. All rights reserved.

import numpy as np

from pandapower.auxiliary import read_from_net, write_to_net
from pandapower.control.controller.trafo_control import TrafoController

Expand Down Expand Up @@ -97,6 +98,8 @@ def is_converged(self, net):
return True

vm_pu = read_from_net(net, "res_bus", self.controlled_bus, "vm_pu", self._read_write_flag)
# this is possible in case the trafo is set out of service by the connectivity check
is_nan = np.isnan(vm_pu)
self.tap_pos = read_from_net(net, self.trafotable, self.controlled_tid, "tap_pos", self._read_write_flag)
difference = 1 - self.vm_set_pu / vm_pu

Expand All @@ -110,4 +113,4 @@ def is_converged(self, net):
else:
converged = np.abs(difference) < self.tol

return np.all(converged)
return np.all(np.logical_or(converged, is_nan))
7 changes: 5 additions & 2 deletions pandapower/control/controller/trafo/DiscreteTapControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
# Copyright (c) 2016-2023 by University of Kassel and Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), Kassel. All rights reserved.
import numpy as np

from pandapower.auxiliary import read_from_net, write_to_net
from pandapower.control.controller.trafo_control import TrafoController


class DiscreteTapControl(TrafoController):
"""
Trafo Controller with local tap changer voltage control.
Expand Down Expand Up @@ -115,6 +117,8 @@ def is_converged(self, net):
return True

vm_pu = read_from_net(net, "res_bus", self.controlled_bus, "vm_pu", self._read_write_flag)
# this is possible in case the trafo is set out of service by the connectivity check
is_nan = np.isnan(vm_pu)
self.tap_pos = read_from_net(net, self.trafotable, self.controlled_tid, "tap_pos", self._read_write_flag)

reached_limit = np.where(self.tap_side_coeff * self.tap_sign == 1,
Expand All @@ -125,5 +129,4 @@ def is_converged(self, net):

converged = np.logical_or(reached_limit, np.logical_and(self.vm_lower_pu < vm_pu, vm_pu < self.vm_upper_pu))

return np.all(converged)

return np.all(np.logical_or(converged, is_nan))

0 comments on commit 875a3cb

Please sign in to comment.