Hooking up electricity buy price and more correctly#792
Draft
johnjasa wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connect
buy_pricefrom technology cost models to the SLC controllerResolves the linked issue. There were some complexities because of the flexibility afforded by grid electricity price inputs (can be a scalar,
plant_life, or an 8760) as well as the feedstocks setup.{tech_name}_buy_priceinput directly to the corresponding technology's own buy-price input via an OpenMDAO 3.44 input-to-input connection inH2IntegrateModel.add_system_level_controller, so a singleprob.set_val()on (for example)plant.grid.electricity_buy_pricenow propagates to the SLC instead of silently using only the YAML default.self.model(notself.plant), because OpenMDAO 3.44 only resolves input-to-input connections registered on the top-level group; using promoted names works because the plant subgroup is added withpromotes=["*"]._get_tech_buy_price_input_namehelper insystem_level_control_base.py(shared by both files) that returns the tech's actual input name (electricity_buy_pricefor Grid,pricefor Feedstock)._get_buy_price_default_and_shapeso the SLC's{tech}_buy_priceinput is created with the same shape as the tech's input (driven bybuy_price_modefor Grid; by price-array length for Feedstock). This is required because input-to-input connections need matching shapes; per-timestep, per-year, constant, and scalar configurations are all handled._buy_price_marginal_costto broadcast scalar / per-year arrays up ton_timestepsso the existing merit-order dispatch code is unchanged.test_slc_complex_profit_maxtest, which was implicitly relying on the bug (the example'sgrid_buy_price = sell_price + 0.02makes grid never profitable, but the SLC was using the constant0.06default, which sometimes beat the sell-price spikes). The corrected assertion verifies grid is never dispatched, which is now the right behavior.Section 1: Type of Contribution
Section 2: Draft PR Checklist
Type of Reviewer Feedback Requested (on Draft PR)
Implementation feedback:
_get_tech_buy_price_input_namecurrently recognizeselectricity_buy_price(Grid) andprice(Feedstock). If other techs grow buy-price inputs, this is the spot to extend. It may be worthwhile to standardize the naming now or in the future?Other feedback:
Section 3: General PR Checklist
docs/files are up-to-date, or added when necessaryCHANGELOG.md"A complete thought. PR XYZ", where
XYZshould be replaced with the actual number.Section 4: Related Issues
Fully resolves #790
Section 5: Impacted Areas of the Software
Section 5.1: New Files
Section 5.2: Modified Files
h2integrate/core/h2integrate_model.pyadds the input-to-input connection forcost_per_tech: buy_pricetechs and updates the relevant docstring.h2integrate/control/control_strategies/system_level/system_level_control_base.pyadds the two helpers, sizes the SLC{tech}_buy_priceinput to match the tech, and broadcasts in_buy_price_marginal_cost.h2integrate/control/control_strategies/system_level/test/test_slc_examples.pyreplaces the buggy "grid used when needed" assertion with the now-correct "grid not dispatched when always unprofitable" check.Section 6: Additional Supporting Information
The user explicitly requested using the OpenMDAO 3.44 input-to-input connection feature here. The 25 unit tests in
test_slc_controllers.pykeep usingset_val("slc.{tech}_buy_price", ...)because those tests instantiate the SLC component in isolation (no tech subgroup to connect from), so they validate the controller behavior independently of the new wiring.Section 7: Test Results, if applicable
N/A
Section 8 (Optional): New Model Checklist
N/A