diff --git a/CHANGELOG.md b/CHANGELOG.md index 073bd92a2..002bb2f9b 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) - Removed the last of the logic that was based on technology names rather than model classes [PR 654](https://github.com/NatLabRockies/H2Integrate/pull/654) ## 0.7.1 [March 13, 2026] 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/h2integrate_model.py b/h2integrate/core/h2integrate_model.py index 574ce1f49..4ae2d089a 100644 --- a/h2integrate/core/h2integrate_model.py +++ b/h2integrate/core/h2integrate_model.py @@ -1167,7 +1167,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..e6ca140a0 100644 --- a/h2integrate/core/test/test_framework.py +++ b/h2integrate/core/test/test_framework.py @@ -324,6 +324,33 @@ 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, + } + 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 + + @pytest.mark.unit def test_reports_turned_off(temp_dir): # Path to the original config files in the example directory