You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow for connections including slice specifications (#774)
* move tests for split indices
* revert obsolete changes to plant schema
* fix bugs in length 3 connections for src_indices
* remove use of eval
* add ValueError for non-zero destination slice starts
* allow for src_indices tiling into destination
* update wind solar electrolyzer example to demonstrate different finance and connection approaches
* add tests for each finance/connection approach added to wind solar electrolyzer example
* add documentation for variable slicing in technology connections
* update changelog
* fix typo
* Update docs/user_guide/connecting_technologies.md
improve comment
Co-authored-by: elenya-grant <116225007+elenya-grant@users.noreply.github.com>
---------
Co-authored-by: elenya-grant <116225007+elenya-grant@users.noreply.github.com>
- Added capability to specify demand technology for system-level control, and renamed the framework-derived system-level control classification dict from `slc_config` to `slc_topology` to distinguish it from the user-authored `control_parameters` block. [PR 784](https://github.com/NatLabRockies/H2Integrate/pull/784)
60
+
- Add support for slice notation in technology connections to allow users to connect between variables of different shapes. [PR 774](https://github.com/NatLabRockies/H2Integrate/pull/774)
Copy file name to clipboardExpand all lines: docs/user_guide/connecting_technologies.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,31 @@ There are two connection formats:
61
61
The `source_parameter` and `destination_parameter` should be input into the array as another array. If it's input as a tuple the model will raise an error.
62
62
```
63
63
64
+
##### Slice notation for mismatched shapes
65
+
66
+
3-element connections with different shared parameter names allow the user to append a NumPy-style slice in square brackets to the source and/or destination parameter name.
67
+
This is used to connect variables whose shapes differ, for example feeding a scalar finance output into a per-timestep input.
68
+
The slice is parsed into OpenMDAO `src_indices`, and the bracketed text is stripped from the parameter name before the connection is made.
69
+
70
+
```yaml
71
+
technology_interconnections: [
72
+
# select a subset of the source to connect to the destination
-**Source only** (`"source_param[0:100]"`): the slice selects source indices directly (supports start/stop/step, e.g. `[0:100:2]`, and `[:]` for the full range).
82
+
-**Destination only** or **both sides equal**: no `src_indices` are applied (the slice is treated as documentation of the target shape).
83
+
-**Both sides** (`"LCOE[0]"` → `"electricity_buy_price[0:8760]"`): the source indices are *tiled* to fill the destination length. A single index is repeated (e.g. `[0]` → 8760 copies) and a multi-index source such as `[0,1]` is cycled to fill the destination.
84
+
85
+
```{note}
86
+
When the destination has a slice, it must (1) start at `0` (a non-zero start raises a `ValueError`) and (2) include the destination length, e.g. `[0:8760]`. The length is required because the input shape is not known until `prob.setup()` has run.
87
+
```
88
+
64
89
### Internal connection logic
65
90
66
91
H2Integrate processes these connections in the `connect_technologies()` method of `h2integrate_model.py`. Here's what happens internally:
depr_period: 5# 5 years - for clean energy facilities as specified by the IRS MACRS schedule https://www.irs.gov/publications/p946#en_US_2020_publink1000107507
62
84
refurb: [0.]
63
85
finance_subgroups:
86
+
# Upstream electricity finance group: levelized cost of the wind + solar
87
+
# electricity. Its LCOE output feeds Approaches B and C below.
64
88
electricity:
65
89
commodity: electricity
66
90
commodity_stream: combiner # use the total electricity output from the combiner for the finance calc
67
91
technologies: [wind, solar]
92
+
# Approach A - "same finance model": wind + solar + electrolyzer are all
93
+
# financed together, so the renewable capital is embedded directly in the LCOH.
68
94
hydrogen:
69
95
commodity: hydrogen
70
96
commodity_stream: electrolyzer
71
97
technologies: [wind, solar, electrolyzer]
98
+
# Approach B - "upstream LCOE feedstock": only the electrolyzer capital plus the
99
+
# purchased-electricity cost (electricity_feedstock priced at the LCOE above)
100
+
# are financed here. This should give an LCOH close to Approach A.
0 commit comments