Running Scenarios with run_scenarios.py
The run_scenarios.py script is a command-line utility designed to streamline the process of running various scenarios for your project. It allows you to select base configurations, specific scenarios, and execution profiles (e.g., for local CPU usage or a computer cluster).
How it Works
The script guides you through a series of interactive prompts to configure your run:
- Select Project Configuration: You first choose the project configuration file (e.g.,
config/config.go.yaml) that defines the default settings for your project. - Select Scenario Configuration: Next, you select a scenario configuration file (e.g.,
config/scenarios.go.yaml) which contains different predefined scenarios. - Choose Scenarios: From the selected scenario configuration, you pick one or more specific scenarios you want to execute.
- Select Execution Profile: Finally, you decide whether to run the scenarios on a computer cluster (using
--profile slurm) or locally, specifying the number of CPUs to utilize.
Once all selections are made, the script dynamically updates a temporary configuration file, executes a snakemake command with the chosen parameters, and then cleans up the temporary file.
Steps to Create and Run Scenarios
To effectively use the run_scenarios.py script, follow these steps:
1. Activate Your Environment
Activate the conda environment as described in Installation
$ conda activate pypsa-eur
2. Define Your Project Configuration
Create a base configuration file in the config/ directory. This file should be named following the pattern config*.yaml (e.g., config/config.go.yaml). It will contain the default settings for your project.
# config/config.go.yaml
# Example of settings
foresight: myopic
scenario:
clusters:
- 39
opts:
- ''
sector_opts:
- ''
planning_horizons:
- 2025
- 2030
- 2035
- 2040
3. Define Your Scenarios
Create a scenario configuration file in the config/ directory. This file should be named following the pattern scenarios*.yaml (e.g., config/scenarios.go.yaml). Each top-level key in this file represents a distinct scenario, and its value will be merged into the base configuration.
# 1) Baseline
baseline:
enable:
certificate: false
# 2) C&I 50%, energy matching
energy-match-50:
certificate:
new_demand:
enable: true
participant: ci
energy_matching: 50
hourly_matching: 0
4. Run the Scenario Script
Navigate to the root directory of your project in the terminal and execute the run_scenarios.py script:
python run_scenarios.py
The script will then prompt you to:
- Select a base configuration: Choose from the
config/config*.yamlfiles. - Select a scenario configuration: Choose from the
config/scenarios*.yamlfiles. - Select a scenario: You can select one or more scenarios from the list presented. After each selection, you will be asked if you want to add more runs.
- Specify execution profile: Indicate whether you are running on a computer cluster (
y) or locally (n). If local, you can specify the number of CPUs to use (e.g.,allor a specific number).
4. Review Results
The script will execute the snakemake command for each selected scenario, dynamically applying the configurations. Monitor your terminal for output and results generated by the snakemake workflow.