Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement sclopf #710

Merged
merged 33 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6c43797
Add first draft of sclopf and contingency analysis
ClaraBuettner Jan 8, 2024
463116b
Add check if dataframe is empty
ClaraBuettner Jan 8, 2024
fb1ebb4
Call sclopf in appl.py
ClaraBuettner Jan 8, 2024
e354e05
Adjust imports
ClaraBuettner Jan 16, 2024
40330e7
Apply checks on contingency only on relevnt subnetwork
ClaraBuettner Jan 16, 2024
9aa1030
Merge branch 'dev' into features/implement-sclopf-pypsa0262
ClaraBuettner Jan 16, 2024
a17b3f5
Move sclopf file into execute module
ClaraBuettner Jan 16, 2024
1c9f194
Add sclopf to etrago.optimize
ClaraBuettner Jan 16, 2024
d630249
Add possible options for method type
ClaraBuettner Jan 16, 2024
4bdc346
Remove sclopf call from appl.py
ClaraBuettner Jan 16, 2024
fbeae8e
Temporary drop DLR as it is currently not compatible to the sclopf
ClaraBuettner Jan 16, 2024
b8526fd
Use sclopf in grid_optimization
ClaraBuettner Jan 16, 2024
354b82f
Fix argments for csv export
ClaraBuettner Jan 16, 2024
2424a6b
Apply black
ClaraBuettner Jan 16, 2024
cf436be
Consider branch outage for each line by default
ClaraBuettner Jan 31, 2024
95c66ec
Delete unused lines
ClaraBuettner Jan 31, 2024
b984c9d
Try fixing dividing extended lines
ClaraBuettner Jan 31, 2024
ef9b1f8
Move warning outside of loop
ClaraBuettner Jan 31, 2024
84ced25
Do not split extended lines, since it still creates problems
ClaraBuettner Jan 31, 2024
f1f1057
Black
ClaraBuettner Jan 31, 2024
e404039
Applly black version 24
ClaraBuettner Jan 31, 2024
701ce0e
Consider outages of all lines in the main subnetwork
ClaraBuettner Feb 13, 2024
1ca51b2
Remove prints used for debugging
ClaraBuettner Feb 13, 2024
1e1f765
Add other secors to main subnetwork when checking for n-1-security
ClaraBuettner Feb 13, 2024
c80ae0f
Set div_extended_lines to False
ClaraBuettner Feb 13, 2024
2146de7
Black
ClaraBuettner Feb 13, 2024
54510a3
Set extra_functionalities in sclopf
ClaraBuettner Feb 14, 2024
e9425b1
Black
ClaraBuettner Feb 14, 2024
984cb27
Merge branch 'dev' into features/implement-sclopf-pypsa0262
ClaraBuettner Feb 14, 2024
2aea2bb
Add description for different optimization types
ClaraBuettner Feb 26, 2024
083525c
Exclude DLR only if optimization type is not lopf
ClaraBuettner Feb 26, 2024
2e0083d
Remove outdated patameter
ClaraBuettner Feb 26, 2024
ff0dc69
Apply black
ClaraBuettner Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion 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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the description of the "type" parameter in the docstrings

"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 @@ -736,6 +737,9 @@ def run_etrago(args, json_path):
# skip snapshots
etrago.skip_snapshots()

# Temporary drop DLR as it is currently not working with sclopf
etrago.network.lines_t.s_max_pu = pd.DataFrame(index=etrago.network.snapshots, columns=etrago.network.lines.index, data=1.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is implemented, we will be dropping DLR also for LOPF or market_grid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also needed for market_grid as that method also used the sclopf. But I can adjust it for the lopf


# start linear optimal powerflow calculations

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

self.grid_optimization()

elif self.args["method"]["type"] == "sclopf":
self.sclopf(
post_lopf=False,
extra_functionality=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function iterate_sclopf() is failing due to an unexpected keyword. Error message:


  File ~/env/etrago_710_fail-fix/lib/python3.10/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File ~/git/eTraGo/etrago/appl.py:770
    etrago = run_etrago(args, json_path=None)

  File ~/git/eTraGo/etrago/appl.py:749 in run_etrago
    etrago.optimize()

  File ~/git/eTraGo/etrago/execute/__init__.py:422 in optimize
    self.sclopf(

TypeError: iterate_sclopf() got an unexpected keyword argument 'extra_functionality'

n_process=4,
delta=0.01,
n_overload=0,
div_ext_lines=False,
)
else:
print("Method not defined")

Expand Down Expand Up @@ -579,7 +588,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