예제 #1
0
    def test_nrel_domain(self):
        mato = pomato.POMATO(wdir=self.wdir,
                             options_file="profiles/nrel118.json",
                             logging_level=logging.ERROR)
        mato.load_data('data_input/nrel_118.zip')

        R2_to_R3 = [
            "bus118", "bus076", "bus077", "bus078", "bus079", "bus080",
            "bus081", "bus097", "bus098", "bus099"
        ]
        mato.data.nodes.loc[R2_to_R3, "zone"] = "R3"

        folder = self.wdir.parent.joinpath(
            "tests/test_data/nrel_result/scopf_market_results")
        mato.data.process_results(folder, mato.grid)

        basecase = mato.data.results[folder.name]
        mato.options["grid"]["minram"] = 0.1
        mato.options["grid"]["sensitivity"] = 0.05
        mato.fbmc.calculate_parameters()

        mato.fbmc.create_flowbased_parameters(basecase,
                                              gsk_strategy="gmax",
                                              reduce=False)
        mato.fbmc.create_flowbased_parameters(basecase,
                                              gsk_strategy="dynamic",
                                              reduce=False)
예제 #2
0
    def test_run_ieee(self):
        """Simply run the ieee case"""
        mato = pomato.POMATO(wdir=self.wdir, logging_level=logging.ERROR)
        mato.load_data('data_input/pglib_opf_case118_ieee.m')
        mato.create_geo_plot(name="IEEE_blank", show=False)

        ### Set Mock Julia Model and copy precalculated results
        mato.cbco_module.julia_instance = JuliaMockup()
        mato.market_model.julia_model = JuliaMockup()
        prepared_result = self.wdir.parent.joinpath(
            'tests/test_data/dispatch_result/')
        to_folder = self.wdir.joinpath(
            'data_temp/julia_files/results/dispatch_result')
        to_folder.mkdir()
        copytree(prepared_result, to_folder)

        mato.options["optimization"]["type"] = "dispatch"
        mato.create_grid_representation()
        mato.update_market_model_data()
        mato.run_market_model()

        result_folder = mato.market_model.result_folders[0]
        result = mato.data.results[result_folder.name]
        result.default_plots()

        # df1, df2 = result.overloaded_lines_n_1()
        # df3, df4 = result.overloaded_lines_n_0()
        mato._clear_data()
예제 #3
0
 def setUp(self):
     wdir = Path.cwd().joinpath("examples")
     self.mato = pomato.POMATO(wdir=wdir, options_file="profiles/nrel118.json",
                               logging_level=logging.ERROR)
     self.mato.load_data('data_input/nrel_118.zip')
     
     R2_to_R3 = ["bus118", "bus076", "bus077", "bus078", "bus079", 
                 "bus080", "bus081", "bus097", "bus098", "bus099"]
     self.mato.data.nodes.loc[R2_to_R3, "zone"] = "R3"
     # For GeoPLot option 3
     self.mato.data.lines["cb"] = False
     self.mato.data.lines.loc["line001", "cb"] = True  
     
     market_folder = self.mato.wdir.parent.joinpath("tests/test_data/nrel_result/dispatch_market_results")
     redispatch_folder = self.mato.wdir.parent.joinpath("tests/test_data/nrel_result/dispatch_redispatch")
     self.mato.initialize_market_results([market_folder, redispatch_folder])
     self.mato.data.results["dispatch_redispatch"].result_attributes["corresponding_market_result_name"] = "dispatch_market_results"
예제 #4
0
    def test_run_de(self):
        """Simply run the DE case"""

        mato = pomato.POMATO(wdir=self.wdir,
                             options_file="profiles/de.json",
                             logging_level=logging.ERROR)
        mato.load_data('data_input/dataset_de.xlsx')

        ### Set Mock Julia Model and copy precalculated results
        mato.cbco_module.julia_instance = JuliaMockup()
        mato.market_model.julia_model = JuliaMockup()
        prepared_result_market = self.wdir.parent.joinpath(
            'tests/test_data/market_result_DE/')
        prepared_result_redispatch = self.wdir.parent.joinpath(
            'tests/test_data/redispatch_DE/')
        to_folder_market = self.wdir.joinpath(
            'data_temp/julia_files/results/market_result_DE')
        to_folder_redispatch = self.wdir.joinpath(
            'data_temp/julia_files/results/redispatch_DE')
        to_folder_redispatch.mkdir()
        to_folder_market.mkdir()
        copytree(prepared_result_market, to_folder_market)
        copytree(prepared_result_redispatch, to_folder_redispatch)

        # Init Model
        mato.create_grid_representation()
        mato.update_market_model_data()
        mato.run_market_model()

        # There are two market results loaded into data.results.
        # Specify redisp and market result for analysis
        redisp_result = mato.data.results[next(r
                                               for r in list(mato.data.results)
                                               if "redispatch" in r)]
        market_result = mato.data.results[next(r
                                               for r in list(mato.data.results)
                                               if "market_result" in r)]

        redisp_result.default_plots()
        market_result.default_plots()
        # # Check for Overloaded lines N-0, N-1 (should be non for N-0, but plenty for N-1)
        # df1, df2 = redisp_result.overloaded_lines_n_1()
        # df3, df4 = redisp_result.overloaded_lines_n_0()
        mato.create_geo_plot(name="DE", show=False)
예제 #5
0
 def test_init_ieee_matfile(self):
     mato = pomato.POMATO(wdir=self.wdir, logging_level=logging.ERROR)
     mato.load_data('data_input/pglib_opf_case118_ieee.mat')
