def _change_status(self, from_status, to_status): # Do we need to scale production on generators due to droop? if len(self._scale_area): scale_area = self._scale_area else: scale_area = MonsterPssPy.aareaint(-1, 1, 'NUMBER')[0] # Get total load try: s_total = MonsterPssPy.loddt2(self.from_bus.number, self.identificator, 'TOTAL', 'ACT') except PsseLoddtException as e: if to_status == ComponentStatus.on and e._ierr == 4: s_total = -e._value else: raise if self.status() == to_status: if to_status == ComponentStatus.off: raise PsseBaseException('Load component already out of service.', None) else: raise PsseBaseException('Load component already in service.', None) try: MonsterPssPy.load_chng( self.from_bus.number, self.identificator, intgar1=to_status.get_index() ) # Define SID for scale area sid = 2 MonsterPssPy.bsys(sid, numarea=len(scale_area), areas=scale_area) # Scale with (3) incremental powers, (0) ignore machine # power limits, (0) No Q changes and (2) only type 2 and 3 # buses. MonsterPssPy.scal(sid, 0, 0, [0, 0, 0, 2, 0], [0.0, -s_total.real] + [0.0] * 5) except PsseBaseException: raise
def get_pq(self): """ Get PQ value from case as a complex value """ return MonsterPssPy.loddt2(self.from_bus.number, self.identificator, 'MVA', 'ACT')