Skip to content

Allow country-specific district heating potentials#1742

Merged
fneum merged 4 commits intomasterfrom
country-dh-pot
Jul 11, 2025
Merged

Allow country-specific district heating potentials#1742
fneum merged 4 commits intomasterfrom
country-dh-pot

Conversation

@cpschau
Copy link
Copy Markdown
Contributor

@cpschau cpschau commented Jul 7, 2025

Changes proposed in this Pull Request

This PR extends the sector:district_heating:potential config parameter to accept either a single float (as before) or a dictionary with country-specific district heating potentials.

  • Default behavior: If no dictionary is provided, the parameter remains a float (default: 0.6).

  • Country-specific potentials: Users can supply a dictionary mapping country codes to potential values:

    • For partial coverage, the dictionary must include:

      • country codes for countries with specific potentials
      • a 'default' key for all other countries as a fallback value
    • For full coverage, the dictionary must contain a value for each country code in the model.

Testing

Using config.default.yaml the following scenarios:

country_specific:
  scenario:
    clusters:
      - 39
  countries:
    - DE
    - DK
  clustering:
    temporal:
      resolution_sector: 365h
  sector:
    district_heating:
      potential:
        DE: 0.3
        default: 0.9

uniform:
  scenario:
    clusters:
      - 39
  countries:
    - DE
    - DK
  clustering:
    temporal:
      resolution_sector: 365h

Screenshot from 2025-07-08 13-51-42

Checklist

  • I tested my contribution locally and it works as intended.
  • Code and workflow changes are sufficiently documented.
  • Changes in configuration options are added in config/config.default.yaml.
  • Changes in configuration options are documented in doc/configtables/*.csv.
  • A release note doc/release_notes.rst is added.

@cpschau cpschau requested a review from amos-schledorn July 7, 2025 15:29
Copy link
Copy Markdown
Member

@fneum fneum left a comment

Choose a reason for hiding this comment

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

LGTM

@amos-schledorn amos-schledorn requested a review from Copilot July 10, 2025 09:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends the district_heating: potential configuration to accept either a float or a country-specific dictionary with an optional default fallback.

  • Adds logic to detect and apply dictionary-based potentials, filling missing countries with a required default value.
  • Maps the resulting per-country potentials onto each node’s population layout.
  • Updates documentation tables and release notes to describe the new config option.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
scripts/build_district_heat_share.py Add branch to handle dict-typed potential, enforce default, and map per-country values
doc/release_notes.rst Note support for dictionary-based district heating potentials
doc/configtables/sector.csv Update the potential config table entry to mention dict support
Comments suppressed due to low confidence (3)

scripts/build_district_heat_share.py:69

  • Consider adding unit tests covering the new dictionary-based branch, including cases for full country mappings, missing default raising a ValueError, and correct fallback behavior to ensure this logic is exercised.
    if isinstance(central_fraction, dict):

doc/release_notes.rst:14

  • [nitpick] The release note could also mention that supplying a partial mapping requires a default key for unspecified countries and describe the fallback behavior to make it fully clear to users.
* Allow district heating potentials to be optionally specified as a dictionary as an alternative to a float, with country codes as keys of the parameter `district_heating: potential`.

doc/configtables/sector.csv:11

  • [nitpick] The indentation for the potential entry was changed from three hyphens to two; please align it with the existing hierarchical dash conventions in this CSV to maintain consistency and parsing correctness.
-- potential,--,Dictionary with country codes as keys or float.,"Maximum fraction of urban demand which can be supplied by district heating. If given as dictionary, specify one value per country modeled or provide a default value with key `default` to fill values for all unspecified countries."

Copy link
Copy Markdown
Contributor

@amos-schledorn amos-schledorn left a comment

Choose a reason for hiding this comment

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

Looks great! I'd just suggest adding some comments to explain the logic

@cpschau cpschau requested a review from amos-schledorn July 10, 2025 14:19
@fneum fneum merged commit 06cc0ad into master Jul 11, 2025
4 of 5 checks passed
@fneum fneum deleted the country-dh-pot branch July 11, 2025 07:19
toniseibold pushed a commit that referenced this pull request Dec 1, 2025
* allow country-specific district heating potentials

* fix: handle missing district heating potential for countries

* docs: add comments to enhance comprehensibility

---------

Co-authored-by: cpschau <[email protected]>
Co-authored-by: Fabian Neumann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants