Skip to content

Removed is_electricity_producer#785

Closed
johnjasa wants to merge 5 commits into
NatLabRockies:developfrom
johnjasa:remove_electricity_producer
Closed

Removed is_electricity_producer#785
johnjasa wants to merge 5 commits into
NatLabRockies:developfrom
johnjasa:remove_electricity_producer

Conversation

@johnjasa

@johnjasa johnjasa commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Remove is_electricity_producer and make finance components commodity-agnostic

Previously, the finance components (ProFastBase / ProFastLCO / ProFastNPV and NumpyFinancialNPV) inspected commodity_type to decide whether to use electricity units (kW, kWh, USD/(kW*h)) or mass units (kg/h, kg, USD/kg). A helper named is_electricity_producer was also used in H2IntegrateModel.create_finance_model to special-case detection of the commodity-stream technology when the user did not specify one for an electricity finance subgroup.

This PR removes that electricity-specific logic from the finance layer so the finance components only know about units, not commodities, and the model-build layer is responsible for selecting the correct units when constructing finance components.

Finance components

ProFastBase and NumpyFinancialNPV now expose three explicit unit options:

self.options.declare("commodity_rate_units", default="kg/h", ...)
self.options.declare("commodity_amount_units", default="kg", ...)
self.options.declare("price_units", default="USD/kg", ...)

H2IntegrateModel.create_finance_model

  • Removed the import of is_electricity_producer
  • The previous if commodity == "electricity" branch is gone
  • A new default_commodity_units mapping near fin_comp creation supplies electricity-specific defaults (kW / kWh / USD/(kW*h)) and falls back to mass defaults for any other commodity

H2IntegrateModel.create_technology_models

  • Added self.tech_perf_models: dict[str, om.System], populated as each tech group is built, so other model-build steps can look up a tech's performance-model component directly by tech_name rather than having to walk the OpenMDAO subsystem tree.

commodity_stream_definitions.py

  • Removed the is_electricity_producer function and its module-docstring item.
  • Removed test_is_electricity_producer.

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)

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]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
      XYZ should be replaced with the actual number.

Section 4: Related Issues

Resolves #604

Section 5: Impacted Areas of the Software

Section 5.1: New Files

  • N/A

Section 5.2: Modified Files

A lot!

Section 6: Additional Supporting Information

This change is behavior-preserving for users who build models through H2IntegrateModel with the standard YAML configuration: electricity finance subgroups still default to kW / kWh / USD/(kW*h), mass-commodity subgroups still default to kg/h / kg / USD/kg, and default commodity-stream detection still finds the same producer technologies (now identified by the model's own commodity attribute rather than a hard-coded prefix table).

Section 7: Test Results, if applicable

  • h2integrate/core/test/ and h2integrate/finances/test/: 67 passed locally.
  • Full unit and regression suites still to be run in CI.

@johnjasa johnjasa requested a review from elenya-grant June 17, 2026 19:57
@johnjasa johnjasa marked this pull request as ready for review June 18, 2026 14:58
@johnjasa johnjasa requested review from elenya-grant and removed request for elenya-grant June 18, 2026 19:27
@johnjasa johnjasa marked this pull request as draft June 18, 2026 19:49
@johnjasa johnjasa added the on hold This PR is waiting on some other things before it can come in / is not the top priority currently label Jun 18, 2026
@johnjasa

Copy link
Copy Markdown
Collaborator Author

Waiting on #786 to pass and come in, then I'll revamp this

@johnjasa

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #786 once I update it a bit

@johnjasa johnjasa closed this Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on hold This PR is waiting on some other things before it can come in / is not the top priority currently

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant