Skip to content

Commit

Permalink
Merge pull request #889 from PyPSA/read-solver-threads
Browse files Browse the repository at this point in the history
correctly read number of solver threads in rule definition
  • Loading branch information
fneum authored Jan 23, 2024
2 parents 9f05558 + eeb3d07 commit 2932167
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Upcoming Release

* Cluster residential and services heat buses by default. Can be disabled with ``cluster_heat_buses: false``.

* Bugfix: Correctly read out number of solver threads from configuration file.

PyPSA-Eur 0.9.0 (5th January 2024)
==================================
Expand Down
7 changes: 7 additions & 0 deletions rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ for path in helper_source_path:
from _helpers import validate_checksum


def solver_threads(w):
solver_options = config["solving"]["solver_options"]
option_set = config["solving"]["solver"]["options"]
threads = solver_options[option_set].get("threads", 4)
return threads


def memory(w):
factor = 3.0
for o in w.opts.split("-"):
Expand Down
2 changes: 1 addition & 1 deletion rules/solve_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rule solve_network:
+ "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_python.log",
benchmark:
BENCHMARKS + "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}"
threads: 4
threads: solver_threads
resources:
mem_mb=memory,
walltime=config["solving"].get("walltime", "12:00:00"),
Expand Down
2 changes: 1 addition & 1 deletion rules/solve_myopic.smk
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ rule solve_sector_network_myopic:
+ "elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}_solver.log",
python=LOGS
+ "elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}_python.log",
threads: 4
threads: solver_threads
resources:
mem_mb=config["solving"]["mem"],
walltime=config["solving"].get("walltime", "12:00:00"),
Expand Down
4 changes: 1 addition & 3 deletions rules/solve_overnight.smk
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ rule solve_sector_network:
+ "logs/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}_memory.log",
python=RESULTS
+ "logs/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}_python.log",
threads: config["solving"]["solver_options"][config["solving"]["solver"]["options"]].get(
"threads", 4
)
threads: solver_threads
resources:
mem_mb=config["solving"]["mem"],
walltime=config["solving"].get("walltime", "12:00:00"),
Expand Down
2 changes: 1 addition & 1 deletion rules/solve_perfect.smk
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ rule solve_sector_network_perfect:
output:
RESULTS
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
threads: 4
threads: solver_threads
resources:
mem_mb=config["solving"]["mem"],
shadow:
Expand Down

0 comments on commit 2932167

Please sign in to comment.