def __init__(self, system, config): ExcBase.__init__(self, system, config) self.LG = Lag( u=self.v, T=self.TR, K=1, info='Sensing delay', ) self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', ) self.vi.v_str = 'vf0 / KA' self.vi.e_str = '(vref0 - LG_y) - vi' self.vref0 = PostInitService( info='Const reference voltage', tex_name='V_{ref0}', v_str='v + vf0 / KA', ) self.HLI = HardLimiter( u=self.vi, lower=self.VIMIN, upper=self.VIMAX, info='Hard limiter on input', ) self.LL = LeadLag( u='vi * HLI_zi + VIMIN * HLI_zl + VIMAX * HLI_zu', T1=self.TC, T2=self.TB, info='Lead-lag compensator', zero_out=True, ) self.LR = Lag(u=self.LL_y, T=self.TA, K=self.KA, info='Regulator') # the following uses `XadIfd` for `IIFD` in the PSS/E manual self.vfmax = Algeb( info='Upper bound of output limiter', tex_name='V_{fmax}', v_str='VRMAX - KC * XadIfd', e_str='VRMAX - KC * XadIfd - vfmax', ) self.vfmin = Algeb( info='Lower bound of output limiter', tex_name='V_{fmin}', v_str='VRMIN - KC * XadIfd', e_str='VRMIN - KC * XadIfd - vfmin', ) self.HLR = HardLimiter(u=self.LR_y, lower=self.vfmin, upper=self.vfmax, info='Hard limiter on regulator output') self.vout.e_str = 'ue * (LR_y*HLR_zi + vfmin*HLR_zl + vfmax*HLR_zu) - vout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) self.vref = Algeb(info='Reference voltage input', tex_name='V_{ref}', unit='p.u.', v_str='v + vf0 / KA', e_str='vref0 - vref' ) self.vref0 = PostInitService(info='constant vref', v_str='vref', tex_name='V_{ref0}', ) # input excitation voltages; PSS outputs summed at vi self.vi = Algeb(info='Total input voltages', tex_name='V_i', unit='p.u.', ) self.vi.v_str = 'vf0 / KA' self.vi.e_str = '(vref - LG_y - WF_y) - vi' self.LG = Lag(u=self.v, T=self.TR, K=1, info='Sensing delay', ) self.HLI = HardLimiter(u=self.vi, lower=self.VIMIN, upper=self.VIMAX, info='Hard limiter on input', ) self.vl = Algeb(info='Input after limiter', tex_name='V_l', v_str='HLI_zi*vi + HLI_zu*VIMAX + HLI_zl*VIMIN', e_str='HLI_zi*vi + HLI_zu*VIMAX + HLI_zl*VIMIN - vl', ) self.LL = LeadLag(u=self.vl, T1=self.TC, T2=self.TB, info='Lead-lag compensator', zero_out=True) self.LR = Lag(u=self.LL_y, T=self.TA, K=self.KA, info='Regulator') self.WF = Washout(u=self.LR_y, T=self.TF, K=self.KF, info='Stablizing circuit feedback') # the following uses `XadIfd` for `IIFD` in the PSS/E manual self.vfmax = Algeb(info='Upper bound of output limiter', tex_name='V_{fmax}', v_str='VRMAX - KC * XadIfd', e_str='VRMAX - KC * XadIfd - vfmax', ) self.vfmin = Algeb(info='Lower bound of output limiter', tex_name='V_{fmin}', v_str='VRMIN - KC * XadIfd', e_str='VRMIN - KC * XadIfd - vfmin', ) self.HLR = HardLimiter(u=self.WF_y, lower=self.vfmin, upper=self.vfmax, info='Hard limiter on regulator output') self.vout.e_str = 'LR_y*HLR_zi + vfmin*HLR_zl + vfmax*HLR_zu - vout'
def __init__(self, system, config): TGBase.__init__(self, system, config) self.gain = ConstService( v_str='ue/R', tex_name='G', ) self.pref = Algeb( info='Reference power input', tex_name='P_{ref}', v_str='tm0 * R', e_str='pref0 * R - pref', ) self.wd = Algeb( info='Generator under speed', unit='p.u.', tex_name=r'\omega_{dev}', v_str='0', e_str='ue * (omega - wref) - wd', ) self.pd = Algeb(info='Pref plus under speed times gain', unit='p.u.', tex_name="P_d", v_str='ue * tm0', e_str='ue*(- wd + pref + paux) * gain - pd') self.v9 = Algeb( tex_name=r'V_{9}', info='V_9 for LVGate input', v_str='ue * (AT + KT * (AT - tm0))', e_str='ue * (AT + KT * (AT - LG3_y)) - v9', ) self.LVG = LVGate( u1=self.pd, u2=self.v9, info='LVGate', ) self.LAG = LagAntiWindup( u=self.LVG_y, K=1, T=self.T1, lower=self.VMIN, upper=self.VMAX, ) self.LG2 = Lag(u=self.LAG_y, T=self.T2, K=1, info='Lag T2') self.LG3 = Lag(u=self.LG2_y, T=self.T3, K=1, info='Lag T3') self.pout.e_str = 'ue * (LG2_y - Dt * wd) - pout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) ExcVsum.__init__(self) self.LP = Lag( u=self.v, T=self.TR, K=1, info='Voltage transducer', ) self.vi = Algeb( info='Total voltage input', unit='pu', e_str='ue * (-LP_y + vref + Vs - WF_y ) -vi ', v_str='ue*(-v +vref)', ) self.VRMAXu = ConstService('VRMAX * ue + (1-ue) * 999') self.VRMINu = ConstService('VRMIN * ue + (1-ue) * -999') self.VR = LagAntiWindup( u=self.vi, T=self.TA, K=self.KA, upper=self.VRMAXu, lower=self.VRMINu, ) self.LL = LeadLag( u=self.VR_y, T1=self.TF3, T2=self.TF2, ) self.WF = Washout(u=self.LL_y, T=self.TF1, K=self.KF) self.INTin = 'ue * (VR_y - VFE)' ExcACSat.__init__(self) self.vref.v_str = 'v + VFE / KA' self.vref0 = PostInitService( info='Initial reference voltage input', tex_name='V_{ref0}', v_str='vref', ) self.VFE.v_str = "INT_y * KE + Se " self.VFE.e_str = "ue * (INT_y * KE + Se - VFE) " # disable iterative initialization of the integrator output self.INT.y.v_str = 'vf0' self.INT.y.v_iter = None self.vout.e_str = 'ue * INT_y - vout'
def __init__(self, system, config): TGBase.__init__(self, system, config) self.F1 = Lag( u='omega - wref', T=self.T1, K=self.K1, ) self.F2 = LeadLag( u=self.F1_y, T1=self.T2, T2=self.T3, K=1.0, ) self.HL = GainLimiter( u='paux + pref0 - F2_y', K=1.0, lower=self.PMIN, upper=self.PMAX, ) self.F3 = Lag( u=self.HL_y, T=self.T4, K=1.0, ) self.F4 = Lag( u=self.F3_y, T=self.T5, K=self.K2, ) self.F5 = Lag( u=self.F4_y, T=self.T6, K=self.K3, ) self.pout.e_str = '(1 - K2) * F3_y + (1-K3) * F4_y + F5_y - pout'
def __init__(self, system, config): ModelData.__init__(self) Model.__init__(self, system, config) self.flags.tds = True self.group = 'FreqMeasurement' # Parameters self.bus = IdxParam(info="bus idx", mandatory=True) self.Tf = NumParam(default=0.02, info="input digital filter time const", unit="sec", tex_name='T_f') self.Tw = NumParam(default=0.02, info="washout time const", unit="sec", tex_name='T_w') self.fn = NumParam(default=60.0, info="nominal frequency", unit='Hz', tex_name='f_n') # Variables self.iwn = ConstService(v_str='u / (2 * pi * fn)', tex_name=r'1/\omega_n') self.a0 = ExtService(src='a', model='Bus', indexer=self.bus, tex_name=r'\theta_0', info='initial phase angle', ) self.a = ExtAlgeb(model='Bus', src='a', indexer=self.bus, tex_name=r'\theta', ) self.v = ExtAlgeb(model='Bus', src='v', indexer=self.bus, tex_name=r'V', ) self.L = Lag(u='(a-a0)', T=self.Tf, K=1, info='digital filter', ) self.WO = Washout(u=self.L_y, K=self.iwn, T=self.Tw, info='angle washout', ) self.f = Algeb(info='frequency output', unit='p.u. (Hz)', tex_name='f', v_str='1', e_str='1 + WO_y - f', )
def __init__(self, system, config): super().__init__(system, config) self.flags.tds = True self.group = 'PLL' self.a = ExtAlgeb(model='Bus', src='a', indexer=self.bus, tex_name=r'\theta', info='Bus voltage angle') self.af = Lag( u=self.a, T=self.Tf, K=1, D=1, info='input angle signal filter', ) self.PI = PIController( u='u * (af_y - am)', kp=self.Kp, ki=self.Ki, tex_name='PI', info='PI controller', ) self.ae = State(info='PLL angle output before filter', e_str='2 * pi *fn * PI_y', v_str='a', tex_name=r'\theta_{est}') self.am = State(info='PLL output angle after filtering', e_str='ae - am', t_const=self.Tp, v_str='a', tex_name=r'\theta_{PLL}')
def __init__(self, system, config): ExcBase.__init__(self, system, config) # vd, vq, Id, Iq from SynGen self.vd = ExtAlgeb( src='vd', model='SynGen', indexer=self.syn, tex_name=r'V_d', info='d-axis machine voltage', ) self.vq = ExtAlgeb( src='vq', model='SynGen', indexer=self.syn, tex_name=r'V_q', info='q-axis machine voltage', ) self.Id = ExtAlgeb( src='Id', model='SynGen', indexer=self.syn, tex_name=r'I_d', info='d-axis machine current', ) self.Iq = ExtAlgeb( src='Iq', model='SynGen', indexer=self.syn, tex_name=r'I_q', info='q-axis machine current', ) self.VE = VarService( tex_name=r'V_{E}', info=r'V_{E}', v_str='Abs(KP * (vd + 1j*vq) + 1j*KI*(Id + 1j*Iq))', ) self.V40 = ConstService('sqrt(VE ** 2 - (0.78 * XadIfd) ** 2)') self.VR0 = ConstService(info='Initial VR', tex_name='V_{R0}', v_str='vf0 * KE - V40') self.vb0 = ConstService(info='Initial vb', tex_name='V_{b0}', v_str='VR0 / KA') # Set VRMAX to 999 when VRMAX = 0 self._zVRM = FlagValue( self.VRMAX, value=0, tex_name='z_{VRMAX}', ) self.VRMAXc = ConstService( v_str='VRMAX + 999*(1-_zVRM)', info='Set VRMAX=999 when zero', ) self.LG = Lag(u=self.v, T=self.TR, K=1, info='Sensing delay') ExcVsum.__init__(self) self.vref.v_str = 'v + vb0' self.vref0 = PostInitService(info='Constant vref', tex_name='V_{ref0}', v_str='vref') # NOTE: for offline exciters, `vi` equation ignores ext. voltage changes self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', e_str='ue * (-LG_y + vref + UEL + OEL + Vs - vi)', v_str='vref - v', diag_eps=True, ) self.LA3 = LagAntiWindup( u='ue * (vi - WF_y)', T=self.TA, K=self.KA, upper=self.VRMAXc, lower=self.VRMIN, info=r'V_{R}, Lag Anti-Windup', ) # LA3_y is V_R # FIXME: antiwindup out of limit is not warned of in initialization self.zeros = ConstService(v_str='0.0') self.LA1 = Lag( 'ue * (VB_y * HL_zi + VBMAX * HL_zu)', T=self.TE, K=1, D=self.KE, ) self.WF = Washout(u=self.LA1_y, T=self.TF, K=self.KF, info='V_F, stablizing circuit feedback, washout') self.SQE = Algeb( tex_name=r'SQE', info=r'Square of error after mul', v_str='VE ** 2 - (0.78 * XadIfd) ** 2', e_str='VE ** 2 - (0.78 * XadIfd) ** 2 - SQE', ) self.SL = LessThan(u=self.zeros, bound=self.SQE, equal=False, enable=True, cache=False) self.VB = Piecewise(self.SQE, points=(0, ), funs=('ue * LA3_y', 'ue * (sqrt(SQE) + LA3_y)')) self.HL = HardLimiter( u=self.VB_y, lower=self.zeros, upper=self.VBMAX, info='Hard limiter for VB', ) self.vout.e_str = 'ue * (LA1_y - vout)'
def __init__(self, system, config): ExcBase.__init__(self, system, config) self.config.add(OrderedDict(( ('ksr', 2), ('ksm', 2), ))) self.config.add_extra( '_help', ksr='Tracking gain for outer PI controller', ksm='Tracking gain for inner PI controller', ) self.config.add_extra( '_tex', ksr='K_{sr}', ksm='K_{sm}', ) self.KPC = ConstService(v_str='KP * exp(1j * radians(THETAP))', tex_name='K_{PC}', info='KP polar THETAP', vtype=complex) # vd, vq, Id, Iq from SynGen self.vd = ExtAlgeb( src='vd', model='SynGen', indexer=self.syn, tex_name=r'V_d', info='d-axis machine voltage', ) self.vq = ExtAlgeb( src='vq', model='SynGen', indexer=self.syn, tex_name=r'V_q', info='q-axis machine voltage', ) self.Id = ExtAlgeb( src='Id', model='SynGen', indexer=self.syn, tex_name=r'I_d', info='d-axis machine current', ) self.Iq = ExtAlgeb( src='Iq', model='SynGen', indexer=self.syn, tex_name=r'I_q', info='q-axis machine current', ) # control block begin self.LG = Lag( self.v, T=self.TR, K=1, info='Voltage transducer', ) self.UEL = Algeb(info='Interface var for under exc. limiter', tex_name='U_{EL}', v_str='0', e_str='0 - UEL') # lower part: VB signal self.VE = VarService( tex_name='V_E', info='VE', v_str='Abs(KPC*(vd + 1j*vq) + 1j*(KI + KPC*XL)*(Id + 1j*Iq))', ) self.IN = Algeb( tex_name='I_N', info='Input to FEX', v_str='safe_div(KC * XadIfd, VE)', e_str='ue * (KC * XadIfd - VE * IN)', diag_eps=True, ) self.FEX = Piecewise( u=self.IN, points=(0, 0.433, 0.75, 1), funs=('1', '1 - 0.577*IN', 'sqrt(0.75 - IN ** 2)', '1.732*(1 - IN)', 0), info='Piecewise function FEX', ) self.VBMIN = dummify(-9999) self.VGMIN = dummify(-9999) self.VB = GainLimiter( u='VE*FEX_y', K=1, R=1, upper=self.VBMAX, lower=self.VBMIN, no_lower=True, info='VB with limiter', ) self.VG = GainLimiter( u=self.vout, K=self.KG, R=1, upper=self.VGMAX, lower=self.VGMIN, no_lower=True, info='Feedback gain with HL', ) self.vref = Algeb(info='Reference voltage input', tex_name='V_{ref}', unit='p.u.', v_str='v', e_str='vref0 - vref') self.vref0 = PostInitService( info='Const reference voltage', tex_name='V_{ref0}', v_str='vref', ) self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', e_str='-LG_y + vref - vi', v_str='-v + vref', ) self.PI1 = PITrackAW(u=self.vi, kp=self.KPR, ki=self.KIR, ks=self.config.ksr, lower=self.VRMIN, upper=self.VRMAX, x0='VG_y') self.LA = Lag( u=self.PI1_y, T=self.TA, K=1.0, info='Regulation delay', ) self.PI2 = PITrackAW( u='LA_y - VG_y', kp=self.KPM, ki=self.KIM, ks=self.config.ksm, lower=self.VMMIN, upper=self.VMMAX, x0='safe_div(vf0, VB_y)', ) # TODO: add back LV Gate self.vout.e_str = 'VB_y * PI2_y - vout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) # Set VRMAX to 999 when VRMAX = 0 self._zVRM = FlagValue( self.VRMAX, value=0, tex_name='z_{VRMAX}', ) self.VRMAXc = ConstService( v_str='VRMAX + 999*(1-_zVRM)', info='Set VRMAX=999 when zero', ) # Saturation self.SAT = ExcQuadSat( self.E1, self.SE1, self.E2, self.SE2, info='Field voltage saturation', ) self.Se0 = ConstService( info='Initial saturation output', tex_name='S_{e0}', v_str='Indicator(vf0>SAT_A) * SAT_B * (SAT_A - vf0) ** 2 / vf0', ) self.vr0 = ConstService(info='Initial vr', tex_name='V_{r0}', v_str='(KE + Se0) * vf0') self.vb0 = ConstService(info='Initial vb', tex_name='V_{b0}', v_str='vr0 / KA') self.vref0 = ConstService( info='Initial reference voltage input', tex_name='V_{ref0}', v_str='v + vb0', ) self.vfe0 = ConstService( v_str='vf0 * (KE + Se0)', tex_name='V_{FE0}', ) self.vref = Algeb(info='Reference voltage input', tex_name='V_{ref}', unit='p.u.', v_str='vref0', e_str='vref0 - vref') self.LG = Lag( u=self.v, T=self.TR, K=1, info='Sensing delay', ) self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', e_str='-LG_y + vref - vi', v_str='-v + vref', ) self.LA = LagAntiWindup( u='vi + WF_y', T=self.TA, K=self.KA, upper=self.VRMAXc, lower=self.VRMIN, info='Anti-windup lag', ) self.VFE = Algeb(info='Combined saturation feedback', tex_name='V_{FE}', unit='p.u.', v_str='vfe0', e_str='INT_y * (KE + Se) - VFE') self.INT = Integrator( u='LA_y - VFE', T=self.TE, K=1, y0=self.vf0, info='Integrator', ) self.SL = LessThan(u=self.vout, bound=self.SAT_A, equal=False, enable=True, cache=False) self.Se = Algeb( tex_name=r"S_e(|V_{out}|)", info='saturation output', v_str='Se0', e_str='SL_z0 * (INT_y - SAT_A) ** 2 * SAT_B / INT_y - Se', ) self.WF = Washout(u=self.vout, T=self.TF, K=self.KF, info='Stablizing circuit feedback') self.vout.e_str = 'INT_y - vout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) ExcVsum.__init__(self) self.UEL0.v_str = '-999' self.OEL0.v_str = '999' self.flags.nr_iter = True # NOTE: e_str `KC*XadIfd / INT_y - IN` causes numerical inaccuracies self.IN = Algeb(tex_name='I_N', info='Input to FEX', v_str='1', v_iter='KC * XadIfd - INT_y * IN', e_str='ue * (KC * XadIfd - INT_y * IN)', diag_eps=True, ) self.FEX = Piecewise(u=self.IN, points=(0, 0.433, 0.75, 1), funs=('1', '1 - 0.577*IN', 'sqrt(0.75 - IN ** 2)', '1.732*(1 - IN)', 0), info='Piecewise function FEX', ) self.FEX.y.v_str = '1' self.FEX.y.v_iter = self.FEX.y.e_str # control block begin self.LG = Lag(self.v, T=self.TR, K=1, info='Voltage transducer', ) # input excitation voltages; self.vi = Algeb(info='Total input voltages', tex_name='V_i', unit='p.u.', e_str='ue * (-LG_y + vref + UEL + OEL + Vs - vi)', v_str='-v + vref', diag_eps=True, ) self.LL = LeadLag(u=self.vi, T1=self.TC, T2=self.TB, info='V_A, Lead-lag compensator', zero_out=True, ) # LL_y == VA self.VAMAXu = ConstService('VAMAX * ue + (1-ue) * 999') self.VAMINu = ConstService('VAMIN * ue + (1-ue) * -999') self.LA = LagAntiWindup(u=self.LL_y, T=self.TA, K=self.KA, upper=self.VAMAXu, lower=self.VAMINu, info='V_A, Anti-windup lag', ) # LA_y == VA self.HVG = HVGate(u1=self.UEL, u2=self.LA_y, info='HVGate for under excitation', ) self.LVG = LVGate(u1=self.HVG_y, u2=self.OEL, info='HVGate for under excitation', ) self.INTin = 'ue * (LVG_y - VFE)' ExcACSat.__init__(self) self.vref.v_str = 'v + VFE / KA' self.vref0 = PostInitService(info='Initial reference voltage input', tex_name='V_{ref0}', v_str='vref', ) self.WF = Washout(u=self.VFE, T=self.TF, K=self.KF, info='Stablizing circuit feedback', ) self.vout.e_str = 'ue * FEX_y * INT_y - vout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) # Set VRMAX to 999 when VRMAX = 0 self._zVRM = FlagValue( self.VRMAX, value=0, tex_name='z_{VRMAX}', ) self.VRMAXc = ConstService( v_str='VRMAX + 999*(1-_zVRM)', info='Set VRMAX=999 when zero', ) self.LG = Lag( u=self.v, T=self.TR, K=1, info='Transducer delay', ) self.SAT = ExcQuadSat( self.E1, self.SE1, self.E2, self.SE2, info='Field voltage saturation', ) self.Se0 = ConstService( tex_name='S_{e0}', v_str='(vf0>SAT_A) * SAT_B*(SAT_A-vf0) ** 2 / vf0', ) self.vfe0 = ConstService( v_str='vf0 * (KE + Se0)', tex_name='V_{FE0}', ) self.vref0 = ConstService( info='Initial reference voltage input', tex_name='V_{ref0}', v_str='v + vfe0 / KA', ) self.vref = Algeb(info='Reference voltage input', tex_name='V_{ref}', unit='p.u.', v_str='vref0', e_str='vref0 - vref') self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', v_str='vref0 - v', e_str='(vref - v - WF_y) - vi', ) self.LL = LeadLag( u=self.vi, T1=self.TC, T2=self.TB, info='Lead-lag compensator', zero_out=True, ) self.UEL = Algeb(info='Interface var for under exc. limiter', tex_name='U_{EL}', v_str='0', e_str='0 - UEL') self.HG = HVGate( u1=self.UEL, u2=self.LL_y, info='HVGate for under excitation', ) self.VRU = VarService( v_str='VRMAXc * v', tex_name='V_T V_{RMAX}', ) self.VRL = VarService( v_str='VRMIN * v', tex_name='V_T V_{RMIN}', ) # TODO: WARNING: HVGate is temporarily skipped self.LA = LagAntiWindup( u=self.LL_y, T=self.TA, K=self.KA, upper=self.VRU, lower=self.VRL, info='Anti-windup lag', ) # LA_y == VR # `LessThan` may be causing memory issue in (SL_z0 * vout) - uncertain yet self.SL = LessThan(u=self.vout, bound=self.SAT_A, equal=False, enable=True, cache=False) self.Se = Algeb( tex_name=r"S_e(|V_{out}|)", info='saturation output', v_str='Se0', e_str='SL_z0 * (INT_y - SAT_A) ** 2 * SAT_B / INT_y - Se', ) self.VFE = Algeb(info='Combined saturation feedback', tex_name='V_{FE}', unit='p.u.', v_str='vfe0', e_str='INT_y * (KE + Se) - VFE') self.INT = Integrator( u='LA_y - VFE', T=self.TE, K=1, y0=self.vf0, info='Integrator', ) self.WF = Washout(u=self.INT_y, T=self.TF1, K=self.KF, info='Feedback to input') self.vout.e_str = 'INT_y - vout'
def __init__(self, system, config): TGBase.__init__(self, system, config) self.VELMn = ConstService( v_str='-VELM', tex_name='-VELM', ) self.tr = ConstService( v_str='r * Tr', tex_name='r*Tr', ) self.gr = ConstService( v_str='1/r', tex_name='1/r', ) self.ratel = ConstService( v_str='- VELM - gr', tex_name='rate_l', ) self.rateu = ConstService( v_str='VELM - gr', tex_name='rate_u', ) self.q0 = ConstService( v_str='tm0 / At + qNL', tex_name='q_0', ) self.pref = Algeb( info='Reference power input', tex_name='P_{ref}', v_str='R * q0', e_str='R * q0 - pref', ) self.wd = Algeb( info='Generator speed deviation', unit='p.u.', tex_name=r'\omega_{dev}', v_str='0', e_str='ue * (omega - wref) - wd', ) self.pd = Algeb( info='Pref plus speed deviation times gain', unit='p.u.', tex_name="P_d", v_str='0', e_str='ue * (- wd + pref + paux - R * dg) - pd', ) self.LG = Lag( u=self.pd, K=1, T=self.Tf, info='filter after speed deviation (e)', ) self.gtpos = State(info='State in gate position (c)', unit='rad', v_str='q0', tex_name=r'\delta', e_str='LG_y') self.dgl = VarService( tex_name='dg_{lower}', info='dg lower limit', v_str='- VELM - gr * LG_y', ) self.dgu = VarService( tex_name='dg_{upper}', info='dg upper limit', v_str='VELM - gr * LG_y', ) self.dg_lim = AntiWindupRate( u=self.gtpos, lower=self.GMIN, upper=self.GMAX, rate_lower=self.dgl, rate_upper=self.dgu, tex_name='lim_{dg}', info='gate velocity and position limiter', ) self.dg = Algeb( info='desired gate (c)', unit='p.u.', tex_name="dg", v_str='q0', e_str='gtpos + gr * LG_y - dg', ) self.LAG = Lag( u=self.dg, K=1, T=self.Tg, info='gate opening (g)', ) self.h = Algeb( info='turbine head', unit='p.u.', tex_name="h", e_str='q_y**2 / LAG_y**2 - h', v_str='1', ) self.q = Integrator(u="1 - q_y**2 / LAG_y**2", T=self.Tw, K=1, y0='q0', check_init=False, info="turbine flow (q)") self.pout.e_str = 'ue * (At * h * (q_y - qNL) - Dt * wd * LAG_y) - pout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) self.flags.nr_iter = True self.SAT = ExcQuadSat(self.E1, self.SE1, self.E2, self.SE2, info='Field voltage saturation', ) self.SL = LessThan(u=self.vout, bound=self.SAT_A, equal=False, enable=True, cache=False) self.Se0 = ConstService(info='Initial saturation output', tex_name='S_{e0}', v_str='Indicator(vf0>SAT_A) * SAT_B * (SAT_A - vf0) ** 2 / vf0', ) self.IN = Algeb(tex_name='I_N', info='Input to FEX', v_str='1', v_iter='KC * XadIfd - INT_y * IN', e_str='KC * XadIfd / INT_y - IN', ) self.FEX = Piecewise(u=self.IN, points=(0, 0.433, 0.75, 1), funs=('1', '1 - 0.577*IN', 'sqrt(0.75 - IN ** 2)', '1.732*(1 - IN)', 0), info='Piecewise function FEX', ) self.FEX.y.v_iter = '1' self.FEX.y.v_iter = self.FEX.y.e_str self.LG = Lag(self.v, T=self.TR, K=1, info='Voltage transducer', ) self.vi = Algeb(info='Total input voltages', tex_name='V_i', unit='p.u.', e_str='-v + vref - WF_y - vi', v_str='-v + vref', ) self.LL = LeadLag(u=self.vi, T1=self.TC, T2=self.TB, info='Regulator', zero_out=True, ) self.LA = LagAntiWindup(u=self.LL_y, T=self.TA, K=self.KA, lower=self.VRMIN, upper=self.VRMAX, info='Lag AW on VR', ) self.INT = Integrator(u='LA_y - VFE', T=self.TE, K=1, y0=0, info='Integrator', ) self.INT.y.v_str = 0.1 self.INT.y.v_iter = 'INT_y * FEX_y - vf0' self.Se = Algeb(tex_name=r"S_e(|V_{out}|)", info='saturation output', v_str='Se0', e_str='SL_z0 * (INT_y - SAT_A) ** 2 * SAT_B / INT_y - Se', ) self.VFE = Algeb(info='Combined saturation feedback', tex_name='V_{FE}', unit='p.u.', v_str='INT_y * (KE + Se) + XadIfd * KD', e_str='INT_y * (KE + Se) + XadIfd * KD - VFE' ) self.vref = Algeb(info='Reference voltage input', tex_name='V_{ref}', unit='p.u.', v_str='v + VFE / KA', e_str='vref0 - vref', ) self.vref0 = PostInitService(info='Initial reference voltage input', tex_name='V_{ref0}', v_str='vref', ) self.WF = Washout(u=self.VFE, T=self.TF, K=self.KF, info='Stablizing circuit feedback', ) self.vout.e_str = 'INT_y * FEX_y - vout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) self.flags.nr_iter = True ExcVsum.__init__(self) self.UEL0.v_str = '-999' self.OEL0.v_str = '999' self.ulim = ConstService('9999') self.llim = ConstService('-9999') self.SWUEL = Switcher(u=self.UELc, options=[0, 1, 2, 3], tex_name='SW_{UEL}', cache=True) self.SWVOS = Switcher(u=self.VOSc, options=[0, 1, 2], tex_name='SW_{VOS}', cache=True) # control block begin self.LG = Lag( self.v, T=self.TR, K=1, info='Voltage transducer', ) self.SG0 = ConstService(v_str='0', info='SG initial value.') self.SG = Algeb( tex_name='SG', info='SG', v_str='SG0', e_str='SG0 - SG', ) self.zero = ConstService('0') self.LR = GainLimiter( u='XadIfd - ILR', K=self.KLR, R=1, upper=self.ulim, lower=self.zero, no_upper=True, info='Exciter output current gain limiter', ) self.VA0 = PostInitService(tex_name='V_{A0}', v_str='vf0 - SWVOS_s2 * SG + LR_y', info='VA (LA_y) initial value') self.vref.v_str = 'ue * (v + (vf0 - SWVOS_s2 * SG + LR_y) / KA - SWVOS_s1 * SG - SWUEL_s1 * UEL)' self.vref.v_iter = 'ue * (v + (vf0 - SWVOS_s2 * SG + LR_y) / KA - SWVOS_s1 * SG - SWUEL_s1 * UEL)' self.vref0 = PostInitService( info='Initial reference voltage input', tex_name='V_{ref0}', v_str='vref', ) self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', e_str= 'ue * (-LG_y + vref - WF_y + SWUEL_s1 * UEL + SWVOS_s1 * SG + Vs) - vi', v_iter= 'ue * (-LG_y + vref - WF_y + SWUEL_s1 * UEL + SWVOS_s1 * SG + Vs)', v_str= 'ue * (-LG_y + vref - WF_y + SWUEL_s1 * UEL + SWVOS_s1 * SG + Vs)', ) self.vil = GainLimiter( u=self.vi, K=1, R=1, upper=self.VIMAX, lower=self.VIMIN, info='Exciter voltage input limiter', ) self.UEL2 = Algeb( tex_name='UEL_2', info='UEL_2 as HVG1 u1', v_str='ue * (SWUEL_s2 * UEL + (1 - SWUEL_s2) * llim)', e_str='ue * (SWUEL_s2 * UEL + (1 - SWUEL_s2) * llim) - UEL2', ) self.HVG1 = HVGate( u1=self.UEL2, u2=self.vil_y, info='HVGate after V_I', ) self.LL = LeadLag( u=self.HVG1_y, T1=self.TC, T2=self.TB, info='Lead-lag compensator', zero_out=True, ) self.LL1 = LeadLag( u=self.LL_y, T1=self.TC1, T2=self.TB1, info='Lead-lag compensator 1', zero_out=True, ) self.LA = LagAntiWindup( u=self.LL1_y, T=self.TA, K=self.KA, upper=self.VAMAX, lower=self.VAMIN, info='V_A, Anti-windup lag', ) # LA_y is VA self.vas = Algeb( tex_name=r'V_{As}', info='V_A after subtraction, as HVG u2', v_str='ue * (SWVOS_s2 * SG + LA_y - LR_y)', v_iter='ue * (SWVOS_s2 * SG + LA_y - LR_y)', e_str='ue * (SWVOS_s2 * SG + LA_y - LR_y) - vas', ) self.UEL3 = Algeb( tex_name='UEL_3', info='UEL_3 as HVG u1', v_str='ue * (SWUEL_s3 * UEL + (1 - SWUEL_s3) * llim)', e_str='ue * (SWUEL_s3 * UEL + (1 - SWUEL_s3) * llim) - UEL3', ) self.HVG = HVGate( u1=self.UEL3, u2=self.vas, info='HVGate for under excitation', ) self.LVG = LVGate( u1=self.HVG_y, u2=self.OEL, info='HVGate for over excitation', ) # vd, vq, Id, Iq from SynGen self.vd = ExtAlgeb( src='vd', model='SynGen', indexer=self.syn, tex_name=r'V_d', info='d-axis machine voltage', ) self.vq = ExtAlgeb( src='vq', model='SynGen', indexer=self.syn, tex_name=r'V_q', info='q-axis machine voltage', ) self.efdu = VarService( info='Output exciter voltage upper bound', tex_name=r'efd_{u}', v_str='Abs(vd + 1j*vq) * VRMAX - KC * XadIfd', ) self.efdl = VarService(info='Output exciter voltage lower bound', tex_name=r'efd_{l}', v_str='Abs(vd + 1j*vq) * VRMIN') self.vol = GainLimiter( u=self.LVG_y, K=1, R=1, upper=self.efdu, lower=self.efdl, info='Exciter output limiter', ) self.WF = Washout( u=self.LVG_y, T=self.TF, K=self.KF, info='V_F, Stablizing circuit feedback', ) self.vout.e_str = 'ue * vol_y - vout'
def __init__(self, system, config): PSSBase.__init__(self, system, config) # ALL THE FOLLOWING IS FOR INPUT 2 # retrieve indices of bus and bus freq self.buss2 = DataSelect(self.busr2, self.bus, info='selected bus (bus or busr)') self.busfreq2 = DeviceFinder(self.busf2, link=self.buss2, idx_name='bus') # from Bus self.v2 = ExtAlgeb( model='Bus', src='v', indexer=self.buss2, tex_name=r'V', info='Bus (or busr2, if given) terminal voltage', ) # from BusFreq 2 self.f2 = ExtAlgeb(model='FreqMeasurement', src='f', indexer=self.busfreq2, export=False, info='Bus frequency 2') # Config self.config.add(OrderedDict([('freq_model', 'BusFreq')])) self.config.add_extra( '_help', {'freq_model': 'default freq. measurement model'}) self.config.add_extra('_alt', {'freq_model': ('BusFreq', )}) self.busf.model = self.config.freq_model self.busf2.model = self.config.freq_model # input signal switch self.dv = Derivative(self.v) self.dv2 = Derivative(self.v2) self.SnSb = ExtService( model='SynGen', src='M', indexer=self.syn, attr='pu_coeff', info='Machine base to sys base factor for power', tex_name='(Sb/Sn)') self.SW = Switcher( u=self.MODE, options=[0, 1, 2, 3, 4, 5, 6, np.nan], ) self.SW2 = Switcher( u=self.MODE2, options=[0, 1, 2, 3, 4, 5, 6, np.nan], ) # Input signals self.sig = Algeb( tex_name='S_{ig}', info='Input signal', ) self.sig.v_str = 'SW_s1*(omega-1) + SW_s2*0 + SW_s3*(tm0/SnSb) + ' \ 'SW_s4*(tm-tm0) + SW_s5*v + SW_s6*0' self.sig.e_str = 'SW_s1*(omega-1) + SW_s2*(f-1) + SW_s3*(te/SnSb) + ' \ 'SW_s4*(tm-tm0) + SW_s5*v + SW_s6*dv_v - sig' self.sig2 = Algeb( tex_name='S_{ig2}', info='Input signal 2', ) self.sig2.v_str = 'SW2_s1*(omega-1) + SW2_s2*0 + SW2_s3*(tm0/SnSb) + ' \ 'SW2_s4*(tm-tm0) + SW2_s5*v2 + SW2_s6*0' self.sig2.e_str = 'SW2_s1*(omega-1) + SW2_s2*(f2-1) + SW2_s3*(te/SnSb) + ' \ 'SW2_s4*(tm-tm0) + SW2_s5*v2 + SW2_s6*dv2_v - sig2' self.L1 = Lag( u=self.sig, K=self.K1, T=self.T1, info='Transducer 1', ) self.L2 = Lag( u=self.sig2, K=self.K2, T=self.T2, info='Transducer 2', ) self.IN = Algeb( tex_name='I_N', info='Sum of inputs', v_str='L1_y + L2_y', e_str='L1_y + L2_y - IN', ) self.WO = WashoutOrLag( u=self.IN, K=self.T3, T=self.T4, ) self.LL1 = LeadLag( u=self.WO_y, T1=self.T5, T2=self.T6, zero_out=True, ) self.LL2 = LeadLag( u=self.LL1_y, T1=self.T7, T2=self.T8, zero_out=True, ) self.LL3 = LeadLag( u=self.LL2_y, T1=self.T9, T2=self.T10, zero_out=True, ) self.VSS = GainLimiter(u=self.LL3_y, K=1, lower=self.LSMIN, upper=self.LSMAX) self.VOU = ConstService(v_str='VCUr + v0') self.VOL = ConstService(v_str='VCLr + v0') self.OLIM = Limiter(u=self.v, lower=self.VOL, upper=self.VOU, info='output limiter') self.vsout.e_str = 'OLIM_zi * VSS_y - vsout'
def __init__(self): self.LGId = Lag(u=self.PIvd_y, T=self.Tid, K=-1) # Id self.LGIq = Lag(u=self.PIvq_y, T=self.Tiq, K=1) # Iq self.Id.e_str = 'LGId_y - Id' self.Iq.e_str = 'LGIq_y - Iq'
def __init__(self, system, config): ExcBase.__init__(self, system, config) self.flags.nr_iter = True self.config.add(OrderedDict((('ks', 2), ))) self.config.add_extra('_help', ks='Tracking gain for PID controller', ) self.IN = Algeb(tex_name='I_N', info='Input to FEX', v_str='1', v_iter='KC * XadIfd - INT_y * IN', e_str='ue * (KC * XadIfd - INT_y * IN)', diag_eps=True, ) self.FEX = Piecewise(u=self.IN, points=(0, 0.433, 0.75, 1), funs=('1', '1 - 0.577*IN', 'sqrt(0.75 - IN ** 2)', '1.732*(1 - IN)', 0), info='Piecewise function FEX', ) self.FEX.y.v_str = '0.5' self.FEX.y.v_iter = self.FEX.y.e_str # control block begin self.LG = Lag(self.v, T=self.TR, K=1, info='Voltage transducer', ) ExcVsum.__init__(self) self.vref.v_str = 'v' self.vi = Algeb(info='Total input voltages', tex_name='V_i', unit='p.u.', e_str='ue * (-LG_y + vref + UEL + OEL + Vs - vi)', v_str='-v + vref', diag_eps=True, ) # chekck y0 self.PID = PIDTrackAW(u=self.vi, kp=self.kP, ki=self.kI, ks=self.config.ks, kd=self.kD, Td=self.Td, x0='VFE / KA', lower=self.VPMIN, upper=self.VPMAX, tex_name='PID', info='PID', name='PID', ) self.LA = LagAntiWindup(u=self.PID_y, T=self.TA, K=self.KA, upper=self.VRMAX, lower=self.VRMIN, info=r'V_{R}, Anti-windup lag', ) self.INTin = 'ue * (LA_y - VFE)' ExcACSat.__init__(self) self.vref0 = PostInitService(info='Initial reference voltage input', tex_name='V_{ref0}', v_str='v', ) self.vout.e_str = 'ue * (FEX_y * INT_y - vout)'
def __init__(self, system, config): ExcBase.__init__(self, system, config) self.KPC = ConstService(v_str='KP * exp(1j * radians(THETAP))', tex_name='K_{PC}', info='KP polar THETAP', vtype=np.complex) # vd, vq, Id, Iq from SynGen self.vd = ExtAlgeb( src='vd', model='SynGen', indexer=self.syn, tex_name=r'V_d', info='d-axis machine voltage', ) self.vq = ExtAlgeb( src='vq', model='SynGen', indexer=self.syn, tex_name=r'V_q', info='q-axis machine voltage', ) self.Id = ExtAlgeb( src='Id', model='SynGen', indexer=self.syn, tex_name=r'I_d', info='d-axis machine current', ) self.Iq = ExtAlgeb( src='Iq', model='SynGen', indexer=self.syn, tex_name=r'I_q', info='q-axis machine current', ) # control block begin self.LG = Lag( self.v, T=self.TR, K=1, info='Voltage transducer', ) self.UEL = Algeb(info='Interface var for under exc. limiter', tex_name='U_{EL}', v_str='0', e_str='0 - UEL') self.VE = VarService( tex_name='V_E', info='VE', v_str='Abs(KPC*(vd + 1j*vq) + 1j*(KI + KPC*XL)*(Id + 1j*Iq))', ) self.IN = Algeb( tex_name='I_N', info='Input to FEX', v_str='KC * XadIfd / VE', e_str='KC * XadIfd / VE - IN', ) self.FEX = Piecewise( u=self.IN, points=(0, 0.433, 0.75, 1), funs=('1', '1 - 0.577*IN', 'sqrt(0.75 - IN ** 2)', '1.732*(1 - IN)', 0), info='Piecewise function FEX', ) self.VBMIN = dummify(-9999) self.VGMIN = dummify(-9999) self.VB = GainLimiter( u='VE*FEX_y', K=1, upper=self.VBMAX, lower=self.VBMIN, no_lower=True, info='VB with limiter', ) self.VG = GainLimiter( u=self.vout, K=self.KG, upper=self.VGMAX, lower=self.VGMIN, no_lower=True, info='Feedback gain with HL', ) self.vrs = Algeb( tex_name='V_{RS}', info='VR subtract feedback VG', v_str='vf0 / VB_y / KM', e_str='LAW1_y - VG_y - vrs', ) self.vref = Algeb( info='Reference voltage input', tex_name='V_{ref}', unit='p.u.', v_str='(vrs + VG_y) / KA + v', e_str='vref0 - vref', ) self.vref0 = PostInitService( info='Initial reference voltage input', tex_name='V_{ref0}', v_str='vref', ) # input excitation voltages; PSS outputs summed at vi self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', e_str='-LG_y + vref - vi', v_str='-v + vref', ) self.vil = Algeb(info='Input voltage after limit', tex_name='V_{il}', v_str='HLI_zi*vi + HLI_zl*VIMIN + HLI_zu*VIMAX', e_str='HLI_zi*vi + HLI_zl*VIMIN + HLI_zu*VIMAX - vil') self.HG = HVGate( u1=self.UEL, u2=self.vil, info='HVGate for under excitation', ) self.LL = LeadLag( u=self.HG_y, T1=self.TC, T2=self.TB, info='Regulator', zero_out=True, ) # LL_y == VA self.LAW1 = LagAntiWindup( u=self.LL_y, T=self.TA, K=self.KA, lower=self.VRMIN, upper=self.VRMAX, info='Lag AW on VR', ) # LAW1_y == VR self.HLI = HardLimiter( u=self.vi, lower=self.VIMIN, upper=self.VIMAX, info='Input limiter', ) self.LAW2 = LagAntiWindup( u=self.vrs, T=self.TM, K=self.KM, lower=self.VMMIN, upper=self.VMMAX, info='Lag AW on VM', ) # LAW2_y == VM self.vout.e_str = 'VB_y * LAW2_y - vout'
def __init__(self, system, config): TGBase.__init__(self, system, config, add_sn=False) # check if K1-K8 sums up to 1 self._sumK18 = ConstService(v_str='K1+K2+K3+K4+K5+K6+K7+K8', info='summation of K1-K8', tex_name=r"\sum_{i=1}^8 K_i") self._K18c1 = InitChecker( u=self._sumK18, info='summation of K1-K8 and 1.0', equal=1, ) # check if `tm0 * (K2 + k4 + K6 + K8) = tm02 *(K1 + K3 + K5 + K7) self._tm0K2 = PostInitService( info='mul of tm0 and (K2+K4+K6+K8)', v_str='zsyn2*tm0*(K2+K4+K6+K8)', ) self._tm02K1 = PostInitService( info='mul of tm02 and (K1+K3+K5+K6)', v_str='tm02*(K1+K3+K5+K7)', ) self._Pc = InitChecker( u=self._tm0K2, info='proportionality of tm0 and tm02', equal=self._tm02K1, ) self.Sg2 = ExtParam( src='Sn', model='SynGen', indexer=self.syn2, allow_none=True, default=0.0, tex_name='S_{n2}', info='Rated power of Syn2', unit='MVA', export=False, ) self.Sg12 = ParamCalc( self.Sg, self.Sg2, func=np.add, tex_name="S_{g12}", info='Sum of generator power ratings', ) self.Sn = NumSelect( self.Tn, fallback=self.Sg12, tex_name='S_n', info='Turbine or Gen rating', ) self.zsyn2 = FlagValue( self.syn2, value=None, tex_name='z_{syn2}', info='Exist flags for syn2', ) self.tm02 = ExtService( src='tm', model='SynGen', indexer=self.syn2, tex_name=r'\tau_{m02}', info='Initial mechanical input of syn2', allow_none=True, default=0.0, ) self.tm012 = ConstService( info='total turbine power', v_str='tm0 + tm02', ) self.tm2 = ExtAlgeb( src='tm', model='SynGen', indexer=self.syn2, allow_none=True, tex_name=r'\tau_{m2}', e_str='zsyn2 * u * (PLP - tm02)', info='Mechanical power to syn2', ) self.wd = Algeb( info='Generator under speed', unit='p.u.', tex_name=r'\omega_{dev}', v_str='0', e_str='(wref - omega) - wd', ) self.LL = LeadLag( u=self.wd, T1=self.T2, T2=self.T1, K=self.K, info='Signal conditioning for wd', ) # `P0` == `tm0` self.vs = Algeb( info='Valve speed', tex_name='V_s', v_str='0', e_str='(LL_y + tm012 + paux - IAW_y) / T3 - vs', ) self.HL = HardLimiter( u=self.vs, lower=self.UC, upper=self.UO, info='Limiter on valve acceleration', ) self.vsl = Algeb( info='Valve move speed after limiter', tex_name='V_{sl}', v_str='vs * HL_zi + UC * HL_zl + UO * HL_zu', e_str='vs * HL_zi + UC * HL_zl + UO * HL_zu - vsl', ) self.IAW = IntegratorAntiWindup( u=self.vsl, T=1, K=1, y0=self.tm012, lower=self.PMIN, upper=self.PMAX, info='Valve position integrator', ) self.L4 = Lag( u=self.IAW_y, T=self.T4, K=1, info='first process', ) self.L5 = Lag( u=self.L4_y, T=self.T5, K=1, info='second (reheat) process', ) self.L6 = Lag( u=self.L5_y, T=self.T6, K=1, info='third process', ) self.L7 = Lag( u=self.L6_y, T=self.T7, K=1, info='fourth (second reheat) process', ) self.PHP = Algeb( info='HP output', tex_name='P_{HP}', v_str='K1*L4_y + K3*L5_y + K5*L6_y + K7*L7_y', e_str='K1*L4_y + K3*L5_y + K5*L6_y + K7*L7_y - PHP', ) self.PLP = Algeb( info='LP output', tex_name='P_{LP}', v_str='K2*L4_y + K4*L5_y + K6*L6_y + K8*L7_y', e_str='K2*L4_y + K4*L5_y + K6*L6_y + K8*L7_y - PLP', ) self.pout.e_str = 'PHP - pout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) self.SAT = ExcQuadSat(self.E1, self.SE1, self.E2, self.SE2, info='Field voltage saturation', ) # calculate `Se0` ahead of time in order to calculate `vr0` # The term `1-ug` is to prevent division by zero when generator is off self.Se0 = ConstService(info='Initial saturation output', tex_name='S_{e0}', v_str='Indicator(vf0>SAT_A) * SAT_B * (SAT_A - vf0) ** 2 / (vf0 + 1 - ug)', ) self.vr0 = ConstService(info='Initial vr', tex_name='V_{r0}', v_str='(KE + Se0) * vf0') self.vb0 = ConstService(info='Initial vb', tex_name='V_{b0}', v_str='vr0 / KA') self.vref = Algeb(info='Reference voltage input', tex_name='V_{ref}', unit='p.u.', v_str='v + vb0', e_str='vref0 - vref' ) self.vref0 = PostInitService(info='Constant v ref', tex_name='V_{ref0}', v_str='vref', ) self.SL = LessThan(u=self.vout, bound=self.SAT_A, equal=False, enable=True, cache=False, ) self.Se = Algeb(tex_name=r"S_e(|V_{out}|)", info='saturation output', v_str='Se0', e_str='SL_z0 * (vp - SAT_A) ** 2 * SAT_B - Se * vp', diag_eps=True, ) self.vp = State(info='Voltage after saturation feedback, before speed term', tex_name='V_p', unit='p.u.', v_str='vf0', e_str='ue * (LA_y - KE*vp - Se*vp)', t_const=self.TE, ) self.LS = Lag(u=self.v, T=self.TR, K=1.0, info='Sensing lag TF') # input excitation voltages; PSS outputs summed at vi self.vi = Algeb(info='Total input voltages', tex_name='V_i', unit='p.u.', ) self.vi.v_str = 'vb0' self.vi.e_str = '(vref - LS_y - W_y) - vi' self.LL = LeadLag(u=self.vi, T1=self.TC, T2=self.TB, info='Lead-lag for internal delays', zero_out=True, ) self.LA = LagAntiWindup(u=self.LL_y, T=self.TA, K=self.KA, upper=self.VRMAX, lower=self.VRMIN, info='Anti-windup lag', ) self.W = Washout(u=self.vp, T=self.TF1, K=self.KF1, info='Signal conditioner' ) self.vout.e_str = 'ue * omega * vp - vout'
def __init__(self, system, config): ExcBase.__init__(self, system, config) # vd, vq, Id, Iq from SynGen self.vd = ExtAlgeb( src='vd', model='SynGen', indexer=self.syn, tex_name=r'V_d', info='d-axis machine voltage', ) self.vq = ExtAlgeb( src='vq', model='SynGen', indexer=self.syn, tex_name=r'V_q', info='q-axis machine voltage', ) self.Id = ExtAlgeb( src='Id', model='SynGen', indexer=self.syn, tex_name=r'I_d', info='d-axis machine current', ) self.Iq = ExtAlgeb( src='Iq', model='SynGen', indexer=self.syn, tex_name=r'I_q', info='q-axis machine current', ) self.VE = VarService( tex_name=r'V_{E}', info=r'V_{E}', v_str='Abs(KP * (vd + 1j*vq) + 1j*KI*(Id + 1j*Iq))', ) self.V40 = ConstService('sqrt(VE ** 2 - (0.78 * XadIfd) ** 2)') self.VR0 = ConstService(info='Initial VR', tex_name='V_{R0}', v_str='vf0 * KE - V40') self.vb0 = ConstService(info='Initial vb', tex_name='V_{b0}', v_str='VR0 / KA') # Set VRMAX to 999 when VRMAX = 0 self._zVRM = FlagValue( self.VRMAX, value=0, tex_name='z_{VRMAX}', ) self.VRMAXc = ConstService( v_str='VRMAX + 999*(1-_zVRM)', info='Set VRMAX=999 when zero', ) self.LG = Lag(u=self.v, T=self.TR, K=1, info='Sensing delay') ExcVsum.__init__(self) self.vref.v_str = 'v + vb0' self.vref0 = PostInitService(info='Constant vref', tex_name='V_{ref0}', v_str='vref') # NOTE: for offline exciters, `vi` equation ignores ext. voltage changes self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', e_str='ue * (-LG_y + vref + UEL + OEL + Vs - vi)', v_str='-v + vref', diag_eps=True, ) self.LA3 = LagAntiWindup( u='ue * (vi - WF_y)', T=self.TA, K=self.KA, upper=self.VRMAXc, lower=self.VRMIN, info=r'V_{R}, Lag Anti-Windup', ) # LA3_y is V_R self.zero = ConstService(v_str='0.0') self.one = ConstService(v_str='1.0') self.LA1 = LagAntiWindup( u='ue * (LA3_y + V4)', T=self.TE, K=self.one, D=self.KE, upper=self.VBMAX, lower=self.zero, info=r'E_{FD}, vout, Lag Anti-Windup', ) # LA1_y is final output self.WF = Washout(u=self.LA1_y, T=self.TF, K=self.KF, info='V_F, stablizing circuit feedback, washout') self.SQE = VarService( tex_name=r'SQE', info=r'Square Error', v_str='VE ** 2 - (0.78 * XadIfd) ** 2', ) self.SL = LessThan(u=self.zero, bound=self.SQE, equal=False, enable=True, cache=False) self.V4 = VarService( tex_name='V_4', v_str='SL_z1 * sqrt(SQE)', ) self.vout.e_str = 'ue * (LA1_y - vout)'
def __init__(self, system, config): Model.__init__(self, system, config) self.flags.tds = True self.group = 'DG' self.config.add(OrderedDict((('plim', 0), ))) self.config.add_extra('_help', plim='enable input power limit check bound by [0, pmx]', ) self.config.add_extra('_tex', plim='P_{lim}', ) self.config.add_extra('_alt', plim=(0, 1), ) self.SWPQ = Switcher(u=self.pqflag, options=(0, 1), tex_name='SW_{PQ}', cache=True) self.buss = DataSelect(self.igreg, self.bus, info='selected bus (bus or igreg)', ) self.busfreq = DeviceFinder(self.busf, link=self.buss, idx_name='bus') # --- initial values from power flow --- # a : bus voltage angle # v : bus voltage magnitude # p0s : active power from connected static PV generator # q0s : reactive power from connected static PV generator # pref0 : initial active power set point for the PVD1 device # qref0 : initial reactive power set point for the PVD1 device self.a = ExtAlgeb(model='Bus', src='a', indexer=self.buss, tex_name=r'\theta', info='bus (or igreg) phase angle', unit='rad.', e_str='-Ipout_y * v * u', ename='P', tex_ename='P', ) self.v = ExtAlgeb(model='Bus', src='v', indexer=self.buss, tex_name='V', info='bus (or igreg) terminal voltage', unit='p.u.', e_str='-Iqout_y * v * u', ename='Q', tex_ename='Q', ) self.p0s = ExtService(model='StaticGen', src='p', indexer=self.gen, tex_name='P_{0s}', info='Initial P from static gen', ) self.q0s = ExtService(model='StaticGen', src='q', indexer=self.gen, tex_name='Q_{0s}', info='Initial Q from static gen', ) # --- calculate the initial P and Q for this distributed device --- self.pref0 = ConstService(v_str='gammap * p0s', tex_name='P_{ref0}', info='Initial P for the PVD1 device', ) self.qref0 = ConstService(v_str='gammaq * q0s', tex_name='Q_{ref0}', info='Initial Q for the PVD1 device', ) # frequency measurement variable `f` self.f = ExtAlgeb(model='FreqMeasurement', src='f', indexer=self.busfreq, export=False, info='Bus frequency', unit='p.u.', ) self.fHz = Algeb(info='frequency in Hz', v_str='fn * f', e_str='fn * f - fHz', unit='Hz', tex_name='f_{Hz}', ) # --- frequency branch --- self.FL1 = Limiter(u=self.fHz, lower=self.ft0, upper=self.ft1, info='Under frequency comparer', no_warn=True, ) self.FL2 = Limiter(u=self.fHz, lower=self.ft2, upper=self.ft3, info='Over frequency comparer', no_warn=True, ) self.Kft01 = ConstService(v_str='1/(ft1 - ft0)', tex_name='K_{ft01}') self.Ffl = Algeb(info='Coeff. for under frequency', v_str='FL1_zi * Kft01 * (fHz - ft0) + FL1_zu', e_str='FL1_zi * Kft01 * (fHz - ft0) + FL1_zu - Ffl', tex_name='F_{fl}', discrete=self.FL1, ) self.Kft23 = ConstService(v_str='1/(ft3 - ft2)', tex_name='K_{ft23}') self.Ffh = Algeb(info='Coeff. for over frequency', v_str='FL2_zl + FL2_zi * (1 + Kft23 * (ft2 - fHz))', e_str='FL2_zl + FL2_zi * (1 + Kft23 * (ft2 - fHz)) - Ffh', tex_name='F_{fh}', discrete=self.FL2, ) self.Fdev = Algeb(info='Frequency deviation', v_str='fn - fHz', e_str='fn - fHz - Fdev', unit='Hz', tex_name='f_{dev}', ) self.DB = DeadBand1(u=self.Fdev, center=0.0, lower=self.fdbd, upper=0.0, gain=self.ddn, info='frequency deviation deadband with gain', ) # outputs `Pdrp` self.DB.db.no_warn = True # --- Voltage flags --- self.VL1 = Limiter(u=self.v, lower=self.vt0, upper=self.vt1, info='Under voltage comparer', no_warn=True, ) self.VL2 = Limiter(u=self.v, lower=self.vt2, upper=self.vt3, info='Over voltage comparer', no_warn=True, ) self.Kvt01 = ConstService(v_str='1/(vt1 - vt0)', tex_name='K_{vt01}') self.Fvl = Algeb(info='Coeff. for under voltage', v_str='VL1_zi * Kvt01 * (v - vt0) + VL1_zu', e_str='VL1_zi * Kvt01 * (v - vt0) + VL1_zu - Fvl', tex_name='F_{vl}', discrete=self.VL1, ) self.Kvt23 = ConstService(v_str='1/(vt3 - vt2)', tex_name='K_{vt23}') self.Fvh = Algeb(info='Coeff. for over voltage', v_str='VL2_zl + VL2_zi * (1 + Kvt23 * (vt2 - v))', e_str='VL2_zl + VL2_zi * (1 + Kvt23 * (vt2 - v)) - Fvh', tex_name='F_{vh}', discrete=self.VL2, ) # --- sensed voltage with lower limit of 0.01 --- self.VLo = Limiter(u=self.v, lower=0.01, upper=999, no_upper=True, info='Voltage lower limit (0.01) flag', ) self.vp = Algeb(tex_name='V_p', info='Sensed positive voltage', v_str='v * VLo_zi + 0.01 * VLo_zl', e_str='v * VLo_zi + 0.01 * VLo_zl - vp', ) self.Pext0 = ConstService(info='External additional signal added to Pext', tex_name='P_{ext0}', v_str='0', ) self.Pext = Algeb(tex_name='P_{ext}', info='External power signal (for AGC)', v_str='u * Pext0', e_str='u * Pext0 - Pext' ) self.Pref = Algeb(tex_name='P_{ref}', info='Reference power signal (for scheduling setpoint)', v_str='u * pref0', e_str='u * pref0 - Pref' ) self.Psum = Algeb(tex_name='P_{tot}', info='Sum of P signals', v_str='u * (Pext + Pref + DB_y)', e_str='u * (Pext + Pref + DB_y) - Psum', ) # `DB_y` is `Pdrp` (f droop) self.PHL = Limiter(u=self.Psum, lower=0.0, upper=self.pmx, enable=self.config.plim, info='limiter for Psum in [0, pmx]', ) self.Vcomp = VarService(v_str='abs(v*exp(1j*a) + (1j * xc) * (Ipout_y + 1j * Iqout_y))', info='Voltage before Xc compensation', tex_name='V_{comp}' ) self.Vqu = ConstService(v_str='v1 - (qref0 - qmn) / dqdv', info='Upper voltage bound => qmx', tex_name='V_{qu}', ) self.Vql = ConstService(v_str='v0 + (qmx - qref0) / dqdv', info='Lower voltage bound => qmn', tex_name='V_{ql}', ) self.VQ1 = Limiter(u=self.Vcomp, lower=self.Vql, upper=self.v0, info='Under voltage comparer for Q droop', no_warn=True, ) self.VQ2 = Limiter(u=self.Vcomp, lower=self.v1, upper=self.Vqu, info='Over voltage comparer for Q droop', no_warn=True, ) Qdrp = 'u * VQ1_zl * qmx + VQ2_zu * qmn + ' \ 'u * VQ1_zi * (qmx + dqdv *(Vqu - Vcomp)) + ' \ 'u * VQ2_zi * (dqdv * (v1 - Vcomp)) ' self.Qdrp = Algeb(tex_name='Q_{drp}', info='External power signal (for AGC)', v_str=Qdrp, e_str=f'{Qdrp} - Qdrp', discrete=(self.VQ1, self.VQ2), ) self.Qref = Algeb(tex_name=r'Q_{ref}', info='Reference power signal (for scheduling setpoint)', v_str='u * qref0', e_str='u * qref0 - Qref' ) self.Qsum = Algeb(tex_name=r'Q_{tot}', info='Sum of Q signals', v_str=f'u * (qref0 + {Qdrp})', e_str='u * (Qref + Qdrp) - Qsum', discrete=(self.VQ1, self.VQ2), ) self.Ipul = Algeb(info='Ipcmd before Ip hard limit', v_str='(Psum * PHL_zi + pmx * PHL_zu) / vp', e_str='(Psum * PHL_zi + pmx * PHL_zu) / vp - Ipul', tex_name='I_{p,ul}', ) self.Iqul = Algeb(info='Iqcmd before Iq hard limit', v_str='Qsum / vp', e_str='Qsum / vp - Iqul', tex_name='I_{q,ul}', ) # --- Ipmax, Iqmax and Iqmin --- Ipmaxsq = "(Piecewise((0, Le(ialim**2 - Iqcmd_y**2, 0)), ((ialim**2 - Iqcmd_y ** 2), True)))" Ipmaxsq0 = "(Piecewise((0, Le(ialim**2 - (u*qref0/v)**2, 0)), ((ialim**2 - (u*qref0/v) ** 2), True)))" self.Ipmaxsq = VarService(v_str=Ipmaxsq, tex_name='I_{pmax}^2') self.Ipmaxsq0 = ConstService(v_str=Ipmaxsq0, tex_name='I_{pmax0}^2') self.Ipmax = Algeb(v_str='(SWPQ_s1 * ialim + SWPQ_s0 * sqrt(Ipmaxsq0))', e_str='(SWPQ_s1 * ialim + SWPQ_s0 * sqrt(Ipmaxsq)) - Ipmax', tex_name='I_{pmax}', ) Iqmaxsq = "(Piecewise((0, Le(ialim**2 - Ipcmd_y**2, 0)), ((ialim**2 - Ipcmd_y ** 2), True)))" Iqmaxsq0 = "(Piecewise((0, Le(ialim**2 - (u*pref0/v)**2, 0)), ((ialim**2 - (u*pref0/v) ** 2), True)))" self.Iqmaxsq = VarService(v_str=Iqmaxsq, tex_name='I_{qmax}^2') self.Iqmaxsq0 = ConstService(v_str=Iqmaxsq0, tex_name='I_{qmax0}^2') self.Iqmax = Algeb(v_str='SWPQ_s0 * ialim + SWPQ_s1 * sqrt(Iqmaxsq0)', e_str='SWPQ_s0 * ialim + SWPQ_s1 * sqrt(Iqmaxsq) - Iqmax', tex_name='I_{qmax}', ) # TODO: set option whether to use degrading gain # --- `Ipcmd` and `Iqcmd` --- self.Ipcmd = GainLimiter(u=self.Ipul, K=1, R='Fvl * Fvh * Ffl * Ffh * recflag + 1 * (1 - recflag)', lower=0, upper=self.Ipmax, info='Ip with limiter and coeff.', tex_name='I^{pcmd}', ) self.Iqcmd = GainLimiter(u=self.Iqul, K=1, R='Fvl * Fvh * Ffl * Ffh * recflag + 1 * (1 - recflag)', lower=self.Iqmax, sign_lower=-1, upper=self.Iqmax, info='Iq with limiter and coeff.', tex_name='I^{qcmd}', ) self.Ipout = Lag(u=self.Ipcmd_y, T=self.tip, K=1.0, info='Output Ip filter', ) self.Iqout = Lag(u=self.Iqcmd_y, T=self.tiq, K=1.0, info='Output Iq filter', )
def __init__(self, system, config): ExcBase.__init__(self, system, config) self.Se0 = ConstService( info='Initial saturation output', tex_name='S_{e0}', v_str='Ae * exp(Be * vf0)', ) self.vr0 = ConstService(info='Initial vr', tex_name='V_{r0}', v_str='(KE + Se0) * vf0') self.vb0 = ConstService(info='Initial vb', tex_name='V_{b0}', v_str='vr0 / KA') self.vref0 = ConstService(info='Initial reference voltage input', tex_name='V_{ref0}', v_str='vb0 + v') self.Se = Algeb(info='Saturation output', tex_name='S_e', unit='p.u.', v_str='Se0', e_str='Ae * exp(Be * vout) - Se') self.vp = State( info='Voltage after saturation feedback, before speed term', tex_name='V_p', unit='p.u.', v_str='vf0', e_str='(LA_x - KE * vp - Se * vp) / TE') self.LS = Lag(u=self.v, T=self.TR, K=1.0, info='Sensing lag TF') self.vref = Algeb(info='Reference voltage input', tex_name='V_{ref}', unit='p.u.', v_str='vref0', e_str='vref0 - vref') self.vi = Algeb( info='Total input voltages', tex_name='V_i', unit='p.u.', v_str='vb0', e_str='(vref - LS_x - W_y) - vi', ) self.LL = LeadLag( u=self.vi, T1=self.TC, T2=self.TB, info='Lead-lag for internal delays', ) self.LA = LagAntiWindup( u=self.LL_y, T=self.TA, K=self.KA, upper=self.VRMAX, lower=self.VRMIN, info='Anti-windup lag', ) self.W = Washout( u=self.vp, T=self.TF1, K=self.KF1, ) self.vout.e_str = 'omega * vp - vout'