Skip to content

Added more expansive feedstock tests for SLC#793

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

Added more expansive feedstock tests for SLC#793
johnjasa wants to merge 1 commit into
NatLabRockies:developfrom
johnjasa:more_feedstock_slc_tests

Conversation

@johnjasa

@johnjasa johnjasa commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Add tests for multi-feedstock handling in the system-level controller

  1. Verified that the existing cost_per_tech: feedstock logic in SystemLevelControlBase already discovers all upstream feedstocks via nx.ancestors (any graph depth) and sums their first-year VarOpEx values when computing the dispatchable technology's marginal cost. No code changes were required.
  2. Added three new unit tests in test_slc_controllers.py to lock in this behavior against the fuel-cell scenario in the issue (a dispatchable consuming both hydrogen and oxygen as feedstocks):
    • test_feedstock_fuel_cell_h2_o2 exercises a fuel cell with H2 and O2 feedstocks under CostMinimizationControl and checks that the combined feedstock cost yields full dispatch.
    • test_feedstock_multiple_sum_not_average pins the marginal-cost combination to a sum (not a mean) by selecting VarOpEx values where the summed cost is just above the sell price; averaging would incorrectly dispatch the tech.
    • test_feedstock_indirect_upstream connects one feedstock directly and another through an intermediate combiner, verifying that the ancestor-based discovery sees both.

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): test coverage additions

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)

Structural feedback:

  • N/A

Implementation feedback:

  • N/A

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 #789

Section 5: Impacted Areas of the Software

Section 5.1: New Files

  • N/A

Section 5.2: Modified Files

  • h2integrate/control/control_strategies/system_level/test/test_slc_controllers.py - adds three multi-feedstock tests covering the fuel cell H2+O2 case, sum-vs-average correctness, and indirect graph ancestry.

Section 6: Additional Supporting Information

The existing test_feedstock_multiple already covered a 2-feedstock summation case with generic names, but we now cover the fuel-cell H2+O2 scenario plus assurance that the summation is correct under conditions where averaging would change the outcome. The new tests address both.

Section 7: Test Results, if applicable

$ python -m pytest h2integrate/control/control_strategies/system_level/test/test_slc_controllers.py -q
28 passed in 0.58s

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