예제 #6
0
 def test_run_ieee_init_invalid_data(self):
     mato = pomato.POMATO(wdir=self.wdir, logging_level=logging.ERROR)
     self.assertRaises(FileNotFoundError, mato.load_data, "INVALID_PATH")
예제 #7
0
 def test_run_ieee_init_no_option(self):
     mato = pomato.POMATO(wdir=self.wdir, logging_level=logging.ERROR)
     self.assertTrue(mato.options == pomato.tools.default_options())
예제 #8
0
 def test_run_ieee_init_invalid_option(self):
     mato = pomato.POMATO(wdir=self.wdir,
                          options_file="INVALID_PATH",
                          logging_level=logging.ERROR)
     self.assertTrue(mato.options == pomato.tools.default_options())
예제 #9
0
    def test_run_nrel(self):
        # What takes how long
        mato = pomato.POMATO(wdir=self.wdir,
                             options_file="profiles/nrel118.json",
                             logging_level=logging.ERROR)
        mato.load_data('data_input/nrel_118.zip')

        my_file = self.wdir.parent.joinpath(
            'tests/test_data/cbco_nrel_118.csv')
        to_file = self.wdir.joinpath(
            'data_temp/julia_files/cbco_data/cbco_nrel_118.csv')
        shutil.copyfile(str(my_file), str(to_file))

        R2_to_R3 = [
            "bus118", "bus076", "bus077", "bus078", "bus079", "bus080",
            "bus081", "bus097", "bus098", "bus099"
        ]
        mato.data.nodes.loc[R2_to_R3, "zone"] = "R3"

        mato.options["optimization"]["model_horizon"] = [0, 1]
        mato.options["optimization"]["constrain_nex"] = False
        mato.options["optimization"]["redispatch"]["include"] = True
        mato.options["optimization"]["redispatch"]["zones"] = list(
            mato.data.zones.index)
        mato.options["optimization"]["infeasibility"]["electricity"][
            "bound"] = 200
        mato.options["optimization"]["infeasibility"]["electricity"][
            "cost"] = 1000
        mato.options["optimization"]["redispatch"]["cost"] = 20

        # %% NTC Model NEX = 0
        mato.data.results = {}
        mato.options["optimization"]["type"] = "ntc"
        mato.options["optimization"]["constrain_nex"] = True
        mato.data.set_default_net_position(0)
        mato.create_grid_representation()
        # mato.update_market_model_data()
        # mato.run_market_model()

        # NTC Model NTC = 100
        mato.data.results = {}
        mato.options["optimization"]["type"] = "ntc"
        mato.options["optimization"]["constrain_nex"] = False
        mato.create_grid_representation()
        mato.grid_representation.ntc["ntc"] = \
            mato.grid_representation.ntc["ntc"]*0.001
        # mato.update_market_model_data()
        # mato.run_market_model()

        # %% Zonal PTDF model
        mato.data.results = {}
        mato.options["optimization"]["type"] = "zonal"
        mato.options["grid"]["gsk"] = "gmax"
        mato.create_grid_representation()
        # mato.update_market_model_data()
        # mato.run_market_model()

        # %% Nodal PTDF model
        mato.data.results = {}
        mato.options["optimization"]["type"] = "nodal"
        mato.create_grid_representation()
        mato.update_market_model_data()
        mato.run_market_model()

        # %% FBMC basecase
        # mato.data.results = {}
        mato.options["optimization"]["timeseries"]["market_horizon"] = 168
        mato.options["optimization"]["type"] = "cbco_nodal"
        mato.grid_model.options["grid"]["cbco_option"] = "clarkson_base"
        mato.options["optimization"]["redispatch"]["include"] = False
        mato.options["optimization"]["chance_constrained"]["include"] = False
        mato.options["grid"]["sensitivity"] = 0.05

        mato.grid_model.options["grid"]["precalc_filename"] = "cbco_nrel_118"
        mato.create_grid_representation()
        # mato.update_market_model_data()
        # mato.run_market_model()

        result_name = next(r for r in list(mato.data.results))
        basecase = mato.data.results[result_name]
        mato.options["grid"]["minram"] = 0.1
        mato.options["grid"]["sensitivity"] = 0.05
        fb_parameters = mato.create_flowbased_parameters(basecase,
                                                         gsk_strategy="gmax",
                                                         reduce=False)

        # %% FBMC market clearing
        mato.data.results = {}
        mato.options["optimization"]["timeseries"]["market_horizon"] = 100
        mato.options["optimization"]["redispatch"]["include"] = True
        mato.options["optimization"]["redispatch"]["zones"] = list(
            mato.data.zones.index)
        mato.create_grid_representation(flowbased_paramters=fb_parameters)
        mato.update_market_model_data()
        mato.run_market_model()

        mato.create_geo_plot()
        mato._join_julia_instances()
예제 #10
0
 def test_init_nrel_folder(self):
     mato = pomato.POMATO(wdir=self.wdir, logging_level=logging.ERROR)
     mato.load_data('data_input/nrel_118/')
예제 #11
0
 def test_init_nrel_direct_filepath(self):
     mato = pomato.POMATO(wdir=self.wdir, logging_level=logging.ERROR)
     filepath = self.wdir.joinpath('data_input/nrel_118.zip')
     mato.load_data(filepath)
예제 #12
0
 def test_init_de_zip(self):
     mato = pomato.POMATO(wdir=self.wdir, logging_level=logging.ERROR)
     mato.load_data('data_input/dataset_de.zip')