Skip to content

Commit

Permalink
Merge pull request #710 from openego/features/implement-sclopf-pypsa0262
Browse files Browse the repository at this point in the history
Implement sclopf
  • Loading branch information
ClaraBuettner authored Feb 28, 2024
2 parents 04bf4e0 + ff0dc69 commit 49eb0f0
Show file tree
Hide file tree
Showing 5 changed files with 1,075 additions and 5 deletions.
16 changes: 13 additions & 3 deletions etrago/appl.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import datetime
import os
import os.path
import pandas as pd

__copyright__ = (
"Flensburg University of Applied Sciences, "
Expand All @@ -51,7 +52,7 @@
"db": "egon-data", # database session
"gridversion": None, # None for model_draft or Version number
"method": { # Choose method and settings for optimization
"type": "market_grid", # type of optimization, 'lopf' or 'market_grid'
"type": "market_grid", # type of optimization, 'lopf', 'sclopf' or 'market_grid'
"n_iter": 1, # abort criterion of iterative optimization, 'n_iter' or 'threshold'
"pyomo": True, # set if pyomo is used for model building
"formulation": "pyomo",
Expand Down Expand Up @@ -187,8 +188,9 @@ def run_etrago(args, json_path):
Choose method and settings for optimization.
The provided dictionary can have the following entries:
* "lopf" : str
Type of optimization, currently only "lopf". Default: "lopf".
* "type" : str
Choose the type of optimization. Current options: "lopf", "sclopf"
or "market_grid". Default: "market_grid".
* "n_iter" : int
In case of extendable lines, several LOPFs have to be performed.
You can either set "n_iter" and specify a fixed number of
Expand Down Expand Up @@ -736,6 +738,14 @@ def run_etrago(args, json_path):
# skip snapshots
etrago.skip_snapshots()

# Temporary drop DLR as it is currently not working with sclopf
if etrago.args["method"] != "lopf":
etrago.network.lines_t.s_max_pu = pd.DataFrame(
index=etrago.network.snapshots,
columns=etrago.network.lines.index,
data=1.0,
)

# start linear optimal powerflow calculations

etrago.network.storage_units.cyclic_state_of_charge = True
Expand Down
11 changes: 10 additions & 1 deletion etrago/execute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ def optimize(self):

self.grid_optimization()

elif self.args["method"]["type"] == "sclopf":
self.sclopf(
post_lopf=False,
n_process=4,
delta=0.01,
n_overload=0,
div_ext_lines=False,
)
else:
print("Method not defined")

Expand Down Expand Up @@ -579,7 +587,8 @@ def import_gen_from_links(network, drop_small_capacities=True):
df["control"] = "PV"
df.reset_index(inplace=True)

df.index = df.bus + " " + df.carrier
if not df.empty:
df.index = df.bus + " " + df.carrier

# Aggregate disptach time series for new generators
gas_to_add["bus1_carrier"] = gas_to_add.bus + " " + gas_to_add.carrier
Expand Down
8 changes: 7 additions & 1 deletion etrago/execute/grid_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ def grid_optimization(self):
# self.network.links.index.str.contains('ramp')
# ].index, inplace=True)
logger.info("Start solving grid optimization model")
self.lopf()
self.sclopf(
post_lopf=False,
n_process=4,
delta=0.01,
n_overload=0,
div_ext_lines=False,
)


def fix_chp_generation(self):
Expand Down
Loading

0 comments on commit 49eb0f0

Please sign in to comment.