def init1(self, dae): # check the exclusivity of rate and amount # obtain the p0 and q0 at the time of the start self.copy_data_ext("StaticLoad", field="p0", dest="p0", idx=self.load) self.copy_data_ext("StaticLoad", field="q0", dest="q0", idx=self.load) self.copy_data_ext("StaticLoad", field="a", dest="a", idx=self.load) self.copy_data_ext("StaticLoad", field="v", dest="v", idx=self.load) self.p_out = zeros(self.n, 1) self.q_out = zeros(self.n, 1)
def run_step0(self): """ For the 0th step, store the data and stream data Returns ------- None """ dae = self.system.dae system = self.system self.inc = zeros(dae.m + dae.n, 1) system.varout.store(self.t, self.step) self.streaming_step()
def run_step0(self): """ For the 0th step, store the data and stream data Returns ------- None """ dae = self.system.dae system = self.system config = self.config # compute line and area flow if config.compute_flows: dae.init_fg() self.compute_flows() # TODO: move to PowerSystem self.inc = zeros(dae.m + dae.n, 1) system.varout.store(self.t, self.step) self.streaming_step()
def init1(self, dae): self.ace = [[]] * self.n for idx, item in enumerate(self.BA): self.ace[idx] = self.read_data_ext('BArea', field='ace', idx=item) self.en = zeros(self.n, 1)
def init1(self, dae): if globals()['cp'] is None: try: globals()['cp'] = importlib.import_module('cvxpy') except ImportError: logger.error( 'CVXPY import error. Install optional package `cvxpy` to use AGCMPC' ) sys.exit(1) self.t = -1 self.tlast = -1 # state array x = [delta, omega, xg1] # input array u = [dpin] self.copy_data_ext('Governor', field='gen', dest='syn', idx=self.tg) self.copy_data_ext('Synchronous', field='delta', dest='delta', idx=self.syn) self.copy_data_ext('Synchronous', field='omega', dest='omega', idx=self.syn) self.copy_data_ext('Synchronous', field='e1d', dest='e1d', idx=self.syn) self.copy_data_ext('Synchronous', field='e1q', dest='e1q', idx=self.syn) self.copy_data_ext('Synchronous', field='e2d', dest='e2d', idx=self.syn) self.copy_data_ext('Synchronous', field='e2q', dest='e2q', idx=self.syn) self.copy_data_ext('Governor', field='xg1', dest='xg1', idx=self.tg) self.copy_data_ext('Governor', field='xg2', dest='xg2', idx=self.tg) self.copy_data_ext('Governor', field='xg3', dest='xg3', idx=self.tg) self.copy_data_ext('Governor', field='pin', dest='pin', idx=self.tg) self.copy_data_ext('AVR', field='vm', dest='vm', idx=self.avr) self.copy_data_ext('AVR', field='vr1', dest='vr1', idx=self.avr) self.copy_data_ext('AVR', field='vr2', dest='vr2', idx=self.avr) self.copy_data_ext('AVR', field='vfout', dest='vfout', idx=self.avr) dae.y[self.dpin] = 0 self.dpin0 = zeros(self.n, 1) # build state/ input /other algebraic idx array self.xidx = matrix([ self.delta, self.omega, self.e1d, self.e1q, self.e2d, self.e2q, self.xg1, self.xg2, self.xg3, self.vm, self.vr1, self.vr2, self.vfout ]) self.x0 = dae.x[self.xidx] self.x = zeros(len(self.xidx), 1) self.dx = zeros(len(self.xidx), 1) self.xlast = dae.x[self.xidx] self.uidx = matrix([self.dpin]) self.ulast = zeros(self.n, 1) self.dpin_calc = zeros(self.n, 1) self.widx = self.system.PQ.a self.w0 = self.system.PQ.p0 self.wlast = matrix(self.w0) self.yidx = self.omega self.yidx_in_x = [index(self.xidx, y)[0] for y in self.yidx] yidx = np.delete(np.arange(dae.m), np.array(self.uidx)) self.yxidx = matrix(yidx) # optimization problem self.uvar = cp.Variable((len(self.uidx), self.H + 1), 'u') self.uzero = cp.Parameter((len(self.uidx), ), 'u0') self.xazero = cp.Parameter((2 * len(self.xidx), 1), 'xa') self.prob = None self.t_store = [] self.xpred_store = []