Skip to content

Commit

Permalink
more simple motor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
JKeen8 committed Oct 24, 2023
1 parent 8cebb4c commit 712b988
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions PyDSS/pyControllers/Controllers/MotorStallSimple.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import random
import math
import os
import pdb

class MotorStallSimple(ControllerAbstract):
"""The controller locks a regulator in the event of reverse power flow. Subclass of the :class:`PyDSS.pyControllers.
Expand Down Expand Up @@ -61,11 +62,11 @@ def debugInfo(self):

def Update(self, Priority, Time, UpdateResults):
assert Priority in [0, 1, 2], "Valid control priorities can range from 0-2."
Ve_mags = 1.0
if Priority == 0:
Vbase = self._ControlledElm.sBus[0].GetVariable('kVBase') * 1000
Ve_mags = max(self._ControlledElm.GetVariable('VoltagesMagAng')[::2])/ Vbase

if Ve_mags < self.__Settings['Vstall'] and not self.stall:
if Ve_mags < self.__Settings['Vstall'] and not self.stall and not self.disconnected:
self._ControlledElm.SetParameter('kw', self.kw * self.__Settings['Pfault'] )
self._ControlledElm.SetParameter('kvar', self.kvar * self.__Settings['Qfault'] )
self._ControlledElm.SetParameter('model', 2)
Expand All @@ -75,6 +76,7 @@ def Update(self, Priority, Time, UpdateResults):
return 0
if Priority == 1:
if self.stall:

self.stall_time = self.__dssSolver.GetTotalSeconds() - self.stall_time_start
if self.stall_time > self.__Settings['Tprotection']:
self.stall = False
Expand All @@ -87,7 +89,7 @@ def Update(self, Priority, Time, UpdateResults):
if Priority == 2:
if self.disconnected:
time = self.__dssSolver.GetTotalSeconds() - self.Tdisconnect_start
if time > self.__Settings['Treconnect']:
if time > self.__Settings['Treconnect'] and Ve_mags > self.__Settings['Vstall']:
self.disconnected = False
self._ControlledElm.SetParameter('kw', self.kw)
self._ControlledElm.SetParameter('kvar', self.kvar)
Expand Down

0 comments on commit 712b988

Please sign in to comment.