{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"__copyright__ = \"Reiner Lemoine Institut gGmbH\"\n",
"__license__ = \"GNU Affero General Public License Version 3 (AGPL-3.0)\"\n",
"__url__ = \"https://github.com/openego/eDisGo/blob/master/LICENSE\"\n",
"__author__ = \"gplssm, birgits, khelfen\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# eDisGo basic example\n",
"\n",
"This example shows you the first steps with eDisGo. Grid expansion costs for an example distribution grid are calculated assuming renewable and conventional power plant capacities as stated in the scenario framework of the German Grid Development Plan 2015 (Netzentwicklungsplan) for the year 2035 (scenario B2). Through this, the data structure used in eDisGo is explained and it is shown how to get distribution grid data, how to use the automatic grid reinforcement methodology to determine grid expansion needs and costs and how to evaluate your results.\n",
"\n",
"\n",
"## Learn more about eDisGo\n",
"\n",
"* __[eDisGo Source Code](https://github.com/openego/eDisGo)__\n",
"* __[eDisGo Documentation](https://edisgo.readthedocs.io/en/dev/)__\n",
"\n",
"## Table of Contents\n",
"\n",
"\n",
"* [Installation](#Installation)\n",
"* [Settings](#Settings)\n",
"* [eDisGo data structure](#eDisGo-data-structure)\n",
"* [Future generator scenario](#Future-generator-scenario)\n",
"* [Grid reinforcement](#Grid-reinforcement)\n",
"* [Results evaluation](#Evaluate-results)\n",
"* [References](#References)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Installation \n",
"\n",
"This notebook requires a working installation of eDisGo.\n",
"Checkout the eDisGo documentation on [how to install eDisGo](https://edisgo.readthedocs.io/en/dev/installation.html) for more information."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Import packages"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import networkx as nx\n",
"import requests\n",
"\n",
"from edisgo import EDisGo\n",
"from edisgo.tools.logger import setup_logger"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Set up logger"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# set up logger that streams edisgo logging messages with level info and above\n",
"# and other logging messages with level warning and above to stdout\n",
"setup_logger(\n",
" loggers=[\n",
" {\"name\": \"root\", \"file_level\": None, \"stream_level\": \"warning\"},\n",
" {\"name\": \"edisgo\", \"file_level\": None, \"stream_level\": \"info\"},\n",
" ]\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Settings \n",
"\n",
"The class **EDisGo** serves as the top-level API for\n",
"setting up your scenario, invocation of data import, power flow analysis, grid reinforcement and flexibility measures. It also provides access to all relevant data. See the [class documentation](https://edisgo.readthedocs.io/en/dev/autoapi/edisgo/edisgo/EDisGo.html) for more information.\n",
"\n",
"To set up a scenario to do a worst-case analysis that considers the heavy load flow and reverse power flow cases used in distribution grid planning, you simply have to provide a grid and call the function`set_time_series_worst_case_analysis`, which is both explained in the following two sections. \n",
"\n",
"### Distribution grid data\n",
"\n",
"Currently, synthetic grid data generated with the python project\n",
"[ding0](https://github.com/openego/ding0)\n",
"is the only supported data source for distribution grid data. ding0 provides the grid topology data in the form of csv files, with separate files for buses, lines, loads, generators, etc. You can retrieve ding0 data from\n",
"[Zenodo](https://zenodo.org/records/10405129)\n",
"(make sure you choose latest data) or check out the\n",
"[Ding0 documentation](https://dingo.readthedocs.io/en/dev/usage_details.html#ding0-examples)\n",
"on how to generate grids yourself. A ding0 example grid can be viewed [here](https://github.com/openego/eDisGo/tree/dev/tests/data/ding0_test_network_2). It is possible to provide your own grid data if it is in the same format as the ding0 grid data. \n",
"\n",
"This example works with any ding0 grid data. If you don't have grid data yet, you can execute the following to download the example grid data mentioned above."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def download_ding0_example_grid():\n",
"\n",
" # create directories to save ding0 example grid into\n",
" ding0_example_grid_path = os.path.join(\n",
" os.path.expanduser(\"~\"), \".edisgo\", \"ding0_test_network\"\n",
" )\n",
" os.makedirs(ding0_example_grid_path, exist_ok=True)\n",
"\n",
" # download files\n",
" filenames = [\n",
" \"buses\",\n",
" \"generators\",\n",
" \"lines\",\n",
" \"loads\",\n",
" \"network\",\n",
" \"switches\",\n",
" \"transformers\",\n",
" \"transformers_hvmv\",\n",
" ]\n",
"\n",
" for file in filenames:\n",
" req = requests.get(\n",
" f\"https://raw.githubusercontent.com/openego/eDisGo/dev/tests/data/ding0_test_network_2/{file}.csv\"\n",
" )\n",
" filename = os.path.join(ding0_example_grid_path, f\"{file}.csv\")\n",
" with open(filename, \"wb\") as fout:\n",
" fout.write(req.content)\n",
"\n",
"\n",
"download_ding0_example_grid()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ding0 grid you want to use in your analysis is specified through the input parameter 'ding0_grid' of the EDisGo class. The following assumes you want to use the ding0 example grid downloaded above. To use a different ding0 grid, just change the path below."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ding0_grid = os.path.join(os.path.expanduser(\"~\"), \".edisgo\", \"ding0_test_network\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Specifying worst-cases\n",
"\n",
"In conventional grid expansion planning worst-cases, the heavy load flow and the reverse power flow, are used to determine grid expansion needs. eDisGo allows you to analyze these cases separately or together. Choose between the following options:\n",
"\n",
"* **’feed-in_case’** \n",
" \n",
" Feed-in and demand for the worst-case scenario \"reverse power flow\" are generated (e.g. conventional electricity demand is set to 15% of maximum demand for loads connected to the MV grid and 10% for loads connected to the LV grid and feed-in of all generators is set to the nominal power of the generator, except for PV systems where it is by default set to 85% of the nominal power)\n",
"\n",
" \n",
"* **’load_case’**\n",
"\n",
" Feed-in and demand for the worst-case scenario \"heavy load flow\" are generated (e.g. demand of all conventional loads is by default set to maximum demand and feed-in of all generators is set to zero)\n",
"\n",
"\n",
"* **[’feed-in_case’, ’load_case’]**\n",
"\n",
" Both cases are set up.\n",
" \n",
"By default both cases are set up.\n",
"\n",
"Feed-in and demand in the two worst-cases are defined in the [config file 'config_timeseries.cfg'](https://edisgo.readthedocs.io/en/dev/reference/configs.html#config-timeseries) and can be changed by setting different values in the config file. \n",
"\n",
"Instead of doing a worst-case analysis you can also provide your own timeseries for demand and feed-in and use those in the power flow analysis. EDisGo also offers methods to generate load and feed-in time series. Check out the [documentation on options on how to set up time series](https://edisgo.readthedocs.io/en/dev/userguide/time_series.html) and examples in the [getting started documentation section](https://edisgo.readthedocs.io/en/dev/quickstart.html#the-five-minute-example) for more information."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cases = [\"load_case\", \"feed-in_case\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we are ready to initialize the edisgo object and set up worst case time series."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo = EDisGo(ding0_grid=ding0_grid)\n",
"\n",
"edisgo.set_time_series_worst_case_analysis(cases=cases)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## eDisGo data structure \n",
"\n",
"As stated above, the EDisGo class serves as the top-level API and provides access to all relevant data. It also enables plotting of the grid topology. In order to have a look at the MV grid topology, you can use the following plot."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo.plot_mv_grid_topology(technologies=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here, red nodes stand for the substation's secondary side, light blue nodes for distribution substation's primary sides, green nodes for nodes fluctuating generators are connected to, grey nodes for disconnecting points and dark blue nodes show branch tees.\n",
"Underlying LV grids are not yet georeferenced in ding0, wherefore a plotting for LV grids analog to the one shown above is not provided. A different possibility to get a graphical representation of LV grids is shown later in this example. Let's first get into eDisGo's data structure.\n",
"\n",
"Grid data is stored in the [Topology](https://edisgo.readthedocs.io/en/dev/autoapi/edisgo/network/topology/Topology.html) class.\n",
"Time series data can be found in the [TimeSeries](https://edisgo.readthedocs.io/en/dev/autoapi/edisgo/network/timeseries/TimeSeries.html) class. Results data holding results e.g. from the power flow analysis and grid expansion is stored in the [Results](https://edisgo.readthedocs.io/en/dev/autoapi/edisgo/network/results/Results.html) class.\n",
"Configuration data from the config files (see [default_configs](https://edisgo.readthedocs.io/en/dev/reference/configs.html#configuration-data)) is stored\n",
"in the [Config](https://edisgo.readthedocs.io/en/dev/autoapi/edisgo/tools/config/Config.html) class.\n",
"All these can be accessed as follows:\n",
"\n",
"```python\n",
"edisgo.topology\n",
"edisgo.timeseries\n",
"edisgo.results\n",
"edisgo.config\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The grid data in the Topology object is stored in pandas DataFrames.\n",
"There are extra data frames for all grid elements (buses, lines, switches, transformers), as well as generators, loads and storage units.\n",
"You can access those dataframes as follows:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Access all buses in MV grid and underlying LV grids\n",
"# .head() enables only viewing the first entries of the dataframe\n",
"edisgo.topology.buses_df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Access all lines in MV grid and underlying LV grids\n",
"edisgo.topology.mv_grid.lines_df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Access all generators in MV grid and underlying LV grids\n",
"edisgo.topology.generators_df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The grids can also be accessed individually. The MV grid is stored in an [MVGrid](https://edisgo.readthedocs.io/en/dev/autoapi/edisgo/network/grids/MVGrid.html) object and each LV grid in an\n",
"[LVGrid](https://edisgo.readthedocs.io/en/dev/autoapi/edisgo/network/grids/LVGrid.html) object.\n",
"The MV grid topology can be accessed through:\n",
"\n",
"```python\n",
"edisgo.topology.mv_grid\n",
"```\n",
"\n",
"Its components can be accessed analog to those of the whole grid topology as shown above."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Access all buses in MV grid\n",
"edisgo.topology.mv_grid.buses_df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Access all generators in MV grid\n",
"edisgo.topology.mv_grid.generators_df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A list of all LV grids can be retrieved through:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get list of all underlying LV grids\n",
"# (Note that MVGrid.lv_grids returns a generator object that must first be\n",
"# converted to a list in order to view the LVGrid objects)\n",
"list(edisgo.topology.mv_grid.lv_grids) # list(edisgo.topology.lv_grids) yields the same"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Access to a single LV grid's components can be obtained analog to shown above for\n",
"the whole topology and the MV grid:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get single LV grid by providing its name or ID\n",
"lv_grid = edisgo.topology.get_lv_grid(\n",
" \"LVGrid_170173\"\n",
") # edisgo.topology.get_lv_grid(170173) yields the same"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Access all buses in that LV grid\n",
"lv_grid.buses_df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Access all loads in that LV grid\n",
"lv_grid.loads_df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A single grid's generators, loads, storage units and switches can also be\n",
"retrieved as [Generator](https://edisgo.readthedocs.io/en/features-refactoring/api/edisgo.network.html#edisgo.network.components.Generator) object,\n",
"[Load](https://edisgo.readthedocs.io/en/features-refactoring/api/edisgo.network.html#edisgo.network.components.Load) object, [Storage](https://edisgo.readthedocs.io/en/features-refactoring/api/edisgo.network.html#edisgo.network.components.Storage) object, and\n",
"[Switch](https://edisgo.readthedocs.io/en/features-refactoring/api/edisgo.network.html#edisgo.network.components.Switch) objects, respecitvely:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get all switch disconnectors in MV grid as Switch objects\n",
"# (Note that objects are returned as a python generator object that must\n",
"# first be converted to a list in order to view the Load objects)\n",
"list(edisgo.topology.mv_grid.switch_disconnectors)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Have a look at the state (open or closed) of one of the switch disconnectors\n",
"switch = list(edisgo.topology.mv_grid.switch_disconnectors)[0]\n",
"switch.state"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get all loads in LV grid as Load objects\n",
"list(lv_grid.loads)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Have a look at the load time series of one of the loads\n",
"load = list(lv_grid.loads)[0]\n",
"load.active_power_timeseries"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For some applications it is helpful to get a graph representation of the grid,\n",
"e.g. to find the path from the station to a generator. The graph representation\n",
"of the whole topology or each single grid can be retrieved as follows:\n",
"\n",
"```python\n",
"\n",
"# Get graph representation of whole topology\n",
"edisgo.to_graph()\n",
"\n",
"# Get graph representation for MV grid\n",
"edisgo.topology.mv_grid.graph\n",
"\n",
"# Get graph representation for LV grid\n",
"lv_grid.graph\n",
"```\n",
"\n",
"The returned graph is :networkx:`networkx.Graph`, where lines are represented\n",
"by edges in the graph, and buses and transformers are represented by nodes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo.to_graph()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In case of the LV grids, the graph can be used to get a rudimentary graphical representation:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# draw graph of one of the LV grids\n",
"lv_grid = list(edisgo.topology.mv_grid.lv_grids)[5]\n",
"nx.draw(lv_grid.graph)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Future generator scenario \n",
"\n",
"eDisGo was originally developed in the [open_eGo](https://openegoproject.wordpress.com/) research project. In the open_eGo project two future scenarios, the 'NEP 2035' and the 'ego 100' scenario, were developed. The 'NEP 2035' scenario closely follows the B2-Scenario 2035 from the German network developement plan (Netzentwicklungsplan NEP) 2015. The share of renewables is 65.8%, electricity demand is assumed to stay the same as in the status quo. The 'ego 100' scenario is based on the e-Highway 2050 scenario and assumes a share of renewables of 100% and again an equal electricity demand as in the status quo.\n",
"\n",
"As mentioned earlier, ding0 grids represent status quo networks with status quo generator capacities (base year is the year 2015). In order to analyse future scenarios future generators have to be imported into the network."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get installed capacity in Status Quo\n",
"edisgo.topology.generators_df.p_nom.sum()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Import generators\n",
"scenario = \"nep2035\"\n",
"edisgo.import_generators(generator_scenario=scenario)\n",
"edisgo.set_time_series_worst_case_analysis()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get installed capacity in NEP 2035 scenario\n",
"edisgo.topology.generators_df.p_nom.sum()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's have a look at the MV grid topology in the NEP 2035 scenario:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo.plot_mv_grid_topology(technologies=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Grid reinforcement \n",
"\n",
"Now we can calculate grid expansion costs that arise from the integration of the new generators.\n",
"\n",
"The grid expansion methodology is based on the distribution grid study of dena [1] and Baden-Wuerttemberg [2] (see [References](#References)). The order grid expansion measures are conducted is as follows:\n",
"\n",
"* Reinforce transformers and lines due to overloading issues\n",
"* Reinforce lines in MV grid due to voltage issues\n",
"* Reinforce distribution substations due to voltage issues\n",
"* Reinforce lines in LV grid due to voltage issues\n",
"* Reinforce transformers and lines due to overloading issues\n",
"\n",
"Reinforcement of transformers and lines due to overloading issues is performed twice, once in the beginning and again after fixing voltage problems, as the changed power flows after reinforcing the grid may lead to new overloading issues. (For further explanation see the [documentation](https://edisgo.readthedocs.io/en/dev/methodology/grid_reinforcement.html#grid-reinforcement).)\n",
"\n",
"After each reinforcement step a non-linear power flow analyses is conducted using PyPSA. Let's do a power flow analysis before the reinforcement to see how many over-loading and voltage issues there are."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Do non-linear power flow analysis with PyPSA\n",
"edisgo.analyze()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# feed-in case\n",
"edisgo.plot_mv_line_loading(\n",
" node_color=\"voltage_deviation\",\n",
" timestep=edisgo.timeseries.timeindex_worst_cases[\"feed-in_case_mv\"],\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# load case\n",
"edisgo.plot_mv_line_loading(\n",
" node_color=\"voltage_deviation\",\n",
" timestep=edisgo.timeseries.timeindex_worst_cases[\"load_case_mv\"],\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's check voltages and line loadings before the reinforcement."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo.histogram_voltage(binwidth=0.005)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo.histogram_relative_line_load(binwidth=0.2, voltage_level=\"mv\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Reinforcement is invoked by calling `edisgo.reinforce()`. To make this example faster we will only conduct grid reinforcement for the MV and MV-LV stations, which is defined by the parameter `mode`. To conduct reinforcement for all voltage levels (MV, MV-LV and LV) set parameter `mode` to None.\n",
"With the parameter `without_generator_import` it can be specified if costs arising from connecting new generators to the grid should be included in the calculation of grid reinforcement costs or not."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Do grid reinforcement\n",
"edisgo.reinforce(mode=\"mvlv\", without_generator_import=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's check voltages and line loadings again:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# load and feed-in case\n",
"edisgo.plot_mv_line_loading(node_color=\"voltage_deviation\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo.histogram_voltage(binwidth=0.005)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo.histogram_relative_line_load(binwidth=0.2, voltage_level=\"mv\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Evaluate results \n",
"\n",
"Results such as voltages at nodes and line loading from the power flow analysis as well as\n",
"grid expansion costs are provided through the [Results](https://edisgo.readthedocs.io/en/dev/autoapi/edisgo/network/results/Results.html) class. Above it was already shown how to access \n",
"the results:\n",
"\n",
"```python\n",
"edisgo.results\n",
"```\n",
"\n",
"Get voltages at nodes through `v_res` attribute and line loading through `s_res` or `i_res` attribute.\n",
"The `equipment_changes` attribute holds details about measures performed during grid expansion. Associated costs can be obtained through the `grid_expansion_costs` attribute."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get voltages at nodes from last power flow analysis\n",
"edisgo.results.v_res"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# View reinforced equipment\n",
"edisgo.results.equipment_changes.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get costs in kEUR for reinforcement per equipment\n",
"costs = edisgo.results.grid_expansion_costs\n",
"costs.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Group costs by voltage level\n",
"costs_grouped_nep = costs.groupby([\"voltage_level\"]).sum()\n",
"costs_grouped_nep.loc[:, [\"total_costs\"]]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"An overview of the assumptions used to calculate grid expansion costs can be found in the [documentation]( https://edisgo.readthedocs.io/en/dev/methodology/grid_reinforcement.html#grid-expansion-costs).\n",
"\n",
"You can also view grid expansion costs for equipment in the MV using the following plot:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edisgo.plot_mv_grid_expansion_costs()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Results can be saved to csv files with:\n",
"\n",
"```python\n",
"edisgo.results.save('path/to/results/directory/')\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let's compare the grid expansion costs for the 'NEP 2035' scenario with grid expansion costs for the 'ego 100' scenario. Therefore, we first have to setup the new scenario and calculate grid expansion costs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# initialize new EDisGo object with 'ego 100' scenario\n",
"edisgo_ego100 = EDisGo(\n",
" ding0_grid=ding0_grid,\n",
" generator_scenario=\"ego100\",\n",
")\n",
"edisgo_ego100.set_time_series_worst_case_analysis()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# conduct grid reinforcement\n",
"edisgo_ego100.reinforce(mode=\"mvlv\", without_generator_import=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# get grouped costs\n",
"costs_grouped_ego100 = edisgo_ego100.results.grid_expansion_costs.groupby(\n",
" [\"voltage_level\"]\n",
").sum()\n",
"costs_grouped_ego100.loc[:, [\"total_costs\"]]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# compare expansion costs for both scenarios in a plot\n",
"# set up dataframe to plot\n",
"costs_df = (\n",
" costs_grouped_nep.loc[:, [\"total_costs\"]]\n",
" .join(\n",
" costs_grouped_ego100.loc[:, [\"total_costs\"]],\n",
" rsuffix=\"_ego100\",\n",
" lsuffix=\"_nep2035\",\n",
" )\n",
" .rename(columns={\"total_costs_ego100\": \"ego100\", \"total_costs_nep2035\": \"NEP2035\"})\n",
" .T\n",
")\n",
"# plot\n",
"costs_df.plot(kind=\"bar\", stacked=True)\n",
"plt.xticks(rotation=0)\n",
"plt.ylabel(\"Grid reinforcement costs in k€\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## References \n",
"\n",
"[1] A.C. Agricola et al.: dena-Verteilnetzstudie: Ausbau- und Innovationsbedarf der Stromverteilnetze in Deutschland bis 2030. 2012.\n",
"\n",
"[2] C. Rehtanz et al.: Verteilnetzstudie für das Land Baden-Württemberg, ef.Ruhr GmbH, 2017."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.13"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}