Skip to content

Hooking up electricity buy price and more correctly#792

Draft
johnjasa wants to merge 1 commit into
NatLabRockies:developfrom
johnjasa:issue_790
Draft

Hooking up electricity buy price and more correctly#792
johnjasa wants to merge 1 commit into
NatLabRockies:developfrom
johnjasa:issue_790

Conversation

@johnjasa

Copy link
Copy Markdown
Collaborator

Connect buy_price from technology cost models to the SLC controller

Resolves the linked issue. There were some complexities because of the flexibility afforded by grid electricity price inputs (can be a scalar, plant_life, or an 8760) as well as the feedstocks setup.

  1. Wired each cost-aware system-level controller's {tech_name}_buy_price input directly to the corresponding technology's own buy-price input via an OpenMDAO 3.44 input-to-input connection in H2IntegrateModel.add_system_level_controller, so a single prob.set_val() on (for example) plant.grid.electricity_buy_price now propagates to the SLC instead of silently using only the YAML default.
  2. The connection is created on self.model (not self.plant), because OpenMDAO 3.44 only resolves input-to-input connections registered on the top-level group; using promoted names works because the plant subgroup is added with promotes=["*"].
  3. Added a small _get_tech_buy_price_input_name helper in system_level_control_base.py (shared by both files) that returns the tech's actual input name (electricity_buy_price for Grid, price for Feedstock).
  4. Added _get_buy_price_default_and_shape so the SLC's {tech}_buy_price input is created with the same shape as the tech's input (driven by buy_price_mode for Grid; by price-array length for Feedstock). This is required because input-to-input connections need matching shapes; per-timestep, per-year, constant, and scalar configurations are all handled.
  5. Updated _buy_price_marginal_cost to broadcast scalar / per-year arrays up to n_timesteps so the existing merit-order dispatch code is unchanged.
  6. Fixed the test_slc_complex_profit_max test, which was implicitly relying on the bug (the example's grid_buy_price = sell_price + 0.02 makes grid never profitable, but the SLC was using the constant 0.06 default, which sometimes beat the sell-price spikes). The corrected assertion verifies grid is never dispatched, which is now the right behavior.

Section 1: Type of Contribution

  • Feature Enhancement
    • Framework
    • New Model
    • Updated Model
    • Tools/Utilities
    • Other (please describe):
  • Bug Fix
  • Documentation Update
  • CI Changes
  • Other (please describe):

Section 2: Draft PR Checklist

  • Open draft PR
  • Describe the feature that will be added
  • Fill out TODO list steps
  • Describe requested feedback from reviewers on draft PR
  • Complete Section 8: New Model Checklist (if applicable)

Type of Reviewer Feedback Requested (on Draft PR)

Implementation feedback:

  • _get_tech_buy_price_input_name currently recognizes electricity_buy_price (Grid) and price (Feedstock). If other techs grow buy-price inputs, this is the spot to extend. It may be worthwhile to standardize the naming now or in the future?

Other feedback:

  • N/A

Section 3: General PR Checklist

  • PR description thoroughly describes the new feature, bug fix, etc.
  • Added tests for new functionality or bug fixes
  • Tests pass (If not, and this is expected, please elaborate in the Section 6: Test Results)
  • Documentation
    • Docstrings are up-to-date
    • Related docs/ files are up-to-date, or added when necessary
    • Documentation has been rebuilt successfully
    • Examples have been updated (if applicable)
  • CHANGELOG.md
    • At least one complete sentence has been provided to describe the changes made in this PR
    • After the above, a hyperlink has been provided to the PR using the following format:
      "A complete thought. PR XYZ", where
      XYZ should be replaced with the actual number.

Section 4: Related Issues

Fully resolves #790

Section 5: Impacted Areas of the Software

Section 5.1: New Files

  • N/A

Section 5.2: Modified Files

  • h2integrate/core/h2integrate_model.py adds the input-to-input connection for cost_per_tech: buy_price techs and updates the relevant docstring.
  • h2integrate/control/control_strategies/system_level/system_level_control_base.py adds the two helpers, sizes the SLC {tech}_buy_price input to match the tech, and broadcasts in _buy_price_marginal_cost.
  • h2integrate/control/control_strategies/system_level/test/test_slc_examples.py replaces the buggy "grid used when needed" assertion with the now-correct "grid not dispatched when always unprofitable" check.

Section 6: Additional Supporting Information

The user explicitly requested using the OpenMDAO 3.44 input-to-input connection feature here. The 25 unit tests in test_slc_controllers.py keep using set_val("slc.{tech}_buy_price", ...) because those tests instantiate the SLC component in isolation (no tech subgroup to connect from), so they validate the controller behavior independently of the new wiring.

Section 7: Test Results, if applicable

N/A

Section 8 (Optional): New Model Checklist

N/A

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.

1 participant