From 591141a74b8ed4435dd8987f50527c417a7537f5 Mon Sep 17 00:00:00 2001 From: Jonas Danke Date: Mon, 8 Jul 2024 11:42:50 +0200 Subject: [PATCH 01/16] Fix docs link check and build issues --- doc/conf.py | 5 ++++- doc/index.rst | 2 +- doc/quickstart.rst | 4 ++-- doc/usage_details.rst | 2 +- edisgo/edisgo.py | 16 ++++++++-------- edisgo/io/dsm_import.py | 2 +- edisgo/io/generators_import.py | 4 ++-- edisgo/io/heat_pump_import.py | 2 +- edisgo/io/timeseries_import.py | 10 +++++----- edisgo/network/heat.py | 8 ++++---- edisgo/network/timeseries.py | 2 +- 11 files changed, 30 insertions(+), 27 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 851a3fb6d..ad1be2546 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -128,7 +128,10 @@ def setup(sphinx): "shapely.%s", ), "ding0": ("https://dingo.readthedocs.io/en/dev/api/ding0.html#%s", "ding0.%s"), - "pypsa": ("https://pypsa.readthedocs.io/en/latest/components.html#%s", "pypsa.%s"), + "pypsa": ( + "https://pypsa.readthedocs.io/en/latest/user-guide/components.html#%s", + "pypsa.%s", + ), "plotly": ( "https://plotly.com/python-api-reference/generated/%s.html", "plotly.%s", diff --git a/doc/index.rst b/doc/index.rst index dfebb4369..444e35f04 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -15,7 +15,7 @@ The toolbox currently includes: * `ding0 `_ tool for synthetic medium and low voltage grid topologies for the whole of Germany - * `OpenEnergy DataBase (oedb) `_ for + * `OpenEnergy DataBase (oedb) `_ for feed-in time series of fluctuating renewables and scenarios for future power plant park of Germany * `demandlib `_ for electrical load time series diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 4ce437c05..a4af052f7 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -188,8 +188,8 @@ Aside from grid topology data you may eventually need a dataset on future installation of power plants. You may therefore use the scenarios developed in the `open_eGo `_ project that are available in the -`OpenEnergy DataBase (oedb) `_ -hosted on the `OpenEnergy Platform (OEP) `_. +`OpenEnergy DataBase (oedb) `_ +hosted on the `OpenEnergy Platform (OEP) `_. eDisGo provides an interface to the oedb using the package `ego.io `_. ego.io gives you a python SQL-Alchemy representations of the oedb and access to it by using the diff --git a/doc/usage_details.rst b/doc/usage_details.rst index aac09982f..a35ba1e20 100644 --- a/doc/usage_details.rst +++ b/doc/usage_details.rst @@ -241,7 +241,7 @@ This mode can be invoked as follows: For the following components you can use existing time series: * Fluctuating generators: Feed-in time series for solar and wind power plants can be - retrieved from the `OpenEnergy DataBase `_. + retrieved from the `OpenEnergy DataBase `_. * Conventional loads: Standard load profiles for the different sectors residential, commercial, agricultural and industrial are generated using the oemof `demandlib `_. diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index dca1660b2..52e708b2d 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -417,7 +417,7 @@ def set_time_series_active_power_predefined( Technology- and weather cell-specific hourly feed-in time series are obtained from the `OpenEnergy DataBase - `_. See + `_. See :func:`edisgo.io.timeseries_import.feedin_oedb` for more information. This option requires that the parameter `engine` is provided in case @@ -478,7 +478,7 @@ def set_time_series_active_power_predefined( Sets active power demand time series using individual hourly electricity load time series for one year obtained from the `OpenEnergy DataBase - `_. + `_. This option requires that the parameters `engine` and `scenario` are provided. For further settings, the parameter `timeindex` can also be @@ -933,7 +933,7 @@ def import_generators(self, generator_scenario=None, **kwargs): Gets generator park for specified scenario and integrates generators into grid. The generator data is retrieved from the - `open energy platform `_. Decommissioned + `open energy platform `_. Decommissioned generators are removed from the grid, generators with changed capacity updated and new generators newly integrated into the grid. @@ -1928,7 +1928,7 @@ def import_electromobility( Imports electromobility data and integrates charging points into grid. Electromobility data can be obtained from the `OpenEnergy DataBase - `_ or from self-provided + `_ or from self-provided data. In case you want to use self-provided data, it needs to be generated using the tools `SimBEV `_ (required version: @@ -1960,7 +1960,7 @@ def import_electromobility( * "oedb" Electromobility data is obtained from the `OpenEnergy DataBase - `_. + `_. This option requires that the parameters `scenario` and `engine` are provided. @@ -2143,7 +2143,7 @@ def import_heat_pumps(self, scenario, engine, timeindex=None, import_types=None) between two scenarios: 'eGon2035' and 'eGon100RE'. The data is retrieved from the - `open energy platform `_. + `open energy platform `_. # ToDo Add information on scenarios and from which tables data is retrieved. @@ -2305,7 +2305,7 @@ def apply_heat_pump_operating_strategy( def import_dsm(self, scenario: str, engine: Engine, timeindex=None): """ Gets industrial and CTS DSM profiles from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. Profiles comprise minimum and maximum load increase in MW as well as maximum energy pre- and postponing in MWh. The data is written to the @@ -2356,7 +2356,7 @@ def import_home_batteries( between two scenarios: 'eGon2035' and 'eGon100RE'. The data is retrieved from the - `open energy platform `_. + `open energy platform `_. The batteries are integrated into the grid (added to :attr:`~.network.topology.Topology.storage_units_df`) based on their building diff --git a/edisgo/io/dsm_import.py b/edisgo/io/dsm_import.py index fac856d9f..648ae5039 100644 --- a/edisgo/io/dsm_import.py +++ b/edisgo/io/dsm_import.py @@ -28,7 +28,7 @@ def oedb( ): """ Gets industrial and CTS DSM profiles from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. Profiles comprise minimum and maximum load increase in MW as well as maximum energy pre- and postponing in MWh. diff --git a/edisgo/io/generators_import.py b/edisgo/io/generators_import.py index e9628c6d9..281e78a04 100755 --- a/edisgo/io/generators_import.py +++ b/edisgo/io/generators_import.py @@ -42,9 +42,9 @@ def oedb_legacy(edisgo_object, generator_scenario, **kwargs): The importer uses SQLAlchemy ORM objects. These are defined in `ego.io `_. The data is imported from the tables - `conventional power plants `_ and - `renewable power plants `_. When the generator data is retrieved, the following steps are conducted: diff --git a/edisgo/io/heat_pump_import.py b/edisgo/io/heat_pump_import.py index bb80064b7..69133ca11 100644 --- a/edisgo/io/heat_pump_import.py +++ b/edisgo/io/heat_pump_import.py @@ -583,7 +583,7 @@ def _grid_integration( def efficiency_resistive_heaters_oedb(scenario, engine): """ Get efficiency of resistive heaters from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. Parameters ---------- diff --git a/edisgo/io/timeseries_import.py b/edisgo/io/timeseries_import.py index 83e4afc65..5d154b965 100644 --- a/edisgo/io/timeseries_import.py +++ b/edisgo/io/timeseries_import.py @@ -74,7 +74,7 @@ def _timeindex_helper_func( def feedin_oedb_legacy(edisgo_object, timeindex=None): """ Import feed-in time series data for wind and solar power plants from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. Parameters ---------- @@ -158,7 +158,7 @@ def feedin_oedb( ): """ Import feed-in time series data for wind and solar power plants from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. Parameters ---------- @@ -319,7 +319,7 @@ def load_time_series_demandlib(edisgo_obj, timeindex=None): def cop_oedb(edisgo_object, engine, weather_cell_ids, timeindex=None): """ Get COP (coefficient of performance) time series data from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. Parameters ---------- @@ -377,7 +377,7 @@ def cop_oedb(edisgo_object, engine, weather_cell_ids, timeindex=None): def heat_demand_oedb(edisgo_obj, scenario, engine, timeindex=None): """ Get heat demand profiles for heat pumps from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. Heat demand data is returned for all heat pumps in the grid. For more information on how individual heat demand profiles are obtained see @@ -498,7 +498,7 @@ def electricity_demand_oedb( ): """ Get electricity demand profiles for all conventional loads from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. Conventional loads comprise conventional electricity applications in the residential, CTS and industrial sector. diff --git a/edisgo/network/heat.py b/edisgo/network/heat.py index 22403d0f2..1762f56c7 100644 --- a/edisgo/network/heat.py +++ b/edisgo/network/heat.py @@ -131,7 +131,7 @@ def set_cop(self, edisgo_object, ts_cop, **kwargs): Write COP time series for heat pumps to py:attr:`~cop_df`. COP time series can either be given to this function or be obtained from the - `OpenEnergy DataBase `_. + `OpenEnergy DataBase `_. In case they are obtained from the OpenEnergy DataBase the heat pumps need to already be integrated into the grid, i.e. given in :attr:`~.network.topology.Topology.loads_df`. @@ -150,7 +150,7 @@ def set_cop(self, edisgo_object, ts_cop, **kwargs): * 'oedb' COP / efficiency data are obtained from the `OpenEnergy DataBase - `_. + `_. In case of heat pumps weather cell specific hourly COP time series are obtained (see :func:`edisgo.io.timeseries_import.cop_oedb` for more information). Using information on which weather cell each heat pump @@ -317,7 +317,7 @@ def set_heat_demand(self, edisgo_object, ts_heat_demand, **kwargs): Write heat demand time series of heat pumps to py:attr:`~heat_demand_df`. Heat demand time series can either be given to this function or be obtained from - the `OpenEnergy DataBase `_. + the `OpenEnergy DataBase `_. In case they are obtained from the OpenEnergy DataBase the heat pumps need to already be integrated into the grid, i.e. given in :attr:`~.network.topology.Topology.loads_df`. @@ -336,7 +336,7 @@ def set_heat_demand(self, edisgo_object, ts_heat_demand, **kwargs): * 'oedb' Heat demand time series are obtained from the `OpenEnergy DataBase - `_ (see + `_ (see :func:`edisgo.io.timeseries_import.heat_demand_oedb` for more information). Time series are only obtained for heat pumps that are already integrated diff --git a/edisgo/network/timeseries.py b/edisgo/network/timeseries.py index 8da353ff2..585240e98 100644 --- a/edisgo/network/timeseries.py +++ b/edisgo/network/timeseries.py @@ -1204,7 +1204,7 @@ def predefined_fluctuating_generators_by_technology( Technology and weather cell specific hourly feed-in time series are obtained from the `OpenEnergy DataBase - `_. See + `_. See :func:`edisgo.io.timeseries_import.feedin_oedb` for more information. This option requires that the parameter `engine` is provided in case From 41888aa0bb1e2d705d303b5aefd55c790c833ed9 Mon Sep 17 00:00:00 2001 From: Jonas Danke Date: Mon, 8 Jul 2024 11:43:59 +0200 Subject: [PATCH 02/16] update installation instructions --- doc/dev_notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dev_notes.rst b/doc/dev_notes.rst index e012ce874..953ae282b 100644 --- a/doc/dev_notes.rst +++ b/doc/dev_notes.rst @@ -24,7 +24,7 @@ following commands within your eDisGo directory: .. code-block:: bash - python -m pip install -e .[full] # install eDisGo from source + python -m pip install -e .[dev] # install eDisGo from source pre-commit install # install pre-commit hooks From 64a4f7b7412e4f898e7997a3e8bf36c2a9e646be Mon Sep 17 00:00:00 2001 From: Jonas Danke Date: Mon, 8 Jul 2024 11:54:02 +0200 Subject: [PATCH 03/16] Update PyPSA power flow analysis link in EDisGo class --- edisgo/edisgo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 52e708b2d..3930a5659 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -1003,7 +1003,7 @@ def analyze( Conducts a static, non-linear power flow analysis. Conducts a static, non-linear power flow analysis using - `PyPSA `_ and writes results (active, reactive and apparent power as well as current on lines and voltages at buses) to :class:`~.network.results.Results` From af1b79d2d7c78216c0f652649dd9fe2ef1d1fe64 Mon Sep 17 00:00:00 2001 From: Jonas Danke Date: Mon, 8 Jul 2024 13:49:24 +0200 Subject: [PATCH 04/16] Update installation instructions for edisgoOPF package --- doc/quickstart.rst | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/quickstart.rst b/doc/quickstart.rst index a4af052f7..f0dad32d6 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -44,41 +44,41 @@ Installation using MacOS We don't have any experience with our package on MacOS yet! If you try eDisGo on MacOS we would be happy if you let us know about your experience! -Requirements for edisgoOPF package ----------------------------------- +edisgoOPF Package +----------------- -.. warning:: The non-linear optimal power flow is currently not maintained and might not work out of the box! +Introduction +^^^^^^^^^^^^^ +edisgoOPF is a Python package designed for optimal power flow (OPF) calculations in electrical distribution systems. This package leverages the power of Julia, a high-performance programming language for technical computing, to perform efficient OPF calculations. -To use the multiperiod optimal power flow that is provided in the julia package -edisgoOPF in eDisGo you additionally need to install julia version 1.1.1. -Download julia from -`julia download page `_ and -add it to your path (see -`platform specific instructions `_ -for more information). -Before using the edisgoOPF julia package for the first time you need to -instantiate it. Therefore, in a terminal change directory to the edisgoOPF -package located in eDisGo/edisgo/opf/edisgoOPF and call julia from there. -Change to package mode by typing -.. code-block:: bash +To use edisgoOPF effectively, you'll need to set up a specific environment that includes: - ] +1. **Julia**: Version 1.6.7 is required. +2. **Gurobi Optimizer**: A powerful optimization solver. -Then activate the package: +Installation Steps +^^^^^^^^^^^^^^^^^^^ + +1. Install Julia 1.6.7 -.. code-block:: bash - (v1.0) pkg> activate . +Download Julia 1.6.7 from the `Julia LTS releases page `_. -And finally instantiate it: +For Linux users, you can use the following commands: .. code-block:: bash - (SomeProject) pkg> instantiate + wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.7-linux-x86_64.tar.gz + tar zxvf julia-1.6.7-linux-x86_64.tar.gz + export PATH="$PATH:/julia-1.6.7/bin" + +2. Install Gurobi + + +Follow the `Gurobi installation guide `_ to install Gurobi and add it to your system path. -.. _prerequisites: Additional linear solver ^^^^^^^^^^^^^^^^^^^^^^^^^ From 7db9daf2012bd35224342cb014337aa18bd87036 Mon Sep 17 00:00:00 2001 From: joda9 Date: Mon, 8 Jul 2024 17:07:55 +0200 Subject: [PATCH 05/16] update setup.py to newest pypsa and pyomo versions --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4f570f745..0d83f01f4 100644 --- a/setup.py +++ b/setup.py @@ -50,10 +50,10 @@ def read(fname): "plotly", "pydot", "pygeos", - "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release + # "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release "pypower", "pyproj >= 3.0.0", - "pypsa >= 0.17.0, <= 0.20.1", + "pypsa", "pyyaml", "saio", "scikit-learn <= 1.1.1", From 579eb5647c796c3e06e4db3311a871c781d820b2 Mon Sep 17 00:00:00 2001 From: joda9 Date: Mon, 8 Jul 2024 17:13:59 +0200 Subject: [PATCH 06/16] add linkcheck_ignore gurobi --- doc/conf.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index ad1be2546..134f16573 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -138,9 +138,14 @@ def setup(sphinx): ), } # ignore the following external links when checking the links -# stackoverflow is listed here because for some reason the link check fails for these +# stackoverflow and gurobi is listed here because for some reason +# the link check fails for these # in the github action, even though the link is correct -linkcheck_ignore = [r"https://stackoverflow.com*"] +linkcheck_ignore = [ + r"https://stackoverflow.com*", + r"https://support.gurobi.com/hc/en-us/articles\ + /14799677517585-Getting-Started-with-Gurobi-Optimizer", +] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] From a090f0d8c0a6a29d7b966e23a2095f80f0aceeb6 Mon Sep 17 00:00:00 2001 From: joda9 <66819219+joda9@users.noreply.github.com> Date: Mon, 8 Jul 2024 17:19:09 +0200 Subject: [PATCH 07/16] Update conf.py --- doc/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 134f16573..2b2867de2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -143,8 +143,7 @@ def setup(sphinx): # in the github action, even though the link is correct linkcheck_ignore = [ r"https://stackoverflow.com*", - r"https://support.gurobi.com/hc/en-us/articles\ - /14799677517585-Getting-Started-with-Gurobi-Optimizer", + r"https://support.gurobi.com/*", ] # Add any paths that contain templates here, relative to this directory. From c400c804a791ef78d930349c35f42b37e34f2c79 Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 11:33:04 +0200 Subject: [PATCH 08/16] add pytest.mark.oedbtest for failing tests due to oedb error --- tests/conftest.py | 10 ++++++++++ tests/io/test_generators_import.py | 4 ++++ tests/io/test_timeseries_import.py | 2 ++ tests/network/test_timeseries.py | 1 + tests/test_edisgo.py | 1 + tests/test_examples.py | 2 ++ tests/tools/test_tools.py | 1 + 7 files changed, 21 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 6809eb81a..8dedbc6cb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -57,6 +57,9 @@ def pytest_addoption(parser): default=False, help="run tests that only work locally", ) + parser.addoption( + "--runoedbtest", action="store_true", default=False, help="Run OEDB tests" + ) def pytest_collection_modifyitems(config, items): @@ -75,3 +78,10 @@ def pytest_collection_modifyitems(config, items): for item in items: if "runonlinux" in item.keywords: item.add_marker(skip_windows) + if config.getoption("--runoedbtest"): + # If the --runoedbtest option is specified, do not skip any tests + return + skip_oedbtest = pytest.mark.skip(reason="Need --runoedbtest option to run") + for item in items: + if "oedbtest" in item.keywords: + item.add_marker(skip_oedbtest) diff --git a/tests/io/test_generators_import.py b/tests/io/test_generators_import.py index 9adfdde1e..51ee4b5ee 100644 --- a/tests/io/test_generators_import.py +++ b/tests/io/test_generators_import.py @@ -484,6 +484,7 @@ class TestGeneratorsImportOEDB: """ @pytest.mark.slow + @pytest.mark.oedbtest def test_oedb_legacy_without_timeseries(self): edisgo = EDisGo( ding0_grid=pytest.ding0_test_network_2_path, @@ -497,6 +498,7 @@ def test_oedb_legacy_without_timeseries(self): assert np.isclose(edisgo.topology.generators_df.p_nom.sum(), 20.18783) @pytest.mark.slow + @pytest.mark.oedbtest def test_oedb_legacy_with_worst_case_timeseries(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_2_path) edisgo.set_time_series_worst_case_analysis() @@ -568,6 +570,7 @@ def test_oedb_legacy_with_worst_case_timeseries(self): # :, new_solar_gen.name] / new_solar_gen.p_nom).all() @pytest.mark.slow + @pytest.mark.oedbtest def test_oedb_legacy_with_timeseries_by_technology(self): timeindex = pd.date_range("1/1/2012", periods=3, freq="H") ts_gen_dispatchable = pd.DataFrame( @@ -647,6 +650,7 @@ def test_oedb_legacy_with_timeseries_by_technology(self): # :, new_solar_gen.name] / new_solar_gen.p_nom).all() @pytest.mark.slow + @pytest.mark.oedbtest def test_target_capacity(self): edisgo = EDisGo( ding0_grid=pytest.ding0_test_network_2_path, diff --git a/tests/io/test_timeseries_import.py b/tests/io/test_timeseries_import.py index 93825e9ac..2bae3cf27 100644 --- a/tests/io/test_timeseries_import.py +++ b/tests/io/test_timeseries_import.py @@ -59,6 +59,7 @@ def test__timeindex_helper_func(self): assert_index_equal(ind, given_index) assert_index_equal(ind_full, timeindex) + @pytest.mark.oedbtest def test_feedin_oedb_legacy(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_path) timeindex = pd.date_range("1/1/2010", periods=3000, freq="H") @@ -86,6 +87,7 @@ def test_feedin_oedb(self): assert feedin_df.shape == (6, 4) assert_index_equal(feedin_df.index, timeindex) + @pytest.mark.oedbtest def test_load_time_series_demandlib(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_path) timeindex = pd.date_range("1/1/2018", periods=7000, freq="H") diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 2c05eda49..3818aaf3b 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1235,6 +1235,7 @@ def test_worst_case_storage_units(self): ) @pytest.mark.slow + @pytest.mark.oedbtest def test_predefined_fluctuating_generators_by_technology(self): timeindex = pd.date_range("1/1/2011 12:00", periods=2, freq="H") self.edisgo.timeseries.timeindex = timeindex diff --git a/tests/test_edisgo.py b/tests/test_edisgo.py index e0379bd59..dbfa03a33 100755 --- a/tests/test_edisgo.py +++ b/tests/test_edisgo.py @@ -382,6 +382,7 @@ def test_to_graph(self): ) @pytest.mark.slow + @pytest.mark.oedbtest def test_generator_import(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_2_path) edisgo.import_generators("nep2035") diff --git a/tests/test_examples.py b/tests/test_examples.py index 8e31d88d9..9f0a862eb 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -26,6 +26,7 @@ def test_plot_example_ipynb(self): assert result.exec_error is None @pytest.mark.slow + @pytest.mark.oedbtest def test_electromobility_example_ipynb(self): path = os.path.join(self.examples_dir_path, "electromobility_example.ipynb") notebook = pytest_notebook.notebook.load_notebook(path=path) @@ -39,6 +40,7 @@ def test_electromobility_example_ipynb(self): assert result.exec_error is None @pytest.mark.slow + @pytest.mark.oedbtest def test_edisgo_simple_example_ipynb(self): path = os.path.join(self.examples_dir_path, "edisgo_simple_example.ipynb") notebook = pytest_notebook.notebook.load_notebook(path=path) diff --git a/tests/tools/test_tools.py b/tests/tools/test_tools.py index 606c60d81..40c34a63b 100644 --- a/tests/tools/test_tools.py +++ b/tests/tools/test_tools.py @@ -168,6 +168,7 @@ def test_determine_bus_voltage_level(self): assert tools.determine_bus_voltage_level(self.edisgo, bus_voltage_level_6) == 6 assert tools.determine_bus_voltage_level(self.edisgo, bus_voltage_level_7) == 7 + @pytest.mark.oedbtest def test_get_weather_cells_intersecting_with_grid_district(self): weather_cells = tools.get_weather_cells_intersecting_with_grid_district( self.edisgo From 3faa30bb3e4a355824ec7f6030d7f497e420c0a5 Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 11:38:35 +0200 Subject: [PATCH 09/16] Add pytest.mark.oedbtest for failing tests due to oedb error --- tests/network/test_timeseries.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 3818aaf3b..8cef16dc9 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1550,6 +1550,7 @@ def test_predefined_dispatchable_generators_by_technology(self): ) # fmt: on + @pytest.mark.oedbtest # WARNING: This is NO oedb error, but a demandlib error def test_predefined_conventional_loads_by_sector(self, caplog): index = pd.date_range("1/1/2018", periods=3, freq="H") self.edisgo.timeseries.timeindex = index From 22450da42d78ebfe5d8f3fad96975e32c3932fcb Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 11:54:30 +0200 Subject: [PATCH 10/16] update demandlib dependency to version < 0.2.0 due to demandlib error --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0d83f01f4..17e87f85a 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def read(fname): requirements = [ "contextily", "dash < 2.9.0", - "demandlib", + "demandlib < 0.2.0", "descartes", "egoio >= 0.4.7", "geoalchemy2 < 0.7.0", From 90dc28b307967561fd4b71b8381b530b78621418 Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 12:03:19 +0200 Subject: [PATCH 11/16] Remove pytest.mark.oedbtest for demandlib error --- tests/network/test_timeseries.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 8cef16dc9..3818aaf3b 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1550,7 +1550,6 @@ def test_predefined_dispatchable_generators_by_technology(self): ) # fmt: on - @pytest.mark.oedbtest # WARNING: This is NO oedb error, but a demandlib error def test_predefined_conventional_loads_by_sector(self, caplog): index = pd.date_range("1/1/2018", periods=3, freq="H") self.edisgo.timeseries.timeindex = index From 4dcc0eeedcd70cf8e6a391c88d470748ee4ce4ec Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 12:11:44 +0200 Subject: [PATCH 12/16] Revert "update setup.py to newest pypsa and pyomo versions" This reverts commit 7db9daf2012bd35224342cb014337aa18bd87036. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 17e87f85a..b77dba80f 100644 --- a/setup.py +++ b/setup.py @@ -50,10 +50,10 @@ def read(fname): "plotly", "pydot", "pygeos", - # "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release + "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release "pypower", "pyproj >= 3.0.0", - "pypsa", + "pypsa >= 0.17.0, <= 0.20.1", "pyyaml", "saio", "scikit-learn <= 1.1.1", From 7c4cbbbdc8771673cae09f8452adc029271fa0bc Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 17:12:52 +0200 Subject: [PATCH 13/16] Remove pytest.mark.oedbtest for demandlib error --- tests/io/test_timeseries_import.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/io/test_timeseries_import.py b/tests/io/test_timeseries_import.py index 2bae3cf27..17340163b 100644 --- a/tests/io/test_timeseries_import.py +++ b/tests/io/test_timeseries_import.py @@ -87,7 +87,6 @@ def test_feedin_oedb(self): assert feedin_df.shape == (6, 4) assert_index_equal(feedin_df.index, timeindex) - @pytest.mark.oedbtest def test_load_time_series_demandlib(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_path) timeindex = pd.date_range("1/1/2018", periods=7000, freq="H") From 47abe91ccadb56e4f04105f150a38a5696fd1e48 Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 17:13:38 +0200 Subject: [PATCH 14/16] Skip oedbtest in pytest unless --runoedbtest option is specified --- tests/conftest.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 8dedbc6cb..998adaebb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -78,10 +78,8 @@ def pytest_collection_modifyitems(config, items): for item in items: if "runonlinux" in item.keywords: item.add_marker(skip_windows) - if config.getoption("--runoedbtest"): - # If the --runoedbtest option is specified, do not skip any tests - return - skip_oedbtest = pytest.mark.skip(reason="Need --runoedbtest option to run") - for item in items: - if "oedbtest" in item.keywords: - item.add_marker(skip_oedbtest) + if not config.getoption("--runoedbtest"): + skip_oedbtest = pytest.mark.skip(reason="need --runoedbtest option to run") + for item in items: + if "oedbtest" in item.keywords: + item.add_marker(skip_oedbtest) From 04878dd2854342e68c6e587adec95c99e429593c Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 10 Jul 2024 16:08:58 +0200 Subject: [PATCH 15/16] Adapt installation documentation --- doc/quickstart.rst | 95 +++------------------------------------------- 1 file changed, 5 insertions(+), 90 deletions(-) diff --git a/doc/quickstart.rst b/doc/quickstart.rst index f0dad32d6..2d64df52f 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -3,11 +3,11 @@ Getting started ================ +.. warning:: Make sure to use python 3.8 or higher! + Installation using Linux ------------------------- -.. warning:: Make sure to use python 3.8 or higher! - Install latest eDisGo version through pip. Therefore, we highly recommend using a virtual environment and its pip. @@ -21,8 +21,6 @@ You may also consider installing a developer version as detailed in Installation using Windows -------------------------- -.. warning:: Make sure to use python 3.8 or higher! - For Windows users we recommend using Anaconda and to install the geo stack using the conda-forge channel prior to installing eDisGo. You may use the provided `eDisGo_env.yml file `_ @@ -44,16 +42,10 @@ Installation using MacOS We don't have any experience with our package on MacOS yet! If you try eDisGo on MacOS we would be happy if you let us know about your experience! -edisgoOPF Package ------------------ +Additional requirements for Optimal Power Flow +--------------------------------------------------- -Introduction -^^^^^^^^^^^^^ -edisgoOPF is a Python package designed for optimal power flow (OPF) calculations in electrical distribution systems. This package leverages the power of Julia, a high-performance programming language for technical computing, to perform efficient OPF calculations. - - - -To use edisgoOPF effectively, you'll need to set up a specific environment that includes: +In order to use the optimal power flow, you additionally need: 1. **Julia**: Version 1.6.7 is required. 2. **Gurobi Optimizer**: A powerful optimization solver. @@ -79,83 +71,6 @@ For Linux users, you can use the following commands: Follow the `Gurobi installation guide `_ to install Gurobi and add it to your system path. - -Additional linear solver -^^^^^^^^^^^^^^^^^^^^^^^^^ - -As with the default linear solver in Ipopt (local solver used in the OPF) -the limit for prolem sizes is reached quite quickly, you may want to instead use -the solver HSL_MA97. -The steps required to set up HSL are also described in the -`Ipopt Documentation `_. -Here is a short version for reference: - -First, you need to obtain an academic license for HSL Solvers. -Under https://licences.stfc.ac.uk/product/coin-hsl download the sources for Coin-HSL Full (Stable). -You will need to provide an institutional e-mail to gain access. - -Unpack the tar.gz: - -.. code-block:: bash - - tar -xvzf coinhsl-2014.01.10.tar.gz - -To install the solver, clone the Ipopt Third Party HSL tools: - -.. code-block:: bash - - git clone https://github.com/coin-or-tools/ThirdParty-HSL.git - cd ThirdParty-HSL - - -Under `ThirdParty-HSL`, create a folder for the HSL sources named `coinhsl` and -copy the contents of the HSL archive into it. -Under Ubuntu, you'll need BLAS, LAPACK and GCC for Fortran. If you don't have them, install them via: - -.. code-block:: bash - - sudo apt-get install libblas-dev liblapack-dev gfortran - -You can then configure and install your HSL Solvers: - -.. code-block:: bash - - ./configure - make - sudo make install - -To make Ipopt pick up the solver, you need to add it to your path. -During install, there will be an output that tells you where the libraries have -been put. Usually like this: - -.. code-block:: bash - - Libraries have been installed in: - /usr/local/lib - - -Add this path to the variable `LD_LIBRARY_PATH`: - -.. code-block:: bash - - export LD_LIBRARY="/usr/local/bin":$LD_LIBRARY_PATH - -You might also want to add this to your .bashrc to make it persistent. - -For some reason, Ipopt looks for a library named `libhsl.so`, which is not what -the file is named, so we'll also need to provide a symlink: - -.. code-block:: bash - - cd /usr/local/lib - ln -s libcoinhsl.so libhsl.so - -MA97 should now work and can be called from Julia with: - -.. code-block:: julia - - JuMP.setsolver(pm.model,IpoptSolver(linear_solver="ma97")) - Prerequisites ------------- From 2f06b51bd3b0b4b614223f6d905eac50eccd22c2 Mon Sep 17 00:00:00 2001 From: joda9 Date: Wed, 10 Jul 2024 17:17:57 +0200 Subject: [PATCH 16/16] Update installation instructions for Julia --- doc/quickstart.rst | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 2d64df52f..04f12fbaf 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -58,13 +58,8 @@ Installation Steps Download Julia 1.6.7 from the `Julia LTS releases page `_. -For Linux users, you can use the following commands: +Install Julia by following the instructions in the `Julia installation guide `_. Make sure to add Julia to your system path. -.. code-block:: bash - - wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.7-linux-x86_64.tar.gz - tar zxvf julia-1.6.7-linux-x86_64.tar.gz - export PATH="$PATH:/julia-1.6.7/bin" 2. Install Gurobi