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

Linopy integration for Power and Sector-Coupled Modelling #1172

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
747441f
docs(contributor): contrib-readme-action has updated readme
github-actions[bot] Oct 30, 2024
d6afd52
Update PyPSA & enable linopy (#1167)
ekatef Nov 4, 2024
bb95325
Enable linopy - power model (#1169)
ekatef Nov 5, 2024
5c48d60
Get back CI for Windows
ekatef Nov 5, 2024
35517e9
Update environment
ekatef Nov 5, 2024
c71c538
Add H2 carrier if not exists
yerbol-akhmetov Oct 15, 2024
b40e643
Add battery carrier if not exists only
yerbol-akhmetov Oct 15, 2024
fc11c02
use H2 in both AC and DC buses in h2_hc_conversions function
yerbol-akhmetov Oct 22, 2024
38f6090
use AC and DC based H2 to make parameters of m.add consistent shape
yerbol-akhmetov Oct 22, 2024
8c9077e
add release notes
yerbol-akhmetov Oct 30, 2024
5f52c50
docs(contributor): contrib-readme-action has updated readme (#1162)
github-actions[bot] Oct 31, 2024
763fb32
Update PyPSA & enable linopy (#1167)
ekatef Nov 4, 2024
994804a
Enable linopy - power model (#1169)
ekatef Nov 5, 2024
0d3ebdf
Get back CI for Windows
ekatef Nov 5, 2024
34b6168
Update environment
ekatef Nov 5, 2024
268851b
revise implementation to accomodate linopy for sec
GbotemiB Nov 7, 2024
82d9f10
Merge branch 'pypsa_linopy_update' into linopy-sec
GbotemiB Nov 13, 2024
9fcee64
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 13, 2024
08bd2bd
Update PyPSA version
ekatef Nov 15, 2024
fe025fc
Merge remote-tracking branch 'upstream/main' into pypsa_linopy_update
ekatef Nov 18, 2024
6e892ea
Merge branch 'pypsa_linopy_update' into linopy-sec
GbotemiB Nov 18, 2024
5264e62
Lift a version restriction
ekatef Nov 19, 2024
cedfda8
Enable augmented network
ekatef Nov 19, 2024
f61058a
Add a requirement to update countrycode
ekatef Nov 20, 2024
fdacd80
Merge branch 'pypsa_linopy_update' into linopy-sec
GbotemiB Nov 20, 2024
c5a4764
Use an installation from the source for countrycode
ekatef Nov 20, 2024
acc9431
Remove redundand initialisation
ekatef Nov 20, 2024
04065eb
Switch on extra functionality
ekatef Nov 20, 2024
dc4dba3
Fix grouping in add_res_constraints
ekatef Nov 20, 2024
25a9b55
Add missed import
ekatef Nov 20, 2024
876a5f8
Merge branch 'main' into pypsa_linopy_update
ekatef Nov 20, 2024
b6343e2
Fix refuse aligning dimensions
ekatef Nov 20, 2024
129db46
Improve naming
ekatef Nov 20, 2024
200a954
Merge remote-tracking branch 'upstream/pypsa_linopy_update' into pyps…
ekatef Nov 20, 2024
6770144
Remove outdated n.variables
ekatef Nov 20, 2024
aa92c9a
adjust warning for h2_cap
GbotemiB Nov 21, 2024
1ba8d94
revert wildcards rules
GbotemiB Nov 21, 2024
e909f3d
remove comment for .variables
GbotemiB Nov 21, 2024
b0d9cb7
Merge branch 'pypsa_linopy_update' into linopy-sec
GbotemiB Nov 21, 2024
92c931b
Merge pull request #1182 from GbotemiB/linopy-sec
ekatef Nov 21, 2024
0cd0fb5
Merge branch 'main' into pypsa_linopy_update
ekatef Dec 20, 2024
ffdf4a4
Remove outdated dependency hint
ekatef Dec 20, 2024
95d7a29
Update comments
ekatef Dec 20, 2024
ff939d4
Add a docstring
ekatef Dec 20, 2024
8172112
Update the release notes
ekatef Dec 20, 2024
6ca4177
Update scripts/solve_network.py
ekatef Dec 20, 2024
75b60ca
Merge branch 'main' of https://github.com/pypsa-meets-earth/pypsa-ear…
ekatef Dec 21, 2024
eafc486
Add a workflow to update environments in PR
ekatef Dec 21, 2024
2678af3
Merge branch 'main' into pypsa_linopy_update
ekatef Dec 21, 2024
3ff85e7
[github-actions.ci] Update pinned envs (#1253)
github-actions[bot] Dec 21, 2024
36f45f0
Remove an outdated dependency
ekatef Dec 21, 2024
25f6d73
Remove a redundand workflow
ekatef Dec 21, 2024
cad2731
Merge remote-tracking branch 'upstream/pypsa_linopy_update' into pyps…
ekatef Dec 21, 2024
0f1d8ce
Get back CI for Windows
ekatef Dec 22, 2024
1d507dc
Merge branch 'main' into pypsa_linopy_update
ekatef Dec 22, 2024
9dcfd1e
Minor refactoring
ekatef Dec 24, 2024
82e431f
Replace merge functions
ekatef Dec 24, 2024
5a7efce
Merge main into pypsa_linopy_update
ekatef Dec 24, 2024
d6b3659
Add a TODO
ekatef Dec 24, 2024
e4386fc
Fix typo
ekatef Dec 24, 2024
2ee49f3
Merge pypsa-earth/main into pypsa_linopy_update
ekatef Dec 27, 2024
4b05b02
Update configuration strategies
ekatef Dec 27, 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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
env_file: envs/linux-pinned.yaml
- os: macos
env_file: envs/macos-pinned.yaml
# - os: windows
# env_file: envs/windows-pinned.yaml
- os: windows
env_file: envs/windows-pinned.yaml

defaults:
run:
Expand Down
3 changes: 3 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ rule add_electricity:

rule simplify_network:
params:
aggregation_strategies=config["cluster_options"]["aggregation_strategies"],
renewable=config["renewable"],
geo_crs=config["crs"]["geo_crs"],
cluster_options=config["cluster_options"],
Expand Down Expand Up @@ -606,6 +607,7 @@ if config["augmented_line_connection"].get("add_to_snakefile", False) == True:

rule cluster_network:
params:
aggregation_strategies=config["cluster_options"]["aggregation_strategies"],
build_shape_options=config["build_shape_options"],
electricity=config["electricity"],
costs=config["costs"],
Expand Down Expand Up @@ -691,6 +693,7 @@ if config["augmented_line_connection"].get("add_to_snakefile", False) == False:

rule cluster_network:
params:
aggregation_strategies=config["cluster_options"]["aggregation_strategies"],
build_shape_options=config["build_shape_options"],
electricity=config["electricity"],
costs=config["costs"],
Expand Down
1 change: 1 addition & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ cluster_options:
p_nom_max: sum
p_nom_min: sum
p_min_pu: mean
p_max_pu: weighted_average
marginal_cost: mean
committable: any
ramp_limit_up: max
Expand Down
1 change: 1 addition & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ PyPSA-Earth 0.4.0

* Add an option to use csv format for custom demand imports. `PR #995 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/995>`__


**Minor Changes and bug-fixing**

* Minor bug-fixing to run the cluster wildcard min `PR #1019 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1019>`__
Expand Down
5 changes: 3 additions & 2 deletions envs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ dependencies:
- pip
- mamba # esp for windows build

- pypsa>=0.24, <0.25
- pypsa>=0.25
# - atlite>=0.2.4 # until https://github.com/PyPSA/atlite/issues/244 is not merged
- dask
# currently the packages are being installed with pip
# need to move back to conda once the issues will be resolved
Expand All @@ -28,6 +29,7 @@ dependencies:
- memory_profiler
- ruamel.yaml<=0.17.26
- pytables
- pyscipopt # added to compy with the quadratic objective requirement of the clustering script
- lxml
- numpy
# starting from 1.3.5 numpoly requires numpy>2.0 which leads to issues
Expand Down Expand Up @@ -80,7 +82,6 @@ dependencies:

# Default solver for tests (required for CI)
- glpk
- ipopt
- gurobi

- pip:
Expand Down
9 changes: 7 additions & 2 deletions envs/linux-pinned.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ dependencies:
- contourpy=1.3.1
- country_converter=1.2
- cpp-expected=1.1.0
- cppad=20240000.7
- cycler=0.12.1
- cyrus-sasl=2.1.27
- cytoolz=1.0.1
Expand Down Expand Up @@ -350,6 +351,7 @@ dependencies:
- metis=5.1.0
- minizip=4.0.7
- mistune=3.0.2
- mpfr=4.2.1
- mpg123=1.32.9
- msgpack-python=1.1.0
- multipledispatch=0.6.0
Expand Down Expand Up @@ -432,13 +434,14 @@ dependencies:
- pydoe2=1.3.0
- pygments=2.18.0
- pyogrio=0.10.0
- pyomo=6.8.2
- pyomo=6.6.1
- pyparsing=3.2.0
- pyppmd=1.1.0
- pyproj=3.7.0
- pypsa=0.24.0
- pypsa=0.28.0
- pyqt=5.15.9
- pyqt5-sip=12.12.2
- pyscipopt=5.2.1
- pyshp=2.3.1
- pysocks=1.7.1
- pytables=3.10.1
Expand Down Expand Up @@ -474,6 +477,7 @@ dependencies:
- ruamel.yaml.clib=0.2.8
- s2n=1.5.10
- scikit-learn=1.6.0
- scip=9.2.0
- scipy=1.14.1
- seaborn=0.13.2
- seaborn-base=0.13.2
Expand All @@ -497,6 +501,7 @@ dependencies:
- statsmodels=0.14.4
- stopit=1.1.2
- tabulate=0.9.0
- tbb=2022.0.0
- tblib=3.0.0
- terminado=0.18.1
- texttable=1.7.0
Expand Down
11 changes: 8 additions & 3 deletions envs/macos-pinned.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ dependencies:
- contourpy=1.3.1
- country_converter=1.2
- cpp-expected=1.1.0
- cppad=20240000.7
- cycler=0.12.1
- cyrus-sasl=2.1.27
- cytoolz=1.0.1
Expand Down Expand Up @@ -243,6 +244,7 @@ dependencies:
- libgoogle-cloud=2.32.0
- libgoogle-cloud-storage=2.32.0
- libgrpc=1.67.1
- libhwloc=2.11.2
- libiconv=1.17
- libintl=0.22.5
- libjpeg-turbo=3.0.0
Expand Down Expand Up @@ -303,6 +305,7 @@ dependencies:
- metis=5.1.0
- minizip=4.0.7
- mistune=3.0.2
- mpfr=4.2.1
- msgpack-python=1.1.0
- multipledispatch=0.6.0
- multiurl=0.3.3
Expand Down Expand Up @@ -382,11 +385,12 @@ dependencies:
- pyobjc-core=10.3.2
- pyobjc-framework-cocoa=10.3.2
- pyogrio=0.10.0
- pyomo=6.8.2
- pyomo=6.6.1
- pyparsing=3.2.0
- pyppmd=1.1.0
- pyproj=3.7.0
- pypsa=0.24.0
- pypsa=0.28.0
- pyscipopt=5.2.1
- pyshp=2.3.1
- pysocks=1.7.1
- pytables=3.10.1
Expand Down Expand Up @@ -420,6 +424,7 @@ dependencies:
- ruamel.yaml=0.17.26
- ruamel.yaml.clib=0.2.8
- scikit-learn=1.6.0
- scip=9.2.0
- scipy=1.14.1
- seaborn=0.13.2
- seaborn-base=0.13.2
Expand All @@ -442,6 +447,7 @@ dependencies:
- statsmodels=0.14.4
- stopit=1.1.2
- tabulate=0.9.0
- tbb=2022.0.0
- tblib=3.0.0
- terminado=0.18.1
- texttable=1.7.0
Expand Down Expand Up @@ -480,7 +486,6 @@ dependencies:
- xarray=2023.11.0
- xerces-c=3.2.5
- xlrd=2.0.1
- xorg-libxau=1.0.12
- xorg-libxdmcp=1.1.5
- xyzservices=2024.9.0
- yaml=0.2.5
Expand Down
12 changes: 10 additions & 2 deletions envs/windows-pinned.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ dependencies:
- contourpy=1.3.1
- country_converter=1.2
- cpp-expected=1.1.0
- cppad=20240000.7
- cpython=3.10.16
- cycler=0.12.1
- cytoolz=1.0.1
Expand Down Expand Up @@ -140,6 +141,7 @@ dependencies:
- glib=2.82.2
- glib-tools=2.82.2
- glpk=5.0
- gmp=6.3.0
- graphite2=1.3.13
- graphviz=12.0.0
- gst-plugins-base=1.24.7
Expand Down Expand Up @@ -200,6 +202,7 @@ dependencies:
- libarrow-dataset=18.1.0
- libarrow-substrait=18.1.0
- libblas=3.9.0
- libboost=1.86.0
- libbrotlicommon=1.1.0
- libbrotlidec=1.1.0
- libbrotlienc=1.1.0
Expand Down Expand Up @@ -233,6 +236,7 @@ dependencies:
- libgoogle-cloud=2.32.0
- libgoogle-cloud-storage=2.32.0
- libgrpc=1.67.1
- libhwloc=2.11.2
- libiconv=1.17
- libintl=0.22.5
- libintl-devel=0.22.5
Expand Down Expand Up @@ -290,6 +294,7 @@ dependencies:
- mercantile=1.2.1
- minizip=4.0.7
- mistune=3.0.2
- mpfr=4.2.1
- msgpack-python=1.1.0
- multipledispatch=0.6.0
- multiurl=0.3.3
Expand Down Expand Up @@ -361,14 +366,15 @@ dependencies:
- pydoe2=1.3.0
- pygments=2.18.0
- pyogrio=0.10.0
- pyomo=6.8.2
- pyomo=6.6.1
- pyparsing=3.2.0
- pyppmd=1.1.0
- pyproj=3.7.0
- pypsa=0.24.0
- pypsa=0.28.0
- pyqt=5.15.9
- pyqt5-sip=12.12.2
- pyreadline3=3.5.4
- pyscipopt=5.2.1
- pyshp=2.3.1
- pysocks=1.7.1
- pytables=3.10.1
Expand Down Expand Up @@ -404,6 +410,7 @@ dependencies:
- ruamel.yaml=0.17.26
- ruamel.yaml.clib=0.2.8
- scikit-learn=1.6.0
- scip=9.2.0
- scipy=1.14.1
- seaborn=0.13.2
- seaborn-base=0.13.2
Expand All @@ -427,6 +434,7 @@ dependencies:
- statsmodels=0.14.4
- stopit=1.1.2
- tabulate=0.9.0
- tbb=2022.0.0
- tblib=3.0.0
- terminado=0.18.1
- texttable=1.7.0
Expand Down
10 changes: 10 additions & 0 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,16 @@ def get_last_commit_message(path):
return last_commit_message


def update_config_dictionary(
config_dict,
parameter_key_to_fill="lines",
dict_to_use={"geometry": "first", "bounds": "first"},
):
config_dict.setdefault(parameter_key_to_fill, {})
config_dict[parameter_key_to_fill].update(dict_to_use)
return config_dict


# PYPSA-EARTH-SEC
def annuity(n, r):
"""
Expand Down
14 changes: 0 additions & 14 deletions scripts/base_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,20 +523,6 @@ def base_network(
result_type="reduce",
)
n.import_components_from_dataframe(lines_ac, "Line")
# The columns which names starts with "bus" are mixed up with the third-bus specification
# when executing additional_linkports()
lines_dc.drop(
labels=[
"bus0_lon",
"bus0_lat",
"bus1_lon",
"bus1_lat",
"bus_0_coors",
"bus_1_coors",
],
axis=1,
inplace=True,
)
n.import_components_from_dataframe(lines_dc, "Link")

n.import_components_from_dataframe(transformers, "Transformer")
Expand Down
25 changes: 25 additions & 0 deletions scripts/build_osm_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@
logger = create_logger(__name__)


# Keep only a predefined set of columns, as otherwise conflicts are possible
# e.g. the columns which names starts with "bus" are mixed up with
# the third-bus specification when executing additional_linkports()
LINES_COLUMNS = [
"line_id",
"circuits",
"tag_type",
"voltage",
"bus0",
"bus1",
"length",
"underground",
"under_construction",
"tag_frequency",
"dc",
"country",
"geometry",
"bounds",
]


def line_endings_to_bus_conversion(lines):
# Assign to every line a start and end point

Expand Down Expand Up @@ -720,6 +741,7 @@ def built_network(
countries_config,
geo_crs,
distance_crs,
lines_cols_standard,
force_ac=False,
):
logger.info("Stage 1/5: Read input data")
Expand Down Expand Up @@ -784,6 +806,8 @@ def built_network(
if not os.path.exists(outputs["lines"]):
os.makedirs(os.path.dirname(outputs["lines"]), exist_ok=True)

lines = lines[lines_cols_standard]

to_csv_nafix(lines, outputs["lines"]) # Generate CSV
to_csv_nafix(converters, outputs["converters"]) # Generate CSV
to_csv_nafix(transformers, outputs["transformers"]) # Generate CSV
Expand Down Expand Up @@ -819,5 +843,6 @@ def built_network(
countries,
geo_crs,
distance_crs,
lines_cols_standard=LINES_COLUMNS,
force_ac=force_ac,
)
Loading
Loading