コード例 #1
0
    def test_config_option(self):
        """
        Test single and multiple config_option passed to `andes.run`.
        """

        path = andes.get_case("5bus/pjm5bus.json")
        self.assertRaises(ValueError,
                          andes.load,
                          path,
                          config_option={"TDS = 1"})
        self.assertRaises(ValueError,
                          andes.load,
                          path,
                          config_option={"System.TDS.any = 1"})
        self.assertRaises(ValueError,
                          andes.load,
                          path,
                          config_option={"TDS.tf == 1"})

        ss = andes.load(path,
                        config_option={"PQ.pq2z = 0"},
                        default_config=True)
        self.assertEqual(ss.PQ.config.pq2z, 0)

        ss = andes.load(path, config_option={"PQ.pq2z=0"}, default_config=True)
        self.assertEqual(ss.PQ.config.pq2z, 0)

        ss = andes.load(path,
                        config_option=["PQ.pq2z=0", "TDS.tf = 1"],
                        default_config=True)
        self.assertEqual(ss.PQ.config.pq2z, 0)
        self.assertEqual(ss.TDS.config.tf, 1)
コード例 #2
0
ファイル: test_snapshot.py プロジェクト: treymingee/andes
    def test_save_load_ss(self):
        """
        Test loading a snapshot and continuing the simulation
        """

        # --- save a snapshot ---
        ss = andes.run(andes.get_case("kundur/kundur_full.xlsx"),
                       no_output=True,
                       default_config=True,  # remove if outside tests
                       )

        ss.TDS.config.tf = 2.0
        ss.TDS.run()

        path = save_ss('kundur_full_2s.pkl', ss)

        # --- load a snapshot ---
        ss = load_ss(path)

        # set a new simulation end time
        ss.TDS.config.tf = 3.0
        ss.TDS.run()

        np.testing.assert_almost_equal(ss.GENROU.omega.v,
                                       np.array([1.00549119, 1.00529052, 1.00426882, 1.0039297]))

        os.remove(path)
コード例 #3
0
ファイル: test_tds_resume.py プロジェクト: willjschmitt/andes
class TestTDSResume(unittest.TestCase):
    def test_tds_resume(self):
        case = andes.get_case('kundur/kundur_full.xlsx')

        ss = andes.run(case, routine='tds', tf=0.1, no_output=True,
                       default_config=True)

        ss.TDS.config.tf = 0.5
        ss.TDS.run()

        self.assertEqual(ss.exit_code, 0.0)

        # check if time stamps are correctly stored
        self.assertIn(0.1, ss.dae.ts._ys)
        self.assertIn(0.5, ss.dae.ts._ys)

        # check if values are correctly stored
        self.assertTrue(len(ss.dae.ts._ys[0.1]) > 0)
        self.assertTrue(len(ss.dae.ts._ys[0.5]) > 0)

        # check if `get_data` works
        data1 = ss.dae.ts.get_data((ss.GENROU.omega, ss.GENROU.v))
        data2 = ss.dae.ts.get_data((ss.GENROU.omega, ss.GENROU.v), a=[2])
        nt = len(ss.dae.ts.t)

        self.assertEqual(data1.shape[1], 8)
        self.assertEqual(data1.shape[0], nt)

        self.assertEqual(data2.shape[1], 2)
        self.assertEqual(data2.shape[0], nt)
コード例 #4
0
ファイル: test_group.py プロジェクト: treymingee/andes
 def setUp(self):
     self.ss = andes.run(
         andes.get_case("ieee14/ieee14_pvd1.xlsx"),
         default_config=True,
         no_output=True,
     )
     self.ss.config.warn_limits = 0
     self.ss.config.warn_abnormal = 0
コード例 #5
0
 def test_relative_path(self):
     ss = andes.run(
         'ieee14.raw',
         input_path=andes.get_case('ieee14/', check=False),
         no_output=True,
         default_config=True,
     )
     self.assertNotEqual(ss, None)
