Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix NaN in tap controllers #2185

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Loading