Skip to content

Commit

Permalink
Merge pull request #144 from cuihantao:develop
Browse files Browse the repository at this point in the history
develop
  • Loading branch information
cuihantao authored Jun 6, 2021
2 parents 90f8ee8 + 3d7db18 commit 2d12222
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion andes/core/npfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def safe_div(a, b, out=None):
if out is None:
out = np.zeros_like(a)

return np.divide(a, b, out=np.zeros_like(a), where=(b != 0))
return np.divide(a, b, out=out, where=(b != 0))
3 changes: 3 additions & 0 deletions andes/models/distributed/pvd1.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ class PVD1(PVD1Data, PVD1Model):
write to `pref0.v` and `qref0.v` in place.
AGC signals should write to `pext0.v` in place.
Maximum power limit `pmx` can be enabled by editing the configuration
file by setting `plim=1`. It cannot be modified in runtime.
Reference:
[1] ESIG, WECC Distributed and Small PV Plants Generic Model (PVD1), [Online],
Available:
Expand Down
15 changes: 10 additions & 5 deletions andes/models/exciter/exac1.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,17 @@ def __init__(self, system, config):
self.vi = Algeb(info='Total input voltages',
tex_name='V_i',
unit='p.u.',
e_str='-v + vref - WF_y - vi',
e_str='ue * (-v + vref - WF_y - vi)',
v_str='-v + vref',
diag_eps=True,
)

self.LL = LeadLag(u=self.vi, T1=self.TC, T2=self.TB,
info='Regulator',
zero_out=True,
)

# LA_y is VR
self.LA = LagAntiWindup(u=self.LL_y,
T=self.TA,
K=self.KA,
Expand All @@ -149,7 +152,7 @@ def __init__(self, system, config):
info='Lag AW on VR',
)

self.INT = Integrator(u='LA_y - VFE',
self.INT = Integrator(u='ue * (LA_y - VFE)',
T=self.TE,
K=1,
y0=0,
Expand All @@ -162,14 +165,16 @@ def __init__(self, system, config):

self.Se = Algeb(tex_name=r"V_{out}*S_e(|V_{out}|)", info='saturation output',
v_str='Indicator(INT_y > SAT_A) * SAT_B * (INT_y - SAT_A) ** 2',
e_str='SL_z0 * (INT_y - SAT_A) ** 2 * SAT_B - Se',
e_str='ue * (SL_z0 * (INT_y - SAT_A) ** 2 * SAT_B - Se)',
diag_eps=True,
)

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'
e_str='ue * (INT_y * KE + Se + XadIfd * KD - VFE)',
diag_eps=True,
)

self.vref = Algeb(info='Reference voltage input',
Expand All @@ -190,7 +195,7 @@ def __init__(self, system, config):
info='Stablizing circuit feedback',
)

self.vout.e_str = 'ue * INT_y * FEX_y - vout'
self.vout.e_str = 'ue * (INT_y * FEX_y - vout)'


class EXAC1(EXAC1Data, EXAC1Model):
Expand Down
1 change: 1 addition & 0 deletions andes/models/exciter/excbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self, system, config):
self.vout = Algeb(info='Exciter final output voltage',
tex_name='v_{out}',
v_str='vf0',
diag_eps=True,
)

