#!/usr/bin/env python # coding: utf-8 # HSF # # # #
Abschlussworkshop open_eGo 2018
# # ##
Session eTraGo - Optimaler Netz- und Speicherausbau auf Hoch- und Höchstspannungsebene
# # # # Agenda # # # * [Wichtige Links](#links) # * [Installation](#install) # * [Allgemeine Vorgehensweise](#allgemein) # * Mögliche Fragestellungen # * [Optimaler Speicherausbau](#speicher) # * [Optimaler Netz- und Speicherausbau](#netz_speicher) # * [Bewertung der NEP-Maßnahmen](#nep) # # Wichtige Links # # * __[eTraGo Source Code](https://github.com/openego/eTraGo)__ # * __[eTraGo Documentation](http://etrago.readthedocs.io/)__ # # # Installation # Zur Verwendung dieses Notebooks wird die aktuelle eTraGo Version sowie das python package jupyter benötigt. Installiere diese mit # # `pip3 install eTraGo --process-dependency-links` # # `pip3 install jupyter` # # Allgemeine Vorgehensweise # # 1. Parameter-Einstellungen (args) in appl.py vornehmen. # (evtl. darüber hinaus default-Annahmen in untergelagerten Funktionsaufrufen anpassen) # 2. appl.py bzw. etrago(args) ausführen. # 3. Ergebnisse auswerten. # 4. evtl als csv oder in der oedb speichern. # # # # Optimaler Speicherausbau im NEP 2035 Szenario # # # ## Fragestellung # # 1. An welchen Netzknoten entstehen in Zukunft welche Speicherbedarfe? (zentrale vs. dezentrale Lösungen) # 2. Welches Einsatzverhalten weisen diese optimierten Speicher auf? (Langzeit- vs. Kurzzeitspeicher) # In[1]: # enable jupyter interactive plotting get_ipython().run_line_magic('matplotlib', 'notebook') from ipywidgets import * # ### Importieren der benötigten allgemeinen und eTraGo spezifischen python Packete # In[2]: import datetime import os import os.path import time import numpy as np import pandas as pd if 'READTHEDOCS' not in os.environ: # Sphinx does not run this code. # Do not import internal packages directly from etrago.cluster.disaggregation import ( MiniSolverDisaggregation, UniformDisaggregation) from etrago.cluster.networkclustering import ( busmap_from_psql, cluster_on_extra_high_voltage, kmean_clustering) from etrago.tools.io import ( NetworkScenario, results_to_oedb, extension, decommissioning) from etrago.tools.plot import ( plot_line_loading, plot_stacked_gen, add_coordinates, curtailment, gen_dist, storage_distribution, storage_expansion, nodal_gen_dispatch, network_expansion) from etrago.tools.utilities import ( load_shedding, data_manipulation_sh, convert_capital_costs, results_to_csv, parallelisation, pf_post_lopf, loading_minimization, calc_line_losses, group_parallel_lines, add_missing_components, distribute_q, set_q_foreign_loads, clip_foreign, foreign_links, crossborder_capacity, ramp_limits, geolocation_buses, get_args_setting, set_branch_capacity) from etrago.tools.extendable import extendable, extension_preselection from etrago.cluster.snapshot import snapshot_clustering, daily_bounds from egoio.tools import db from sqlalchemy.orm import sessionmaker import oedialect from etrago.appl import etrago # ### Parameter-Einstellungen (args) in appl.py vornehmen # # Für diesen Fall sollen die Netzkapazitäten keine Variable sein. Neben der dispatch-Optimierung soll ausschließlich Speicherausbau optimiert werden. Hierzu wird die array Variable 'extendable': ['storage'] gesetzt. # In[3]: args = { # Setup and Configuration: 'db': 'local', # database session 'gridversion': 'v0.4.5', # None for model_draft or Version number 'method': 'lopf', # lopf or pf 'pf_post_lopf': False, # perform a pf after a lopf simulation 'start_snapshot': 48, 'end_snapshot': 52, 'solver': 'gurobi', # glpk, cplex or gurobi 'solver_options': {}, # {} for default or dict of solver options 'scn_name': 'NEP 2035', # a scenario: Status Quo, NEP 2035, eGo 100 # Scenario variations: 'scn_extension': None, # None or array of extension scenarios 'scn_decommissioning': None, # None or decommissioning scenario # Export options: 'lpfile': False, # save pyomo's lp file: False or /path/tofolder 'csv_export': './results', # save results as csv: False or /path/tofolder 'db_export': False, # export the results back to the oedb # Settings: 'extendable': ['storage'], # Array of components to optimize 'generator_noise': 789456, # apply generator noise, False or seed number 'minimize_loading': False, 'ramp_limits': False, # Choose if using ramp limit of generators 'extra_functionality': None, # Choose function name or None # Clustering: 'network_clustering_kmeans': 500, # False or the value k for clustering 'load_cluster': "load_cluster_nep_500", # False or predefined busmap for k-means 'network_clustering_ehv': False, # clustering of HV buses to EHV buses. 'disaggregation': None, # or None, 'mini' or 'uniform' 'snapshot_clustering': False, # False or the number of 'periods' # Simplifications: 'parallelisation': False, # run snapshots parallely. 'skip_snapshots': False, 'line_grouping': False, # group lines parallel lines 'branch_capacity_factor': {'HV': 0.5, 'eHV' : 0.7}, # factors to change branch capacities 'load_shedding': False, # meet the demand at very high cost 'foreign_lines' : {'carrier': 'AC', 'capacity': 'osmTGmod'}, # dict containing carrier and capacity settings of foreign lines 'comments': None} # ### Starten der Rechnung # # Hierzu muss die appl.py bzw. die Funktion etrago(args) ausgeführt werden. Die Ergebnisse werden in Form eines PyPSA container (pandas) zur Verfügung gestellt. # In[4]: network, disagg_network = etrago(args) # ### Auswertung # # Insbesondere die Plotting-Funktionen in etrago.tools.plot können für die Analyse der Ergebnisse verwendet werden. # In[5]: # Speicherausbau je Technologie und Knoten storage_expansion(network, scaling=1) # # # Optimaler Netz- und Speicherausbau # # # ## Fragestellung # # Welche Kombination aus Netz- und Speicherausbau ist ökonmisch sinnvoll und technisch machbar? # # ## args Einstellungen vornehmen # # 1. Zeitraum einstellen: 'start_snapshot': 48, 'end_snapshot': 72 # 2. Szenario einstellen: 'scn_name': 'eGo 100' # 3. Netzausbau aktivieren und Speicherausbau im Ausland als Variable setzen: 'extendable': ['network', 'storage', 'foreign_storage'] # # In[8]: args_gs = { # Setup and Configuration: 'db': 'local', # database session 'gridversion': 'v0.4.5', # None for model_draft or Version number 'method': 'lopf', # lopf or pf 'pf_post_lopf': False, # perform a pf after a lopf simulation 'start_snapshot': 48, 'end_snapshot': 72, 'solver': 'gurobi', # glpk, cplex or gurobi 'solver_options': {}, # {} for default or dict of solver options 'scn_name': 'eGo 100', # a scenario: Status Quo, NEP 2035, eGo 100 # Scenario variations: 'scn_extension': None, # None or array of extension scenarios 'scn_decommissioning': None, # None or decommissioning scenario # Export options: 'lpfile': False, # save pyomo's lp file: False or /path/tofolder 'csv_export': './results', # save results as csv: False or /path/tofolder 'db_export': False, # export the results back to the oedb # Settings: 'extendable': ['network', 'storage', 'foreign_storage'], # Array of components to optimize 'generator_noise': 789456, # apply generator noise, False or seed number 'minimize_loading': False, 'ramp_limits': False, # Choose if using ramp limit of generators 'extra_functionality': None, # Choose function name or None # Clustering: 'network_clustering_kmeans': 50, # False or the value k for clustering 'load_cluster': False, # False or predefined busmap for k-means 'network_clustering_ehv': False, # clustering of HV buses to EHV buses. 'disaggregation': None, # or None, 'mini' or 'uniform' 'snapshot_clustering': False, # False or the number of 'periods' # Simplifications: 'parallelisation': False, # run snapshots parallely. 'skip_snapshots': False, 'line_grouping': False, # group lines parallel lines 'branch_capacity_factor': {'HV': 0.5, 'eHV' : 0.7}, # factors to change branch capacities 'load_shedding': False, # meet the demand at very high cost 'foreign_lines' : {'carrier': 'AC', 'capacity': 'osmTGmod'}, # dict containing carrier and capacity settings of foreign lines 'comments': None} # ### Starten der Rechnung # In[9]: network, disagg_network = etrago(args_gs) # In[10]: # Netzausbau je Leitung relativ zur ursprünglich installierten Leistung # maximal-möglicher Leitungsausbau je Leitung beträgt vier Mal der ursprünglich installierten Leistung network_expansion(network, ext_width=80) # In[11]: # Speicherausbau je Technologie und Knoten storage_expansion(network, scaling=100) # # Bewertung von NEP Maßnahmen # # ## Fragestellung # # ### Wie werden die Maßnahmen des NEP 2035 B2 in eTraGo bewertet? # # # ## Daraus resultierende Einstellungen # # - Auswahl von Szenario NEP 2035 # - geplante Leitungen nach dem NEP 2035 B2 hinzufügen # - Rückbau aus dem Bestandsnetz nach dem NEP 2035 B2 # - technisch-wirtschaftliche Optimierung der geplanten Leitungen # In[15]: args_nep = { # Setup and Configuration: 'db': 'oedb', # database session 'gridversion': None, # None for model_draft or Version number 'method': 'lopf', # lopf or pf 'pf_post_lopf': False, # perform a pf after a lopf simulation 'start_snapshot': 48, 'end_snapshot': 72, 'solver': 'gurobi', # glpk, cplex or gurobi 'solver_options': {'BarConvTol': 1.e-5, 'FeasibilityTol': 1.e-5, 'method':2, 'crossover':0, 'logFile': 'solver.log'}, # {} for default options 'scn_name': 'NEP 2035', # a scenario: Status Quo, NEP 2035, eGo 100 # Scenario variations: 'scn_extension': ['nep2035_b2', 'BE_NO_NEP 2035'], # None or array of extension scenarios 'scn_decommissioning': 'nep2035_b2', # None or decommissioning scenario # Export options: 'lpfile': False, # save pyomo's lp file: False or /path/tofolder 'csv_export': False, # save results as csv: False or /path/tofolder 'db_export': False, # export the results back to the oedb # Settings: 'extendable': ['overlay_network'], # Array of components to optimize 'generator_noise': 789456, # apply generator noise, False or seed number 'minimize_loading': False, 'ramp_limits': False, # Choose if using ramp limit of generators 'extra_functionality': None, # Choose function name or None # Clustering: 'network_clustering_kmeans': 500, # False or the value k for clustering 'load_cluster': 'load_cluster_nep_ext_500', # False or predefined busmap for k-means 'network_clustering_ehv': False, # clustering of HV buses to EHV buses. 'disaggregation': None, # None, 'mini' or 'uniform' 'snapshot_clustering': False, # False or the number of 'periods' # Simplifications: 'parallelisation': False, # run snapshots parallely. 'skip_snapshots': False, 'line_grouping': False, # group lines parallel lines 'branch_capacity_factor': {'HV': 0.5, 'eHV': 0.7}, # p.u. branch derating 'load_shedding': True, # meet the demand at value of loss load cost 'foreign_lines': {'carrier': 'AC', 'capacity': 'osmTGmod'}, 'comments': None} # ### Ausführen der Berechnung # In[16]: # Start eTraGo calculation with args setting # create network object which incluedes all input and output data network, disagg_network = etrago(args_nep) # ### Berechnung des absoluten Netzausbaus # In[17]: (network.lines.s_nom_opt - network.lines.s_nom_min)[network.lines.s_nom_extendable].sum()\ + (network.links.p_nom_opt - network.links.p_nom_min)[network.links.p_nom_extendable].sum() # ### Darstellung des Ausbaus der geplanten Leitungen # In[18]: network_expansion(network, ext_min = 0) # In[ ]: