etrago.execute package¶
execute.py defines optimization and simulation methods for the etrago object.
- etrago.execute.update_electrical_parameters(network, l_snom_pre, t_snom_pre)[source]¶
Update electrical parameters of active branch components considering s_nom of previous iteration.
- Parameters:
network (pypsa.Network object) – Container for all network components.
l_snom_pre (pandas.Series) – s_nom of ac-lines in previous iteration.
t_snom_pre (pandas.Series) – s_nom of transformers in previous iteration.
- Return type:
None.
- etrago.execute.run_lopf(etrago, extra_functionality, method)[source]¶
Function that performs lopf with or without pyomo
- Parameters:
etrago (etrago object) – eTraGo containing all network information and a PyPSA network.
extra_functionality (dict) – Define extra constranits.
method (dict) – Choose ‘n_iter’ and integer for fixed number of iterations or ‘threshold’ and derivation of objective in percent for variable number of iteration until the threshold of the objective function is reached.
- Return type:
None.
- etrago.execute.iterate_lopf(etrago, extra_functionality, method={'n_iter': 4, 'pyomo': True})[source]¶
Run optimization of lopf. If network extension is included, the specified number of iterations is calculated to consider reactance changes.
- Parameters:
etrago (etrago object) – eTraGo containing all network information and a PyPSA network.
extra_functionality (dict) – Define extra constranits.
method (dict) – Choose ‘n_iter’ and integer for fixed number of iterations or ‘threshold’ and derivation of objective in percent for variable number of iteration until the threshold of the objective function is reached.
- etrago.execute.lopf(self)[source]¶
Functions that runs lopf according to arguments.
- Return type:
None.
- etrago.execute.optimize(self)[source]¶
Run optimization of dispatch and grid and storage expansion based on arguments
- Return type:
None.
- etrago.execute.optimize_with_rolling_horizon(n, pre_market, snapshots, horizon, overlap, solver_name, extra_functionality, args, temporal_disaggregation=False)[source]¶
Optimizes the network in a rolling horizon fashion.
- Parameters:
n (pypsa.Network)
snapshots (list-like) – Set of snapshots to consider in the optimization. The default is None.
horizon (int) – Number of snapshots to consider in each iteration. Defaults to 100.
overlap (int) – Number of snapshots to overlap between two iterations. Defaults to 0.
**kwargs – Keyword argument used by linopy.Model.solve, such as solver_name,
- Return type:
None
- etrago.execute.import_gen_from_links(network, drop_small_capacities=True)[source]¶
create gas generators from links in order to not lose them when dropping non-electric carriers
- etrago.execute.run_pf_post_lopf(self)[source]¶
Function that runs pf_post_lopf according to arguments.
- Return type:
None.
- etrago.execute.pf_post_lopf(etrago, calc_losses=False)[source]¶
Function that prepares and runs non-linar load flow using PyPSA pf. If crossborder lines are DC-links, pf is only applied on german network. Crossborder flows are still considerd due to the active behavior of links. To return a network containing the whole grid, the optimised solution of the foreign components can be added afterwards.
- Parameters:
etrago (etrago object) – eTraGo containing all network information and a PyPSA network.
add_foreign_lopf (boolean) – Choose if foreign results of lopf should be added to the network when foreign lines are DC.
q_allocation (str) – Choose allocation of reactive power. Possible settings are listed in distribute_q function.
calc_losses (bolean) – Choose if line losses will be calculated.
- etrago.execute.distribute_q(network, allocation='p_nom')[source]¶
Function that distributes reactive power at bus to all installed generators and storages.
- Parameters:
network (pypsa.Network object) – Container for all network components.
allocation (str) – Choose key to distribute reactive power: ‘p_nom’ to dirstribute via p_nom ‘p’ to distribute via p_set.
- Return type:
None.
- etrago.execute.calc_line_losses(network, converged)[source]¶
Calculate losses per line with PF result data.
- Parameters:
network (pypsa.Network object) – Container for all network components.
converged (pd.Series) – List of snapshots with their status (converged or not).
- Return type:
None.
- etrago.execute.set_slack(network)[source]¶
Function that chosses the bus with the maximum installed power as slack.
- Parameters:
network (pypsa.Network object) – Container for all network components.
- Returns:
network – Container for all network components.
- Return type:
pypsa.Network object
etrago.execute.grid_optimization module¶
Defines the market optimization within eTraGo
- etrago.execute.grid_optimization.grid_optimization(self, factor_redispatch_cost=1, management_cost=0, time_depended_cost=True, fre_mangement_fee=0)[source]¶
- etrago.execute.grid_optimization.add_redispatch_generators(self, factor_redispatch_cost, management_cost, time_depended_cost, fre_mangement_fee)[source]¶
Add components and parameters to model redispatch with costs
This function currently assumes that the market_model includes all generators and links for the spatial resolution of the grid optimization
- Return type:
None.
etrago.execute.market_optimization module¶
Defines the market optimization within eTraGo
- etrago.execute.market_optimization.build_market_model(self, unit_commitment=False)[source]¶
Builds market model based on imported network from eTraGo
import market regions from file or database
Cluster network to market regions
- – consider marginal cost incl. generator noise when grouoping electrical
generation capacities
- Return type:
None.
etrago.execute.sclopf module¶
sclopf.py defines functions for contingency analysis.
- etrago.execute.sclopf.network_lpf_contingency_subnetwork(network, snapshot=None, branch_outages=None)[source]¶
Computes linear power flow for a selection of branch outages within the subnetwork with the highest number of buses
- Parameters:
snapshots (list-like|single snapshot) – A subset or an elements of network.snapshots on which to run the power flow, defaults to network.snapshots NB: currently this only works for a single snapshot
branch_outages (list-like) – A list of passive branches which are to be tested for outages. If None, it’s take as all network.passive_branches_i()
- Returns:
p0 – num_passive_branch x num_branch_outages DataFrame of new power flows
- Return type:
pandas.DataFrame
- etrago.execute.sclopf.post_contingency_analysis_per_line(network, branch_outages, n_process=4, delta=0.01)[source]¶
- etrago.execute.sclopf.iterate_lopf_calc(network, args, l_snom_pre, t_snom_pre)[source]¶
Function that runs iterations of lopf without building new models. Currently only working with model_formulation = ‘kirchhoff’
- Parameters:
network (:class:`pypsa.Network) – Overall container of PyPSA
l_snom_pre (pandas.Series) – s_nom of ac-lines in previous iteration
t_snom_pre (pandas.Series) – s_nom of transformers in previous iteration