# Note:
Expand Down
13 changes: 8 additions & 5 deletions andes/models/exciter/ieeet1.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ def __init__(self, system, config):
self.LG = Lag(u=self.v, T=self.TR, K=1,
info='Sensing delay',
)
# 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='-LG_y + vref - vi',
e_str='ue * (-LG_y + vref - vi)',
v_str='-v + vref',
diag_eps=True,
)
self.LA = LagAntiWindup(u='vi + WF_y',
self.LA = LagAntiWindup(u='ue * (vi - WF_y)',
T=self.TA,
K=self.KA,
upper=self.VRMAXc,
Expand All @@ -150,10 +152,11 @@ def __init__(self, system, config):
tex_name='V_{FE}',
unit='p.u.',
v_str='vfe0',
e_str='INT_y * KE + Se - VFE'
e_str='ue * (INT_y * KE + Se - VFE)',
diag_eps=True,
)

self.INT = Integrator(u='LA_y - VFE',
self.INT = Integrator(u='ue * (LA_y - VFE)',
T=self.TE,
K=1,
y0=self.vf0,
Expand All @@ -169,7 +172,7 @@ def __init__(self, system, config):

self.WF = Washout(u=self.vout, T=self.TF, K=self.KF, info='Stablizing circuit feedback')

self.vout.e_str = 'INT_y - vout'
self.vout.e_str = 'ue * (INT_y - vout)'


class IEEET1(IEEET1Data, IEEET1Model):
Expand Down
4 changes: 3 additions & 1 deletion andes/models/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def __init__(self, system, config):
unit='pu (Hz)',
v_str='u',
tex_name=r'\omega',
e_str='(u / M) * (tm - te - D * (omega - 1))')
e_str='u * (tm - te - D * (omega - 1))',
t_const=self.M,
)

# network algebraic variables
self.a = ExtAlgeb(model='Bus',
Expand Down
8 changes: 4 additions & 4 deletions andes/routines/tds.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def itm_step(self):
elif self.custom_event:
reason = 'custom event set'
elif not self.last_converged:
reason = 'last step did not converge'
reason = 'non-convergence in the last step'
elif self.niter > 4 and (self.niter + 1) % 3 == 0:
reason = 'update every 6 iterations'
elif dae.t - self._last_switch_t < 0.1:
Expand Down Expand Up @@ -944,17 +944,17 @@ def _debug_ac(self, xy_idx):
vars_idx = np.where(np.ravel(matrix(assoc_vars)))[0]

logger.debug('Max. correction is for variable %s [%d]', self.system.dae.xy_name[xy_idx], xy_idx)
logger.debug('Associated equation value is %20g', self.system.dae.fg[xy_idx])
logger.debug('Associated equation rhs is %20g', self.system.dae.fg[xy_idx])
logger.debug('')

logger.debug(f'{"xy_index":<10} {"Equation":<20} {"Derivative":<20} {"Eq. Mismatch":<20}')
logger.debug(f'{"xy_index":<10} {"Equation (row)":<20} {"Derivative":<20} {"Eq. Mismatch":<20}')
for eq in eqns_idx:
eq = eq.tolist()
logger.debug(f'{eq:<10} {self.system.dae.xy_name[eq]:<20} {assoc_eqns[eq]:<20g} '
f'{self.system.dae.fg[eq]:<20g}')

logger.debug('')
logger.debug(f'{"xy_index":<10} {"Variable":<20} {"Derivative":<20} {"Eq. Mismatch":<20}')
logger.debug(f'{"xy_index":<10} {"Variable (col)":<20} {"Derivative":<20} {"Eq. Mismatch":<20}')
for v in vars_idx:
v = v.tolist()
logger.debug(f'{v:<10} {self.system.dae.xy_name[v]:<20} {assoc_vars[v]:<20g} '
Expand Down
2 changes: 1 addition & 1 deletion andes/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ def j_update(self, models: OrderedDict, info=None):
self.j_islands()

if info:
logger.debug("Jacobian updated at t=%.6f due to %s.", self.dae.t, info)
logger.debug("Jacobian updated at t=%.6f: %s.", self.dae.t, info)
else:
logger.debug("Jacobian updated at t=%.6f.", self.dae.t)

Expand Down
4 changes: 4 additions & 0 deletions docs/source/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The APIs before v3.0.0 are in beta and may change without prior notice.

v1.3 Notes
----------
v1.3.10 (2021-06-08)
````````````````````
- Bug fixes for controllers when generators are off.

v1.3.9 (2021-06-02)
```````````````````
- Bug fixes in exciters when generators are offline.
Expand Down

0 comments on commit 2d12222

Please sign in to comment.