From b65632b5e05b131ff18883fbec434abf3d4972ce Mon Sep 17 00:00:00 2001 From: elenya-grant <116225007+elenya-grant@users.noreply.github.com> Date: Tue, 7 Apr 2026 09:54:42 -0600 Subject: [PATCH 1/3] bugfix and added test for connecting one resource model to multiple techs --- h2integrate/core/h2integrate_model.py | 2 +- h2integrate/core/test/test_framework.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/h2integrate/core/h2integrate_model.py b/h2integrate/core/h2integrate_model.py index ba1569c91..d09645e8f 100644 --- a/h2integrate/core/h2integrate_model.py +++ b/h2integrate/core/h2integrate_model.py @@ -1163,7 +1163,7 @@ def connect_technologies(self): resource_models = {} for site_grp, site_grp_inputs in self.plant_config["sites"].items(): for resource_key, resource_params in site_grp_inputs.get("resources", {}).items(): - resource_models[f"{site_grp}-{resource_key}"] = resource_params + resource_models[f"{site_grp}.{resource_key}"] = resource_params resource_source_connections = [c[0] for c in resource_to_tech_connections] # Check if there is a missing resource to tech connection or missing resource model diff --git a/h2integrate/core/test/test_framework.py b/h2integrate/core/test/test_framework.py index d9540984d..dafee19d0 100644 --- a/h2integrate/core/test/test_framework.py +++ b/h2integrate/core/test/test_framework.py @@ -324,6 +324,30 @@ def test_resource_connection_error_missing_resource(temp_dir): temp_highlevel_yaml.unlink(missing_ok=True) +@pytest.mark.unit +def test_no_resource_connection_error_resource_to_multiple_techs(temp_dir): + # Path to the original plant_config.yaml and high-level yaml in the example directory + + driver_config = load_driver_yaml(EXAMPLE_DIR / "08_wind_electrolyzer" / "driver_config.yaml") + tech_config = load_tech_yaml(EXAMPLE_DIR / "08_wind_electrolyzer" / "tech_config.yaml") + plant_config = load_plant_yaml(EXAMPLE_DIR / "08_wind_electrolyzer" / "plant_config.yaml") + # Add a second wind technology + wind_tech = tech_config["technologies"]["wind"] + tech_config["technologies"].update({"wind_plant2": wind_tech}) + resource_to_tech_connections = [ + ["site.wind_resource", "wind", "wind_resource_data"], + ["site.wind_resource", "wind_plant2", "wind_resource_data"], + ] + plant_config["resource_to_tech_connections"] = resource_to_tech_connections + input_config = { + "plant_config": plant_config, + "technology_config": tech_config, + "driver_config": driver_config, + } + H2IntegrateModel(input_config) + assert True + + @pytest.mark.unit def test_reports_turned_off(temp_dir): # Path to the original config files in the example directory From ebdd0a57ba941ac2b45d35269df19b6bb12b5957 Mon Sep 17 00:00:00 2001 From: elenya-grant <116225007+elenya-grant@users.noreply.github.com> Date: Tue, 7 Apr 2026 10:04:28 -0600 Subject: [PATCH 2/3] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64d15e4c5..9f9d5de75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - Added a storage performance baseclass model `StoragePerformanceBase` and updated the other storage performance models to inherit it [PR 624](https://github.com/NatLabRockies/H2Integrate/pull/624) - Modified the calc tilt angle function for pysam solar to support latitudes in the southern hemisphere [PR 646](https://github.com/NatLabRockies/H2Integrate/pull/646) - Added oxygen production metrics and as outputs to `ECOElectrolyzerPerformanceModel` [PR 642](https://github.com/NatLabRockies/H2Integrate/pull/642) +- Bugfix to allow for one resource to be connected to multiple technologies [PR 655](https://github.com/NatLabRockies/H2Integrate/pull/655) ## 0.7.1 [March 13, 2026] From dae5119211cf824a7fd14ce037c62061c9cfe144 Mon Sep 17 00:00:00 2001 From: John Jasa Date: Wed, 8 Apr 2026 10:13:40 -0600 Subject: [PATCH 3/3] Updated test to call setup to trigger connection error --- h2integrate/core/file_utils.py | 2 +- h2integrate/core/test/test_framework.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/h2integrate/core/file_utils.py b/h2integrate/core/file_utils.py index 73266e416..9f19d411e 100644 --- a/h2integrate/core/file_utils.py +++ b/h2integrate/core/file_utils.py @@ -143,7 +143,7 @@ def find_file(filename: str | Path, root_folder: str | Path | None = None): f"the root directory {root_folder}." ) raise ValueError( - f"Cannot find unique file: found {len(files_cwd)} files relative to cwd, " + f"Cannot find unique file for {filename}: found {len(files_cwd)} files relative to cwd, " f"{len(files_h2i)} files relative to H2Integrate root directory, " f"{len(files)} files relative to the root folder." ) diff --git a/h2integrate/core/test/test_framework.py b/h2integrate/core/test/test_framework.py index dafee19d0..e6ca140a0 100644 --- a/h2integrate/core/test/test_framework.py +++ b/h2integrate/core/test/test_framework.py @@ -344,7 +344,10 @@ def test_no_resource_connection_error_resource_to_multiple_techs(temp_dir): "technology_config": tech_config, "driver_config": driver_config, } - H2IntegrateModel(input_config) + h2i_model = H2IntegrateModel(input_config) + h2i_model.setup() + # Need to call final_setup to trigger the potential error related to the resource connections + h2i_model.prob.final_setup() assert True