Bugfix: Update storage models so can use different control types per storage type#615
Bugfix: Update storage models so can use different control types per storage type#615elenya-grant wants to merge 5 commits intoNatLabRockies:developfrom
Conversation
genevievestarke
left a comment
There was a problem hiding this comment.
Ok, so you're breaking the previous if/else into two if statements, based on whether feedback control is used or not, correct?
Could you just take away the "break" part of the loop? I'm assuming not, because the if loop will still be triggered by the pyomo tech to dispatch connection?
jaredthomas68
left a comment
There was a problem hiding this comment.
The logic here seems a little brittle. I'm ok with it for now, but if we keep the logic as is, can you make a test or two (one for each option in the logic maybe)?
One possible fix for the logic is to have a list of controllers that are or are not feedback controllers, or that do or do not need the electricity_set_point input. I don't really like that idea though because it is hard to maintain (like electricity_producing_techs).
Just to clarify, I think tests are always important, but particularly in bug fixes. |
| @@ -306,8 +309,10 @@ def setup(self): | |||
| ]: | |||
| if any(intended_dispatch_tech in name for name in self.tech_group_name): | |||
There was a problem hiding this comment.
I understand that this isn't the point of this PR but it illuminated to me that we have some weird logic in the plant_config. I vote that we potentially make an issue about it.
I think it's ambiguous that it says "tech_to_dispatch_connections" but excludes the open-loop controllers. I vote either we update this name to be more clear that this isn't used for open loop dispatch or we add all dispatch to the "tech_to_dispatch_connections". We also need to spell this out in documentation. It's currently not included.
There was a problem hiding this comment.
Thanks for adding all these tests! Great to see all the different combinations :)
johnjasa
left a comment
There was a problem hiding this comment.
Thanks for these changes! I think it's a step in a great direction. I appreciate you already adding tests based on Jared's feedback. I do think Kaitlin's suggestion for creating an issue for the tech_to_dispatch_connections is useful and reveals a gap in our documentation there already. Could you please create that issue and share your thoughts? Otherwise this is good to come in imo!
jaredthomas68
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for adding the tests and making the issue.
Bugfix: Update storage models so can use different control types per storage type
This is a bugfix that only applies to
h2integrate/storage/storage_performance_model.pyandh2integrate/storage/battery/pysam_battery.py.The use-case where I encountered this example is not tested in H2I. But - basically I'm using a pyomo controller with the pysam battery and using the
StoragePerformanceModelwith the demand open-loop controller for hydrogen storage. This means that for theStoragePerformanceModel, I need the storage model to have the inputhydrogen_set_point. I need the pysam battery to be inputpyomo_dispatch_solver. The existing logic in these two controllers lead to a case where thehydrogen_set_pointwas not being added as an input to the hydrogen storage.The code prior to this PR and how that logic was not working for the hydrogen storage is below:
New logic that works:
Section 1: Type of Contribution
Section 2: Draft PR Checklist
TODO:
Type of Reviewer Feedback Requested (on Draft PR)
Structural feedback:
Implementation feedback:
Other feedback:
Section 3: General PR Checklist
docs/files are up-to-date, or added when necessaryCHANGELOG.md"A complete thought. [PR XYZ]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
XYZshould be replaced with the actual number.Section 3: Related Issues
tech_to_dispatch_connections#620 as part of this PRSection 4: Impacted Areas of the Software
Section 4.1: New Files
h2integrate/control/test/test_multistorage_pyomo_openloop_control.py: new tests to check that the introduced logic works as expected.Section 4.2: Modified Files
h2integrate/storage/storage_performance_model.py: updated logic for setting control input insetup()h2integrate/storage/battery/pysam_battery.py: updated logic for setting control input insetup()h2integrate/control/control_strategies/heuristic_pyomo_controller.py: (bugfix) moved setting the attributes of charge and discharge efficiency fromsetup()toinitialize_parameters()h2integrate/control/test/test_heuristic_with_generic_storage.py: updated tech config to test that the bugfix inheuristic_pyomo_controller.pyworked.h2integrate/control/control_strategies/storage/simple_openloop_controller.py: had to changestrict=Falsewhen creating config to prevent errors when using the simple openloop controller in cases where the cost model and the performance model have shared parameters that are not shared with the openloop controller.Section 5: Additional Supporting Information
Section 6: Test Results, if applicable
Section 7 (Optional): New Model Checklist
docs/developer_guide/coding_guidelines.mdattrsclass to define theConfigto load in attributes for the modelBaseConfigorCostModelBaseConfiginitialize()method,setup()method,compute()methodCostModelBaseClasssupported_models.pycreate_financial_modelinh2integrate_model.pytest_all_examples.pydocs/user_guide/model_overview.mddocs/section<model_name>.mdis added to the_toc.yml