Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
159f964
Skip InitChecker logging for offline devices
jinningwang Apr 28, 2025
07b5677
Skip limiter upper and lower adjust for offline devices
jinningwang Apr 28, 2025
855f1cf
Update release notes
jinningwang Apr 28, 2025
2143ca2
In one model, issue a warning only once for NumParam value checks
jinningwang Apr 28, 2025
153e9a3
Wording
jinningwang Apr 28, 2025
701b131
Add tests for InitChecker logging
jinningwang Apr 28, 2025
b7fbce6
Add test for correction warning only show up once for one model param
jinningwang Apr 28, 2025
11cedc1
Minor fix
jinningwang Apr 28, 2025
c7a6ed3
Ensure ue type
jinningwang Apr 28, 2025
07087a0
Remove the setuptools in RTD config
jinningwang Apr 28, 2025
7815ff3
Issue warning only once for unused data
jinningwang Apr 29, 2025
30adfd1
Add tests on modeldata add warning trigger
jinningwang Apr 29, 2025
49dd376
Update release notes
jinningwang Apr 29, 2025
3704089
Reverse logging only once for out of range numparam
jinningwang May 4, 2025
0c33a7c
Update release notes
jinningwang May 12, 2025
87b50d6
Remove tests on numparam logging
jinningwang May 12, 2025
c82c328
Extend group RenPlant with common param ree
jinningwang May 13, 2025
4d934a5
Extend group TurbineGov with common param syn
jinningwang May 13, 2025
2721e9b
Extend group VoltComp with common param avr
jinningwang May 13, 2025
757f8f3
Extend group PSS with common param avr
jinningwang May 13, 2025
8f1124e
Extend groups FreqMeasurement and PhasorMeasurement with common param…
jinningwang May 13, 2025
7a15c62
Extend group PLLwith common param bus
jinningwang May 13, 2025
1264a14
Extend group Motor with common param bus
jinningwang May 13, 2025
4049317
Minor fix
jinningwang May 13, 2025
ddc308c
Minor fix
jinningwang May 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions andes/core/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ def do_adjust_lower(self, val, lower, allow_adjust=True, adjust_lower=False):
"""

if allow_adjust:
mask = (val < lower)

ue = self.owner.services.get('ue', self.owner.params.get('u', np.ones(self.owner.n))).v
mask = np.logical_and(val < lower, ue)
if sum(mask) == 0:
return

Expand Down Expand Up @@ -540,7 +540,8 @@ def do_adjust_upper(self, val, upper, allow_adjust=True, adjust_upper=False):
"""

if allow_adjust:
mask = (val > upper)
ue = self.owner.services.get('ue', self.owner.params.get('u', np.ones(self.owner.n))).v
mask = (val >= ue * upper)
if sum(mask) == 0:
return

Expand Down
24 changes: 18 additions & 6 deletions andes/core/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ def __init__(self,
self.vin = None # values from input
self.vrange = vrange
self.vtype = vtype
self._non_zero_warning_issued = False
self._non_positive_warning_issued = False
self._non_negative_warning_issued = False

def add(self, value=None):
"""
Expand Down Expand Up @@ -465,20 +468,29 @@ def add(self, value=None):
if isinstance(value, float):
# check for non-zero
if value == 0.0 and self.get_property('non_zero'):
logger.warning('Non-zero parameter %s.%s corrected to %s',
self.owner.class_name, self.name, self.default)
if not self._non_zero_warning_issued:
logger.warning('Non-zero parameter %s.%s corrected to %s. '
'This warning will be shown only once.',
self.owner.class_name, self.name, self.default)
self._non_zero_warning_issued = True
value = self.default

# check for non-positive
if value > 0.0 and self.get_property('non_positive'):
logger.warning('Non-Positive parameter %s.%s corrected to %s',
self.owner.class_name, self.name, self.default)
if not self._non_positive_warning_issued:
logger.warning('Non-Positive parameter %s.%s corrected to %s. '
'This warning will be shown only once.',
self.owner.class_name, self.name, self.default)
self._non_positive_warning_issued = True
value = self.default

# check for non-negative
if value < 0.0 and self.get_property('non_negative'):
logger.warning('Non-negative parameter %s.%s corrected to %s',
self.owner.class_name, self.name, self.default)
if not self._non_negative_warning_issued:
logger.warning('Non-negative parameter %s.%s corrected to %s. '
'This warning will be shown only once.',
self.owner.class_name, self.name, self.default)
self._non_negative_warning_issued = True
value = self.default

super(NumParam, self).add(value)
Expand Down
11 changes: 10 additions & 1 deletion andes/core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,18 @@ def check(self):
if limit is None:
continue

# Determine the operational status of devices, use ue when applicable
ue = self.owner.services.get('ue', self.owner.params.get('u', np.ones(self.owner.n))).v

# Identify online devices
online_devices = np.where(ue == 1)[0]

# Update the flag for devices violating the condition
self.v[:] = np.logical_or(self.v, func(self.u.v, limit.v))

pos = np.argwhere(func(self.u.v, limit.v)).ravel()
# Find positions of online devices violating the condition
violating_devices = np.argwhere(func(self.u.v, limit.v)).ravel()
pos = np.intersect1d(violating_devices, online_devices)

if len(pos) == 0:
continue
Expand Down
2 changes: 2 additions & 0 deletions docs/source/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ v1.9.4 (2025-xx-xx)
list.
- Fix a bug in line model that causes incorrect admittance matrix.
- Correct a typo in the PSSE DYR parser, changing "Tprod" to "Tpord".
- Skip InitChecker logging and limiter adjust for offline devices.
- In one model, issue a warning only once for NumParam value checks.

v1.9.3 (2025-01-05)
-------------------
Expand Down
16 changes: 16 additions & 0 deletions tests/test_numparam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import andes


def test_numparam_online(caplog):
"""
Ensure In one model, issue a warning only once for NumParam value checks.
"""
case = andes.get_case("GBnetwork/GBnetwork.m")
mpc = andes.io.matpower.m2mpc(case)

mpc['branch'][2:5, 3] = 0

ss = andes.system.System()
with caplog.at_level("WARNING"):
andes.io.matpower.mpc2system(mpc, ss)
assert caplog.text.count("Non-zero parameter Line.x corrected to 1e-08.") == 1
34 changes: 34 additions & 0 deletions tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,37 @@ def test_no_find_or_add(self):

# test if the flag for `am` is set to 0 to disable `am` measurement
self.assertEqual(ss.REGCP1.zam.v[0], 0)


def test_init_checker_online(caplog):
"""
Test the initialization checker for online devices.

This test ensures that the initialization checker raises a warning
when a device's parameters are out of the typical range during TDS
initialization process.
"""
ss = andes.run(andes.get_case("npcc/npcc.xlsx"),
setup=True,
default_config=True,
no_output=True)
with caplog.at_level("WARNING"):
ss.TDS.init()
assert "GENCLS (vf range) out of typical lower limit." in caplog.text


def test_init_checker_offline(caplog):
"""
Test the initialization checker for offline devices.

This test ensures that the initialization checker does not raise warnings
for devices that are offline.
"""
ss = andes.run(andes.get_case("npcc/npcc.xlsx"),
setup=True,
default_config=True,
no_output=True)
ss.GENCLS.set(src='u', attr='v', idx=['GENCLS_3', 'GENCLS_4', 'GENCLS_16'], value=0)
with caplog.at_level("WARNING"):
ss.TDS.init()
assert "GENCLS (vf range) out of typical lower limit." not in caplog.text
Loading