etrago.tools package¶
etrago.tools.constraints module¶
Constraints.py includes additional constraints for eTraGo-optimizations
- etrago.tools.constraints.read_max_gas_generation(self)[source]¶
Return the values limiting the gas production in Germany
Read max_gas_generation_overtheyear from scenario.egon_scenario_parameters if the table is available in the database and return the dictionnary containing the values needed for the constraints to limit the gas production in Germany, depending of the scenario.
- Returns:
arg
- Return type:
- etrago.tools.constraints.add_ch4_constraints_linopy(self, network, snapshots)[source]¶
Add CH4 constraints for optimization with linopy
Functionality that limits the dispatch of CH4 generators. In Germany, there is one limitation specific for biogas and one limitation specific for natural gas (natural gas only in eGon2035). Abroad, each generator has its own limitation contains in the column e_nom_max.
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization
- Return type:
None.
- etrago.tools.constraints.add_ch4_constraints(self, network, snapshots)[source]¶
Add CH4 constraints for optimization with pyomo
Functionality that limits the dispatch of CH4 generators. In Germany, there is one limitation specific for biogas and one limitation specific for natural gas (natural gas only in eGon2035). Abroad, each generator has its own limitation contains in the column e_nom_max.
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization
- Return type:
None.
- etrago.tools.constraints.add_ch4_constraints_nmp(self, network, snapshots)[source]¶
Add CH4 constraints for optimization without pyomo
Functionality that limits the dispatch of CH4 generators. In Germany, there is one limitation specific for biogas and one limitation specific for natural gas (natural gas only in eGon2035). Abroad, each generator has its own limitation contains in the column e_nom_max.
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization
- Return type:
None.
- etrago.tools.constraints.snapshot_clustering_daily_bounds(self, network, snapshots)[source]¶
Bound the storage level to 0.5 max_level every 24th hour.
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (pandas.DatetimeIndex) – List of timesteps that will be constrained
- Return type:
None
- etrago.tools.constraints.snapshot_clustering_daily_bounds_nmp(self, network, snapshots)[source]¶
Bound the storage level to 0.5 max_level every 24th hour.
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (pandas.DatetimeIndex) – List of timesteps that will be constrained
- Return type:
None
- etrago.tools.constraints.snapshot_clustering_seasonal_storage(self, network, snapshots, simplified=False)[source]¶
Depicts intertemporal dependencies of storage units and stores when using snapshot clustering to typical periods for temporal complexity reduction.
- According to:
L. Kotzur et al: ‘Time series aggregation for energy system design: Modeling seasonal storage’, 2018
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (list) – A list of datetime objects representing the timestamps of the snapshots to be clustered.
simplified (bool, optional) – A flag indicating whether to use a simplified version of the model that does not include intra-temporal constraints and variables.
- Return type:
None
- etrago.tools.constraints.snapshot_clustering_seasonal_storage_hourly(self, network, snapshots)[source]¶
Depicts intertemporal dependencies of storage units and stores when using snapshot clustering to typical periods for temporal complexity reduction.
- According to:
L. Kotzur et al: ‘Time series aggregation for energy system design: Modeling seasonal storage’, 2018
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (list) – A list of datetime objects representing the timestamps of the snapshots to be clustered.
- Return type:
None
- etrago.tools.constraints.snapshot_clustering_seasonal_storage_nmp(self, n, sns, simplified=False)[source]¶
Depicts intertemporal dependencies of storage units and stores when using snapshot clustering to typical periods for temporal complexity reduction.
- According to:
L. Kotzur et al: ‘Time series aggregation for energy system design: Modeling seasonal storage’, 2018
- Parameters:
n (
pypsa.Network) – Overall container of PyPSAsns (list) – A list of datetime objects representing the timestamps of the snapshots to be clustered.
simplified (bool, optional) – A flag indicating whether to use a simplified version of the model that does not include intra-temporal constraints and variables.
- Return type:
None
- etrago.tools.constraints.snapshot_clustering_seasonal_storage_hourly_nmp(self, n, sns)[source]¶
Depicts intertemporal dependencies of storage units and stores when using snapshot clustering to typical periods for temporal complexity reduction.
- According to:
L. Kotzur et al: ‘Time series aggregation for energy system design: Modeling seasonal storage’, 2018
- Parameters:
n (
pypsa.Network) – Overall container of PyPSAsns (list) – A list of datetime objects representing the timestamps of the snapshots to be clustered.
- Return type:
None
- etrago.tools.constraints.split_dispatch_disaggregation_constraints(self, n, sns)[source]¶
Add constraints for state of charge of storage units and stores when separating the optimization into smaller subproblems while conducting thedispatch_disaggregation in temporally fully resolved network
The state of charge at the end of each slice is set to the value calculated in the optimization with the temporally reduced network to account to ensure compatibility and to reproduce saisonality
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization
- Return type:
None.
- etrago.tools.constraints.fixed_storage_unit_soc_at_the_end(n, sns)[source]¶
Defines energy balance constraints for storage units. In principal the constraints states:
previous_soc + p_store - p_dispatch + inflow - spill == soc
- etrago.tools.constraints.fixed_storage_unit_soc_at_horizon_end(self, n, sns)[source]¶
Sets soc of seasonal storage units (reservoir) at the end of each horizon to the one from the pre market model allowing a small flexibility
1.01 * soc_pre_market >= soc_market >= 0.99 * soc_pre_market
- class etrago.tools.constraints.Constraints(args, conduct_dispatch_disaggregation, apply_on='grid_model', cluster_temporal=None, cluster_ts=None)[source]¶
Bases:
objectMethods
functionality(network, snapshots)Add constraints to pypsa-model using extra-functionality.
- functionality(network, snapshots)[source]¶
Add constraints to pypsa-model using extra-functionality. Serveral constraints can be choosen at once. Possible constraints are set and described in the above functions.
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAsnapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization
- etrago.tools.constraints.add_chp_constraints_nmp(n)[source]¶
Limits the dispatch of combined heat and power links based on T.Brown et. al : Synergies of sector coupling and transmission reinforcement in a cost-optimised, highly renewable European energy system, 2018
- Parameters:
n (pypsa.Network) – Network container
- Return type:
None.
- etrago.tools.constraints.add_chp_constraints(network, snapshots)[source]¶
Limits the dispatch of combined heat and power links based on T.Brown et. al : Synergies of sector coupling and transmission reinforcement in a cost-optimised, highly renewable European energy system, 2018
- Parameters:
network (pypsa.Network) – Network container
snapshots (pandas.DataFrame) – Timesteps to optimize
- Return type:
None.
- etrago.tools.constraints.add_chp_constraints_linopy(network, snapshots)[source]¶
Limits the dispatch of combined heat and power links based on T.Brown et. al : Synergies of sector coupling and transmission reinforcement in a cost-optimised, highly renewable European energy system, 2018
- Parameters:
network (pypsa.Network) – Network container
snapshots (pandas.DataFrame) – Timesteps to optimize
- Return type:
None.
- etrago.tools.constraints.couple_distribution_links(self, n, snapshots)[source]¶
Couple bidirectional distribution grid links such that capacity expansion is identical in both directions.
This ensures that any additional capacity built between transmission and distribution grids is shared physically, i.e. an expansion of e.g. 10 MW applies to both flow directions equally.
The function automatically detects whether the optimization backend is Pyomo or Linopy based on:
self.args[“method”] ∈ {“pyomo”, “linopy”}
- Parameters:
n (pypsa.Network) – The PyPSA network instance.
snapshots (pandas.Index) – Snapshots passed by PyPSA during optimization. (Not used directly but required by the interface.)
Notes
Existing capacities (p_nom) are NOT coupled. Only expansion variables are linked.
Investment costs should only be assigned to one direction of each link pair to avoid double counting.
Link pairs are identified via naming convention:
{bus}_to_distribution_grid {bus}_from_distribution_grid
Only links with carrier == “distribution_grid” are considered.
- Raises:
ValueError – If an unknown optimization method is specified.
etrago.tools.distribution_grids module¶
Defines function to seperate transmission grid from distribution grid in eTraGo
- etrago.tools.distribution_grids.get_ac_nodes_germany(self)[source]¶
Filters AC buses within Germany
- Returns:
Indices of AC buses within Germany.
- Return type:
pd.Series
- etrago.tools.distribution_grids.distribution_grid_buses_and_links(self, mv_grids, seperate_dg_link=True)[source]¶
Adds buses and links modeling simplified distribution grids. The parametrization is derived from bottom-up simulations of distribution grids with eDisGo/eGo.
- Parameters:
mv_grids (pd.DataFrame) – Medium voltage grid districts.
seperate_dg_link (boolean, optional) – Select if distribution grids are modeled as one bi-directional link or as two coupled uni-directional link. The default is True.
- Return type:
None.
- etrago.tools.distribution_grids.seperate_power_plants(self, egon_power_plants, old_network)[source]¶
Divides power plants by grid level (transmission or distribution grid) and connects them to the corresponding bus.
- Parameters:
egon_power_plants (sqlalchemy.ext.declarative.api.DeclarativeMeta) – Pointer to table containing non-aggregated power plants.
old_network (pypsa.Network) – Previous network without adjustments.
- Return type:
None.
- etrago.tools.distribution_grids.seperate_chp(self, egon_chp_plants, egon_district_heating_areas)[source]¶
Divides CHP plants by grid level (transmission or distribution grid) and connects them to the corresponding bus.
- Parameters:
egon_chp_plants (sqlalchemy.ext.declarative.api.DeclarativeMeta) – Pointer to table containing non-aggregated CHP plants.
egon_district_heating_areas (sqlalchemy.ext.declarative.api.DeclarativeMeta) – Pointer to table containing district heating areas.
- Return type:
None
- etrago.tools.distribution_grids.seperate_demands(self, mv_grids, egon_osm_ind_load_curves_individual, egon_sites_ind_load_curves_individual)[source]¶
Divides electrical loads by grid level (transmission or distribution grid) and connects them to the corresponding bus.
- Parameters:
mv_grids (pd.DataFrame) – Medium voltage grid districts.
egon_osm_ind_load_curves_individual – sqlalchemy.ext.declarative.api.DeclarativeMeta Pointer to table containing industrial load curves at OSM areas.
egon_sites_ind_load_curves_individual – sqlalchemy.ext.declarative.api.DeclarativeMeta Pointer to table containing industrial load curves at points.
- Return type:
None.
- etrago.tools.distribution_grids.seperate_storage_units(self, mv_grids)[source]¶
Divides storage units by grid level (transmission or distribution grid) and connects them to the corresponding bus.
- Parameters:
mv_grids (pd.DataFrame) – Medium voltage grid districts.
- Return type:
None.
- etrago.tools.distribution_grids.add_simplified_distribution_grids(self)[source]¶
Adds simplified distrubution grids to each HV/MV substation in the transmission grid model. Load, generation and storage units are connected to the corresponding grid level based on not-aggregated egon-data results.
- Return type:
None.
etrago.tools.extendable module¶
Extendable.py defines function to set PyPSA components extendable.
- etrago.tools.extendable.extendable(self, grid_max_D=None, grid_max_abs_D={'110': {'circuits': 2, 'i': 1020, 'wires': 4}, '220': {'circuits': 4, 'i': 1020, 'wires': 4}, '380': {'circuits': 4, 'i': 1020, 'wires': 4}, 'dc': 0}, grid_max_foreign=4, grid_max_abs_foreign=None)[source]¶
Function that sets selected components extendable.
- Parameters:
grid_max_D (int, optional) – Upper bounds for electrical grid expansion relative to existing capacity. The default is None.
grid_max_abs_D (dict, optional) – Absolute upper bounds for electrical grid expansion in Germany.
grid_max_foreign (int, optional) – Upper bounds for expansion of electrical foreign lines relative to the existing capacity. The default is 4.
grid_max_abs_foreign (dict, optional) – Absolute upper bounds for expansion of foreign electrical grid. The default is None.
- Return type:
None.
- etrago.tools.extendable.snommax(i=1020, u=380, wires=4, circuits=4)[source]¶
Function to calculate limitation for capacity expansion.
- Parameters:
- Returns:
s_nom_max – Limitation for capacity expansion.
- Return type:
- etrago.tools.extendable.line_max_abs(network, buses, line_max_abs={'110': {'circuits': 2, 'i': 1020, 'wires': 4}, '220': {'circuits': 4, 'i': 1020, 'wires': 4}, '380': {'circuits': 4, 'i': 1020, 'wires': 4}, 'dc': 0})[source]¶
Function to calculate limitation for capacity expansion of lines in network.
- Parameters:
network (pypsa.Network object) – Container for all network components.
buses (pypsa.Network buses) – Considered buses in network.
line_max_abs (dict, optional) – Line parameters considered to calculate maximum capacity.
- Return type:
None.
- etrago.tools.extendable.transformer_max_abs(network, buses)[source]¶
Function to calculate limitation for capacity expansion of transformers in network.
- Parameters:
network (pypsa.Network object) – Container for all network components.
buses (pypsa.Network buses) – Considered buses in network.
- Return type:
None.
- etrago.tools.extendable.extension_preselection(etrago, method, days=3)[source]¶
Function that preselects lines which are extendend in snapshots leading to overloading to reduce nubmer of extension variables.
- Parameters:
network (pypsa.Network object) – Container for all network components.
args (dict) – Arguments set in appl.py.
method (str) – Choose method of selection: ‘extreme_situations’ for remarkable timsteps (e.g. minimal resiudual load) ‘snapshot_clustering’ for snapshot clustering with number of days
days (int) – Number of clustered days, only used when method = ‘snapshot_clustering’
- Returns:
network – Container for all network components.
- Return type:
pypsa.Network object
etrago.tools.io module¶
io.py
Input/output operations between powerflow schema in the oedb and PyPSA. Additionally oedb wrapper classes to instantiate PyPSA network objects.
- etrago.tools.io.carr_ormclass¶
Orm class name of table with carrier id to carrier name datasets
- Type:
Notes
A configuration file connecting the chosen optimization method with components to be queried is needed for NetworkScenario class.
- class etrago.tools.io.ScenarioBase(engine, session, version=None)[source]¶
Bases:
objectBase class to address the dynamic provision of orm classes representing powerflow components from egoio
- Parameters:
session (sqla.orm.session.Session) – Handles conversations with the database.
version (str) – Version number of data version control in grid schema of the oedb.
- class etrago.tools.io.NetworkScenario(engine, session, scn_name='Status Quo', start_snapshot=1, end_snapshot=20, temp_id=1, scenario_extension=False, **kwargs)[source]¶
Bases:
ScenarioBaseAdapter class between oedb powerflow data and PyPSA. Provides the method build_network to generate a pypsa.Network.
- Parameters:
Methods
build_network([network])Core method to construct PyPSA Network object.
Construct a DateTimeIndex with the queried temporal resolution, start- and end_snapshot.
fetch_by_relname(name)Construct DataFrame with component data from filtered table data.
series_fetch_by_relname(network, name, ...)Construct DataFrame with component timeseries data from filtered table data.
id_to_source
- configure_timeindex()[source]¶
Construct a DateTimeIndex with the queried temporal resolution, start- and end_snapshot.
- fetch_by_relname(name)[source]¶
Construct DataFrame with component data from filtered table data.
- Parameters:
name (str) – Component name.
- Returns:
Component data.
- Return type:
pd.DataFrame
- etrago.tools.io.clear_results_db(session)[source]¶
Used to clear the result tables in the OEDB. Caution! This deletes EVERY RESULT SET!
- etrago.tools.io.results_to_oedb(session, network, args, grid='hv', safe_results=False)[source]¶
Return results obtained from PyPSA to oedb
- Parameters:
session
network (PyPSA network container) – Holds topology of grid including results from powerflow analysis
args (dict) – Settings from appl.py
grid (str) – Choose voltage-level, currently only ‘hv’ implemented
safe_results (boolean) – If it is set to ‘True’ the result set will be saved to the versioned grid schema eventually apart from being saved to the model_draft by a SQL-script. ONLY set to True if you know what you are doing.
- etrago.tools.io.run_sql_script(conn, scriptname='results_md2grid.sql')[source]¶
This function runs .sql scripts in the folder ‘sql_scripts’
- etrago.tools.io.extension(self, **kwargs)[source]¶
Function that adds an additional network to the existing network container. The new network can include every PyPSA-component (e.g. buses, lines, links). To connect it to the existing network, transformers are needed.
All components and its timeseries of the additional scenario need to be inserted in the fitting ‘model_draft.ego_grid_pf_hv_extension_’ table. The scn_name in the tables have to be labled with ‘extension_’ + scn_name (e.g. ‘extension_nep2035’).
Until now, the tables include three additional scenarios: ‘nep2035_confirmed’: all new lines and needed transformers planed in the ‘Netzentwicklungsplan 2035’ (NEP2035) that have been confirmed by the Bundesnetzagentur (BNetzA)
‘nep2035_b2’: all new lines and needed transformers planned in the NEP 2035 in the scenario 2035 B2
‘BE_NO_NEP 2035’: DC-lines and transformers to connect the upcomming electrical-neighbours Belgium and Norway Generation, loads and its timeseries in Belgium and Norway for scenario ‘NEP 2035’
- Parameters:
network – The existing network container (e.g. scenario ‘NEP 2035’)
session – session-data
overlay_scn_name – Name of the additional scenario (WITHOUT ‘extension_’)
start_snapshot
end_snapshot – Simulation time
- Return type:
Network container including existing and additional network
- etrago.tools.io.decommissioning(self, **kwargs)[source]¶
Function that removes components in a decommissioning-scenario from the existing network container. Currently, only lines can be decommissioned.
All components of the decommissioning scenario need to be inserted in the fitting ‘model_draft.ego_grid_pf_hv_extension_’ table. The scn_name in the tables have to be labled with ‘decommissioning_’ + scn_name (e.g. ‘decommissioning_nep2035’).
- Parameters:
network – The existing network container (e.g. scenario ‘NEP 2035’)
session – session-data
overlay_scn_name – Name of the decommissioning scenario
- Return type:
Network container including decommissioning
- etrago.tools.io.distance(x0, x1, y0, y1)[source]¶
Function that calculates the square of the distance between two points.
- Parameters:
x0 – x - coordinate of point 0
x1 – x - coordinate of point 1
y0 – y - coordinate of point 0
y1 – y - coordinate of point 1
- Returns:
distance – square of distance
- Return type:
etrago.tools.utilities module¶
Utilities.py includes a wide range of useful functions.
- etrago.tools.utilities.filter_links_by_carrier(self, carrier, like=True)[source]¶
- Parameters:
- Returns:
df – Dataframe that contains just links with carriers of the types given in the argument carrier.
- Return type:
pandas.DataFrame object
- etrago.tools.utilities.buses_of_vlvl(network, voltage_level)[source]¶
Get bus-ids of given voltage level(s).
- etrago.tools.utilities.buses_grid_linked(network, voltage_level)[source]¶
Get bus-ids of a given voltage level connected to the grid.
- etrago.tools.utilities.geolocation_buses(self, apply_on='grid_model')[source]¶
If geopandas is installed: Use geometries of buses x/y(lon/lat) and polygons of countries from RenpassGisParameterRegion in order to locate the buses
Else: Use coordinats of buses to locate foreign buses, which is less accurate.
TODO: Why not alway use geopandas??
- Parameters:
etrago (
etrago.Etrago) – Transmission grid objectapply_on (str) – State if this function is applied on the grid_model or the market_model. The market_model options can only be used if the method type is “market_grid”.
- etrago.tools.utilities.buses_by_country(self, apply_on='grid_model')[source]¶
Find buses of foreign countries using coordinates and return them as Pandas Series
- Parameters:
self (Etrago object) – Overall container of PyPSA
apply_on (str) – State if this function is applied on the grid_model or the market_model. The market_model options can only be used if the method type is “market_grid”.
- Return type:
None
- etrago.tools.utilities.clip_foreign(network)[source]¶
Delete all components and timelines located outside of Germany. If applied after optimization, transborder flows divided by country of origin are added as network.foreign_trade.
- etrago.tools.utilities.foreign_links(self)[source]¶
Change transmission technology of foreign lines from AC to DC (links).
- etrago.tools.utilities.set_q_national_loads(self, cos_phi)[source]¶
Set q component of national loads based on the p component and cos_phi
- Parameters:
network (
pypsa.Network) – Overall container of PyPSAcos_phi (float) – Choose ration of active and reactive power of foreign loads
- Returns:
network – Overall container of PyPSA
- Return type:
pypsa.Network
- etrago.tools.utilities.set_q_foreign_loads(self, cos_phi)[source]¶
Set reative power timeseries of loads in neighbouring countries
- etrago.tools.utilities.connected_grid_lines(network, busids)[source]¶
Get grid lines connected to given buses.
- etrago.tools.utilities.connected_transformer(network, busids)[source]¶
Get transformer connected to given buses.
- etrago.tools.utilities.load_shedding(self, temporal_disaggregation=False, negative_load_shedding=['Li_ion'], **kwargs)[source]¶
Implement load shedding in existing network to identify feasibility problems
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
temporal_disaggregation (bool) – It is set to False by default.
negative_load_shedding (False, list) – Define if generators for negative load shedding will be created. It is set to False by default. When activated supply a list of carriers e.g. [“AC”, “Li_ion”]
- Return type:
None.
- etrago.tools.utilities.set_control_strategies(network)[source]¶
Sets control strategies for AC generators and storage units
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
- Return type:
None.
- etrago.tools.utilities.data_manipulation_sh(network)[source]¶
Adds missing components to run calculations with SH scenarios.
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
- Return type:
None
- etrago.tools.utilities.export_to_csv(self, path)[source]¶
Write calculation results to csv-files in path.
- etrago.tools.utilities.loading_minimization(network, snapshots)[source]¶
Minimizes the sum of the products of each element in the passive_branches of the model.
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
snapshots ('pandas.core.indexes.datetimes.DatetimeIndex') – snapshots to perform the minimization
- Return type:
None
- etrago.tools.utilities.agg_series_lines(l0, network)[source]¶
Given a pandas DataFrame l0 containing information about lines in a network and a network object, aggregates the data in l0 for all its attributes. Returns a pandas Series containing the aggregated data.
- Parameters:
l0 (pandas.DataFrame) – contain information about lines in a network.
network (:class:`pypsa.Network) – Overall container of PyPSA
- Returns:
A pandas Series containing aggregated data for the lines in the network.
- Return type:
pandas.Series
- etrago.tools.utilities.group_parallel_lines(network)[source]¶
Function that groups parallel lines of the same voltage level to one line component representing all parallel lines
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
- Return type:
None.
- etrago.tools.utilities.delete_dispensable_ac_buses(etrago)[source]¶
Function that identifies and delete AC buses without links, transformers, generators, loads, stores or storage_units, which also are connected to just one or two other buses
- Parameters:
etrago (etrago object)
- Return type:
None.
- etrago.tools.utilities.set_line_costs(self, cost110=230, cost220=290, cost380=85, costDC=375)[source]¶
Set capital costs for extendable lines in respect to PyPSA [€/MVA]
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
args (dict) – containing settings from appl.py
cost110 – capital costs per km for 110kV lines and cables default: 230€/MVA/km, source: costs for extra circuit in dena Verteilnetzstudie, p. 146)
cost220 – capital costs per km for 220kV lines and cables default: 280€/MVA/km, source: costs for extra circuit in NEP 2025, capactity from most used 220 kV lines in model
cost380 – capital costs per km for 380kV lines and cables default: 85€/MVA/km, source: costs for extra circuit in NEP 2025, capactity from most used 380 kV lines in NEP
costDC – capital costs per km for DC-lines default: 375€/MVA/km, source: costs for DC transmission line in NEP 2035
- etrago.tools.utilities.set_trafo_costs(self, cost110_220=7500, cost110_380=17333, cost220_380=14166)[source]¶
Set capital costs for extendable transformers in respect to PyPSA [€/MVA]
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
cost110_220 – capital costs for 110/220kV transformer default: 7500€/MVA, source: costs for extra trafo in dena Verteilnetzstudie, p. 146; S of trafo used in osmTGmod
cost110_380 – capital costs for 110/380kV transformer default: 17333€/MVA, source: NEP 2025
cost220_380 – capital costs for 220/380kV transformer default: 14166€/MVA, source: NEP 2025
- etrago.tools.utilities.add_missing_components(self)[source]¶
Add a missing transformer at Heizkraftwerk Nord in Munich and a missing transformer in Stuttgart.
- etrago.tools.utilities.convert_capital_costs(self)[source]¶
Convert capital_costs to fit to considered timesteps
- Parameters:
etrago (:class:`etrago.Etrago) – Transmission grid object
- etrago.tools.utilities.find_snapshots(network, carrier, maximum=True, minimum=True, n=3)[source]¶
Function that returns snapshots with maximum and/or minimum feed-in of selected carrier.
- Parameters:
- Returns:
calc_snapshots – List containing snapshots
- Return type:
‘pandas.core.indexes.datetimes.DatetimeIndex’
- etrago.tools.utilities.ramp_limits(network)[source]¶
Add ramping constraints to thermal power plants.
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
- etrago.tools.utilities.get_args_setting(self, jsonpath='scenario_setting.json')[source]¶
Get and open json file with scenaio settings of eTraGo
args. The settings includes all eTraGo specific settings of arguments and parameters for a reproducible calculation.
- etrago.tools.utilities.merge_dicts(dict1, dict2)[source]¶
Return a new dictionary by merging two dictionaries recursively.
- etrago.tools.utilities.get_clustering_data(self, path)[source]¶
Import the final busmap and the initial buses, lines and links
- Parameters:
path (str) – Name of folder from which to import CSVs of network data.
- Return type:
None
- etrago.tools.utilities.set_random_noise(self, sigma=0.01)[source]¶
Sets random noise to marginal cost of each generator.
- etrago.tools.utilities.set_line_country_tags(network)[source]¶
Set country tag for AC- and DC-lines.
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
- etrago.tools.utilities.crossborder_capacity_tyndp2020()[source]¶
This function downloads and extracts a scenario datafile for the TYNDP 2020 (Ten-Year Network Development Plan), reads a specific sheet from the file, filters it based on certain criteria, and then calculates the minimum cross-border capacities for a list of European countries. The minimum cross-border capacity is the minimum of the export and import capacities between two countries.
- Returns:
Dictionary with cossborder capacities.
- Return type:
- etrago.tools.utilities.crossborder_capacity(self)[source]¶
Adjust interconnector capacties.
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
method (string) – Method of correction. Options are ‘ntc_acer’ and ‘thermal_acer’. ‘ntc_acer’ corrects all capacities according to values published by the ACER in 2016. ‘thermal_acer’ corrects certain capacities where our dataset most likely overestimates the thermal capacity.
- etrago.tools.utilities.set_branch_capacity(etrago)[source]¶
Set branch capacity factor of lines and transformers, different factors for HV (110kV) and eHV (220kV, 380kV).
- Parameters:
etrago (:class:`etrago.Etrago) – Transmission grid object
- etrago.tools.utilities.check_args(etrago)[source]¶
Function that checks the consistency of etragos input parameters.
- Parameters:
etrago (:class:`etrago.Etrago) – Overall container of eTraGo
- Return type:
None.
- etrago.tools.utilities.drop_sectors(self, drop_carriers)[source]¶
Manually drop secors from network. Makes sure the network can be calculated without the dropped sectors.
- Parameters:
drop_carriers (array) – List of sectors that will be dropped. e.g. [‘dsm’, ‘CH4’, ‘H2_saltcavern’, ‘H2_grid’, ‘central_heat’, ‘rural_heat’, ‘central_heat_store’, ‘rural_heat_store’, ‘Li ion’] means everything but AC
- Return type:
None.
- etrago.tools.utilities.update_busmap(self, new_busmap)[source]¶
Update busmap after any clustering process
- Parameters:
new_busmap (dictionary) – busmap used to clusted the network.
- Return type:
None.
- etrago.tools.utilities.adjust_CH4_gen_carriers(self)[source]¶
Precise the carrier for the generators with CH4 carrier
For the eGon2035 scenario, the generators with carrier CH4 represent the prodution od biogas and methan. In the data model, these two differents types are differenciated only by the marginal cost of the generator. This function introduces a carrier distion (CH4_biogas and CH4_NG) in order to avoid the clustering of these two types of generator together and facilitate the contraint applying differently to each of them.
- etrago.tools.utilities.residual_load(network, sector='electricity')[source]¶
Calculate the residual load for the specified sector.
In case of the electricity sector residual load is calculated using all AC loads and all renewable generators with carriers ‘wind_onshore’, ‘wind_offshore’, ‘solar’, ‘solar_rooftop’, ‘biomass’, ‘run_of_river’, and ‘reservoir’.
In case of the central heat sector residual load is calculated using all central heat loads and all renewable generators with carriers ‘solar_thermal_collector’ and ‘geo_thermal’.
- Parameters:
network (PyPSA network) – Network to retrieve load and generation time series from, needed to determine residual load.
sector (str) – Sector to determine residual load for. Possible options are ‘electricity’ and ‘central_heat’. Default: ‘electricity’.
- Returns:
Dataframe with residual load for each bus in the network. Columns of the dataframe contain the corresponding bus name and index of the dataframe is a datetime index with the corresponding time step.
- Return type:
pd.DataFrame
- etrago.tools.utilities.manual_fixes_datamodel(etrago)[source]¶
Apply temporal fixes to the data model until a new egon-data run is there
- Parameters:
etrago (:class:`Etrago) – Overall container of Etrago
- Return type:
None.
- etrago.tools.utilities.export_to_shapefile(pypsa_network, shape_files_path=None, srid=4326)[source]¶
Translates all component DataFrames within the pypsa network to GeoDataFrames and saves them to shape files.
Shape files can be used to plot the network in QGIS.
Currently, only the AC network is exported.
- Parameters:
- Returns:
Dictionary with geodataframes.
- Return type:
- etrago.tools.utilities.adjust_PtH2_model(self, apply_on='pre_market_model')[source]¶
Adjust the modelling of electrolyzer with waste-heat and O2-utilisation. The method creates a multiple-link-model out of the single links from the dataset (power_to_H2-, PtH2_waste_heat-, PtH2_O2-links) for each location where coupling-product usage is possible. The resulting model consists of a multiple link, additional buses and stores for waste_heat and O2-utilisation, and the connection link to the final heat- and O2-Bus.
- etrago.tools.utilities.adjust_chp_model(self, apply_on='pre_market_model')[source]¶
Adjust the modelling of chp plants in foreign countries for eGon100RE
- etrago.tools.utilities.levelize_abroad_inland_parameters(self)[source]¶
The method levelize the techno-economic parameters of inland and abroad components of the same carrier. Thus, the favoring of one component is avoided just based on the parameters. The differences in the parameters of the input dataset are caused by a updated source used for the pypsa_eur network and different assumed interest_rates. All necessary parameters of the foreign components are adjusted to the values of the inland components.
- Parameters:
etrago (:class:`Etrago) – Overall container of Etrago
- Return type:
None