-
Notifications
You must be signed in to change notification settings - Fork 27
Standardize performance model outputs #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Standardize performance model outputs #463
Conversation
…ART into converter_baseclass
genevievestarke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great! I like the standardizations proposed and I can see how it's implemented in the individual technologies!
| raise NotImplementedError("This method should be implemented in a subclass.") | ||
|
|
||
|
|
||
| class SolarFinanceBaseClass(om.ExplicitComponent): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this method go somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its not used - this is somewhat leftover from early on where each tech was going to have its own performance, cost, and finance baseclass and models. I imagine a handful of unused baseclasses may be removed in this PR
jmartin4u
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a nice big undertaking and should make interconnectivity between models a lot smoother moving forward, thanks for taking it on. I don't want to throw any wrenches in the gears of implementation except to say it would be nice a have the commodity_rate_units editable in a tech_config parameter, but that could wait for a future feature add.
| self.add_output( | ||
| "capacity_factor", | ||
| val=0.0, | ||
| shape=self.plant_life, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If capacity_factor is an annual calculation I think we should make that clear in the variable name - call it annual_capacity_factor instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a valid name choice, I'd want to get the rest of the teams opinion on it before changing it. Could also be done in a separate PR
bayc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really like these changes! I agree with the others that it brings a much needed uniformity to the models. Left a few comments throughout, some building on others. Thanks @elenya-grant !
| plant_life = int(plant_config["plant"]["plant_life"]) | ||
| n_timesteps = int(plant_config["plant"]["simulation"]["n_timesteps"]) | ||
|
|
||
| # Check that replacement schedule is between 0 and 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These type of tests are useful! Wondering if we also have regression tests for this tech? I see the test below is checking some values, but wondering about checking the values of these standardized outputs. Is that for a future PR? Is the main issue the tedious nature of updating values when they change? Definitely have a lot of thoughts on testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some models did not have regression tests and when a future PR removes "duplicated" outputs, then I'll update existing unit tests to use the new naming convention where applicable. I think that adding in tech-specific unit tests are not part of this effort and should be done when new technologies are added. I made Issue #481 to summarize my thoughts on testing that arose from this, some models did not have any unit tests but I added this basic test to ensure that I didn't forget to set one of the new outputs.
| """ | ||
|
|
||
| def setup(self): | ||
| self.commodity = "ammonia" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seconding @johnjasa suggestion of looking at having these in the config class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thoughts are that most performance models are specific to a technology, which inherently has at least one output commodity and the calculations are done with respect to the units defined. For example, the desalination model uses volume for the water inputs/outputs whereas another model may require water mass. Therefore, I think it makes sense for commodities and commodity units to be inherent to the class rather than the configuration class. I think it makes sense to tie the units to these models to the performance class rather than the configuration class since the units and commodity are specific to the calculations done in the performance class.
Additionally, when I picture getting rid of tech-specific or commodity-specific hard-coded logic in H2IntegrateModel - I'd imagine that it may be useful to get the attribute from the technology class (tech.commodity) rather than its configuration class tech.config.commodity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this was mentioned by multiple folks, I will say that I think this should be discussed with the larger team at some point but could be done after the planned development related to this PR is complete.
|
I realized that to remove some tech-specific logic in class WindPerformanceBaseClass(PerformanceModelBaseClass):
def initialize(self):
super().initialize()
self.commodity = "electricity"
self.commodity_rate_units = "kW"
self.commodity_amount_units = "kW*h"instead of this: def setup(self):
self.commodity = "electricity"
self.commodity_rate_units = "kW"
self.commodity_amount_units = "kW*h"
super().setup()This would also be okay in tech-neutral technologies because most of those would have to define the commodity and units in the |
jaredthomas68
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. I still have a few outstanding comments I would like to get resolved prior to merging this in.
jaredthomas68
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and ready to merge. Well done @elenya-grant!
Standardize performance model outputs
Introducing a baseclass for performance models to standardize outputs. The standardized outputs are:
commodity_outin units ofcommodity_rate_units: commodity output profile of lengthn_timestepstotal_commodity_producedin units ofcommodity_amount_units: sum of commodity produced over simulation (adjusted for timestep if necessary)annual_commodity_producedin units ofcommodity_amount_units/yr: annual commodity production adjusted for a year-long simulation, shape is equal toplant_life.replacement_schedulein units ofunitless: the percent of the capacity that is replaced per year. Defaults to an array of zeros of lengthplant_life.capacity_factorin units ofunitless: the capacity factor of a system as a fraction. Has a shape equal toplant_life.rated_commodity_productionin units ofcommodity_rate_units: rated production capacity of the converter. Used to calculatecapacity_factoroperational_lifein units ofyr: operational life of the technology, defaults to plant life. Tentatively planning on adding it in.The attributes that each performance model needs to define prior to calling the setup() method in the
PerformanceModelBaseClassare:commodity,commodity_rate_unitsandcommodity_amount_units. For example, the wind performance models in the setup method would do:An electrolyzer performance model would do:
This would resolve some issues around hard-coded tech-specific logic in H2IntegrateModel and the profast finance models, and issues relating to unit convention for varying simulation lengths or timesteps. To keep this PR small, this PR will focus on adding these standardized outputs to all the converter models, with the goal of preventing changes in test values. This PR also introduces a lot of TODO notes, which will be addressed in follow-on PRs because most of those changes would likely result in test value changes. Aka - some TODOs will not be removed in this PR.
This PR is primarily focuses on adding outputs to performance models and adding basic tests to ensure that all the outputs are set (not testing the value that they're set to, just that they're not zero). To ensure that the planned changes that may result in different test values or larger framework changes to core models (which this PR lays the foundation for) are highlighted, these are planned to be done in future PRs so that all the additions in this PR do not distract from those changes.
Out of scope for this PR is:
PerformanceModelBaseClassThe follow-on PRs will be:
commodity_rate_unitsandcommodity_amount_units(2/3) #486commodity_rate_unitsandcommodity_amount_units(2/3) #486commodity_rate_unitsandcommodity_amount_units(2/3) #486These PRs can get started once this PR is merged in.
Benefits of this PR are:
Section 1: Type of Contribution
Section 2: Draft PR Checklist
TODO:
Update/add outputs to converter models and add basic unit-tests that outputs are set
Update/add outputs to storage models
simple_generic_storage(future PR, Issue Update remaining models to usecommodity_rate_unitsandcommodity_amount_units(2/3) #486)simple_storage_autosizing(future PR, Issue Update remaining models to usecommodity_rate_unitsandcommodity_amount_units(2/3) #486)[-] Update/add outputs to feedstock model and fix units (future PR)
[-] Update combiners and splitters (as necessary, mostly done in future PR)
[-] Update ProFAST finance models to use capacity factor as utilization and
rated_commodity_productionas capacity (make as a separate PR)[-] Update
AdjustedCapexOpexCompif needed.Update/fix tests as needed
Update post-processing functions as necessary
[-] Update documentation on adding a new technology (future PR)
Add unit-tests to check that all outputs set via
PerformanceModelBaseClassare given values in thecompute()method of parent classes.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.mdhas been updated to describe the changes made in this PRSection 3: Related Issues
Existing Related Issues
Units for varying timesteps and simulation lengths: Issue #244, #204, and #387 (may be partially resolved with this PR)
Standardized naming conventions: Issue #223 (this would be partially resolved with this PR)
Remove dependence on name of the technologies in H2I: Issue #374 (would be partially/fully resolved in this PR)
Issue about converter baseclass (somewhat related): Issue #231
New issues made
commodity_rate_unitsandcommodity_amount_units(2/3) #486 (for follow-on PR)adding_a_new_technology.md#487 (update docs on how to add a new tech)Section 4: Impacted Areas of the Software
Section 4.1: New Files
h2integrate/converters/hydrogen/test/test_pem_electrolyzer_performance.pyh2integrate/converters/steel/test/test_simple_steel.pyh2integrate/converters/methanol/test/test_methanol.pyh2integrate/converters/water_power/test/test_hydro_power.pySection 4.2: Modified Files
Most converter performance models or performance baseclasses and some variable names in subtests
Section 5: Additional Supporting Information
Future development (in other PRs than the ones noted above) that could build on this framework are:
dt) or simulation length (n_timesteps)Section 6: Test Results, if applicable
No test values changed!