Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ python:
path: .
extra_requirements:
- doc
- method: setuptools
path: .
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
2 changes: 1 addition & 1 deletion andes/core/model/modeldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def add(self, **kwargs):
value = kwargs.pop(name, None)
instance.add(value)
if len(kwargs) > 0:
logger.warning("%s: unused data %s", self.class_name, str(kwargs))
logger.warning("%s: unused data %s.", self.class_name, str(kwargs))

def as_dict(self, vin=False):
"""
Expand Down
6 changes: 3 additions & 3 deletions andes/core/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,19 +465,19 @@ 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',
logger.warning('Non-zero parameter %s.%s corrected to %s.',
self.owner.class_name, self.name, self.default)
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',
logger.warning('Non-Positive parameter %s.%s corrected to %s. ',
self.owner.class_name, self.name, self.default)
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',
logger.warning('Non-negative parameter %s.%s corrected to %s. ',
self.owner.class_name, self.name, self.default)
value = self.default

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 = np.asarray(self.owner.services.get(
'ue', self.owner.params.get('u', np.ones(self.owner.n))).v).astype(bool)
# Identify online devices
online_devices = np.where(ue)[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
9 changes: 8 additions & 1 deletion andes/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ class RenPlant(GroupBase):

def __init__(self):
super().__init__()
self.common_params.extend(('ree',))


class RenGovernor(GroupBase):
Expand Down Expand Up @@ -880,6 +881,7 @@ class TurbineGov(GroupBase):

def __init__(self):
super().__init__()
self.common_params.extend(('syn',))
self.common_vars.extend(('pout',))


Expand All @@ -904,7 +906,7 @@ class VoltComp(GroupBase):

def __init__(self):
super().__init__()
self.common_params.extend(('rc', 'xc',))
self.common_params.extend(('rc', 'xc', 'avr',))
self.common_vars.extend(('vcomp',))


Expand All @@ -913,6 +915,7 @@ class PSS(GroupBase):

def __init__(self):
super().__init__()
self.common_params.extend(('avr',))
self.common_vars.extend(('vsout',))


Expand Down Expand Up @@ -941,6 +944,7 @@ class FreqMeasurement(GroupBase):

def __init__(self):
super().__init__()
self.common_params.extend(('bus',))
self.common_vars.extend(('f',))


Expand All @@ -949,6 +953,7 @@ class PhasorMeasurement(GroupBase):

def __init__(self):
super().__init__()
self.common_params.extend(('bus',))
self.common_vars.extend(('am', 'vm'))


Expand All @@ -957,6 +962,7 @@ class PLL(GroupBase):

def __init__(self):
super().__init__()
self.common_params.extend(('bus',))
self.common_vars.extend(('am',))


Expand All @@ -966,6 +972,7 @@ class Motor(GroupBase):

def __init__(self):
super().__init__()
self.common_params.extend(('bus',))


class Information(GroupBase):
Expand Down
1 change: 1 addition & 0 deletions docs/source/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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.

v1.9.3 (2025-01-05)
-------------------
Expand Down
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