-
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
| raise NotImplementedError("This method should be implemented in a subclass.") | ||
|
|
||
|
|
||
| class PerformanceModelBaseClass(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.
I like the idea of enforcing that some of these parameters need to exist to simplify setup and later usage, but there should be an actual enforcement method that requires the commodity, commodity_rate_units, commodity_amount_units, and the later to-be-determined attribues to be defined. Without an actual enforcement it will let the error crop up in a likely confusing place once it's been long enough since this feature has been implemented.
Something along these lines would likely work to avoid getting too fancy with Python's abstract base classes. i would definitely make the error message a bit more descriptive during implementation, but this keeps it to a single line for this example.
class PerformanceModelBaseClass(): # will need om.ExplicitComponent, but am skipping for the sake of a replicable example
def __new__(cls, *args, **kwargs):
required = ("commodity", "commodity_rate_units", "commodity_amount_units")
missing = [el for el in required if not hasattr(cls, el)]
if missing:
missing = ", ".join(missing)
raise NotImplementedError(f"{cls.__name__} missing the following attributes: {missing}")
return super().__new__(cls)In this case, we could define the following two sample subclasses.
class WindPerformanceBaseClass(PerformanceModelBaseClass):
commodity = "electricity"
class OtherPerformanceBaseClass(PerformanceModelBaseClass):
commodity = "electricity"
commodity_rate_units = "kwh"
commodity_amount_units = "kw"When called, OtherPerformaceBaseClass() will successfully initialize, but when attempting to create an instance of WindPerformanceBaseClass, you'll be met with the error.
NotImplementedError: WindPerformanceBaseClass missing the following attributes: commodity_rate_units, commodity_amount_unitsThe only catch is that if base classes themselves aren't tested for basic setup, then this will cascade to the class being instantiated.
class Wind(WindPerformanceBaseClass):
def __init__():
pass
>>> Wind()
NotImplementedError: Wind missing the following attributes: commodity_rate_units, commodity_amount_units
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. Changes to the wind, solar, water power, and electrolyzer converters have already been done and can be reviewed now for reviewers to provide high-level feedback.
Benefits of this PR are:
Section 1: Type of Contribution
Section 2: Draft PR Checklist
TODO:
Update/add outputs to converter models
Update/add outputs to storage models
Update/add outputs to feedstock model and fix units (elenya)
Update combiners and splitters (as necessary)
Update ProFAST finance models to use capacity factor as utilization and
rated_commodity_productionas capacityUpdate
AdjustedCapexOpexCompif needed.Update/fix tests as needed
Update post-processing functions as necessary (elenya)
Update documentation on adding a new technology
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
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
Section 4: Impacted Areas of the Software
Section 4.1: New Files
path/to/file.extensionmethod1: What and why something was changed in one sentence or less.Section 4.2: Modified Files
path/to/file.extensionmethod1: What and why something was changed in one sentence or less.Section 5: Additional Supporting Information
Future development (in other PRs) that could build on this framework are:
Section 6: Test Results, if applicable