forked from CURENT/andes
-
Notifications
You must be signed in to change notification settings - Fork 2
/
busfreq.py
80 lines (71 loc) 路 2.75 KB
/
busfreq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""
Bus frequency estimation based on high-pass filter.
"""
from andes.core import (ModelData, Model, IdxParam, NumParam,
ConstService, ExtService, Algeb, ExtAlgeb,
Lag, Washout)
class BusFreq(ModelData, Model):
"""
Bus frequency measurement. Outputs frequency in per unit value.
The bus frequency output variable is `f`.
The frequency deviation variable is `WO_y`.
"""
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',
)
# the output `WO_y` is the frequency deviation in p.u.
self.WO = Washout(u=self.L_y,
K=self.iwn,
T=self.Tw,
info='angle washout',
)
self.WO_y.info = 'frequency deviation'
self.WO_y.unit = 'p.u. (Hz)'
self.f = Algeb(info='frequency output',
unit='p.u. (Hz)',
tex_name='f',
v_str='1',
e_str='1 + WO_y - f',
)