Skip to content

Commit

Permalink
Add test on ANDES conversion under parameter updating
Browse files Browse the repository at this point in the history
  • Loading branch information
jinningwang committed Apr 7, 2024
1 parent 35de35e commit 06992a1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_andes.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ def test_convert(self):
for mdl in pflow_mdls:
self.assertTrue(sp.models[mdl].as_df().equals(sa.PFlow.models[mdl].as_df()))

def test_convert_after_update(self):
"""
Test conversion from AMS case to ANDES case after updating parameters.
"""
for ad_case, am_case in zip(self.ad_cases, self.am_cases):
sp = ams.load(ams.get_case(am_case),
setup=True, no_output=True, default_config=True,)
# record initial values
pq_idx = sp.PQ.idx.v
p0 = sp.PQ.p0.v.copy()
sa = to_andes(sp, setup=False, no_output=True, default_config=True)
# before update
np.testing.assert_array_equal(sp.PQ.p0.v, sa.PQ.p0.v)
# after update
sp.PQ.set(src='p0', attr='v', idx=pq_idx, value=0.9*p0)
sa = to_andes(sp, setup=False, no_output=True, default_config=True)
np.testing.assert_array_equal(sp.PQ.p0.v, sa.PQ.p0.v)

def test_extra_dyn(self):
"""
Test conversion when extra dynamic models exist.
Expand Down

0 comments on commit 06992a1

Please sign in to comment.