コード例 #6
0
ファイル: test_services.py プロジェクト: treymingee/andes
    def test_backref_ieee14(self):
        ss = andes.load(andes.get_case("ieee14/ieee14_gentrip.xlsx"))

        self.assertSequenceEqual(ss.Area.Bus.v[0], [1, 2, 3, 4, 5])
        self.assertSequenceEqual(ss.Area.Bus.v[1], [6, 7, 8, 9, 10, 11, 12, 13, 14])

        self.assertSequenceEqual(ss.StaticGen.SynGen.v[0], ['GENROU_2'])
        self.assertSequenceEqual(ss.SynGen.TurbineGov.v[0], ['TGOV1_1'])
コード例 #7
0
ファイル: test_paths.py プロジェクト: Hello-World-Py/andes
    def test_addfile_path(self):
        ieee14 = andes.get_case("ieee14/ieee14.raw")
        path, case = os.path.split(ieee14)
        andes.load('ieee14.raw', addfile='ieee14.dyr', input_path=path)

        andes.run('ieee14.raw',
                  addfile='ieee14.dyr',
                  input_path=path,
                  no_output=True)
コード例 #8
0
class TestTDSResume(unittest.TestCase):
    def test_tds_resume(self):
        case = andes.get_case('kundur/kundur_full.xlsx')

        ss = andes.run(case, routine='tds', tf=0.1, no_output=True,
                       default_config=True)

        ss.TDS.config.tf = 0.5
        ss.TDS.run()

        self.assertEqual(ss.exit_code, 0.0)
コード例 #9
0
ファイル: test_plbvfu1.py プロジェクト: YaeSakura1/andes
    def test_PLBVFU1(self):
        """
        Test PLVBFU1 model.
        """

        ss = andes.run(
            andes.get_case("ieee14/ieee14_plbvfu1.xlsx"),
            default_config=True,
            no_output=True,
        )
        ss.TDS.config.tf = 3.0
        ss.TDS.run()

        self.assertEqual(ss.exit_code, 0)
コード例 #10
0
    def test_output_xyname(self):
        """
        Test x_name and y_name for Output
        """

        ss = andes.load(andes.get_case("5bus/pjm5bus.json"),
                        no_output=True,
                        setup=False,
                        default_config=True)

        ss.add("Output", {"model": "GENCLS", "varname": "omega"})
        ss.add("Output", {"model": "GENCLS", "varname": "delta", "dev": 2})
        ss.add("Output", {"model": "Bus"})

        ss.setup()

        ss.PFlow.run()
        ss.TDS.config.tf = 0.1
        ss.TDS.run()
        ss.TDS.load_plotter()

        nt = len(ss.dae.ts.t)
        nx = 5
        ny = 10

        self.assertEqual(len(ss.dae.x_name_output), nx)
        self.assertEqual(len(ss.dae.y_name_output), ny)

        self.assertEqual(ss.dae.ts.x.shape[1], nx)
        self.assertEqual(ss.dae.ts.y.shape[1], ny)

        np.testing.assert_array_equal(ss.Output.xidx, [1, 4, 5, 6, 7])
        np.testing.assert_array_equal(ss.Output.yidx,
                                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

        # test loaded data by plot
        self.assertEqual(ss.TDS.plt._data.shape, (nt, nx + ny + 1))
        np.testing.assert_array_equal(
            ss.TDS.plt._process_yidx(ss.GENCLS.omega, a=None), [2, 3, 4, 5])
        np.testing.assert_array_equal(
            ss.TDS.plt._process_yidx(ss.GENCLS.delta, a=None), [1])
        np.testing.assert_array_equal(
            ss.TDS.plt._process_yidx(ss.TG2.pout, a=None), [])
コード例 #11
0
ファイル: test_paths.py プロジェクト: willjschmitt/andes
 def setUp(self) -> None:
     self.kundur = 'kundur/'
     self.matpower = 'matpower/'
     self.ieee14 = andes.get_case("ieee14/ieee14.raw")
コード例 #12
0
ファイル: test_repr.py プロジェクト: treymingee/andes
 def setUp(self):
     self.ss = andes.run(
         andes.get_case("ieee14/ieee14_linetrip.xlsx"),
         no_output=True,
         default_config=True,
     )
コード例 #13
0
 def setUp(self):
     self.ss = andes.run(
         andes.get_case("kundur/kundur_full.json"),
         default_config=True,
         no_output=True,
     )