|
11 | 11 | from h2integrate.core.utilities import create_xdsm_from_config |
12 | 12 | from h2integrate.core.dict_utils import check_inputs |
13 | 13 | from h2integrate.core.file_utils import get_path, find_file, load_yaml |
14 | | -from h2integrate.finances.finances import AdjustedCapexOpexComp |
| 14 | +from h2integrate.finances.finances import AdjustedCapexOpexComp, AdjustedCapacityFactorComp |
15 | 15 | from h2integrate.core.supported_models import ( |
16 | 16 | no_cost_models, |
17 | 17 | supported_models, |
@@ -798,7 +798,6 @@ def create_finance_model(self): |
798 | 798 | ) |
799 | 799 | tech_names = subgroup_params.get("technologies") |
800 | 800 | commodity_stream = subgroup_params.get("commodity_stream", None) |
801 | | - |
802 | 801 | if isinstance(finance_group_names, str): |
803 | 802 | finance_group_names = [finance_group_names] |
804 | 803 |
|
@@ -839,9 +838,16 @@ def create_finance_model(self): |
839 | 838 | "commodity": commodity, |
840 | 839 | "commodity_stream": commodity_stream, |
841 | 840 | "is_system_finance_model": True, |
| 841 | + "use_commodity_stream_timeseries": subgroup_params.get( |
| 842 | + "use_commodity_stream_timeseries", False |
| 843 | + ), |
| 844 | + "commodity_stream_output": subgroup_params.get( |
| 845 | + "commodity_stream_output", None |
| 846 | + ), |
842 | 847 | } |
843 | 848 | } |
844 | 849 | ) |
| 850 | + |
845 | 851 | finance_subgroup = om.Group() |
846 | 852 |
|
847 | 853 | # Default logic for handling cases without specified commodity streams |
@@ -1002,6 +1008,24 @@ def create_finance_model(self): |
1002 | 1008 | # uniquely named outputs |
1003 | 1009 | commodity_output_desc = commodity_output_desc + f"_{finance_group_name}" |
1004 | 1010 |
|
| 1011 | + if finance_subgroups[subgroup_name]["use_commodity_stream_timeseries"]: |
| 1012 | + if ( |
| 1013 | + finance_subgroups[subgroup_name].get("commodity_stream_output", None) |
| 1014 | + is None |
| 1015 | + ): |
| 1016 | + msg = ( |
| 1017 | + "`commodity_stream_output` is a required input if " |
| 1018 | + f"`use_commodity_stream_timeseries` is True. Please add the " |
| 1019 | + f"`commodity_stream_output` for finance subgroup `{subgroup_name}`" |
| 1020 | + ) |
| 1021 | + raise ValueError(msg) |
| 1022 | + |
| 1023 | + adj_cf_comp = AdjustedCapacityFactorComp( |
| 1024 | + plant_config=filtered_plant_config, |
| 1025 | + commodity_type=commodity, |
| 1026 | + ) |
| 1027 | + finance_subgroup.add_subsystem("adjusted_cf_comp", adj_cf_comp, promotes=["*"]) |
| 1028 | + |
1005 | 1029 | # create the finance component |
1006 | 1030 | fin_comp = fin_model( |
1007 | 1031 | driver_config=self.driver_config, |
@@ -1298,17 +1322,24 @@ def connect_technologies(self): |
1298 | 1322 | is_system_finance_model = group_configs.get("is_system_finance_model") |
1299 | 1323 |
|
1300 | 1324 | if is_system_finance_model: |
1301 | | - # Connect the rated commodity production and capacity factor |
1302 | | - # for system-level finance models |
1303 | | - self.plant.connect( |
1304 | | - f"{commodity_stream}.rated_{primary_commodity_type}_production", |
1305 | | - f"finance_subgroup_{group_id}.rated_{primary_commodity_type}_production", |
1306 | | - ) |
| 1325 | + if group_configs.get("use_commodity_stream_timeseries", False): |
| 1326 | + # TODO: finish this logic |
| 1327 | + self.plant.connect( |
| 1328 | + f"{commodity_stream}.{group_configs.get('commodity_stream_output')}", |
| 1329 | + f"finance_subgroup_{group_id}.{primary_commodity_type}_produced", |
| 1330 | + ) |
| 1331 | + else: |
| 1332 | + # Connect the rated commodity production and capacity factor |
| 1333 | + # for system-level finance models |
| 1334 | + self.plant.connect( |
| 1335 | + f"{commodity_stream}.rated_{primary_commodity_type}_production", |
| 1336 | + f"finance_subgroup_{group_id}.rated_{primary_commodity_type}_production", |
| 1337 | + ) |
1307 | 1338 |
|
1308 | | - self.plant.connect( |
1309 | | - f"{commodity_stream}.capacity_factor", |
1310 | | - f"finance_subgroup_{group_id}.capacity_factor", |
1311 | | - ) |
| 1339 | + self.plant.connect( |
| 1340 | + f"{commodity_stream}.capacity_factor", |
| 1341 | + f"finance_subgroup_{group_id}.capacity_factor", |
| 1342 | + ) |
1312 | 1343 |
|
1313 | 1344 | # Only connect technologies that are included in the finance stackup |
1314 | 1345 | for tech_name in tech_configs.keys(): |
|
0 commit comments