Skip to content

expand opex statistics to include all operational costs#1195

Merged
lkstrp merged 6 commits intomasterfrom
opex-fix
Mar 31, 2025
Merged

expand opex statistics to include all operational costs#1195
lkstrp merged 6 commits intomasterfrom
opex-fix

Conversation

@fneum
Copy link
Copy Markdown
Member

@fneum fneum commented Mar 30, 2025

Closes #1185.

Changes proposed in this Pull Request

The function n.statistics.opex() now includes all operational cost
components: marginal costs, quadratic marginal costs, storage costs, spill
costs, start-up costs, shut-down costs, and stand-by costs. Previously, only
marginal costs were considered. A new parameter, cost_types, allows for selecting which cost components to include.

In this way, n.statistics.opex() + n.statistics.capex() gives total system costs (all terms from objective function. See #1183.

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

Copy link
Copy Markdown

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 pull request expands the operational expenditure calculation by incorporating all operational cost components (marginal, quadratic marginal, storage-related, spill, start-up, shut-down, and stand-by costs) into the n.statistics.opex() function with a new cost_types parameter.

  • Expanded n.statistics.opex() to conditionally include a variety of cost components.
  • Updated the function’s documentation and added comprehensive tests to verify new behaviors.
  • Adjusted the optimization objective to correctly reference quadratic cost entries.

Reviewed Changes

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

File Description
test/test_statistics.py Added test_opex() to validate the operational expenditure calculations.
pypsa/statistics/expressions.py Updated opex() to dynamically include various cost components based on cost_types.
pypsa/optimization/optimize.py Modified the cost lookup loop to reference marginal_cost_quadratic for quadratic costs.
Files not reviewed (4)
  • doc/references/release-notes.rst: Language not supported
  • pypsa/data/component_attrs/generators.csv: Language not supported
  • pypsa/data/component_attrs/links.csv: Language not supported
  • pypsa/data/variables.csv: Language not supported

@lkstrp lkstrp enabled auto-merge (squash) March 31, 2025 11:56
@lkstrp lkstrp merged commit fedbf00 into master Mar 31, 2025
22 checks passed
@lkstrp lkstrp deleted the opex-fix branch March 31, 2025 12:13
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.

n.statistics.opex() omit start-up, shut-down and quadratic marginal costs

3 participants