Skip to content

Removed remaining naming dependencies#654

Merged
johnjasa merged 4 commits intoNatLabRockies:developfrom
johnjasa:remove_last_name_dependence
Apr 7, 2026
Merged

Removed remaining naming dependencies#654
johnjasa merged 4 commits intoNatLabRockies:developfrom
johnjasa:remove_last_name_dependence

Conversation

@johnjasa
Copy link
Copy Markdown
Collaborator

@johnjasa johnjasa commented Apr 6, 2026

Use model class instead of tech name to skip no-cost technologies in finance connections

Previously, the finance connection logic in connect_technologies used string-based checks on the technology name (e.g., "splitter" in tech_name, tech_name == "cable") to decide which technologies to skip when connecting CapEx/OpEx/VarOpEx to finance subgroups. This was fragile because renaming a technology could silently break the skip logic.

Now the code looks up each technology's performance_model.model from the tech config and checks it against a set of known no-cost model classes. This decouples the behavior from naming conventions.

no_cost_models = {
    "GenericSplitterPerformanceModel",
    "GenericCombinerPerformanceModel",
    "GasStreamCombinerPerformanceModel",
    "CablePerformanceModel",
    "PipePerformanceModel",
}

for tech_name in tech_configs.keys():
    perf_model = tech_configs[tech_name].get("performance_model").get("model")
    if perf_model in no_cost_models:
        continue

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: 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 3: Related Issues

Fully resolved #374

Section 4: Impacted Areas of the Software

Section 4.1: New Files

N/A

Section 4.2: Modified Files

  • h2integrate/core/h2integrate_model.py
    • connect_technologies: Replaced name-based "splitter"/"combiner"/"cable"/"pipe" string checks with a lookup against no_cost_models using the technology's configured model class.

Section 5: Additional Supporting Information

N/A

Section 6: Test Results, if applicable

N/A

Section 7 (Optional): New Model Checklist

N/A

@johnjasa johnjasa requested a review from elenya-grant April 6, 2026 21:57
Copy link
Copy Markdown
Collaborator

@elenya-grant elenya-grant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR John! I had a few small questions but thanks for making this PR to finally remove all naming-specific logic!

continue
if tech_name == "cable" or tech_name == "pipe":
# Skip technologies whose models doesn't add costs
perf_model = tech_configs[tech_name].get("performance_model").get("model")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would using dictionary defaults prevent issues in case a technology (maybe not one that exists now) has a cost model but not a performance model?

perf_model = tech_configs[tech_name].get("performance_model", {}).get("model", None)

Copy link
Copy Markdown
Collaborator Author

@johnjasa johnjasa Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good consideration. This would avoid issues in the future for models that don't necessarily exist now, but it may also obfuscate the issue. Or at least I'd want to catch it sooner than this (connection time). So based on this comment, I've added required: [performance_model] to the tech_schema.yaml to require models there and do the checking.

Copy link
Copy Markdown
Collaborator

@elenya-grant elenya-grant Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay - I think requiring the performance model makes sense for now (I was spooked when you said performance and cost model since splitters and combiners can be defined in the tech config but don't have an associated cost model). Thanks for explaining!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I underthought it at first and thought we could require both but you're exactly right!

)

# Model classes that do not contribute costs to the finance stackup
no_cost_models = {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you extend this comment to mention that these models are like "internal models" so that's why they don't contribute to the costs for the finance modeling?

no_cost_models = {
"GenericSplitterPerformanceModel",
"GenericCombinerPerformanceModel",
"GasStreamCombinerPerformanceModel",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you put these in h2integrate_model.py instead of supported_models.py? I almost think that I'd be nice to have these in supported models so its a bit more "upfront" than buried within a class method but I'd love to hear your reasoning

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love your suggestion! That makes total sense. I didn't have a great reason for putting them here; I think with your suggestion, we'll also have a good setup for other similar groupings. Will change it now, thank you!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! Love that this file can be removed!

@johnjasa johnjasa added the ready for review This PR is ready for input from folks label Apr 7, 2026
@elenya-grant elenya-grant self-requested a review April 7, 2026 18:06
Copy link
Copy Markdown
Collaborator

@elenya-grant elenya-grant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making these changes!

@johnjasa johnjasa merged commit a4210f1 into NatLabRockies:develop Apr 7, 2026
5 checks passed
@johnjasa johnjasa deleted the remove_last_name_dependence branch April 7, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review This PR is ready for input from folks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants