-
Notifications
You must be signed in to change notification settings - Fork 113
/
test_global_to_local_dc.py
46 lines (38 loc) · 1.81 KB
/
test_global_to_local_dc.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
# Copyright (c) 2019-2023, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# This file is part of Grid2Op, Grid2Op a testbed platform to model sequential decision making in power systems.
import unittest
import warnings
import grid2op
import pandapower as pp
import numpy as np
import pdb
class TestBugShuntDC(unittest.TestCase):
def setUp(self) -> None:
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
self.env = grid2op.make("l2rpn_case14_sandbox", test=True)
def tearDown(self) -> None:
self.env.close()
def test_shunt_dc(self):
self.env.backend.runpf(is_dc=True)
p_subs, q_subs, p_bus, q_bus, diff_v_bus = self.env.backend.check_kirchoff()
assert np.abs(p_subs).max() <=1e-5
assert np.abs(p_bus).max() <=1e-5
# below it does not pass due to https://github.com/e2nIEE/pandapower/issues/1996
# assert np.abs(diff_v_bus).max() <=1e-5
def test_shunt_dc_alone(self):
self.env.backend._grid.shunt["bus"][0] += 14
self.env.backend._grid.bus["in_service"][self.env.backend._grid.shunt["bus"][0]] = True
self.env.backend.runpf(is_dc=True)
p_subs, q_subs, p_bus, q_bus, diff_v_bus = self.env.backend.check_kirchoff()
assert np.abs(p_subs).max() <=1e-5
assert np.abs(p_bus).max() <=1e-5
# below it does not pass due to https://github.com/e2nIEE/pandapower/issues/1996
# assert np.abs(diff_v_bus).max() <=1e-5
if __name__ == "__main__":
unittest.main()