Skip to content

Conversation

@kim-mskw
Copy link
Contributor

@kim-mskw kim-mskw commented Dec 10, 2025

Related Issue

Closes #688

Description

This PR fixes unintuitive redispatch results when using nodal market design with complex_clearing. In the current implementation, complex_clearing behaves as a transport model based on NTCs and ignores line reactances x, even if they are present in lines.csv. As a result, the market clearing can produce dispatch patterns that are infeasible for the underlying PyPSA grid model, which then shows up as large redispatch needs and even unmet demand in the subsequent simulation.

Changes in this PR

  • Warning for complex_clearing

    • When complex_clearing is used and a column x is present in lines.csv, a warning is issued that the underlying transport model does not take grid physics (reactances) into account.
  • New nodal clearing with physics-based grid representation

    • Introduces a nodal clearing that:
      • Uses line reactances and a PTDF-based formulation (via PyPSA’s OPF).
      • Formulates nodal energy balances for non-slack buses plus a system-wide balance, ensuring physical feasibility of dispatch and flows.
    • For example_01d this new nodal clearing produces feasible dispatch and flows without additional redispatch (storage tests still pending).
  • Direct extraction of dispatched bids

    • Adds a code path to extract accepted bids directly from the optimization model, avoiding the LMP-based reconstruction of dispatch.

Checklist

  • Documentation updated (docstrings, READMEs, user guides, inline comments, doc folder updates etc.)
  • New unit/integration tests added (if applicable)
  • Changes noted in release notes (if any)
  • Consent to release this PR's code under the GNU Affero General Public License v3.0

@kim-mskw kim-mskw linked an issue Dec 10, 2025 that may be closed by this pull request
@kim-mskw
Copy link
Contributor Author

nodal clearing is now logging flows :)

@kim-mskw kim-mskw requested a review from gugrimm December 12, 2025 10:15
@gugrimm
Copy link
Contributor

gugrimm commented Dec 22, 2025

@kim-mskw Everything ready. Just waiting for the tests.
Here is the docu: https://assume--703.org.readthedocs.build/en/703/market_mechanism.html

@gugrimm gugrimm marked this pull request as ready for review December 22, 2025 15:35
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 73.51351% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.62%. Comparing base (0e2aa1a) to head (4a7a4d1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...sume/markets/clearing_algorithms/nodal_clearing.py 70.55% 48 Missing ⚠️
assume/scenario/loader_csv.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #703      +/-   ##
==========================================
+ Coverage   81.27%   81.62%   +0.35%     
==========================================
  Files          54       55       +1     
  Lines        8046     8225     +179     
==========================================
+ Hits         6539     6714     +175     
- Misses       1507     1511       +4     
Flag Coverage Δ
pytest 81.62% <73.51%> (+0.35%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kim-mskw kim-mskw merged commit 108455a into main Dec 23, 2025
8 of 9 checks passed
@kim-mskw kim-mskw deleted the redispacth_and_nodal_pricing_bug branch December 23, 2025 12:53
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.

Unintuative Redispatch Behavior

3 participants